mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-195808 Odd warning when change parameter order of method with @Contract
This commit is contained in:
@@ -36,7 +36,7 @@ public final class ContractConverter {
|
||||
throw new ContractConversionException("automatic update of external annotation is not supported");
|
||||
}
|
||||
if (annotation.getOwner() != method.getModifierList()) {
|
||||
throw new ContractConversionException("annotation is inherited from base method");
|
||||
throw new ContractInheritedException();
|
||||
}
|
||||
if (annotation.findDeclaredAttributeValue(MutationSignature.ATTR_MUTATES) != null) {
|
||||
throw new ContractConversionException("it contains mutation contract");
|
||||
@@ -107,9 +107,15 @@ public final class ContractConverter {
|
||||
return oldToNewIndex;
|
||||
}
|
||||
|
||||
public static final class ContractConversionException extends Exception {
|
||||
public static class ContractConversionException extends Exception {
|
||||
ContractConversionException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
||||
|
||||
public static class ContractInheritedException extends ContractConversionException {
|
||||
ContractInheritedException() {
|
||||
super("annotation is inherited from base method");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+8
-3
@@ -1046,7 +1046,7 @@ public class JavaChangeSignatureUsageProcessor implements ChangeSignatureUsagePr
|
||||
if (checkUnusedParameter) {
|
||||
checkParametersToDelete(myChangeInfo.getMethod(), toRemove, conflictDescriptions);
|
||||
}
|
||||
checkContract(conflictDescriptions, myChangeInfo.getMethod());
|
||||
checkContract(conflictDescriptions, myChangeInfo.getMethod(), false);
|
||||
|
||||
for (UsageInfo usageInfo : usagesSet) {
|
||||
final PsiElement element = usageInfo.getElement();
|
||||
@@ -1066,7 +1066,7 @@ public class JavaChangeSignatureUsageProcessor implements ChangeSignatureUsagePr
|
||||
}
|
||||
}
|
||||
|
||||
checkContract(conflictDescriptions, method);
|
||||
checkContract(conflictDescriptions, method, true);
|
||||
}
|
||||
else if (element instanceof PsiMethodReferenceExpression && MethodReferenceUsageInfo.needToExpand(myChangeInfo)) {
|
||||
conflictDescriptions.putValue(element, RefactoringBundle.message("expand.method.reference.warning"));
|
||||
@@ -1105,10 +1105,15 @@ public class JavaChangeSignatureUsageProcessor implements ChangeSignatureUsagePr
|
||||
}
|
||||
}
|
||||
|
||||
private void checkContract(MultiMap<PsiElement, String> conflictDescriptions, PsiMethod method) {
|
||||
private void checkContract(MultiMap<PsiElement, String> conflictDescriptions, PsiMethod method, boolean override) {
|
||||
try {
|
||||
ContractConverter.convertContract(method, myChangeInfo);
|
||||
}
|
||||
catch (ContractConverter.ContractInheritedException e) {
|
||||
if (!override) {
|
||||
conflictDescriptions.putValue(method, "@Contract annotation cannot be updated automatically: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
catch (ContractConverter.ContractConversionException e) {
|
||||
conflictDescriptions.putValue(method, "@Contract annotation cannot be updated automatically: " + e.getMessage());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user