mirror of
https://github.com/sigmasternchen/xtext-core
synced 2025-03-15 08:18:55 +00:00
potential fix for endless loop
check progress on smallest branch in every iteration not just the first -> now loops in token analysis should always exit, either by being done or by tripping the endless loop protection
This commit is contained in:
parent
b7f69d8a65
commit
3af9fd0c4a
1 changed files with 6 additions and 6 deletions
|
@ -269,11 +269,11 @@ public class TokenAnalysis {
|
|||
result = TokenAnalysisPaths.empty(prefix);
|
||||
}
|
||||
|
||||
int currentPosition = result.getMinPosition();
|
||||
|
||||
do {
|
||||
current = TokenAnalysisPaths.empty(result);
|
||||
current.resetProgress();
|
||||
int currentPosition = current.getMinPosition();
|
||||
|
||||
for (AbstractElement element : path.getElements()) {
|
||||
current = current.merge(getTokenPaths(element, result, false, false, shortcutEndlessLoops));
|
||||
}
|
||||
|
@ -283,7 +283,7 @@ public class TokenAnalysis {
|
|||
|
||||
if (current.getMinPosition() == currentPosition) {
|
||||
// endless loop
|
||||
// result will never be done since there is no progress to the shortest path
|
||||
// current will never be done since there is no progress to the shortest path
|
||||
if (shortcutEndlessLoops) {
|
||||
if (!result.hasProgress()) {
|
||||
// no progress
|
||||
|
@ -408,10 +408,10 @@ public class TokenAnalysis {
|
|||
|
||||
boolean loop = isVirtualMultipleCardinality(cardinality);
|
||||
|
||||
int currentMinPosition = result.getMinPosition();
|
||||
|
||||
do {
|
||||
int currentMinPosition = result.getMinPosition();
|
||||
result.resetProgress();
|
||||
|
||||
TokenAnalysisPaths tokenPaths = getTokenPathsTrivial(path, result, shortcutEndlessLoops);
|
||||
|
||||
if (tokenPaths.isDone()) {
|
||||
|
@ -533,7 +533,7 @@ public class TokenAnalysis {
|
|||
}
|
||||
}
|
||||
private boolean tokenCombinations(long prefix, int prefixLength, int ones, Function<List<Integer>, Boolean> callback, MutableWrapper<Integer> limit) {
|
||||
if (ones == 0) {
|
||||
if (ones <= 0) {
|
||||
List<Integer> indexes = new ArrayList<>(limit.get());
|
||||
int l = limit.get();
|
||||
for (int i = 0; i < l; i++) {
|
||||
|
|
Loading…
Reference in a new issue