mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-03-22 06:50:54 +07:00
[java-completion] IDEA-357258 Java 23: .switch postfix completion is not supported for primitive data types
GitOrigin-RevId: ae848584ee81611bde2e1201c79923c2e170f6e6
This commit is contained in:
committed by
intellij-monorepo-bot
parent
8980aa2c1f
commit
d72eba89a1
@@ -19,6 +19,7 @@ import com.intellij.psi.*;
|
||||
import com.intellij.psi.codeStyle.CodeStyleManager;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
import com.intellij.psi.util.TypeConversionUtil;
|
||||
import com.intellij.util.Function;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -48,6 +49,9 @@ public class SwitchStatementPostfixTemplate extends SurroundPostfixTemplateBase
|
||||
if (PsiUtil.isAvailable(JavaFeature.STRING_SWITCH, javaFile)) return true;
|
||||
}
|
||||
|
||||
if (PsiUtil.isAvailable(JavaFeature.PRIMITIVE_TYPES_IN_PATTERNS, expression) &&
|
||||
TypeConversionUtil.isPrimitiveAndNotNull(type)) return true;
|
||||
|
||||
return false;
|
||||
});
|
||||
};
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
|
||||
class Main {
|
||||
int g(long o) {
|
||||
o.swit<caret>
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
|
||||
class Main {
|
||||
int g(long o) {
|
||||
o.swit<caret>
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
|
||||
class Main {
|
||||
int g(long o) {
|
||||
o.swit <caret>
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
|
||||
class Main {
|
||||
int g(long o) {
|
||||
switch (o) {
|
||||
<caret>
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package com.intellij.java.codeInsight.completion;
|
||||
|
||||
import com.intellij.codeInsight.template.impl.LiveTemplateCompletionContributor;
|
||||
import com.intellij.openapi.application.impl.NonBlockingReadActionImpl;
|
||||
import com.intellij.pom.java.JavaFeature;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import com.intellij.testFramework.IdeaTestUtil;
|
||||
import com.intellij.testFramework.LightProjectDescriptor;
|
||||
@@ -69,6 +70,16 @@ public class NormalSwitchCompletionTest extends NormalCompletionTestCase {
|
||||
|
||||
public void testCompleteSwitchObjectSelectorPostfix() { doTestPostfixCompletion(); }
|
||||
|
||||
public void testCompleteSwitchPrimitiveSelectorPostfix() {
|
||||
IdeaTestUtil.withLevel(myFixture.getModule(), JavaFeature.PRIMITIVE_TYPES_IN_PATTERNS.getMinimumLevel(),
|
||||
() -> doTestPostfixCompletion());
|
||||
}
|
||||
|
||||
public void testCompleteSwitchPrimitiveSelectorPostfixLowerLanguageLevel() {
|
||||
IdeaTestUtil.withLevel(myFixture.getModule(), LanguageLevel.JDK_11,
|
||||
() -> doTestPostfixCompletion());
|
||||
}
|
||||
|
||||
public void testCompleteSwitchSealedSelectorPostfix() { doTestPostfixCompletion(); }
|
||||
|
||||
@NeedsIndex.ForStandardLibrary
|
||||
|
||||
Reference in New Issue
Block a user