mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-21 14:01:44 +07:00
[intention-preview] CreateRecordFromNewFix: start template and set up generic parameters
GitOrigin-RevId: e7fea4d4b8c11d584d53bdf9450d4a29cfb19f6b
This commit is contained in:
committed by
intellij-monorepo-bot
parent
e03e35185f
commit
0e1dd4d61b
@@ -57,8 +57,9 @@ public class CreateClassFromNewFix extends CreateFromUsageBaseFix {
|
||||
if (element == null) return IntentionPreviewInfo.EMPTY;
|
||||
PsiJavaCodeReferenceElement classReference = getReferenceElement(element);
|
||||
if (classReference == null) return IntentionPreviewInfo.EMPTY;
|
||||
PsiClass aClass = getKind().create(JavaPsiFacade.getElementFactory(project), classReference.getReferenceName());
|
||||
PsiClass aClass = (PsiClass)file.add(getKind().create(JavaPsiFacade.getElementFactory(project), classReference.getReferenceName()));
|
||||
setupClassFromNewExpression(aClass, element);
|
||||
setupGenericParameters(aClass, classReference);
|
||||
CodeStyleManager.getInstance(project).reformat(aClass);
|
||||
return new IntentionPreviewInfo.CustomDiff(JavaFileType.INSTANCE, "", aClass.getText());
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Create class 'MyCollection'" "true"
|
||||
// "Create class 'MyCollection'" "true-preview"
|
||||
import java.util.*;
|
||||
|
||||
public class Test {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Create class 'MyArrayList'" "true"
|
||||
// "Create class 'MyArrayList'" "true-preview"
|
||||
import java.util.*;
|
||||
|
||||
public class Test {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Create class 'MyInteger'" "true"
|
||||
// "Create class 'MyInteger'" "true-preview"
|
||||
public class Test {
|
||||
public static void main() {
|
||||
int xxx = 3;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Create class 'MyCollection'" "true"
|
||||
// "Create class 'MyCollection'" "true-preview"
|
||||
public class Test {
|
||||
public static void main() {
|
||||
Collection[] cc = new MyCollection[10];
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Create class 'MyCollection'" "true"
|
||||
// "Create class 'MyCollection'" "true-preview"
|
||||
import java.util.*;
|
||||
|
||||
public class Test {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Create class 'MyTableModel'" "true"
|
||||
// "Create class 'MyTableModel'" "true-preview"
|
||||
|
||||
public class Test {
|
||||
public static void main() {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Create class 'MyCollection'" "true"
|
||||
// "Create class 'MyCollection'" "true-preview"
|
||||
import java.util.*;
|
||||
|
||||
class Test extends Foo {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Create record 'MyRecord'" "true"
|
||||
// "Create record 'MyRecord'" "true-preview"
|
||||
class Test {
|
||||
void foo () {
|
||||
new MyRecord<String> (1, 2);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Create class 'Generic'" "true"
|
||||
// "Create class 'Generic'" "true-preview"
|
||||
class Test {
|
||||
void foo () {
|
||||
new Generic<String> ();
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
// "Create record 'MyRecord'" "true-preview"
|
||||
class Test {
|
||||
void foo () {
|
||||
new MyRecord (1);
|
||||
new MyRecord (1, 2);
|
||||
}
|
||||
}
|
||||
|
||||
public record MyRecord(int i) {
|
||||
public record MyRecord(int i, int i1) {
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Create class 'MyCollection'" "true"
|
||||
// "Create class 'MyCollection'" "true-preview"
|
||||
import java.util.*;
|
||||
|
||||
public class Test {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Create class 'MyArrayList'" "true"
|
||||
// "Create class 'MyArrayList'" "true-preview"
|
||||
import java.util.*;
|
||||
|
||||
public class Test {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Create class 'MyInteger'" "true"
|
||||
// "Create class 'MyInteger'" "true-preview"
|
||||
public class Test {
|
||||
public static void main() {
|
||||
int xxx = 3;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Create class 'MyCollection'" "true"
|
||||
// "Create class 'MyCollection'" "true-preview"
|
||||
public class Test {
|
||||
public static void main() {
|
||||
Collection[] cc = new <caret>MyCollection[10];
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Create class 'MyCollection'" "true"
|
||||
// "Create class 'MyCollection'" "true-preview"
|
||||
import java.util.*;
|
||||
|
||||
public class Test {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Create class 'MyTableModel'" "true"
|
||||
// "Create class 'MyTableModel'" "true-preview"
|
||||
|
||||
public class Test {
|
||||
public static void main() {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Create class 'MyCollection'" "true"
|
||||
// "Create class 'MyCollection'" "true-preview"
|
||||
import java.util.*;
|
||||
|
||||
class Test extends Foo {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Create record 'MyRecord'" "true"
|
||||
// "Create record 'MyRecord'" "true-preview"
|
||||
class Test {
|
||||
void foo () {
|
||||
new <caret>MyRecord<String> (1, 2);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Create class 'Generic'" "true"
|
||||
// "Create class 'Generic'" "true-preview"
|
||||
class Test {
|
||||
void foo () {
|
||||
new <caret>Generic<String> ();
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// "Create record 'MyRecord'" "true-preview"
|
||||
class Test {
|
||||
void foo () {
|
||||
new <caret>MyRecord (1);
|
||||
new <caret>MyRecord (1, 2);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
public class MyCollection implements Collection {
|
||||
public MyCollection(int i, String test) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
public class MyArrayList extends ArrayList {
|
||||
public MyArrayList(int i, String test) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
public class MyInteger {
|
||||
public MyInteger(int xxx) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
public class MyCollection {
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
public class MyCollection implements Collection {
|
||||
public MyCollection(int i) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
public class MyTableModel implements TableModel {
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
public class MyCollection implements Collection {
|
||||
public MyCollection(int i) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
public record MyRecord<T>(int i, int i1) {
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
public class Generic<T> {
|
||||
}
|
||||
@@ -1,2 +1,2 @@
|
||||
public record MyRecord(int i) {
|
||||
public record MyRecord(int i, int i1) {
|
||||
}
|
||||
Reference in New Issue
Block a user