mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[java] pull up: don't transform super calls unnecessary (IDEA-277680)
GitOrigin-RevId: 4dce57984e4dd79813781493614d19bb2ec0c535
This commit is contained in:
committed by
intellij-monorepo-bot
parent
1673673d88
commit
d92c835832
@@ -766,8 +766,6 @@ public class JavaPullUpHelper implements PullUpHelper<MemberInfo> {
|
||||
}
|
||||
|
||||
private class ExplicitSuperDeleter extends JavaRecursiveElementWalkingVisitor {
|
||||
private final PsiExpression myThisExpression = JavaPsiFacade.getElementFactory(myProject).createExpressionFromText("this", null);
|
||||
|
||||
@Override
|
||||
public void visitReferenceExpression(PsiReferenceExpression expression) {
|
||||
super.visitReferenceExpression(expression);
|
||||
@@ -779,10 +777,6 @@ public class JavaPullUpHelper implements PullUpHelper<MemberInfo> {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitSuperExpression(PsiSuperExpression expression) {
|
||||
expression.replace(myThisExpression);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitClass(PsiClass aClass) {
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
|
||||
class A {
|
||||
public boolean foo() {
|
||||
return Math.random() > 0.5;
|
||||
}
|
||||
}
|
||||
|
||||
class B extends A {
|
||||
}
|
||||
|
||||
class Test extends B {
|
||||
@Override
|
||||
public boolean f<caret>oo() {
|
||||
if (!super.foo()) {
|
||||
return false;
|
||||
}
|
||||
return Math.random() > 0.5;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
|
||||
class A {
|
||||
public boolean foo() {
|
||||
return Math.random() > 0.5;
|
||||
}
|
||||
}
|
||||
|
||||
class B extends A {
|
||||
@Override
|
||||
public boolean foo() {
|
||||
if (!super.foo()) {
|
||||
return false;
|
||||
}
|
||||
return Math.random() > 0.5;
|
||||
}
|
||||
}
|
||||
|
||||
class Test extends B {
|
||||
}
|
||||
@@ -1,18 +1,4 @@
|
||||
/*
|
||||
* Copyright 2000-2017 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.
|
||||
*/
|
||||
// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.java.refactoring;
|
||||
|
||||
import com.intellij.JavaTestUtil;
|
||||
@@ -237,6 +223,10 @@ public class PullUpTest extends LightRefactoringTestCase {
|
||||
public void testPullUpFromAnonymousToInterface() {
|
||||
doTest(false, new RefactoringTestUtil.MemberDescriptor("foo", PsiMethod.class, true));
|
||||
}
|
||||
|
||||
public void testSuperExprQualifying() {
|
||||
doTest(false, new RefactoringTestUtil.MemberDescriptor("foo", PsiMethod.class, false));
|
||||
}
|
||||
|
||||
private void doTest(RefactoringTestUtil.MemberDescriptor... membersToFind) {
|
||||
doTest(true, membersToFind);
|
||||
|
||||
Reference in New Issue
Block a user