IDEA-161862 Lambda Expressions not showing as implementations of an interface

This commit is contained in:
peter
2016-09-29 11:31:20 +02:00
parent b9a06d65b9
commit 53867e057f
3 changed files with 29 additions and 2 deletions

View File

@@ -101,12 +101,17 @@ public class ReferenceChainLink {
PsiPackage pkg = JavaPsiFacade.getInstance(project).findPackage(referenceName);
if (pkg != null && pkg.getDirectories(scope).length > 0) return null;
if (!cache.processFieldsWithName(referenceName, processor, scope, null) ||
!cache.processClassesWithName(referenceName, processor, scope, null)) {
if (!cache.processFieldsWithName(referenceName, processor, scope, null)) {
markExpensive(project);
return null;
}
}
if (!cache.processClassesWithName(referenceName, processor, scope, null)) {
markExpensive(project);
return null;
}
return candidates;
}

View File

@@ -0,0 +1,17 @@
class A {
void foo() {
new IterHelper<>().loopMap((k, val) -> {
//do something
});
}
}
final class IterHelper<K, V> {
public void loopMap(final MapIterCallback<K, V> callback) {
//do something
}
public static interface MapIterCallback<K, V> {
abstract void eval(K k, V v);
}
}

View File

@@ -140,6 +140,11 @@ public class FindFunctionalInterfaceTest extends LightCodeInsightFixtureTestCase
assertSize(1, FunctionalExpressionSearch.search(findClass("I")).findAll());
}
public void testChainStartingWithConstructor() {
configure();
assertSize(1, FunctionalExpressionSearch.search(findClass("IterHelper.MapIterCallback")).findAll());
}
public void testDontVisitInapplicableFiles() {
PsiClass sam = myFixture.addClass("interface I { void foo(); }");
myFixture.addClass("class Some { " +