summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clangd/CodeCompletionStrings.h
diff options
context:
space:
mode:
authorEric Liu <ioeric@google.com>2017-12-20 17:24:31 +0000
committerEric Liu <ioeric@google.com>2017-12-20 17:24:31 +0000
commit63696e14e310501bbc0b48d3215442d23df84408 (patch)
tree98c6e467acca69a139c081bfc04599224620a76a /clang-tools-extra/clangd/CodeCompletionStrings.h
parent188adaf46b98354e1758d065db27eff0f23bf0c6 (diff)
downloadbcm5719-llvm-63696e14e310501bbc0b48d3215442d23df84408.tar.gz
bcm5719-llvm-63696e14e310501bbc0b48d3215442d23df84408.zip
[clangd] Pull CodeCompletionString handling logic into its own file and add unit test.
Reviewers: sammccall Subscribers: klimek, mgorny, ilya-biryukov, cfe-commits Differential Revision: https://reviews.llvm.org/D41450 llvm-svn: 321193
Diffstat (limited to 'clang-tools-extra/clangd/CodeCompletionStrings.h')
-rw-r--r--clang-tools-extra/clangd/CodeCompletionStrings.h46
1 files changed, 46 insertions, 0 deletions
diff --git a/clang-tools-extra/clangd/CodeCompletionStrings.h b/clang-tools-extra/clangd/CodeCompletionStrings.h
new file mode 100644
index 00000000000..2c500a3a956
--- /dev/null
+++ b/clang-tools-extra/clangd/CodeCompletionStrings.h
@@ -0,0 +1,46 @@
+//===--- CodeCompletionStrings.h ---------------------------------*- C++-*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===---------------------------------------------------------------------===//
+//
+// Functions for retrieving code completion information from
+// `CodeCompletionString`.
+//
+//===---------------------------------------------------------------------===//
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_CODECOMPLETIONSTRINGS_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_CODECOMPLETIONSTRINGS_H
+
+#include "clang/Sema/CodeCompleteConsumer.h"
+
+namespace clang {
+namespace clangd {
+
+/// Gets label and insert text for a completion item. For example, for function
+/// `Foo`, this returns <"Foo(int x, int y)", "Foo"> without snippts enabled.
+///
+/// If \p EnableSnippets is true, this will try to use snippet for the insert
+/// text. Otherwise, the insert text will always be plain text.
+void getLabelAndInsertText(const CodeCompletionString &CCS, std::string *Label,
+ std::string *InsertText, bool EnableSnippets);
+
+/// Gets the documentation for a completion item. For example, comment for the
+/// a class declaration.
+std::string getDocumentation(const CodeCompletionString &CCS);
+
+/// Gets detail to be used as the detail field in an LSP completion item. This
+/// is usually the return type of a function.
+std::string getDetail(const CodeCompletionString &CCS);
+
+/// Gets the piece of text that the user is expected to type to match the
+/// code-completion string, typically a keyword or the name of a declarator or
+/// macro.
+std::string getFilterText(const CodeCompletionString &CCS);
+
+} // namespace clangd
+} // namespace clang
+
+#endif
OpenPOWER on IntegriCloud