From edbc92024724b4bf1b42d9eb87633780bd51cfb5 Mon Sep 17 00:00:00 2001 From: overflowerror Date: Fri, 7 Jan 2022 20:44:36 +0100 Subject: [PATCH] changed token limit for tree rebuild is necessary because otherwise the identity analysis might not be able to detect if paths are identical up to the token limit (which should cause an error) --- .../generator/parser/antlr/hoisting/HoistingProcessor.java | 2 +- .../parser/antlr/hoisting/pathAnalysis/TokenAnalysis.java | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/org.eclipse.xtext.xtext.generator/src/org/eclipse/xtext/xtext/generator/parser/antlr/hoisting/HoistingProcessor.java b/org.eclipse.xtext.xtext.generator/src/org/eclipse/xtext/xtext/generator/parser/antlr/hoisting/HoistingProcessor.java index 51df56ba9..9ad351e47 100644 --- a/org.eclipse.xtext.xtext.generator/src/org/eclipse/xtext/xtext/generator/parser/antlr/hoisting/HoistingProcessor.java +++ b/org.eclipse.xtext.xtext.generator/src/org/eclipse/xtext/xtext/generator/parser/antlr/hoisting/HoistingProcessor.java @@ -238,7 +238,7 @@ public class HoistingProcessor { // all paths are trivial // if there is a terminal on all branches set has terminal to true - // else we need might need to consider the following tokens in the path + // else we might need to consider the following tokens in the path if (guards.stream().allMatch(HoistingGuard::hasTerminal)) { return HoistingGuard.terminal(); } else { diff --git a/org.eclipse.xtext.xtext.generator/src/org/eclipse/xtext/xtext/generator/parser/antlr/hoisting/pathAnalysis/TokenAnalysis.java b/org.eclipse.xtext.xtext.generator/src/org/eclipse/xtext/xtext/generator/parser/antlr/hoisting/pathAnalysis/TokenAnalysis.java index 43a48273a..41953d2da 100644 --- a/org.eclipse.xtext.xtext.generator/src/org/eclipse/xtext/xtext/generator/parser/antlr/hoisting/pathAnalysis/TokenAnalysis.java +++ b/org.eclipse.xtext.xtext.generator/src/org/eclipse/xtext/xtext/generator/parser/antlr/hoisting/pathAnalysis/TokenAnalysis.java @@ -500,7 +500,7 @@ public class TokenAnalysis { tokenCombinations(indexList -> { log.info("current index list: " + indexList); - // no context analysis + // no context analysis // TODO why? List> tokenListsForPath = getTokenPaths(element, indexList, false); List> tokenListForContext = getTokenPathsContextOnly(element, indexList); @@ -572,7 +572,8 @@ public class TokenAnalysis { } public List> getAllPossiblePaths(AbstractElement path) { - return getTokenPaths(path, new TokenAnalysisPaths(range(0, config.getTokenLimit() + 1)), false, false, true) + // token limit + 2 so identity analysis will recognize paths that are identical up to the token limit on the flattened tree + return getTokenPaths(path, new TokenAnalysisPaths(range(0, config.getTokenLimit() + 2)), false, false, true) .getTokenPaths() .stream() .map(l -> l.stream()