You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was playing with eliminating left recursion in a grammar when JDT refused to extract a piece of code to a new method. I found this in Eclipse 2023-03, and confirmed it in 2024-03 as well.
There are two probably different refusals in the same original code, here I'll show the first one.
Reduced to a small example:
packagecompletion2.grammar;
importjava.util.List;
publicclassRefactorFalseNegativeBreakContinue {
publicstaticvoidfalseNegativeBreakRefactor(List<List<String>> defs) {
for (List<String> def: defs) {
booleanisLeftRecursive = false;
for (Stringrule: def) {
if (!rule.isEmpty()) {
break;
}
}
if (!isLeftRecursive) {
continue;
}
}
}
}
I want to refactor the body of the outer loop:
Message from Eclipse refactoring:
It looks asif JDT fails to see that the break is in an inner loop.
If either the break or the continue is removed, it works (although I haven't checked what it does then).
The text was updated successfully, but these errors were encountered:
Alberth289346
changed the title
Refactor false negative on break in loop inside the refactored code
Refactor "extract method" false negative on break in loop inside the refactored code
Mar 29, 2024
- fix ExtractMethodAnalyzer.canHandleBranches() to not flag a
non-labelled break statement if the for loop is included
- add new test to ExtractMethodTests
- fixeseclipse-jdt#1291
- fix ExtractMethodAnalyzer.canHandleBranches() to not flag a
non-labelled break statement if the for loop is included
- add new test to ExtractMethodTests
- fixeseclipse-jdt#1291
I was playing with eliminating left recursion in a grammar when JDT refused to extract a piece of code to a new method. I found this in Eclipse 2023-03, and confirmed it in 2024-03 as well.
There are two probably different refusals in the same original code, here I'll show the first one.
Reduced to a small example:
I want to refactor the body of the outer loop:
Message from Eclipse refactoring:
It looks asif JDT fails to see that the
break
is in an inner loop.If either the
break
or thecontinue
is removed, it works (although I haven't checked what it does then).The text was updated successfully, but these errors were encountered: