diff options
author | Samuel Benzaquen <sbenza@google.com> | 2014-08-12 21:11:37 +0000 |
---|---|---|
committer | Samuel Benzaquen <sbenza@google.com> | 2014-08-12 21:11:37 +0000 |
commit | 646f23b80934387d7b0873014bcd1aa6cf28372c (patch) | |
tree | e43ec14c24a6f747a197aaf63f10493c4c0ea78b /clang/unittests/ASTMatchers/Dynamic/RegistryTest.cpp | |
parent | 4834ad2609515295a5e4132711b1f8f263500892 (diff) | |
download | bcm5719-llvm-646f23b80934387d7b0873014bcd1aa6cf28372c.tar.gz bcm5719-llvm-646f23b80934387d7b0873014bcd1aa6cf28372c.zip |
Support named values in the autocomplete feature.
Summary:
This includes:
- Passing a Sema to completeExpression to allow for named values in the
expression.
- Passing a map of names to values to the parser.
- Update the Sema interface to include completion for matchers.
- Change the parser to use the Sema for completion, instead of going
directly to Registry.
Reviewers: pcc
Subscribers: klimek, cfe-commits
Differential Revision: http://reviews.llvm.org/D3509
llvm-svn: 215472
Diffstat (limited to 'clang/unittests/ASTMatchers/Dynamic/RegistryTest.cpp')
-rw-r--r-- | clang/unittests/ASTMatchers/Dynamic/RegistryTest.cpp | 29 |
1 files changed, 12 insertions, 17 deletions
diff --git a/clang/unittests/ASTMatchers/Dynamic/RegistryTest.cpp b/clang/unittests/ASTMatchers/Dynamic/RegistryTest.cpp index e659b3a733d..5552790bcac 100644 --- a/clang/unittests/ASTMatchers/Dynamic/RegistryTest.cpp +++ b/clang/unittests/ASTMatchers/Dynamic/RegistryTest.cpp @@ -82,8 +82,9 @@ public: typedef std::vector<MatcherCompletion> CompVector; CompVector getCompletions() { - return Registry::getCompletions( - ArrayRef<std::pair<MatcherCtor, unsigned> >()); + std::vector<std::pair<MatcherCtor, unsigned> > Context; + return Registry::getMatcherCompletions( + Registry::getAcceptedCompletionTypes(Context)); } CompVector getCompletions(StringRef MatcherName1, unsigned ArgNo1) { @@ -92,7 +93,8 @@ public: if (!Ctor) return CompVector(); Context.push_back(std::make_pair(*Ctor, ArgNo1)); - return Registry::getCompletions(Context); + return Registry::getMatcherCompletions( + Registry::getAcceptedCompletionTypes(Context)); } CompVector getCompletions(StringRef MatcherName1, unsigned ArgNo1, @@ -106,18 +108,16 @@ public: if (!Ctor) return CompVector(); Context.push_back(std::make_pair(*Ctor, ArgNo2)); - return Registry::getCompletions(Context); + return Registry::getMatcherCompletions( + Registry::getAcceptedCompletionTypes(Context)); } bool hasCompletion(const CompVector &Comps, StringRef TypedText, - StringRef MatcherDecl = StringRef(), - unsigned *Index = nullptr) { + StringRef MatcherDecl = StringRef()) { for (CompVector::const_iterator I = Comps.begin(), E = Comps.end(); I != E; ++I) { if (I->TypedText == TypedText && (MatcherDecl.empty() || I->MatcherDecl == MatcherDecl)) { - if (Index) - *Index = I - Comps.begin(); return true; } } @@ -445,17 +445,12 @@ TEST_F(RegistryTest, Completion) { CompVector WhileComps = getCompletions("whileStmt", 0); - unsigned HasBodyIndex, HasParentIndex, AllOfIndex; EXPECT_TRUE(hasCompletion(WhileComps, "hasBody(", - "Matcher<WhileStmt> hasBody(Matcher<Stmt>)", - &HasBodyIndex)); + "Matcher<WhileStmt> hasBody(Matcher<Stmt>)")); EXPECT_TRUE(hasCompletion(WhileComps, "hasParent(", - "Matcher<Stmt> hasParent(Matcher<Decl|Stmt>)", - &HasParentIndex)); - EXPECT_TRUE(hasCompletion(WhileComps, "allOf(", - "Matcher<T> allOf(Matcher<T>...)", &AllOfIndex)); - EXPECT_GT(HasParentIndex, HasBodyIndex); - EXPECT_GT(AllOfIndex, HasParentIndex); + "Matcher<Stmt> hasParent(Matcher<Decl|Stmt>)")); + EXPECT_TRUE( + hasCompletion(WhileComps, "allOf(", "Matcher<T> allOf(Matcher<T>...)")); EXPECT_FALSE(hasCompletion(WhileComps, "whileStmt(")); EXPECT_FALSE(hasCompletion(WhileComps, "ifStmt(")); |