PsiElement resolve = reference != null ? reference.resolve() : null; if (resolve != null) return; boolean foundReference = !ReferencesSearch.search(o, o.getUseScope()).forEach(reference1 -> { ProgressManager.checkCanceled(); PsiElement element = reference1.getElement();
@Override public void visitConstDefinition(@NotNull GoConstDefinition o) { if (o.isBlank()) return; if (ReferencesSearch.search(o, o.getUseScope()).findFirst() == null) { String constName = o.getName(); holder.registerProblem(o, "Unused constant <code>#ref</code> #loc", ProblemHighlightType.LIKE_UNUSED_SYMBOL, new GoDeleteConstDefinitionQuickFix(constName)); } } };
@NotNull @Override public Set<AliasDesc> getClassAliasDescriptions(@Nullable PsiElement element) { Optional<PsiClass> clazz = Annotation.ALIAS.toPsiClass(project); if (clazz.isPresent()) { Collection<PsiClass> res = AnnotatedElementsSearch.searchPsiClasses(clazz.get(), GlobalSearchScope.allScope(project)).findAll(); return Sets.newHashSet(Collections2.transform(res, FUN)); } return Collections.emptySet(); }
public static ImpexProcessorModifierValue[] values() { final Project project = currentProject(); final PsiClass clazz; if (project != null) { clazz = JavaPsiFacade.getInstance(project) .findClass( "de.hybris.platform.impex.jalo.imp.ImportProcessor", allScope(project) ); if (clazz != null) { final Query<PsiClass> psiClasses = ClassInheritorsSearch.search(clazz, allScope(project), true); return psiClasses.findAll() .stream() .map(ImpexProcessorModifierValue::new) .toArray(ImpexProcessorModifierValue[]::new); } } return new ImpexProcessorModifierValue[]{}; }
/** * Returns references to the given element. If it is a BashPsiElement a special search scope is used to locate the elements referencing the file. * * @param element References to the given element * @return */ @NotNull @Override public Collection<PsiReference> findReferences(PsiElement element) { //fixme fix the custom scope SearchScope scope = (element instanceof BashPsiElement) ? BashElementSharedImpl.getElementUseScope((BashPsiElement) element, element.getProject()) : GlobalSearchScope.projectScope(element.getProject()); Query<PsiReference> search = ReferencesSearch.search(element, scope); return search.findAll(); }
@Override public void visitLabelDefinition(@NotNull GoLabelDefinition o) { super.visitLabelDefinition(o); if (o.isBlank()) return; if (ReferencesSearch.search(o, o.getUseScope()).findFirst() == null) { String name = o.getName(); holder.registerProblem(o, "Unused label <code>#ref</code> #loc", ProblemHighlightType.GENERIC_ERROR_OR_WARNING, new GoRenameToBlankQuickFix(o), new GoDeleteLabelStatementQuickFix(name)); } } };
static boolean isUsedAsArgument(@NotNull BnfRule rule) { return !ReferencesSearch.search(rule, rule.getUseScope()).forEach(ref -> !isUsedAsArgument(ref)); }
boolean globScanned = element instanceof PerlGlobVariable; for (PsiReference reference : ReferencesSearch.search(element, element.getUseScope()).findAll()) { if (reference instanceof PsiPolyVariantReference) { for (ResolveResult resolveResult : ((PsiPolyVariantReference)reference).multiResolve(false)) {
private void visitParameterList(List<GoParameterDeclaration> parameters, String what) { for (GoParameterDeclaration parameterDeclaration : parameters) { for (GoParamDefinition parameter : parameterDeclaration.getParamDefinitionList()) { ProgressManager.checkCanceled(); if (parameter.isBlank()) continue; Query<PsiReference> search = ReferencesSearch.search(parameter, parameter.getUseScope()); if (search.findFirst() != null) continue; holder.registerProblem(parameter, "Unused " + what + " <code>#ref</code> #loc", ProblemHighlightType.LIKE_UNUSED_SYMBOL); } } } };
@Override public boolean processValues(PsiMethod t, final ProcessingContext context, final PairProcessor<PsiClass, ProcessingContext> processor) { if (!processor.process(t.getContainingClass(), context)) return false; final Ref<Boolean> result = Ref.create(Boolean.TRUE); SuperMethodsSearch.search(t, null, true, false).forEach(new Processor<MethodSignatureBackedByPsiMethod>() { @Override public boolean process(final MethodSignatureBackedByPsiMethod signature) { if (!processor.process(signature.getMethod().getContainingClass(), context)) { result.set(Boolean.FALSE); return false; } return true; } }); return result.get(); } });
final Collection<PsiReference> all1 = all.findAll(); return all1;
@Override public void visitFunctionDeclaration(@NotNull GoFunctionDeclaration o) { if (o.isBlank()) return; GoFile file = o.getContainingFile(); String name = o.getName(); if (!canRun(name)) return; if (GoConstants.MAIN.equals(file.getPackageName()) && GoConstants.MAIN.equals(name)) return; if (GoConstants.INIT.equals(name)) return; if (GoTestFinder.isTestFile(file) && GoTestFunctionType.fromName(name) != null) return; if (ReferencesSearch.search(o, o.getUseScope()).findFirst() == null) { PsiElement id = o.getIdentifier(); TextRange range = TextRange.from(id.getStartOffsetInParent(), id.getTextLength()); holder.registerProblem(o, "Unused function <code>#ref</code> #loc", ProblemHighlightType.LIKE_UNUSED_SYMBOL, range, new GoDeleteQuickFix("Delete function", GoFunctionDeclaration.class), new GoRenameToBlankQuickFix(o)); } } };
FunctionalExpressionSearch.search((PsiClass)member).forEach(functionalExpression -> { PsiFile psiFile = functionalExpression.getContainingFile(); return handleUsage(member, memberClass, memberFile, maxLevel, memberPackage, functionalExpression, psiFile, foundUsage);
@NotNull @Override public Collection<PsiReference> findReferences(PsiElement element) { final Collection<PsiReference> references = super.findReferences(element); final Collection<PsiReference> all = ReferencesSearch.search(element).findAll(); PsiReference elementRef = element.getReference(); PsiElement definitionElement; if (elementRef != null) { definitionElement = elementRef.resolve(); if (definitionElement instanceof Symbol) { SymbolCollector collector = new SymbolCollector((Symbol) definitionElement); element.getContainingFile().accept(collector); references.addAll(collector.myReferences); } } return references; }
private void warn( final PsiElement psiElement, final AnnotationHolder annotationHolder, final PsiElement searchableCurrentElement, final String warning) { final PsiReference first = ReferencesSearch.search(searchableCurrentElement).findFirst(); if (first == null) { Annotation annotation = annotationHolder.createWeakWarningAnnotation(psiElement, warning); annotation.setHighlightType(ProblemHighlightType.LIKE_UNUSED_SYMBOL); } } }
totalVisited.add((BnfRule)parent)) { BnfRule rule = (BnfRule)parent; for (PsiReference reference : ReferencesSearch.search(rule, rule.getUseScope()).findAll()) { PsiElement element = reference.getElement(); if (element instanceof BnfExpression && PsiTreeUtil.getParentOfType(element, BnfPredicate.class) == null) {
private void warn( final PsiElement psiElement, final AnnotationHolder annotationHolder, final PsiElement searchableCurrentElement, final String warning) { final PsiReference first = ReferencesSearch.search(searchableCurrentElement).findFirst(); if (first == null) { Annotation annotation = annotationHolder.createWeakWarningAnnotation(psiElement, warning); annotation.setHighlightType(ProblemHighlightType.LIKE_UNUSED_SYMBOL); } } }
public PackageScope(@NotNull PsiPackage aPackage, boolean includeSubpackages, final boolean includeLibraries) { super(aPackage.getProject()); myPackage = aPackage; myIncludeSubpackages = includeSubpackages; Project project = myPackage.getProject(); myPackageQualifiedName = myPackage.getQualifiedName(); myDirs = PackageIndex.getInstance(project).getDirsByPackageName(myPackageQualifiedName, true).findAll(); myIncludeLibraries = includeLibraries; myPartOfPackagePrefix = JavaPsiFacade.getInstance(getProject()).isPartOfPackagePrefix(myPackageQualifiedName); myPackageQNamePrefix = myPackageQualifiedName + "."; }
@Override public void visitLabelDeclaration(@NotNull PsiPerlLabelDeclaration o) { if (ReferencesSearch.search(o).findFirst() == null) { holder.registerProblem(o, "Unused label declaration (possibly deprecated usage)", ProblemHighlightType.LIKE_UNUSED_SYMBOL); } super.visitLabelDeclaration(o); } };
usages.add(element); final Collection<PsiReference> refs = ReferencesSearch.search(element).findAll(); for (PsiReference ref : refs) { usages.add(ref.getElement());