diff options
| author | Vassil Vassilev <v.g.vassilev@gmail.com> | 2016-07-27 14:56:59 +0000 |
|---|---|---|
| committer | Vassil Vassilev <v.g.vassilev@gmail.com> | 2016-07-27 14:56:59 +0000 |
| commit | 644ea61d2dc1d185994c845e7e3de173d95a5674 (patch) | |
| tree | 3aaf0cf24fcc3e9ced186a9e02905af6c3db8eaf /clang/lib/Lex | |
| parent | 5267d53779b45002837c779e513811aa8e9ad755 (diff) | |
| download | bcm5719-llvm-644ea61d2dc1d185994c845e7e3de173d95a5674.tar.gz bcm5719-llvm-644ea61d2dc1d185994c845e7e3de173d95a5674.zip | |
Implement filtering for code completion of identifiers.
Patch by Cristina Cristescu and Axel Naumann!
Agreed on post commit review (D17820).
llvm-svn: 276878
Diffstat (limited to 'clang/lib/Lex')
| -rw-r--r-- | clang/lib/Lex/Lexer.cpp | 10 | ||||
| -rw-r--r-- | clang/lib/Lex/Preprocessor.cpp | 5 |
2 files changed, 13 insertions, 2 deletions
diff --git a/clang/lib/Lex/Lexer.cpp b/clang/lib/Lex/Lexer.cpp index 9c2a0163ace..9f7638d8329 100644 --- a/clang/lib/Lex/Lexer.cpp +++ b/clang/lib/Lex/Lexer.cpp @@ -1533,7 +1533,15 @@ FinishIdentifier: // preprocessor, which may macro expand it or something. if (II->isHandleIdentifierCase()) return PP->HandleIdentifier(Result); - + + if (II->getTokenID() == tok::identifier && isCodeCompletionPoint(CurPtr) + && II->getPPKeywordID() == tok::pp_not_keyword + && II->getObjCKeywordID() == tok::objc_not_keyword) { + // Return the code-completion token. + Result.setKind(tok::code_completion); + cutOffLexing(); + return true; + } return true; } diff --git a/clang/lib/Lex/Preprocessor.cpp b/clang/lib/Lex/Preprocessor.cpp index 3654ba080d4..8832c7f80c4 100644 --- a/clang/lib/Lex/Preprocessor.cpp +++ b/clang/lib/Lex/Preprocessor.cpp @@ -74,7 +74,7 @@ Preprocessor::Preprocessor(IntrusiveRefCntPtr<PreprocessorOptions> PPOpts, IncrementalProcessing(false), TUKind(TUKind), CodeComplete(nullptr), CodeCompletionFile(nullptr), CodeCompletionOffset(0), LastTokenWasAt(false), ModuleImportExpectsIdentifier(false), - CodeCompletionReached(0), MainFileDir(nullptr), + CodeCompletionReached(0), CodeCompletionII(0), MainFileDir(nullptr), SkipMainFilePreamble(0, true), CurPPLexer(nullptr), CurDirLookup(nullptr), CurLexerKind(CLK_Lexer), CurSubmodule(nullptr), Callbacks(nullptr), CurSubmoduleState(&NullSubmoduleState), MacroArgCache(nullptr), @@ -744,6 +744,9 @@ void Preprocessor::Lex(Token &Result) { } } while (!ReturnedToken); + if (Result.is(tok::code_completion)) + setCodeCompletionIdentifierInfo(Result.getIdentifierInfo()); + LastTokenWasAt = Result.is(tok::at); } |

