@Override public void processQuery( @NotNull MethodReferencesSearch.SearchParameters p, @NotNull Processor<PsiReference> consumer) { final PsiMethod method = p.getMethod(); final PsiClass aClass = method.getContainingClass(); if (aClass == null) return; final String name = method.getName(); if (StringUtil.isEmpty(name)) return; final boolean strictSignatureSearch = p.isStrictSignatureSearch(); final PsiMethod[] methods = strictSignatureSearch ? new PsiMethod[] {method} : aClass.findMethodsByName(name, false); SearchScope accessScope = GroovyScopeUtil.getEffectiveScope(methods); final SearchScope restrictedByAccess = GroovyScopeUtil.restrictScopeToGroovyFiles(p.getScope(), accessScope); final String textToSearch = findLongestWord(name); p.getOptimizer() .searchWord( textToSearch, restrictedByAccess, UsageSearchContext.IN_STRINGS, true, new MethodTextOccurrenceProcessor(aClass, strictSignatureSearch, methods)); }
@Override public void processQuery( @NotNull final MethodReferencesSearch.SearchParameters p, @NotNull final Processor<PsiReference> consumer) { SearchScope scope = p.getEffectiveSearchScope(); if (!(scope instanceof GlobalSearchScope)) { return; } final PsiMethod method = p.getMethod(); final PsiAnnotation stepAnnotation = CucumberJavaUtil.getCucumberStepAnnotation(method); final String regexp = stepAnnotation != null ? CucumberJavaUtil.getPatternFromStepDefinition(stepAnnotation) : null; if (regexp == null) { return; } final String word = CucumberUtil.getTheBiggestWordToSearchByIndex(regexp); if (StringUtil.isEmpty(word)) { return; } final GlobalSearchScope restrictedScope = GlobalSearchScope.getScopeRestrictedByFileTypes( (GlobalSearchScope) scope, GherkinFileType.INSTANCE); ReferencesSearch.search( new ReferencesSearch.SearchParameters(method, restrictedScope, false, p.getOptimizer())) .forEach(consumer); }