void (@NotNull ReferencesSearch.SearchParameters queryParameters, @NotNull Processor<? super PsiReference> consumer) { if (ApplicationManager.getApplication().isUnitTestMode() && !TestModeFlags.is(ENABLE_IN_TESTS)) { return; } final SearchScope scope = queryParameters.getScopeDeterminedByUser(); final PsiElement element = queryParameters.getElementToSearch(); final PsiFile containingFile = element.getContainingFile(); if (!(scope instanceof GlobalSearchScope) && !isApplicableTo(containingFile)) { return; } final LocalSearchScope currentScope; if (scope instanceof LocalSearchScope) { if (queryParameters.isIgnoreAccessScope()) { return; } currentScope = (LocalSearchScope)scope; } else { currentScope = null; } Project project = element.getProject(); if (!project.isInitialized()) { return; // skip default and other projects that look weird } final PsiManager psiManager = PsiManager.getInstance(project); for (VirtualFile virtualFile : FileEditorManager.getInstance(project).getOpenFiles()) { if (!virtualFile.isValid()) continue; if (virtualFile.getFileType().isBinary()) continue; PsiFile file = psiManager.findFile(virtualFile); if (isApplicableTo(file)) { final LocalSearchScope fileScope = new LocalSearchScope(file); final LocalSearchScope searchScope = currentScope == null ? fileScope : fileScope.intersectWith(currentScope); ReferencesSearch.searchOptimized(element, searchScope, true, queryParameters.getOptimizer(), consumer); } } }