mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-125678 ConvertInterfaceToClassIntention.moveExtendsToImplements improved
This commit is contained in:
+8
-5
@@ -106,7 +106,7 @@ public class ConvertInterfaceToClassIntention extends Intention {
|
||||
final PsiClass anInterface = (PsiClass)element.getParent();
|
||||
final SearchScope searchScope = anInterface.getUseScope();
|
||||
final Query<PsiClass> query = ClassInheritorsSearch.search(anInterface, searchScope, false);
|
||||
final MultiMap<PsiElement, String> conflicts = new MultiMap();
|
||||
final MultiMap<PsiElement, String> conflicts = new MultiMap<PsiElement, String>();
|
||||
query.forEach(new Processor<PsiClass>() {
|
||||
@Override
|
||||
public boolean process(PsiClass aClass) {
|
||||
@@ -180,11 +180,14 @@ public class ConvertInterfaceToClassIntention extends Intention {
|
||||
final PsiReferenceList extendsList = anInterface.getExtendsList();
|
||||
final PsiReferenceList implementsList = anInterface.getImplementsList();
|
||||
assert extendsList != null;
|
||||
final PsiJavaCodeReferenceElement[] referenceElements = extendsList.getReferenceElements();
|
||||
for (PsiJavaCodeReferenceElement referenceElement : referenceElements) {
|
||||
final PsiJavaCodeReferenceElement[] extendsRefElements = extendsList.getReferenceElements();
|
||||
for (PsiJavaCodeReferenceElement referenceElement : extendsRefElements) {
|
||||
assert implementsList != null;
|
||||
implementsList.add(referenceElement);
|
||||
referenceElement.delete();
|
||||
final PsiElement resolved = referenceElement.resolve();
|
||||
if (resolved instanceof PsiClass && ((PsiClass)resolved).isInterface()) {
|
||||
implementsList.add(referenceElement);
|
||||
referenceElement.delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
abstract class Foo {
|
||||
|
||||
}
|
||||
|
||||
interface Bar extends F<caret>oo {
|
||||
|
||||
}
|
||||
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
abstract class Foo {
|
||||
|
||||
}
|
||||
|
||||
abstract class Bar extends Foo {
|
||||
|
||||
}
|
||||
|
||||
+1
@@ -24,6 +24,7 @@ public class ConvertInterfaceToClassTest extends IPPTestCase {
|
||||
public void testExtensionMethods() { doTest(); }
|
||||
public void testInnerInterface() { doTest(); }
|
||||
public void testStaticMethods() { doTest(); }
|
||||
public void testInterfaceExtendsClass() { doTest(); }
|
||||
public void testFunctionalExpressions() {
|
||||
try {
|
||||
doTest();
|
||||
|
||||
Reference in New Issue
Block a user