mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
disable "actual param is the same constant" for vararg calls (IDEA-192148)
accept single argument calls but disable the fix as array wrapping is not supported
This commit is contained in:
+6
-5
@@ -554,11 +554,12 @@ public class RefMethodImpl extends RefJavaElementImpl implements RefMethod {
|
||||
}
|
||||
} else {
|
||||
final RefParameter[] params = getParameters();
|
||||
if (params.length <= args.length && params.length > 0) {
|
||||
for (int i = 0; i < args.length; i++) {
|
||||
RefParameter refParameter = params.length <= i ? params[params.length - 1] : params[i];
|
||||
((RefParameterImpl)refParameter).updateTemplateValue(args[i]);
|
||||
}
|
||||
for (int i = 0; i < Math.min(params.length, args.length); i++) {
|
||||
((RefParameterImpl)params[i]).updateTemplateValue(args[i]);
|
||||
}
|
||||
|
||||
if (params.length != args.length) {
|
||||
((RefParameterImpl)params[params.length - 1]).clearTemplateValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+4
@@ -85,6 +85,10 @@ public class RefParameterImpl extends RefJavaElementImpl implements RefParameter
|
||||
}
|
||||
}
|
||||
|
||||
void clearTemplateValue() {
|
||||
myActualValueTemplate = VALUE_IS_NOT_CONST;
|
||||
}
|
||||
|
||||
void updateTemplateValue(PsiExpression expression) {
|
||||
if (myActualValueTemplate == VALUE_IS_NOT_CONST) return;
|
||||
|
||||
|
||||
+1
-1
@@ -271,7 +271,7 @@ public class SameParameterValueInspectionBase extends GlobalJavaBatchInspectionT
|
||||
InspectionsBundle.message("inspection.same.parameter.problem.descriptor",
|
||||
name,
|
||||
StringUtil.unquoteString(shortName)),
|
||||
usedForWriting ? null : createFix(name, stringPresentation),
|
||||
usedForWriting || parameter.isVarArgs() ? null : createFix(name, stringPresentation),
|
||||
ProblemHighlightType.GENERIC_ERROR_OR_WARNING, false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<problems></problems>
|
||||
<problems/>
|
||||
|
||||
|
||||
@@ -10,4 +10,20 @@ public class Test {
|
||||
public static void main(String[] args){
|
||||
new Test().bar();
|
||||
}
|
||||
}
|
||||
class AnotherDiiferentVarargs {
|
||||
private static final String TEXT = "text";
|
||||
private static final String ANOTHER_TEXT = "another text";
|
||||
|
||||
public static void main(String[] args) {
|
||||
printString(TEXT, "optional");
|
||||
printString(ANOTHER_TEXT);
|
||||
}
|
||||
|
||||
private static void printString(String input, String... attrs) {
|
||||
System.out.println(input);
|
||||
for (String string : attrs) {
|
||||
System.out.println(string);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user