mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Local records support (IDEA-228460)
GitOrigin-RevId: 6bd11c1161f4773570573910d88c7a395f972e3c
This commit is contained in:
committed by
intellij-monorepo-bot
parent
bc5e69a390
commit
ee428f70e6
+4
-2
@@ -904,9 +904,11 @@ public class HighlightUtil extends HighlightUtilBase {
|
||||
else {
|
||||
//noinspection DuplicateExpressions
|
||||
if (PsiModifier.STATIC.equals(modifier) || privateOrProtected || PsiModifier.PACKAGE_LOCAL.equals(modifier)) {
|
||||
isAllowed = modifierOwnerParent instanceof PsiClass &&
|
||||
isAllowed = modifierOwnerParent instanceof PsiClass && ((PsiClass)modifierOwnerParent).getQualifiedName() != null ||
|
||||
modifierOwnerParent instanceof PsiDeclarationStatement && aClass.isRecord() ||
|
||||
FileTypeUtils.isInServerPageFile(modifierOwnerParent) ||
|
||||
// non-physical dummy holder might not have FQN
|
||||
((PsiClass)modifierOwnerParent).getQualifiedName() != null || FileTypeUtils.isInServerPageFile(modifierOwnerParent) || !modifierOwnerParent.isPhysical();
|
||||
!modifierOwnerParent.isPhysical();
|
||||
}
|
||||
if (privateOrProtected && !isAllowed) {
|
||||
fix = QUICK_FIX_FACTORY.createChangeModifierFix();
|
||||
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
class Foo {
|
||||
void test() {
|
||||
record NoComponent() {}
|
||||
|
||||
static record DeclaredStatic() {}
|
||||
}
|
||||
|
||||
static int STATIC_VAR = 3;
|
||||
|
||||
int instanceVar;
|
||||
|
||||
void capture() {
|
||||
int outerLocal = 2;
|
||||
final int compileTimeConstant = 3;
|
||||
record Local() {
|
||||
static int X = 2;
|
||||
|
||||
void test() {
|
||||
System.out.println(STATIC_VAR);
|
||||
System.out.println(<error descr="Non-static field 'instanceVar' cannot be referenced from a static context">instanceVar</error>);
|
||||
System.out.println(<error descr="Non-static variable 'outerLocal' cannot be referenced from a static context">outerLocal</error>);
|
||||
System.out.println(X);
|
||||
System.out.println(compileTimeConstant);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+3
@@ -30,6 +30,9 @@ public class LightRecordsHighlightingTest extends LightJavaCodeInsightFixtureTes
|
||||
public void testRecordCompactConstructors() {
|
||||
doTest();
|
||||
}
|
||||
public void testLocalRecords() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
private void doTest() {
|
||||
myFixture.addClass("package java.lang; public abstract class Record {" +
|
||||
|
||||
Reference in New Issue
Block a user