mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
change extends <-> implements: ensure resulted list is formatted (IDEA-201751)
lists are created from light elements which are created from canonical texts and they just do not contain whitespaces
This commit is contained in:
+4
-3
@@ -22,6 +22,7 @@ import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.codeStyle.CodeStyleManager;
|
||||
import com.intellij.psi.codeStyle.JavaCodeStyleManager;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
@@ -147,6 +148,7 @@ public class ExtendsListFix extends LocalQuickFixAndIntentionActionOnPsiElement
|
||||
}
|
||||
}
|
||||
PsiReferenceList list = extendsList;
|
||||
Project project = extendsList.getProject();
|
||||
if (add && !alreadyExtends) {
|
||||
PsiElement anchor;
|
||||
if (position == -1) {
|
||||
@@ -158,8 +160,7 @@ public class ExtendsListFix extends LocalQuickFixAndIntentionActionOnPsiElement
|
||||
else {
|
||||
anchor = referenceElements[position - 1];
|
||||
}
|
||||
PsiJavaCodeReferenceElement classReferenceElement =
|
||||
JavaPsiFacade.getElementFactory(extendsList.getProject()).createReferenceElementByType(myTypeToExtendFrom);
|
||||
PsiJavaCodeReferenceElement classReferenceElement = JavaPsiFacade.getElementFactory(project).createReferenceElementByType(myTypeToExtendFrom);
|
||||
PsiElement element;
|
||||
if (anchor == null) {
|
||||
if (referenceElements.length == 0) {
|
||||
@@ -180,6 +181,6 @@ public class ExtendsListFix extends LocalQuickFixAndIntentionActionOnPsiElement
|
||||
return;
|
||||
}
|
||||
|
||||
JavaCodeStyleManager.getInstance(extendsList.getProject()).shortenClassReferences(list);
|
||||
CodeStyleManager.getInstance(project).reformat(JavaCodeStyleManager.getInstance(project).shortenClassReferences(list));
|
||||
}
|
||||
}
|
||||
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
// "Change 'implements b' to 'extends b'" "true"
|
||||
class a extends b<String, Integer> {
|
||||
}
|
||||
|
||||
class b<T, K> {}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
// "Change 'implements b' to 'extends b'" "true"
|
||||
class a implements <caret>b<String, Integer> {
|
||||
}
|
||||
|
||||
class b<T, K> {}
|
||||
Reference in New Issue
Block a user