Skip to content

Commit

Permalink
#136 Remove ignored following tokens
Browse files Browse the repository at this point in the history
Signed-off-by: vityaman <vityaman.dev@yandex.ru>
  • Loading branch information
vityaman authored and mike-lischke committed Aug 26, 2024
1 parent c24224c commit a9a7b2e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
7 changes: 7 additions & 0 deletions ports/cpp/source/antlr4-c3/CodeCompletionCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,13 @@ CandidatesCollection CodeCompletionCore::collectCandidates(

processRule(atn->ruleToStartState[startRule], 0, callStack, 0, 0, candidates.isCancelled);

for (auto& [_, following] : candidates.tokens) {
auto removed = std::ranges::remove_if(following, [&](size_t token) {
return ignoredTokens.contains(token);
});
following.erase(std::begin(removed), std::end(removed));
}

if (debugOptions.showResult) {
if (candidates.isCancelled) {
std::cout << "*** TIMED OUT ***\n";
Expand Down
4 changes: 2 additions & 2 deletions ports/cpp/test/expr/ExprTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ TEST(SimpleExpressionParser, TypicalSetup) {
auto candidates = completion.collectCandidates(0);
EXPECT_THAT(Keys(candidates.tokens), UnorderedElementsAre(ExprLexer::VAR, ExprLexer::LET));

EXPECT_THAT(candidates.tokens[ExprLexer::VAR], ElementsAre(ExprLexer::ID, ExprLexer::EQUAL));
EXPECT_THAT(candidates.tokens[ExprLexer::LET], ElementsAre(ExprLexer::ID, ExprLexer::EQUAL));
EXPECT_THAT(candidates.tokens[ExprLexer::VAR], ElementsAre());
EXPECT_THAT(candidates.tokens[ExprLexer::LET], ElementsAre());
}
{
// 2) On the variable name ('c').
Expand Down

0 comments on commit a9a7b2e

Please sign in to comment.