本文整理了Java中com.intellij.util.Query
类的一些代码示例,展示了Query
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Query
类的具体详情如下:
包路径:com.intellij.util.Query
类名称:Query
暂无
代码示例来源:origin: go-lang-plugin-org/go-lang-idea-plugin
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();
代码示例来源:origin: go-lang-plugin-org/go-lang-idea-plugin
@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));
}
}
};
代码示例来源:origin: mustfun/mybatis-plus
@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();
}
代码示例来源:origin: AlexanderBartash/hybris-integration-intellij-idea-plugin
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[]{};
}
代码示例来源:origin: BashSupport/BashSupport
/**
* 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();
}
代码示例来源:origin: go-lang-plugin-org/go-lang-idea-plugin
@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));
}
}
};
代码示例来源:origin: JetBrains/Grammar-Kit
static boolean isUsedAsArgument(@NotNull BnfRule rule) {
return !ReferencesSearch.search(rule, rule.getUseScope()).forEach(ref -> !isUsedAsArgument(ref));
}
代码示例来源:origin: Camelcade/Perl5-IDEA
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)) {
代码示例来源:origin: go-lang-plugin-org/go-lang-idea-plugin
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);
}
}
}
};
代码示例来源:origin: com.github.adedayo.intellij.sdk/java-psi-api
@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();
}
});
代码示例来源:origin: halirutan/Mathematica-IntelliJ-Plugin
final Collection<PsiReference> all1 = all.findAll();
return all1;
代码示例来源:origin: go-lang-plugin-org/go-lang-idea-plugin
@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));
}
}
};
代码示例来源:origin: dubreuia/intellij-plugin-save-actions
FunctionalExpressionSearch.search((PsiClass)member).forEach(functionalExpression -> {
PsiFile psiFile = functionalExpression.getContainingFile();
return handleUsage(member, memberClass, memberFile, maxLevel, memberPackage, functionalExpression, psiFile, foundUsage);
代码示例来源:origin: halirutan/Mathematica-IntelliJ-Plugin
@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;
}
代码示例来源:origin: zalando/intellij-swagger
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);
}
}
}
代码示例来源:origin: JetBrains/Grammar-Kit
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) {
代码示例来源:origin: zalando/intellij-swagger
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);
}
}
}
代码示例来源:origin: com.github.adedayo.intellij.sdk/java-psi-api
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 + ".";
}
代码示例来源:origin: Camelcade/Perl5-IDEA
@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);
}
};
代码示例来源:origin: halirutan/Mathematica-IntelliJ-Plugin
usages.add(element);
final Collection<PsiReference> refs = ReferencesSearch.search(element).findAll();
for (PsiReference ref : refs) {
usages.add(ref.getElement());
内容来源于网络,如有侵权,请联系作者删除!