本文整理了Java中com.intellij.util.Query.findFirst
方法的一些代码示例,展示了Query.findFirst
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Query.findFirst
方法的具体详情如下:
包路径:com.intellij.util.Query
类名称:Query
方法名:findFirst
暂无
代码示例来源: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: 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: 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: 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: 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: 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: 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: Camelcade/Perl5-IDEA
@Override
public void visitGlobVariable(@NotNull PsiPerlGlobVariable o) {
if ((o.getExplicitPackageName() != null || !PerlGlobUtil.BUILT_IN.contains(o.getName())) &&
ReferencesSearch.search(o, GlobalSearchScope.projectScope(o.getProject())).findFirst() == null) {
holder.registerProblem(o, "Unused typeglob alias", ProblemHighlightType.LIKE_UNUSED_SYMBOL);
}
}
};
代码示例来源:origin: Camelcade/Perl5-IDEA
@Override
public void visitPerlSubDefinitionElement(@NotNull PerlSubDefinitionElement o) {
PsiElement subNameElement = o.getNameIdentifier();
if (subNameElement != null &&
!EXCLUSIONS.contains(o.getName()) &&
ReferencesSearch.search(o, GlobalSearchScope.projectScope(o.getProject())).findFirst() == null) {
holder.registerProblem(subNameElement, "Unused sub definition", ProblemHighlightType.LIKE_UNUSED_SYMBOL);
}
}
代码示例来源:origin: Camelcade/Perl5-IDEA
@Override
public void visitSubDeclarationElement(@NotNull PerlSubDeclarationElement o) {
PsiElement subNameElement = o.getNameIdentifier();
if (subNameElement != null &&
!EXCLUSIONS.contains(o.getName()) &&
ReferencesSearch.search(o, GlobalSearchScope.projectScope(o.getProject())).findFirst() == null) {
holder.registerProblem(subNameElement, "Unused sub declaration", ProblemHighlightType.LIKE_UNUSED_SYMBOL);
}
}
};
代码示例来源:origin: Camelcade/Perl5-IDEA
@Override
public void checkDeclaration(ProblemsHolder holder, PerlVariableDeclarationElement variableDeclarationWrapper) {
if (variableDeclarationWrapper.isGlobalDeclaration()) {
if (EXCLUSIONS.contains(variableDeclarationWrapper.getText())) {
return;
}
if (ReferencesSearch.search(variableDeclarationWrapper, variableDeclarationWrapper.getUseScope()).findFirst() == null) {
PerlVariable variable = variableDeclarationWrapper.getVariable();
holder.registerProblem(
variable,
"Unused global variable:" + variable.getText(),
ProblemHighlightType.LIKE_UNUSED_SYMBOL);
}
}
}
}
代码示例来源:origin: Camelcade/Perl5-IDEA
TargetElementUtil.getInstance().getNamedElement(myElement, myAdjustedOffset - myElement.getNode().getStartOffset());
if (namedElement != null) {
PsiReference reference = ReferencesSearch.search(namedElement, new LocalSearchScope(myFile)).findFirst();
if (reference instanceof PsiPolyVariantReference) {
List<PsiElement> result = new ArrayList<>();
代码示例来源:origin: Camelcade/Perl5-IDEA
@Override
public void checkDeclaration(ProblemsHolder holder, PerlVariableDeclarationElement variableDeclarationWrapper) {
if (variableDeclarationWrapper.isLexicalDeclaration() &&
!variableDeclarationWrapper.isLocalDeclaration()
) {
if (ReferencesSearch.search(variableDeclarationWrapper, variableDeclarationWrapper.getUseScope()).findFirst() == null) {
PerlVariable variable = variableDeclarationWrapper.getVariable();
holder.registerProblem(
variable,
"Unused lexical variable:" + variable.getText(),
ProblemHighlightType.LIKE_UNUSED_SYMBOL);
}
}
}
}
代码示例来源:origin: Camelcade/Perl5-IDEA
PsiReference inboundReference = ReferencesSearch.search(currentOpener).findFirst();
PsiReference lastOpenerReference = ReferencesSearch.search(lastOpener).findFirst();
if (lastOpenerReference != null) {
PsiElement element = lastOpenerReference.getElement();
inboundReference = ReferencesSearch.search(currentOpener).findFirst();
内容来源于网络,如有侵权,请联系作者删除!