mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
introduce parameter: show conflicts for incomplete calls
This commit is contained in:
+22
-1
@@ -141,7 +141,28 @@ public class JavaIntroduceParameterMethodUsagesProcessor implements IntroducePar
|
||||
}
|
||||
|
||||
|
||||
public void findConflicts(IntroduceParameterData data, UsageInfo[] usages, MultiMap<PsiElement, String> conflicts) {
|
||||
public void findConflicts(IntroduceParameterData data, UsageInfo[] usages, final MultiMap<PsiElement, String> conflicts) {
|
||||
final int parametersCount = data.getMethodToReplaceIn().getParameterList().getParametersCount();
|
||||
for (UsageInfo usage : usages) {
|
||||
if (!isMethodUsage(usage)) continue;
|
||||
final PsiElement element = usage.getElement();
|
||||
final PsiCall call = RefactoringUtil.getCallExpressionByMethodReference(element);
|
||||
final PsiExpressionList argList = call.getArgumentList();
|
||||
if (argList != null) {
|
||||
final int actualParamLength = argList.getExpressions().length;
|
||||
if (actualParamLength < parametersCount) {
|
||||
conflicts.putValue(call, "Incomplete call(" + call.getText() +"): " + parametersCount + " parameters expected but only " + actualParamLength + " found");
|
||||
}
|
||||
data.getParametersToRemove().forEach(new TIntProcedure() {
|
||||
public boolean execute(int paramNum) {
|
||||
if (paramNum >= actualParamLength) {
|
||||
conflicts.putValue(call, "Incomplete call(" + call.getText() +"): expected to delete the " + paramNum + " parameter but only " + actualParamLength + " parameters found");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean processChangeMethodSignature(IntroduceParameterData data, UsageInfo usage, UsageInfo[] usages) throws IncorrectOperationException {
|
||||
|
||||
-3
@@ -63,9 +63,6 @@ public class OldReferenceResolver {
|
||||
myProject = myContext.getProject();
|
||||
myManager = myContext.getManager();
|
||||
|
||||
if (myActualArgs.length < myMethodToReplaceIn.getParameterList().getParametersCount()) {
|
||||
LOG.debug(myContext.getText() + "\n-----\n" + myMethodToReplaceIn.getText());
|
||||
}
|
||||
PsiElementFactory factory = JavaPsiFacade.getInstance(myProject).getElementFactory();
|
||||
PsiExpression instanceRef;
|
||||
if (myContext instanceof PsiMethodCallExpression) {
|
||||
|
||||
@@ -166,7 +166,7 @@ public class IntroduceParameterTest extends LightCodeInsightTestCase {
|
||||
}
|
||||
|
||||
public void testParameterJavaDocBeforeVararg() throws Exception {
|
||||
doTest(IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_INACCESSIBLE, false, false, true, false);
|
||||
doTest(IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_INACCESSIBLE, false, false, true, false, "Incomplete call(method()): 1 parameters expected but only 0 found");
|
||||
}
|
||||
|
||||
public void testIncorrectScope() throws Exception {
|
||||
@@ -230,7 +230,8 @@ public class IntroduceParameterTest extends LightCodeInsightTestCase {
|
||||
}
|
||||
|
||||
public void testIncompleteEnumDefinition() throws Exception {
|
||||
doTest(IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_NONE, true, false, false, false);
|
||||
doTest(IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_NONE, true, false, false, false, "Incomplete call(Root()): 2 parameters expected but only 0 found\n" +
|
||||
"Incomplete call(Root()): expected to delete the 1 parameter but only 0 parameters found");
|
||||
}
|
||||
|
||||
private void doTestThroughHandler() throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user