Skip to content

Commit

Permalink
mike-lischke#136 Fix CppParser::SimpleExample test
Browse files Browse the repository at this point in the history
  • Loading branch information
vityaman committed Jul 31, 2024
1 parent ff80c5c commit 0f5a5f0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 14 deletions.
18 changes: 6 additions & 12 deletions ports/cpp/source/antlr4-c3/CodeCompletionCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -491,18 +491,12 @@ CodeCompletionCore::RuleEndStatus CodeCompletionCore::processRule( // NOLINT
// Start with rule specific handling before going into the ATN walk.

// Check first if we've taken this path with the same input before.
std::map<size_t, RuleEndStatus> positionMap;
if (!shortcutMap.contains(startState->ruleIndex)) {
shortcutMap[startState->ruleIndex] = positionMap;
} else {
positionMap = shortcutMap[startState->ruleIndex];
if (positionMap.contains(tokenListIndex)) {
if (showDebugOutput) {
std::cout << "=====> shortcut" << "\n";
}

return positionMap[tokenListIndex];
std::map<size_t, RuleEndStatus>& positionMap = shortcutMap[startState->ruleIndex];
if (positionMap.contains(tokenListIndex)) {
if (showDebugOutput) {
std::cout << "=====> shortcut" << "\n";
}
return positionMap[tokenListIndex];
}

RuleEndStatus result;
Expand All @@ -521,7 +515,7 @@ CodeCompletionCore::RuleEndStatus CodeCompletionCore::processRule( // NOLINT
antlr4::atn::RuleStopState* stop = atn.ruleToStopState[startState->ruleIndex];
setsPerState[startState->stateNumber] = determineFollowSets(startState, stop);
}

const FollowSetsHolder& followSets = setsPerState[startState->stateNumber];

// Get the token index where our rule starts from our (possibly filtered)
Expand Down
3 changes: 1 addition & 2 deletions ports/cpp/test/cpp14/Cpp14Test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,7 @@ TEST(CPP14Parser, SimpleExample) { // NOLINT: complexity
CPP14Parser::RuleTranslationunit,
CPP14Parser::RuleDeclarationseq,
CPP14Parser::RuleDeclaration,
CPP14Parser::RuleBlockdeclaration, // TS: +- `RuleFunctiondefinition`
CPP14Parser::RuleSimpledeclaration, // TS: --
CPP14Parser::RuleFunctiondefinition,
CPP14Parser::RuleDeclspecifierseq,
CPP14Parser::RuleDeclspecifier,
CPP14Parser::RuleTypespecifier,
Expand Down

0 comments on commit 0f5a5f0

Please sign in to comment.