diff options
author | Douglas Gregor <dgregor@apple.com> | 2010-08-05 09:09:23 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2010-08-05 09:09:23 +0000 |
commit | cee235cdf0b8047761ffac598c4c3a32ab7411a2 (patch) | |
tree | b28a68eb1df50b33f3d65913ef9c743485a6eb5f /lib/Frontend/ASTUnit.cpp | |
parent | 57e97786433e70197a089360228d8f0d82e3ad4c (diff) |
Give clang_codeCompleteAt() an "options" parameter, and add a new
flags enumeration + default-generating function that allows
code-completion to be customized via the libclang API.
Plus, turn on spell-checking when performing code completion.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@110319 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Frontend/ASTUnit.cpp')
-rw-r--r-- | lib/Frontend/ASTUnit.cpp | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/lib/Frontend/ASTUnit.cpp b/lib/Frontend/ASTUnit.cpp index 2d1708ccc6..7c15d82d3b 100644 --- a/lib/Frontend/ASTUnit.cpp +++ b/lib/Frontend/ASTUnit.cpp @@ -1154,6 +1154,8 @@ bool ASTUnit::Reparse(RemappedFile *RemappedFiles, unsigned NumRemappedFiles) { void ASTUnit::CodeComplete(llvm::StringRef File, unsigned Line, unsigned Column, RemappedFile *RemappedFiles, unsigned NumRemappedFiles, + bool IncludeMacros, + bool IncludeCodePatterns, CodeCompleteConsumer &Consumer, Diagnostic &Diag, LangOptions &LangOpts, SourceManager &SourceMgr, FileManager &FileMgr, @@ -1164,13 +1166,18 @@ void ASTUnit::CodeComplete(llvm::StringRef File, unsigned Line, unsigned Column, CompilerInvocation CCInvocation(*Invocation); FrontendOptions &FrontendOpts = CCInvocation.getFrontendOpts(); PreprocessorOptions &PreprocessorOpts = CCInvocation.getPreprocessorOpts(); - - FrontendOpts.ShowMacrosInCodeCompletion = 1; - FrontendOpts.ShowCodePatternsInCodeCompletion = 1; + + FrontendOpts.ShowMacrosInCodeCompletion = IncludeMacros; + FrontendOpts.ShowCodePatternsInCodeCompletion = IncludeCodePatterns; FrontendOpts.CodeCompletionAt.FileName = File; FrontendOpts.CodeCompletionAt.Line = Line; FrontendOpts.CodeCompletionAt.Column = Column; + // Turn on spell-checking when performing code completion. It leads + // to better results. + unsigned SpellChecking = CCInvocation.getLangOpts().SpellChecking; + CCInvocation.getLangOpts().SpellChecking = 1; + // Set the language options appropriately. LangOpts = CCInvocation.getLangOpts(); @@ -1235,4 +1242,5 @@ void ASTUnit::CodeComplete(llvm::StringRef File, unsigned Line, unsigned Column, Clang.takeInvocation(); Clang.takeDiagnosticClient(); Clang.takeCodeCompletionConsumer(); + CCInvocation.getLangOpts().SpellChecking = SpellChecking; } |