[change signature] ensure base method is refactored in functional expression case (IDEA-276192)

don't reorder usages for no reason

GitOrigin-RevId: 2bdeee871d696c7351addc4a1a8e886d148f6186
This commit is contained in:
Anna Kozlova
2021-08-18 13:00:42 +02:00
committed by intellij-monorepo-bot
parent 853f84791d
commit d43848c086
5 changed files with 35 additions and 33 deletions

View File

@@ -1,18 +1,4 @@
/* // 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.
* Copyright 2000-2016 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.
*/
package com.intellij.refactoring.changeSignature; package com.intellij.refactoring.changeSignature;
import com.intellij.lang.java.JavaLanguage; import com.intellij.lang.java.JavaLanguage;
@@ -77,7 +63,7 @@ class JavaChangeSignatureUsageSearcher {
for (PsiMethod psiMethod : methods) { for (PsiMethod psiMethod : methods) {
for (PsiFunctionalExpression functionalExpression : FunctionalExpressionSearch.search(psiMethod)) { for (PsiFunctionalExpression functionalExpression : FunctionalExpressionSearch.search(psiMethod)) {
result.add(new FunctionalInterfaceChangedUsageInfo(functionalExpression, psiMethod)); result.add(new FunctionalInterfaceChangedUsageInfo(functionalExpression, method));
} }
} }

View File

@@ -0,0 +1,13 @@
class Clazz {
public static void main(String[] args) {
Child child = x -> System.out.println();
}
}
interface Parent {
void exec<caret>ute(int i);
}
interface Child extends Parent {
void execute(int i);
}

View File

@@ -0,0 +1,13 @@
class Clazz {
public static void main(String[] args) {
Child child = () -> System.out.println();
}
}
interface Parent {
void exec<caret>ute();
}
interface Child extends Parent {
void execute();
}

View File

@@ -1,4 +1,4 @@
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. // 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.codeInsight.daemon.lambda; package com.intellij.java.codeInsight.daemon.lambda;
import com.intellij.java.refactoring.ChangeSignatureBaseTest; import com.intellij.java.refactoring.ChangeSignatureBaseTest;
@@ -16,6 +16,10 @@ public class ChangeSignatureTouchLambdaTest extends ChangeSignatureBaseTest {
doTest(null, null, null, new ParameterInfoImpl[] {ParameterInfoImpl.createNew().withName("b").withType(PsiType.BOOLEAN)}, new ThrownExceptionInfo[0], false); doTest(null, null, null, new ParameterInfoImpl[] {ParameterInfoImpl.createNew().withName("b").withType(PsiType.BOOLEAN)}, new ThrownExceptionInfo[0], false);
} }
public void testLambdaHierarchy() {
doTest(null, null, null, new ParameterInfoImpl[0] , new ThrownExceptionInfo[0], false);
}
public void testDefaultMethodTouched() { public void testDefaultMethodTouched() {
doTest(null, null, null, new ParameterInfoImpl[] {ParameterInfoImpl.createNew().withName("b").withType(PsiType.BOOLEAN)}, new ThrownExceptionInfo[0], false); doTest(null, null, null, new ParameterInfoImpl[] {ParameterInfoImpl.createNew().withName("b").withType(PsiType.BOOLEAN)}, new ThrownExceptionInfo[0], false);
} }

View File

@@ -1,18 +1,4 @@
/* // 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.
* Copyright 2000-2015 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.
*/
package com.intellij.refactoring.changeSignature; package com.intellij.refactoring.changeSignature;
import com.intellij.ide.actions.CopyReferenceAction; import com.intellij.ide.actions.CopyReferenceAction;
@@ -92,7 +78,7 @@ public abstract class ChangeSignatureProcessorBase extends BaseRefactoringProces
} }
protected static List<UsageInfo> filterUsages(List<? extends UsageInfo> infos) { protected static List<UsageInfo> filterUsages(List<? extends UsageInfo> infos) {
Map<PsiElement, MoveRenameUsageInfo> moveRenameInfos = new HashMap<>(); Map<PsiElement, MoveRenameUsageInfo> moveRenameInfos = new LinkedHashMap<>();
Set<PsiElement> usedElements = new HashSet<>(); Set<PsiElement> usedElements = new HashSet<>();
List<UsageInfo> result = new ArrayList<>(infos.size() / 2); List<UsageInfo> result = new ArrayList<>(infos.size() / 2);