summaryrefslogtreecommitdiffstats
path: root/include/clang/Lex
diff options
context:
space:
mode:
authorSam McCall <sam.mccall@gmail.com>2018-09-18 08:40:41 +0000
committerSam McCall <sam.mccall@gmail.com>2018-09-18 08:40:41 +0000
commitae8dcccdd1f0be33b4c6b26e00382a2585c9b6b4 (patch)
tree37fd462c6138bae1df1ceb729fbc4113ccec6cba /include/clang/Lex
parent0fb55e03c75d4e807dc67af9f9dfba9ff45fefa7 (diff)
[CodeComplete] Add completions for filenames in #include directives.
Summary: The dir component ("somedir" in #include <somedir/fo...>) is considered fixed. We append "foo" to each directory on the include path, and then list its files. Completions are of the forms: #include <somedir/fo^ foo.h> fox/ The filter is set to the filename part ("fo"), so fuzzy matching can be applied to the filename only. No fancy scoring/priorities are set, and no information is added to CodeCompleteResult to make smart scoring possible. Could be in future. Reviewers: ilya-biryukov Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D52076 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@342449 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/Lex')
-rw-r--r--include/clang/Lex/CodeCompletionHandler.h7
-rw-r--r--include/clang/Lex/Lexer.h3
-rw-r--r--include/clang/Lex/Preprocessor.h4
3 files changed, 14 insertions, 0 deletions
diff --git a/include/clang/Lex/CodeCompletionHandler.h b/include/clang/Lex/CodeCompletionHandler.h
index 87089fd7d5..6b368c74c5 100644
--- a/include/clang/Lex/CodeCompletionHandler.h
+++ b/include/clang/Lex/CodeCompletionHandler.h
@@ -14,6 +14,8 @@
#ifndef LLVM_CLANG_LEX_CODECOMPLETIONHANDLER_H
#define LLVM_CLANG_LEX_CODECOMPLETIONHANDLER_H
+#include "llvm/ADT/StringRef.h"
+
namespace clang {
class IdentifierInfo;
@@ -60,6 +62,11 @@ public:
MacroInfo *MacroInfo,
unsigned ArgumentIndex) { }
+ /// Callback invoked when performing code completion inside the filename
+ /// part of an #include directive. (Also #import, #include_next, etc).
+ /// \p Dir is the directory relative to the include path, e.g. "a" for <a/b.
+ virtual void CodeCompleteIncludedFile(llvm::StringRef Dir, bool IsAngled) {}
+
/// Callback invoked when performing code completion in a part of the
/// file where we expect natural language, e.g., a comment, string, or
/// \#error directive.
diff --git a/include/clang/Lex/Lexer.h b/include/clang/Lex/Lexer.h
index 7af9d43b3f..a9b10b6273 100644
--- a/include/clang/Lex/Lexer.h
+++ b/include/clang/Lex/Lexer.h
@@ -711,6 +711,9 @@ private:
bool isHexaLiteral(const char *Start, const LangOptions &LangOpts);
+ void codeCompleteIncludedFile(const char *PathStart,
+ const char *CompletionPoint, bool IsAngled);
+
/// Read a universal character name.
///
/// \param StartPtr The position in the source buffer after the initial '\'.
diff --git a/include/clang/Lex/Preprocessor.h b/include/clang/Lex/Preprocessor.h
index 02ea80aa3f..75910011d0 100644
--- a/include/clang/Lex/Preprocessor.h
+++ b/include/clang/Lex/Preprocessor.h
@@ -1128,6 +1128,10 @@ public:
CodeComplete = nullptr;
}
+ /// Hook used by the lexer to invoke the "included file" code
+ /// completion point.
+ void CodeCompleteIncludedFile(llvm::StringRef Dir, bool IsAngled);
+
/// Hook used by the lexer to invoke the "natural language" code
/// completion point.
void CodeCompleteNaturalLanguage();