mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-19 21:11:28 +07:00
[intention-preview] Create record on record pattern: fix an exception when the record component pattern list is empty
IDEA-304933 GitOrigin-RevId: f0fe135f3bddf5e5705f76de8ebe095543bd18a8
This commit is contained in:
committed by
intellij-monorepo-bot
parent
e056e25116
commit
d0c57ae46f
@@ -6,6 +6,7 @@ import com.intellij.codeInsight.CodeInsightUtilCore;
|
||||
import com.intellij.codeInsight.FileModificationService;
|
||||
import com.intellij.codeInsight.daemon.QuickFixBundle;
|
||||
import com.intellij.codeInsight.intention.preview.IntentionPreviewInfo;
|
||||
import com.intellij.codeInsight.intention.preview.IntentionPreviewUtils;
|
||||
import com.intellij.codeInsight.template.Template;
|
||||
import com.intellij.codeInsight.template.TemplateBuilderImpl;
|
||||
import com.intellij.codeInspection.util.IntentionName;
|
||||
@@ -195,7 +196,7 @@ public class CreateInnerClassFromUsageFix extends CreateClassFromUsageBaseFix {
|
||||
editor.getDocument().deleteString(textRange.getStartOffset(), textRange.getEndOffset());
|
||||
CreateFromUsageBaseFix.startTemplate(editor, template, project, null, text);
|
||||
}
|
||||
else {
|
||||
else if (!IntentionPreviewUtils.isPreviewElement(deconstructionList)) {
|
||||
CodeInsightUtil.positionCursor(project, aClass.getContainingFile(), ObjectUtils.notNull(aClass.getNameIdentifier(), aClass));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
// "Create record 'EmptyBox'" "true-preview"
|
||||
class Test {
|
||||
void foo(Object obj) {
|
||||
switch (obj) {
|
||||
case EmptyBox() -> System.out.println( "Fill it up and send it back");
|
||||
default -> {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public record EmptyBox() {
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
// "Create record 'EmptyBox'" "true-preview"
|
||||
class Test {
|
||||
void foo(Object obj) {
|
||||
switch (obj) {
|
||||
case Empty<caret>Box() -> System.out.println( "Fill it up and send it back");
|
||||
default -> {}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
public record EmptyBox() {
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
// "Create inner record 'EmptyBox'" "true-preview"
|
||||
class Test {
|
||||
void foo(Object obj) {
|
||||
switch (obj) {
|
||||
case EmptyBox() -> System.out.println( "Fill it up and send it back");
|
||||
default -> {}
|
||||
}
|
||||
}
|
||||
|
||||
private record EmptyBox() {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
// "Create inner record 'EmptyBox'" "true-preview"
|
||||
class Test {
|
||||
void foo(Object obj) {
|
||||
switch (obj) {
|
||||
case Empty<caret>Box() -> System.out.println( "Fill it up and send it back");
|
||||
default -> {}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user