mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-69981 ("Redundant array creation" inspection does not warn on enum constant)
This commit is contained in:
+11
-3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2011 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.
|
||||
@@ -125,7 +125,16 @@ public class RedundantArrayForVarargsCallInspection extends GenericsInspectionTo
|
||||
if (arrayElements.length > 0) {
|
||||
copyArgumentList.addRange(arrayElements[0], arrayElements[arrayElements.length - 1]);
|
||||
}
|
||||
final JavaResolveResult resolveResult = copy.resolveMethodGenerics();
|
||||
final JavaResolveResult resolveResult;
|
||||
if (callExpression instanceof PsiEnumConstant) {
|
||||
final PsiEnumConstant enumConstant = (PsiEnumConstant)callExpression;
|
||||
final PsiClass containingClass = enumConstant.getContainingClass();
|
||||
final JavaPsiFacade facade = JavaPsiFacade.getInstance(enumConstant.getProject());
|
||||
final PsiClassType classType = facade.getElementFactory().createType(containingClass);
|
||||
resolveResult = facade.getResolveHelper().resolveConstructor(classType, copyArgumentList, enumConstant);
|
||||
} else {
|
||||
resolveResult = copy.resolveMethodGenerics();
|
||||
}
|
||||
return resolveResult.isValidResult() && resolveResult.getElement() == oldRefMethod;
|
||||
}
|
||||
catch (IncorrectOperationException e) {
|
||||
@@ -170,4 +179,3 @@ public class RedundantArrayForVarargsCallInspection extends GenericsInspectionTo
|
||||
return "RedundantArrayCreation";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<problems>
|
||||
<problem>
|
||||
<file>Test.java</file>
|
||||
<line>3</line>
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Redundant array creation</problem_class>
|
||||
<description>Redundant array creation for calling varargs method</description>
|
||||
</problem>
|
||||
</problems>
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
|
||||
public enum Test {
|
||||
A(new String[]{"1", "2"});
|
||||
|
||||
Test(String... ss) {
|
||||
}
|
||||
}
|
||||
+1
@@ -21,4 +21,5 @@ public class RedundantArrayForVarargsCallInspectionTest extends InspectionTestCa
|
||||
public void testIDEADEV15215() throws Exception { doTest(); }
|
||||
public void testIDEADEV25923() throws Exception { doTest(); }
|
||||
public void testNestedArray() throws Exception { doTest(); }
|
||||
public void testCheckEnumConstant() throws Exception { doTest(); }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user