summaryrefslogtreecommitdiffstats
path: root/clang/lib/Lex/Preprocessor.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2009-09-17 21:32:03 +0000
committerDouglas Gregor <dgregor@apple.com>2009-09-17 21:32:03 +0000
commit2436e7116bb1bda26d8b18b4b34a69a6b5d336d3 (patch)
tree1325762c620a4b86a13623e132661522a34b5cc8 /clang/lib/Lex/Preprocessor.cpp
parentfaacf018a3cc6615a2012348cbe213b2f8a0a880 (diff)
downloadbcm5719-llvm-2436e7116bb1bda26d8b18b4b34a69a6b5d336d3.tar.gz
bcm5719-llvm-2436e7116bb1bda26d8b18b4b34a69a6b5d336d3.zip
Initial implementation of a code-completion interface in Clang. In
essence, code completion is triggered by a magic "code completion" token produced by the lexer [*], which the parser recognizes at certain points in the grammar. The parser then calls into the Action object with the appropriate CodeCompletionXXX action. Sema implements the CodeCompletionXXX callbacks by performing minimal translation, then forwarding them to a CodeCompletionConsumer subclass, which uses the results of semantic analysis to provide code-completion results. At present, only a single, "printing" code completion consumer is available, for regression testing and debugging. However, the design is meant to permit other code-completion consumers. This initial commit contains two code-completion actions: one for member access, e.g., "x." or "p->", and one for nested-name-specifiers, e.g., "std::". More code-completion actions will follow, along with improved gathering of code-completion results for the various contexts. [*] In the current -code-completion-dump testing/debugging mode, the file is truncated at the completion point and EOF is translated into "code completion". llvm-svn: 82166
Diffstat (limited to 'clang/lib/Lex/Preprocessor.cpp')
-rw-r--r--clang/lib/Lex/Preprocessor.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/clang/lib/Lex/Preprocessor.cpp b/clang/lib/Lex/Preprocessor.cpp
index bfa090a09e8..4e522cbb8a4 100644
--- a/clang/lib/Lex/Preprocessor.cpp
+++ b/clang/lib/Lex/Preprocessor.cpp
@@ -71,6 +71,7 @@ Preprocessor::Preprocessor(Diagnostic &diags, const LangOptions &opts,
// Macro expansion is enabled.
DisableMacroExpansion = false;
InMacroArgs = false;
+ IsMainFileEofCodeCompletion = false;
NumCachedTokenLexers = 0;
CachedLexPos = 0;
@@ -368,6 +369,13 @@ void Preprocessor::EnterMainSourceFile() {
// Enter the main file source buffer.
EnterSourceFile(MainFileID, 0);
+ if (IsMainFileEofCodeCompletion) {
+ // Tell our newly-created lexer that it should treat its end-of-file as
+ // a code-completion token.
+ IsMainFileEofCodeCompletion = false;
+ static_cast<Lexer *>(getCurrentFileLexer())->SetEofIsCodeCompletion();
+ }
+
// Tell the header info that the main file was entered. If the file is later
// #imported, it won't be re-entered.
if (const FileEntry *FE = SourceMgr.getFileEntryForID(MainFileID))
OpenPOWER on IntegriCloud