use of com.intellij.psi.search.GlobalSearchScope in project intellij-community by JetBrains.
the class GroovyGoToSymbolContributor method getItemsByName.
@Override
@NotNull
public NavigationItem[] getItemsByName(String name, String pattern, Project project, boolean includeNonProjectItems) {
GlobalSearchScope scope = includeNonProjectItems ? GlobalSearchScope.allScope(project) : GlobalSearchScope.projectScope(project);
List<NavigationItem> symbols = new ArrayList<>();
symbols.addAll(StubIndex.getElements(GrFieldNameIndex.KEY, name, project, scope, GrField.class));
symbols.addAll(StubIndex.getElements(GrMethodNameIndex.KEY, name, project, scope, GrMethod.class));
symbols.addAll(StubIndex.getElements(GrAnnotationMethodNameIndex.KEY, name, project, scope, GrAnnotationMethod.class));
return symbols.toArray(new NavigationItem[symbols.size()]);
}
use of com.intellij.psi.search.GlobalSearchScope in project intellij-community by JetBrains.
the class SceneBuilderImpl method prepareCustomComponents.
@NotNull
private Collection<CustomComponent> prepareCustomComponents(Collection<PsiClass> psiClasses) {
final JavaPsiFacade psiFacade = JavaPsiFacade.getInstance(myProject);
final GlobalSearchScope scope = GlobalSearchScope.allScope(myProject);
final Map<String, BuiltinComponent> builtinComponents = loadBuiltinComponents(className -> psiFacade.findClass(className, scope) != null);
final List<CustomComponent> customComponents = new ArrayList<>();
for (PsiClass psiClass : psiClasses) {
final String qualifiedName = psiClass.getQualifiedName();
final String name = psiClass.getName();
if (qualifiedName != null && name != null) {
BuiltinComponent parentComponent = null;
for (PsiClass aClass = psiClass; aClass != null; aClass = aClass.getSuperClass()) {
final BuiltinComponent component = builtinComponents.get(aClass.getQualifiedName());
if (component != null) {
parentComponent = component;
break;
}
}
final String moduleName = getComponentModuleName(psiClass);
final Map<String, String> attributes = parentComponent != null ? parentComponent.getAttributes() : Collections.emptyMap();
customComponents.add(new CustomComponent(name, qualifiedName, moduleName, attributes));
}
}
return customComponents;
}
use of com.intellij.psi.search.GlobalSearchScope in project intellij-community by JetBrains.
the class SceneBuilderImpl method collectCustomComponents.
private Collection<CustomComponent> collectCustomComponents() {
if (myProject.isDisposed()) {
return Collections.emptyList();
}
final PsiClass nodeClass = JavaPsiFacade.getInstance(myProject).findClass(JavaFxCommonNames.JAVAFX_SCENE_NODE, GlobalSearchScope.allScope(myProject));
if (nodeClass == null) {
return Collections.emptyList();
}
final Collection<PsiClass> psiClasses = CachedValuesManager.getCachedValue(nodeClass, () -> {
// Take custom components from libraries, but not from the project modules, because SceneBuilder instantiates the components' classes.
// Modules might be not compiled or may change since last compile, it's too expensive to keep track of that.
final GlobalSearchScope scope = ProjectScope.getLibrariesScope(nodeClass.getProject());
final String ideJdkVersion = Object.class.getPackage().getSpecificationVersion();
final LanguageLevel ideLanguageLevel = LanguageLevel.parse(ideJdkVersion);
final Query<PsiClass> query = ClassInheritorsSearch.search(nodeClass, scope, true, true, false);
final Set<PsiClass> result = new THashSet<>();
query.forEach(psiClass -> {
if (psiClass.hasModifierProperty(PsiModifier.PUBLIC) && !psiClass.hasModifierProperty(PsiModifier.ABSTRACT) && !isBuiltInComponent(psiClass) && isCompatibleLanguageLevel(psiClass, ideLanguageLevel)) {
result.add(psiClass);
}
});
return CachedValueProvider.Result.create(result, PsiModificationTracker.JAVA_STRUCTURE_MODIFICATION_COUNT);
});
if (psiClasses.isEmpty()) {
return Collections.emptyList();
}
return prepareCustomComponents(psiClasses);
}
use of com.intellij.psi.search.GlobalSearchScope in project intellij-community by JetBrains.
the class JavaFxImplicitUsageProvider method isImplicitMethodUsage.
private static boolean isImplicitMethodUsage(@NotNull PsiMethod method) {
if (!isImplicitFxmlAccess(method))
return false;
if (isInvokedByFxmlLoader(method)) {
return true;
}
final GlobalSearchScope projectScope = GlobalSearchScope.projectScope(method.getProject());
final GlobalSearchScope fxmlScope = new JavaFxScopeEnlarger.GlobalFxmlSearchScope(projectScope);
return isFxmlUsage(method, fxmlScope);
}
use of com.intellij.psi.search.GlobalSearchScope in project intellij-community by JetBrains.
the class JavaFxPsiUtil method isControllerClass.
public static boolean isControllerClass(@NotNull PsiClass psiClass) {
final Project project = psiClass.getProject();
final GlobalSearchScope resolveScope = psiClass.getResolveScope();
if (isControllerClassName(project, psiClass.getQualifiedName(), resolveScope)) {
return true;
}
final Ref<Boolean> refFound = new Ref<>(false);
ClassInheritorsSearch.search(psiClass, resolveScope, true, true, false).forEach((aClass) -> {
if (isControllerClassName(project, aClass.getQualifiedName(), resolveScope)) {
refFound.set(true);
return false;
}
return true;
});
return refFound.get();
}
Aggregations