use of com.intellij.psi.search.RequestResultProcessor in project oxy-template-support-plugin by mutant-industries.
the class DwrMethodReferenceSearch method processQuery.
@Override
public void processQuery(@NotNull MethodReferencesSearch.SearchParameters queryParameters, @NotNull Processor<PsiReference> consumer) {
PsiMethod method = queryParameters.getMethod();
if (!method.getModifierList().hasModifierProperty(PsiModifier.PUBLIC) || !DwrReferenceResolver.isDwrMethod(method)) {
return;
}
String query = method.getName();
SearchScope scope = queryParameters.getEffectiveSearchScope();
if (scope instanceof GlobalSearchScope) {
// intersect(union(original scope, js file type scope), not(java file type scope))
GlobalSearchScope jsFilesScope = GlobalSearchScope.getScopeRestrictedByFileTypes(GlobalSearchScope.allScope(method.getProject()), JavaScriptFileType.INSTANCE);
scope = jsFilesScope.uniteWith((GlobalSearchScope) scope).intersectWith(GlobalSearchScope.notScope(GlobalSearchScope.getScopeRestrictedByFileTypes(GlobalSearchScope.allScope(method.getProject()), JavaFileType.INSTANCE)));
}
queryParameters.getOptimizer().searchWord(query, scope, UsageSearchContext.IN_CODE, true, method, new RequestResultProcessor() {
@Override
public boolean processTextOccurrence(@NotNull PsiElement element, int offsetInElement, @NotNull Processor<PsiReference> consumer) {
PsiElement reference;
return !((element instanceof JSReferenceExpression && (reference = ((JSReferenceExpression) element).resolve()) != null) && reference.isEquivalentTo(method)) || consumer.process((JSReferenceExpression) element);
}
});
}
use of com.intellij.psi.search.RequestResultProcessor in project oxy-template-support-plugin by mutant-industries.
the class GlobalVariableReferenceSearch method processQuery.
@Override
public void processQuery(@NotNull ReferencesSearch.SearchParameters queryParameters, @NotNull Processor<PsiReference> consumer) {
if (!(queryParameters.getElementToSearch() instanceof GlobalVariableDefinition)) {
return;
}
final GlobalVariableDefinition target = (GlobalVariableDefinition) queryParameters.getElementToSearch();
SearchScope scope = restrictScopeToOxyTemplates(queryParameters.getEffectiveSearchScope());
queryParameters.getOptimizer().searchWord(target.getName(), scope, UsageSearchContext.IN_CODE, true, target.getExpression(), new RequestResultProcessor() {
@Override
public boolean processTextOccurrence(@NotNull PsiElement element, int offsetInElement, @NotNull Processor<PsiReference> consumer) {
PsiReference reference;
if (element instanceof JSReferenceExpression && (reference = element.getReference()) != null) {
PsiElement resolveResult = reference.resolve();
if (resolveResult instanceof GlobalVariableDefinition && target.getExpression().isEquivalentTo(((GlobalVariableDefinition) resolveResult).getExpression())) {
return consumer.process(reference);
}
}
return true;
}
});
}
use of com.intellij.psi.search.RequestResultProcessor in project oxy-template-support-plugin by mutant-industries.
the class JavaGetterReferenceSearch method doSearch.
static void doSearch(@NotNull final PsiMethod method, @NotNull final SearchRequestCollector optimizer, SearchScope effectiveSearchScope) {
if (!method.getModifierList().hasModifierProperty(PsiModifier.PUBLIC)) {
return;
}
String methodName = method.getName();
if (!methodName.matches("((^is)|(^get))[A-Z].*")) {
return;
}
String query = StringUtils.decapitalize(methodName.replaceFirst("(^is)|(^get)", ""));
SearchScope scope = OxyTemplateReferenceSearch.restrictScopeToOxyTemplates(effectiveSearchScope);
optimizer.searchWord(query, scope, UsageSearchContext.IN_CODE, true, method, new RequestResultProcessor() {
@Override
public boolean processTextOccurrence(@NotNull PsiElement element, int offsetInElement, @NotNull Processor<PsiReference> consumer) {
PsiElement reference;
return !((element instanceof JSReferenceExpression && (reference = ((JSReferenceExpression) element).resolve()) != null) && reference.isEquivalentTo(method)) || consumer.process((JSReferenceExpression) element);
}
});
}
Aggregations