[java-completion] IDEA-354763 IJ-CR-137494 Don't suggest protected/transient and so on the top file level

- skip `strictfp` according to language level
- more accurately determine position
- refactoring

GitOrigin-RevId: 2d660d7f4fd86bed089da62f4ca746c6f2348aec
This commit is contained in:
Mikhail Pyltsin
2024-06-24 18:35:51 +02:00
committed by intellij-monorepo-bot
parent fc7bb4d813
commit 114a8907cf
4 changed files with 78 additions and 93 deletions

View File

@@ -0,0 +1 @@
public <caret> Cls

View File

@@ -0,0 +1 @@
public <caret> Cls

View File

@@ -36,12 +36,12 @@ public class KeywordCompletionTest extends LightCompletionTestCase {
setLanguageLevel(JavaFeature.IMPLICIT_CLASSES.getMinimumLevel());
doTest(16, "package", "public", "import", "final", "class", "interface", "abstract", "enum",
"transient", "static", "private", "protected", "volatile", "synchronized", "sealed", "non-sealed");
assertNotContainItems("default");
assertNotContainItems("default", "strictfp");
}
public void testFileScopeWithoutPackage2() {
setLanguageLevel(LanguageLevel.JDK_1_8);
doTest(8, "package", "public", "import", "final", "class", "interface", "abstract", "enum");
doTest(9, "package", "public", "import", "final", "class", "interface", "abstract", "enum", "strictfp");
assertNotContainItems("default", "transient", "static", "private", "protected", "volatile", "synchronized", "sealed", "non-sealed");
}
@@ -66,6 +66,15 @@ public class KeywordCompletionTest extends LightCompletionTestCase {
}
public void testClassScope3() { doTest(0, CLASS_SCOPE_KEYWORDS); }
public void testClassScope4() { doTest(11, CLASS_SCOPE_KEYWORDS_2); }
public void testClassScope5() {
setLanguageLevel(JavaFeature.ALWAYS_STRICTFP.getMinimumLevel());
doTestContains("class", "interface", "enum", "record", "sealed", "non-sealed");
assertNotContainItems("default", "transient", "static", "private", "protected", "volatile", "synchronized", "strictfp");
}
public void testClassScope5WithStrictfp() {
setLanguageLevel(LanguageLevel.JDK_1_8);
doTestContains("class", "interface", "enum", "strictfp");
}
public void testInnerClassScope() {
doTest(11, CLASS_SCOPE_KEYWORDS_2);
}