diff options
author | Daniel Dunbar <daniel@zuster.org> | 2009-11-13 08:58:20 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2009-11-13 08:58:20 +0000 |
commit | 3a2838d14251427089c39caec90c8abbc27f7a14 (patch) | |
tree | cfa0899c839011c5e79e08a39c7f2f45d16afe43 /lib/Sema/ParseAST.cpp | |
parent | 0f800391ffbfe3820e1c60246a09a97e5f065179 (diff) |
Rework Sema code completion interface.
- Provide Sema in callbacks, instead of requiring it in constructor. This
eliminates the need for a factory function. Clients now just pass the object
to consume the results in directly.
- CodeCompleteConsumer is cheap to construct, so building it whenever we are
doing code completion is reasonable.
Doug, please review.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@87099 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/ParseAST.cpp')
-rw-r--r-- | lib/Sema/ParseAST.cpp | 14 |
1 files changed, 2 insertions, 12 deletions
diff --git a/lib/Sema/ParseAST.cpp b/lib/Sema/ParseAST.cpp index d3f26d875c..9afc8100c7 100644 --- a/lib/Sema/ParseAST.cpp +++ b/lib/Sema/ParseAST.cpp @@ -35,15 +35,14 @@ using namespace clang; void clang::ParseAST(Preprocessor &PP, ASTConsumer *Consumer, ASTContext &Ctx, bool PrintStats, bool CompleteTranslationUnit, - CodeCompleteConsumer *(*CreateCodeCompleter)(Sema &, void *Data), - void *CreateCodeCompleterData) { + CodeCompleteConsumer *CompletionConsumer) { // Collect global stats on Decls/Stmts (until we have a module streamer). if (PrintStats) { Decl::CollectingStats(true); Stmt::CollectingStats(true); } - Sema S(PP, Ctx, *Consumer, CompleteTranslationUnit); + Sema S(PP, Ctx, *Consumer, CompleteTranslationUnit, CompletionConsumer); Parser P(PP, S); PP.EnterMainSourceFile(); @@ -63,12 +62,6 @@ void clang::ParseAST(Preprocessor &PP, ASTConsumer *Consumer, External->StartTranslationUnit(Consumer); } - CodeCompleteConsumer *CodeCompleter = 0; - if (CreateCodeCompleter) { - CodeCompleter = CreateCodeCompleter(S, CreateCodeCompleterData); - S.setCodeCompleteConsumer(CodeCompleter); - } - Parser::DeclGroupPtrTy ADecl; while (!P.ParseTopLevelDecl(ADecl)) { // Not end of file. @@ -87,9 +80,6 @@ void clang::ParseAST(Preprocessor &PP, ASTConsumer *Consumer, Consumer->HandleTranslationUnit(Ctx); - if (CreateCodeCompleter) - delete CodeCompleter; - if (PrintStats) { fprintf(stderr, "\nSTATISTICS:\n"); P.getActions().PrintStats(); |