mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-05-06 05:10:22 +07:00
redundant lambda code block: ensure conflicts between same param numbers are checked
This commit is contained in:
@@ -88,7 +88,10 @@ public class RedundantLambdaCodeBlockInspection extends BaseJavaBatchLocalInspec
|
||||
final List<CandidateInfo> info = new ArrayList<CandidateInfo>(Arrays.asList(candidates));
|
||||
final LanguageLevel level = PsiUtil.getLanguageLevel(parent);
|
||||
final JavaMethodsConflictResolver conflictResolver = new JavaMethodsConflictResolver((PsiExpressionList)parent, level);
|
||||
conflictResolver.checkSpecifics(info, MethodCandidateInfo.ApplicabilityLevel.FIXED_ARITY, level);
|
||||
final PsiExpressionList argumentList = ((PsiCallExpression)gParent).getArgumentList();
|
||||
if (argumentList == null) return;
|
||||
JavaMethodsConflictResolver.checkParametersNumber(info, argumentList.getExpressions().length, false);
|
||||
conflictResolver.checkSpecifics(info, MethodCandidateInfo.ApplicabilityLevel.VARARGS, level);
|
||||
if (info.size() > 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -308,9 +308,9 @@ public class JavaMethodsConflictResolver implements PsiConflictResolver{
|
||||
return ((MethodCandidateInfo)info).getPertinentApplicabilityLevel() != MethodCandidateInfo.ApplicabilityLevel.NOT_APPLICABLE;
|
||||
}
|
||||
|
||||
private static boolean checkParametersNumber(@NotNull List<CandidateInfo> conflicts,
|
||||
final int argumentsCount,
|
||||
boolean ignoreIfStaticsProblem) {
|
||||
public static boolean checkParametersNumber(@NotNull List<CandidateInfo> conflicts,
|
||||
final int argumentsCount,
|
||||
boolean ignoreIfStaticsProblem) {
|
||||
boolean atLeastOneMatch = false;
|
||||
TIntArrayList unmatchedIndices = null;
|
||||
for (int i = 0; i < conflicts.size(); i++) {
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
// "Replace with expression lambda" "true"
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
class Test {
|
||||
public static void main(String[] args) {
|
||||
Set<String> strings = new HashSet<>();
|
||||
new Test().query("", pResultSet -> strings.add("Col1"));
|
||||
}
|
||||
|
||||
public Object query(String s, final ResultSetExtractor rse) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Object query(String s, final ResultSetExtractor rse, Object.. args) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
interface ResultSetExtractor {
|
||||
Object extractData(ResultSet var1);
|
||||
}
|
||||
class ResultSet {}
|
||||
@@ -0,0 +1,25 @@
|
||||
// "Replace with expression lambda" "true"
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
class Test {
|
||||
public static void main(String[] args) {
|
||||
Set<String> strings = new HashSet<>();
|
||||
new Test().query("", pResultSet -> <caret>{
|
||||
strings.add("Col1");
|
||||
});
|
||||
}
|
||||
|
||||
public Object query(String s, final ResultSetExtractor rse) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Object query(String s, final ResultSetExtractor rse, Object.. args) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
interface ResultSetExtractor {
|
||||
Object extractData(ResultSet var1);
|
||||
}
|
||||
class ResultSet {}
|
||||
Reference in New Issue
Block a user