[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:
Tagir Valeev
2024-06-21 12:17:42 +02:00
committed by intellij-monorepo-bot
parent 3b45af56a7
commit e573732e7c
3 changed files with 30 additions and 3 deletions

View File

@@ -0,0 +1,18 @@
import java.util.*;
public class ExtractMethodRecommenderComment {
void testLongCommentBefore() {
// We are creating a new Date object here and set it's to 12 hours
// We are creating a new Date object here and set it's to 12 hours
// We are creating a new Date object here and set it's to 12 hours
Date d = new Date();
d.setHours(12);
System.out.println(d);
System.out.println(d);
System.out.println(d);
System.out.println(d);
System.out.println(d);
System.out.println(d);
System.out.println(d);
}
}

View File

@@ -33,6 +33,14 @@ public class ExtractMethodRecommenderInspectionTest extends LightJavaCodeInsight
myFixture.checkHighlighting();
}
public void testExtractMethodRecommenderComment() {
ExtractMethodRecommenderInspection inspection = new ExtractMethodRecommenderInspection();
inspection.minLength = 100;
myFixture.enableInspections(inspection);
myFixture.configureByFile(getTestName(false) + ".java");
myFixture.checkHighlighting();
}
public void testImplicitClass() {
ExtractMethodRecommenderInspection inspection = new ExtractMethodRecommenderInspection();
myFixture.enableInspections(inspection);