Search in sources :

Example 1 with ChooseByNameModel

use of com.intellij.ide.util.gotoByName.ChooseByNameModel in project intellij-community by JetBrains.

the class ClassChooserTest method testSubclassModel.

public void testSubclassModel() throws Exception {
    myFixture.addClass("class Foo extends Exception {}");
    myFixture.addClass("class Bar {}");
    PsiClass aClass = JavaPsiFacade.getInstance(getProject()).findClass(CommonClassNames.JAVA_LANG_EXCEPTION, GlobalSearchScope.allScope(getProject()));
    final Ref<ChooseByNameModel> ref = new Ref<>();
    TreeJavaClassChooserDialog dialog = new TreeJavaClassChooserDialog("hey", getProject(), GlobalSearchScope.projectScope(getProject()), null, aClass, null, false) {

        @Override
        protected ChooseByNameModel createChooseByNameModel() {
            ChooseByNameModel model = super.createChooseByNameModel();
            ref.set(model);
            return model;
        }

        @Override
        public JRootPane getRootPane() {
            return new JRootPane();
        }
    };
    Disposer.register(myFixture.getTestRootDisposable(), dialog.getDisposable());
    ChooseByNameModelEx model = (ChooseByNameModelEx) ref.get();
    CommonProcessors.CollectProcessor<String> processor = new CommonProcessors.CollectProcessor<>();
    model.processNames(processor, false);
    List<String> results = (List<String>) processor.getResults();
    assertEquals(1, results.size());
}
Also used : PsiClass(com.intellij.psi.PsiClass) ChooseByNameModelEx(com.intellij.ide.util.gotoByName.ChooseByNameModelEx) TreeJavaClassChooserDialog(com.intellij.ide.util.TreeJavaClassChooserDialog) ChooseByNameModel(com.intellij.ide.util.gotoByName.ChooseByNameModel) Ref(com.intellij.openapi.util.Ref) List(java.util.List) CommonProcessors(com.intellij.util.CommonProcessors)

Aggregations

TreeJavaClassChooserDialog (com.intellij.ide.util.TreeJavaClassChooserDialog)1 ChooseByNameModel (com.intellij.ide.util.gotoByName.ChooseByNameModel)1 ChooseByNameModelEx (com.intellij.ide.util.gotoByName.ChooseByNameModelEx)1 Ref (com.intellij.openapi.util.Ref)1 PsiClass (com.intellij.psi.PsiClass)1 CommonProcessors (com.intellij.util.CommonProcessors)1 List (java.util.List)1