use of com.intellij.util.Processor 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());
}
use of com.intellij.util.Processor in project intellij-community by JetBrains.
the class JavaCompilingVisitor method buildDescendants.
private static List<PsiClass> buildDescendants(String className, boolean includeSelf, OptimizingSearchHelper searchHelper, CompileContext context) {
if (!searchHelper.doOptimizing())
return Collections.emptyList();
final SearchScope scope = context.getOptions().getScope();
if (!(scope instanceof GlobalSearchScope))
return Collections.emptyList();
final PsiShortNamesCache cache = PsiShortNamesCache.getInstance(context.getProject());
final PsiClass[] classes = cache.getClassesByName(className, (GlobalSearchScope) scope);
final List<PsiClass> results = new ArrayList<>();
final Processor<PsiClass> processor = aClass -> {
results.add(aClass);
return true;
};
for (PsiClass aClass : classes) {
ClassInheritorsSearch.search(aClass, scope, true).forEach(processor);
}
if (includeSelf) {
Collections.addAll(results, classes);
}
return results;
}
use of com.intellij.util.Processor in project intellij-plugins by JetBrains.
the class InterceptorRefResolveConverterImpl method fromString.
public InterceptorOrStackBase fromString(@Nullable @NonNls final String name, final ConvertContext context) {
if (name == null) {
return null;
}
final Condition<InterceptorOrStackBase> nameCondition = interceptorOrStackBase -> name.equals(interceptorOrStackBase.getName().getStringValue());
final Ref<InterceptorOrStackBase> resolveResult = new Ref<>();
final Processor<StrutsPackage> processor = strutsPackage -> {
final InterceptorOrStackBase result = ContainerUtil.find(getAllInterceptors(strutsPackage), nameCondition);
if (result != null) {
resolveResult.set(result);
return false;
}
return true;
};
final StrutsPackageHierarchyWalker walker = new StrutsPackageHierarchyWalker(ConverterUtil.getCurrentStrutsPackage(context), processor);
walker.walkUp();
return resolveResult.get();
}
use of com.intellij.util.Processor in project intellij-plugins by JetBrains.
the class ResultTypeResolvingConverterImpl method fromString.
public ResultType fromString(@Nullable @NonNls final String name, final ConvertContext context) {
if (StringUtil.isEmpty(name)) {
return null;
}
final Condition<ResultType> nameCondition = resultType -> Comparing.equal(name, resultType.getName().getStringValue());
final Ref<ResultType> resolveResult = new Ref<>();
final Processor<StrutsPackage> processor = strutsPackage -> {
final ResultType result = ContainerUtil.find(strutsPackage.getResultTypes(), nameCondition);
if (result != null) {
resolveResult.set(result);
return false;
}
return true;
};
final StrutsPackageHierarchyWalker walker = new StrutsPackageHierarchyWalker(ConverterUtil.getCurrentStrutsPackage(context), processor);
walker.walkUp();
return resolveResult.get();
}
use of com.intellij.util.Processor in project intellij-plugins by JetBrains.
the class DefaultInterceptorRefResolveConverterImpl method fromString.
public InterceptorStack fromString(@Nullable @NonNls final String name, final ConvertContext context) {
if (name == null) {
return null;
}
final Condition<InterceptorStack> nameCondition = interceptorStack -> name.equals(interceptorStack.getName().getStringValue());
final Ref<InterceptorStack> resolveResult = new Ref<>();
final Processor<StrutsPackage> processor = strutsPackage -> {
final InterceptorStack result = ContainerUtil.find(strutsPackage.getInterceptorStacks(), nameCondition);
if (result != null) {
resolveResult.set(result);
return false;
}
return true;
};
final StrutsPackageHierarchyWalker walker = new StrutsPackageHierarchyWalker(getCurrentStrutsPackage(context), processor);
walker.walkUp();
return resolveResult.get();
}
Aggregations