enable stats for class name completion in some qualifier

This commit is contained in:
peter
2011-01-19 18:34:24 +01:00
parent a19c2a1281
commit f0449b004e
3 changed files with 22 additions and 0 deletions
@@ -88,6 +88,11 @@ public class JavaCompletionUtil {
static final NullableLazyKey<ExpectedTypeInfo[], CompletionLocation> EXPECTED_TYPES = NullableLazyKey.create("expectedTypes", new NullableFunction<CompletionLocation, ExpectedTypeInfo[]>() {
@Nullable
public ExpectedTypeInfo[] fun(final CompletionLocation location) {
if (PsiJavaPatterns.psiElement().beforeLeaf(PsiJavaPatterns.psiElement().withText("."))
.accepts(location.getCompletionParameters().getPosition())) {
return new ExpectedTypeInfo[0];
}
return JavaSmartCompletionContributor.getExpectedTypes(location.getCompletionParameters());
}
});
@@ -0,0 +1,7 @@
public class MyFirstTestClassFoo {
int foo() {
return FooB<caret>.fff().zoo();
}
}
@@ -139,4 +139,14 @@ public class NormalCompletionOrderingTest extends CompletionSortingTestCase {
assertEquals(2, ((PsiMethod)myItems[2].getObject()).getParameterList().getParametersCount());
}
public void testStatsForClassNameInExpression() throws Throwable {
final VirtualFile foo = getSourceRoot().createChildDirectory(this, "foo");
VfsUtil.saveText(foo.createChildData(this, "FooBar.java"), "package foo; public interface FooBar {}");
VfsUtil.saveText(foo.createChildData(this, "FooBee.java"), "package foo; public interface FooBee {}");
checkPreferredItems(0, "FooBar", "FooBee");
incUseCount(getLookup(), 1);
assertPreferredItems(0, "FooBee", "FooBar");
}
}