use of org.jetbrains.plugins.groovy.lang.psi.impl.search.GrSourceFilterScope in project intellij-community by JetBrains.
the class MethodLateBoundReferencesSearcher method getUseScope.
private static SearchScope getUseScope(final PsiMethod method) {
final SearchScope scope = method.getUseScope();
final PsiFile file = method.getContainingFile();
if (file != null && scope instanceof GlobalSearchScope) {
final VirtualFile vfile = file.getOriginalFile().getVirtualFile();
final Project project = method.getProject();
if (vfile != null && ProjectRootManager.getInstance(project).getFileIndex().isInSource(vfile)) {
return new GrSourceFilterScope((GlobalSearchScope) scope);
}
}
return scope;
}
use of org.jetbrains.plugins.groovy.lang.psi.impl.search.GrSourceFilterScope in project intellij-community by JetBrains.
the class GroovyShortNamesCache method getScriptClassesByFQName.
public List<PsiClass> getScriptClassesByFQName(final String name, final GlobalSearchScope scope, final boolean srcOnly) {
GlobalSearchScope actualScope = srcOnly ? new GrSourceFilterScope(scope) : scope;
final Collection<GroovyFile> files = StubIndex.getElements(GrFullScriptNameIndex.KEY, name.hashCode(), myProject, actualScope, GroovyFile.class);
if (files.isEmpty()) {
return Collections.emptyList();
}
final ArrayList<PsiClass> result = new ArrayList<>();
for (GroovyFile file : files) {
if (file.isScript()) {
final PsiClass scriptClass = file.getScriptClass();
if (scriptClass != null && name.equals(scriptClass.getQualifiedName())) {
result.add(scriptClass);
}
}
}
return result;
}
use of org.jetbrains.plugins.groovy.lang.psi.impl.search.GrSourceFilterScope in project intellij-community by JetBrains.
the class GroovyShortNamesCache method getClassesByFQName.
@NotNull
public List<PsiClass> getClassesByFQName(String name, GlobalSearchScope scope, boolean inSource) {
final List<PsiClass> result = ContainerUtil.newArrayList();
for (PsiElement psiClass : StubIndex.getElements(GrFullClassNameIndex.KEY, name.hashCode(), myProject, inSource ? new GrSourceFilterScope(scope) : scope, PsiClass.class)) {
//hashcode doesn't guarantee equals
if (name.equals(((PsiClass) psiClass).getQualifiedName())) {
result.add((PsiClass) psiClass);
}
}
result.addAll(getScriptClassesByFQName(name, scope, inSource));
return result;
}
use of org.jetbrains.plugins.groovy.lang.psi.impl.search.GrSourceFilterScope in project intellij-community by JetBrains.
the class GroovyShortNamesCache method getMethodsByName.
@Override
@NotNull
public PsiMethod[] getMethodsByName(@NonNls @NotNull String name, @NotNull GlobalSearchScope scope) {
final Collection<? extends PsiMethod> methods = StubIndex.getElements(GrMethodNameIndex.KEY, name, myProject, new GrSourceFilterScope(scope), GrMethod.class);
final Collection<? extends PsiMethod> annMethods = StubIndex.getElements(GrAnnotationMethodNameIndex.KEY, name, myProject, new GrSourceFilterScope(scope), GrAnnotationMethod.class);
if (methods.isEmpty() && annMethods.isEmpty())
return PsiMethod.EMPTY_ARRAY;
return ArrayUtil.mergeCollections(annMethods, methods, PsiMethod.ARRAY_FACTORY);
}
Aggregations