@Nullable public PsiPackage findPackage(@NotNull String qualifiedName) { PsiPackage psiPackage = javaFileManager.findPackage(qualifiedName); if (psiPackage != null) { return psiPackage; } for (PsiElementFinder finder : extensionPsiElementFinders) { psiPackage = finder.findPackage(qualifiedName); if (psiPackage != null) { return psiPackage; } } return psiPackage; }
public PsiClass findClass(@NotNull final String qualifiedName, @NotNull GlobalSearchScope scope) { ProgressIndicatorProvider .checkCanceled(); // We hope this method is being called often enough to cancel daemon // processes smoothly PsiClass aClass = javaFileManager.findClass(qualifiedName, scope); if (aClass != null) { return aClass; } for (PsiElementFinder finder : extensionPsiElementFinders) { aClass = finder.findClass(qualifiedName, scope); if (aClass != null) { return aClass; } } return null; }
@NotNull private PsiClass[] findClassesInDumbMode( @NotNull String qualifiedName, @NotNull GlobalSearchScope scope) { String packageName = StringUtil.getPackageName(qualifiedName); PsiJavaPackage pkg = findPackage(packageName, scope); String className = StringUtil.getShortName(qualifiedName); if (pkg == null && packageName.length() < qualifiedName.length()) { PsiClass[] containingClasses = findClassesInDumbMode(packageName, scope); if (containingClasses.length == 1) { return PsiElementFinder.filterByName(className, containingClasses[0].getInnerClasses()); } return PsiClass.EMPTY_ARRAY; } if (pkg == null || !pkg.containsClassNamed(className)) { return PsiClass.EMPTY_ARRAY; } return pkg.findClassByShortName(className, scope); }
@Override public String toString() { return finder.toString(); }
@Override public PsiJavaPackage findPackage( @NotNull String qualifiedName, @NotNull GlobalSearchScope scope) { // Original element finder can't search packages with scope return finder.findPackage(qualifiedName); }
@Override public PsiClass findClass(@NotNull String qualifiedName, @NotNull GlobalSearchScope scope) { return finder.findClass(qualifiedName, scope); }