show implementations: accept fields as class containers (IDEA-142678)

This commit is contained in:
Anna Kozlova
2015-07-16 16:57:45 +03:00
parent 36385bf0a7
commit 553caedcd9
2 changed files with 20 additions and 0 deletions
@@ -57,6 +57,9 @@ public class ClassPresentationUtil {
else if (element instanceof PsiFile){
return ((PsiFile)element).getName();
}
else if (element instanceof PsiField) {
return ((PsiField)element).getName();
}
else{
return null;
}
@@ -163,6 +163,23 @@ public class ImplementationsViewTest extends LightCodeInsightFixtureTestCase {
assertContent(component, new String[]{"a.java (AFoo)", "a.java"});
}
public void testInterfaceConstants() {
myFixture.configureByText("a.java", "interface AF<caret>oo{\n" +
" AFoo IMPL = new AFoo(){};\n" +
" boolean aaa();\n" +
"}");
PsiClass psiClass =
(PsiClass)TargetElementUtil.findTargetElement(myFixture.getEditor(), TargetElementUtil.getInstance().getAllAccepted());
assert psiClass != null;
final Collection<PsiElement> classes = getClassImplementations(psiClass);
List<PsiElement> all = new ArrayList<PsiElement>();
all.add(psiClass);
all.addAll(classes);
final ImplementationViewComponent component = new ImplementationViewComponent(all.toArray(new PsiElement[all.size()]), 0);
assertContent(component, new String[]{"a.java (AFoo)", "a.java (Anonymous in IMPL)"});
}
public void testInterfaceMethodOfFunctionalInterface() {
myFixture.configureByText("a.java", "interface AFoo{\n" +
" boolean a<caret>aa();\n" +