use of com.intellij.psi.search.PsiShortNamesCache in project intellij-community by JetBrains.
the class CompositeShortNamesCache method getFieldsByName.
@Override
@NotNull
public PsiField[] getFieldsByName(@NotNull String name, @NotNull GlobalSearchScope scope) {
Merger<PsiField> merger = null;
for (PsiShortNamesCache cache : myCaches) {
PsiField[] classes = cache.getFieldsByName(name, scope);
if (classes.length != 0) {
if (merger == null)
merger = new Merger<>();
merger.add(classes);
}
}
PsiField[] result = merger == null ? null : merger.getResult();
return result == null ? PsiField.EMPTY_ARRAY : result;
}
use of com.intellij.psi.search.PsiShortNamesCache in project intellij-community by JetBrains.
the class CompositeShortNamesCache method getAllClassNames.
@Override
@NotNull
public String[] getAllClassNames() {
Merger<String> merger = new Merger<>();
for (PsiShortNamesCache cache : myCaches) {
String[] names = cache.getAllClassNames();
merger.add(names);
}
String[] result = merger.getResult();
return result != null ? result : ArrayUtil.EMPTY_STRING_ARRAY;
}
use of com.intellij.psi.search.PsiShortNamesCache in project intellij-community by JetBrains.
the class CompositeShortNamesCache method getClassesByName.
@Override
@NotNull
public PsiClass[] getClassesByName(@NotNull String name, @NotNull GlobalSearchScope scope) {
Merger<PsiClass> merger = null;
for (PsiShortNamesCache cache : myCaches) {
PsiClass[] classes = cache.getClassesByName(name, scope);
if (classes.length != 0) {
if (merger == null)
merger = new Merger<>();
merger.add(classes);
}
}
PsiClass[] result = merger == null ? null : merger.getResult();
return result != null ? result : PsiClass.EMPTY_ARRAY;
}
use of com.intellij.psi.search.PsiShortNamesCache in project intellij-community by JetBrains.
the class CompositeShortNamesCache method getMethodsByNameIfNotMoreThan.
@Override
@NotNull
public PsiMethod[] getMethodsByNameIfNotMoreThan(@NonNls @NotNull final String name, @NotNull final GlobalSearchScope scope, final int maxCount) {
Merger<PsiMethod> merger = null;
for (PsiShortNamesCache cache : myCaches) {
PsiMethod[] methods = cache.getMethodsByNameIfNotMoreThan(name, scope, maxCount);
if (methods.length == maxCount)
return methods;
if (methods.length != 0) {
if (merger == null)
merger = new Merger<>();
merger.add(methods);
}
}
PsiMethod[] result = merger == null ? null : merger.getResult();
return result == null ? PsiMethod.EMPTY_ARRAY : result;
}
use of com.intellij.psi.search.PsiShortNamesCache in project intellij-community by JetBrains.
the class ReferenceChainLink method getGlobalMembers.
@Nullable
List<PsiMember> getGlobalMembers(VirtualFile placeFile, Project project) {
if (isExpensive(project))
return null;
List<PsiMember> candidates = new ArrayList<>();
AtomicInteger count = new AtomicInteger();
Processor<PsiMember> processor = member -> {
if (!(member instanceof PsiMethod && !ApproximateResolver.canHaveArgCount((PsiMethod) member, argCount))) {
candidates.add(member);
}
return count.incrementAndGet() < 42;
};
PsiShortNamesCache cache = PsiShortNamesCache.getInstance(project);
GlobalSearchScope scope = ResolveScopeManager.getInstance(project).getDefaultResolveScope(placeFile);
if (isCall) {
if (!cache.processMethodsWithName(referenceName, processor, scope, null)) {
markExpensive(project);
return null;
}
} else {
PsiPackage pkg = JavaPsiFacade.getInstance(project).findPackage(referenceName);
if (pkg != null && pkg.getDirectories(scope).length > 0)
return null;
if (!cache.processFieldsWithName(referenceName, processor, scope, null)) {
markExpensive(project);
return null;
}
}
if (!cache.processClassesWithName(referenceName, processor, scope, null)) {
markExpensive(project);
return null;
}
return candidates.stream().filter(candidate -> canBeAccessible(placeFile, candidate)).collect(Collectors.toList());
}
Aggregations