mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
same parameter value: ensure uast method references are correctly processed (IDEA-201335)
This commit is contained in:
+3
@@ -446,6 +446,9 @@ public class SameParameterValueInspection extends GlobalJavaBatchInspectionTool
|
||||
if (!(uElement instanceof UReferenceExpression)) {
|
||||
return false;
|
||||
}
|
||||
if (uElement instanceof UCallableReferenceExpression) {
|
||||
return false;
|
||||
}
|
||||
UElement parent = uElement.getUastParent();
|
||||
if (!(parent instanceof UCallExpression)) {
|
||||
return false;
|
||||
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<problems>
|
||||
<problem>
|
||||
<file>Test.java</file>
|
||||
<line>8</line>
|
||||
<description>Actual value of parameter 'string' is always 'hello'</description>
|
||||
</problem>
|
||||
|
||||
</problems>
|
||||
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
import java.util.function.Consumer;
|
||||
|
||||
class Test {
|
||||
private void main() {
|
||||
bar("hello", this::buzz);
|
||||
}
|
||||
|
||||
private void bar(String string, Consumer<Integer> o) {
|
||||
o.accept(1);
|
||||
use(string);
|
||||
}
|
||||
|
||||
private void buzz(int integer) {
|
||||
use(integer);
|
||||
}
|
||||
|
||||
private void use(Object a) {}
|
||||
}
|
||||
+4
@@ -76,6 +76,10 @@ public class SameParameterValueLocalTest extends InspectionTestCase {
|
||||
doTest(getGlobalTestDir(), myTool);
|
||||
}
|
||||
|
||||
public void testMethodReferenceInCallArguments() {
|
||||
doTest(getGlobalTestDir(), myTool);
|
||||
}
|
||||
|
||||
public void testUsageCount() {
|
||||
int previous = myGlobalTool.minimalUsageCount;
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user