mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-02-04 23:39:07 +07:00
[java-inspections] Extract method recommender: do not include initial comment into the length
Fixes IDEA-354492 "Method can be extracted" includes comments as minimum code length GitOrigin-RevId: 3d4e34e6726f7917fe3b0224653b89f07cd2ae42
This commit is contained in:
committed by
intellij-monorepo-bot
parent
3b45af56a7
commit
e573732e7c
@@ -85,7 +85,8 @@ public final class ExtractMethodRecommenderInspection extends AbstractBaseJavaLo
|
||||
PsiStatement[] range = Arrays.copyOfRange(statements, from, to);
|
||||
if (ContainerUtil.exists(range, e -> e instanceof PsiSwitchLabelStatementBase)) continue;
|
||||
TextRange textRange = getRange(range);
|
||||
if (textRange.getLength() < minLength || textRange.getLength() > maxLength) continue;
|
||||
int length = range[range.length - 1].getTextRange().getEndOffset() - range[0].getTextRange().getStartOffset();
|
||||
if (length < minLength || textRange.getLength() > maxLength) continue;
|
||||
try {
|
||||
ControlFlowWrapper wrapper = new ControlFlowWrapper(fragment, range);
|
||||
Collection<PsiStatement> exitStatements = wrapper.prepareExitStatements(range);
|
||||
@@ -118,11 +119,11 @@ public final class ExtractMethodRecommenderInspection extends AbstractBaseJavaLo
|
||||
JavaAnalysisBundle.message("inspection.extract.method.dont.suggest.parameters", inputVariables.size()),
|
||||
inputVariables.size() - 1)));
|
||||
}
|
||||
if (textRange.getLength() < 10_000) {
|
||||
if (length < 10_000) {
|
||||
fixes.add(LocalQuickFix.from(new UpdateInspectionOptionFix(
|
||||
ExtractMethodRecommenderInspection.this, "minLength",
|
||||
JavaAnalysisBundle.message("inspection.extract.method.dont.suggest.length"),
|
||||
textRange.getLength() + 1)));
|
||||
length + 1)));
|
||||
}
|
||||
int firstLineBreak = textRange.substring(block.getText()).indexOf('\n');
|
||||
PsiElement anchor = block;
|
||||
|
||||
Reference in New Issue
Block a user