mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
less magic on copy method from interface (IDEA-233351)
GitOrigin-RevId: b3196a93a6d4857fcba722e271b71d85d8567094
This commit is contained in:
committed by
intellij-monorepo-bot
parent
b916a8e911
commit
1a18c8df4c
@@ -28,6 +28,7 @@ import com.intellij.psi.impl.source.PsiJavaCodeReferenceElementImpl;
|
||||
import com.intellij.psi.impl.source.SourceTreeToPsiMap;
|
||||
import com.intellij.psi.templateLanguages.OuterLanguageElement;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
|
||||
import java.util.Map;
|
||||
@@ -103,7 +104,7 @@ public class JavaTreeCopyHandler implements TreeCopyHandler {
|
||||
modifierList.setModifierProperty(PsiModifier.STATIC, true);
|
||||
modifierList.setModifierProperty(PsiModifier.FINAL, true);
|
||||
}
|
||||
else if (element.getTreeParent().getElementType() == JavaElementType.METHOD ||
|
||||
else if (element.getTreeParent().getElementType() == JavaElementType.METHOD && !PsiUtil.isLanguageLevel8OrHigher(modifierList) ||
|
||||
element.getTreeParent().getElementType() == JavaElementType.ANNOTATION_METHOD) {
|
||||
modifierList.setModifierProperty(PsiModifier.PUBLIC, true);
|
||||
modifierList.setModifierProperty(PsiModifier.ABSTRACT, true);
|
||||
|
||||
+5
@@ -803,6 +803,11 @@ public class InheritanceToDelegationProcessor extends BaseRefactoringProcessor {
|
||||
String visibility = checkOuterClassAbstractMethod(signature);
|
||||
PsiMethod newOuterMethod = (PsiMethod)myClass.add(myMethod);
|
||||
PsiUtil.setModifierProperty(newOuterMethod, visibility, true);
|
||||
if (containingClass.isInterface() &&
|
||||
!innerClass.isInterface() &&
|
||||
myMethod.getBody() == null) {
|
||||
PsiUtil.setModifierProperty(newOuterMethod, PsiModifier.ABSTRACT, true);
|
||||
}
|
||||
final PsiDocComment docComment = newOuterMethod.getDocComment();
|
||||
if (docComment != null) {
|
||||
docComment.delete();
|
||||
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
public interface Bar {
|
||||
private void foo() {}
|
||||
static void bar() {}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
public interface Foo {
|
||||
private void foo() {}
|
||||
static void bar() {}
|
||||
}
|
||||
@@ -28,6 +28,10 @@ public class CopyClassTest extends LightMultiFileTestCase {
|
||||
public void testReplaceAllOccurrences() throws Exception {
|
||||
doTest("Foo", "Bar");
|
||||
}
|
||||
|
||||
public void testPrivateMethodsInInterfaces() throws Exception {
|
||||
doTest("Foo", "Bar");
|
||||
}
|
||||
|
||||
public void testReplaceAllOccurrences1() throws Exception {
|
||||
doTest("Foo", "Bar");
|
||||
|
||||
Reference in New Issue
Block a user