mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-15 11:58:18 +07:00
Error highlighting for records: record bodies, record members (8.10.2, 8.10.3) IDEA-228460
Also ChangeModifierIntention: do not suggest to change component accessor access modifier Also AddExceptionToThrowsFix: do not suggest to add throws to component accessor GitOrigin-RevId: 6ce3d43f5160c075a2c66ac01af895a1212cc9a3
This commit is contained in:
committed by
intellij-monorepo-bot
parent
d887f8b142
commit
028a78cae3
+20
@@ -0,0 +1,20 @@
|
||||
record Rec(int x, int y) {
|
||||
public <error descr="Incorrect component accessor return type. Expected: 'int', found: 'void'">void</error> x() {}
|
||||
|
||||
public void y(int x) {}
|
||||
}
|
||||
record RecTypeParam(int x) {
|
||||
public <error descr="Record component accessor cannot have type parameters"><T></error> int x() {return this.x;}
|
||||
}
|
||||
record RecStaticAccessor(int x) {
|
||||
public <error descr="Modifier 'static' not allowed here">static</error> int x() {return 0;}
|
||||
}
|
||||
record RecNonPublic(int x, int y, int z) {
|
||||
protected int <error descr="Record component accessor must be 'public'">x</error>() {return x;}
|
||||
int <error descr="Record component accessor must be 'public'">y</error>() {return y;}
|
||||
private int <error descr="Record component accessor must be 'public'">z</error>() {return z;}
|
||||
}
|
||||
record RecThrows(int x) {
|
||||
public int x() <error descr="Record component accessor cannot declare thrown exceptions">throws Exception</error> {return x;}
|
||||
public int y() throws Exception {return x;}
|
||||
}
|
||||
+17
-1
@@ -34,4 +34,20 @@ record IllegalComponentName(
|
||||
record AnnotatedComponents(
|
||||
@SimpleAnno int x,
|
||||
<error descr="'@ConstructorAnno' not applicable to record component">@ConstructorAnno</error> int y,
|
||||
@MethodAnno int z) {}
|
||||
@MethodAnno int z) {}
|
||||
|
||||
class Outer {
|
||||
record NestedRecord() {}
|
||||
class Inner {
|
||||
<error descr="Inner classes cannot have static declarations">record InnerRecord()</error> {}
|
||||
}
|
||||
}
|
||||
|
||||
record ProhibitedMembers() {
|
||||
<error descr="Instance field is not allowed in record">int x = 5;</error>
|
||||
|
||||
<error descr="Instance initializer is not allowed in record">{
|
||||
System.out.println("initializer");
|
||||
}</error>
|
||||
<error descr="Modifier 'native' not allowed here">native</error> void test();
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
// "Add exception to method signature" "false"
|
||||
record X(int foo) {
|
||||
public int foo() {
|
||||
throw new <caret>Exception();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user