decouple PsiSearchHelper from PsiManager

This commit is contained in:
Dmitry Jemerov
2011-08-19 20:48:43 +04:00
parent aa19acec63
commit 3a1e8b3478
35 changed files with 64 additions and 86 deletions
@@ -117,7 +117,7 @@ class ChangedConstantsDependencyProcessor {
}
}
}
final PsiSearchHelper psiSearchHelper = PsiManager.getInstance(myProject).getSearchHelper();
final PsiSearchHelper psiSearchHelper = PsiSearchHelper.SERVICE.getInstance(myProject);
final Ref<CacheCorruptedException> exRef = new Ref<CacheCorruptedException>(null);
final long analysisStart = System.currentTimeMillis();
@@ -537,8 +537,8 @@ public class PostHighlightingPass extends TextEditorHighlightingPass {
// some classes may have references from within XML outside dependent modules, e.g. our actions
if (member instanceof PsiClass) scope = scope.uniteWith(GlobalSearchScope.projectScope(myProject));
PsiSearchHelper.SearchCostResult cheapEnough = myFile.getManager().getSearchHelper().isCheapEnoughToSearch(name, scope, myFile,
progress);
PsiSearchHelper.SearchCostResult cheapEnough = PsiSearchHelper.SERVICE.getInstance(myFile.getProject())
.isCheapEnoughToSearch(name, scope, myFile, progress);
if (cheapEnough == PsiSearchHelper.SearchCostResult.TOO_MANY_OCCURRENCES) return false;
//search usages if it cheap
@@ -388,7 +388,7 @@ public class UnusedDeclarationInspection extends FilteringInspectionTool {
ProgressManager.getInstance().runProcess(new Runnable() {
public void run() {
final RefFilter filter = new StrictUnreferencedFilter(UnusedDeclarationInspection.this);
final PsiSearchHelper helper = PsiManager.getInstance(getRefManager().getProject()).getSearchHelper();
final PsiSearchHelper helper = PsiSearchHelper.SERVICE.getInstance(getRefManager().getProject());
getRefManager().iterate(new RefJavaVisitor() {
@Override public void visitElement(final RefEntity refEntity) {
if (refEntity instanceof RefClass && filter.accepts((RefClass)refEntity)) {
@@ -102,7 +102,7 @@ public class UnusedParametersInspection extends GlobalJavaInspectionTool {
processor.ignoreElement(entryPoint);
}
final PsiSearchHelper helper = PsiManager.getInstance(project).getSearchHelper();
final PsiSearchHelper helper = PsiSearchHelper.SERVICE.getInstance(project);
final AnalysisScope scope = manager.getScope();
manager.iterate(new RefJavaVisitor() {
@Override public void visitElement(RefEntity refEntity) {
@@ -39,6 +39,7 @@ import com.intellij.openapi.project.Project;
import com.intellij.psi.*;
import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.psi.search.PsiNonJavaFileReferenceProcessor;
import com.intellij.psi.search.PsiSearchHelper;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.psi.util.PsiUtil;
import com.intellij.util.IncorrectOperationException;
@@ -418,7 +419,7 @@ public class VisibilityInspection extends GlobalJavaInspectionTool {
String qualifiedName = ownerClass.getElement().getQualifiedName();
if (qualifiedName != null) {
final Project project = manager.getProject();
PsiManager.getInstance(project).getSearchHelper()
PsiSearchHelper.SERVICE.getInstance(project)
.processUsagesInNonJavaFiles(qualifiedName, new PsiNonJavaFileReferenceProcessor() {
public boolean process(PsiFile file, int startOffset, int endOffset) {
entryPointsManager.addEntryPoint(refMethod, false);
@@ -21,12 +21,11 @@ import com.intellij.openapi.help.HelpManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiManager;
import com.intellij.psi.PsiMethod;
import com.intellij.psi.search.LocalSearchScope;
import com.intellij.psi.search.PsiSearchHelper;
import com.intellij.psi.util.MethodSignatureUtil;
import com.intellij.ui.SimpleColoredComponent;
import com.intellij.ui.SimpleTextAttributes;
import com.intellij.ui.StateRestoringCheckBox;
import com.intellij.usageView.UsageViewUtil;
@@ -83,13 +82,9 @@ public abstract class JavaFindUsagesDialog<T extends JavaFindUsagesOptions> exte
}
}
private PsiManager getPsiManager() {
return myPsiElement.getManager();
}
protected boolean isInFileOnly() {
return super.isInFileOnly() ||
myPsiElement != null && getPsiManager().getSearchHelper().getUseScope(myPsiElement)instanceof LocalSearchScope;
myPsiElement != null && PsiSearchHelper.SERVICE.getInstance(myPsiElement.getProject()).getUseScope(myPsiElement)instanceof LocalSearchScope;
}
public void configureLabelComponent(final SimpleColoredComponent coloredComponent) {
@@ -19,6 +19,7 @@ import com.intellij.lang.refactoring.RefactoringSupportProvider;
import com.intellij.psi.*;
import com.intellij.psi.javadoc.PsiDocComment;
import com.intellij.psi.search.LocalSearchScope;
import com.intellij.psi.search.PsiSearchHelper;
import com.intellij.psi.search.SearchScope;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.refactoring.RefactoringActionHandler;
@@ -107,7 +108,7 @@ public class JavaRefactoringSupportProvider extends RefactoringSupportProvider {
public static boolean mayRenameInplace(PsiElement elementToRename, final PsiElement nameSuggestionContext) {
if (nameSuggestionContext != null && nameSuggestionContext.getContainingFile() != elementToRename.getContainingFile()) return false;
if (!(elementToRename instanceof PsiLocalVariable) && !(elementToRename instanceof PsiParameter) && !(elementToRename instanceof PsiTypeParameter)) return false;
SearchScope useScope = elementToRename.getManager().getSearchHelper().getUseScope(elementToRename);
SearchScope useScope = PsiSearchHelper.SERVICE.getInstance(elementToRename.getProject()).getUseScope(elementToRename);
if (!(useScope instanceof LocalSearchScope)) return false;
PsiElement[] scopeElements = ((LocalSearchScope) useScope).getScope();
if (scopeElements.length > 1 && // assume there are no elements with use scopes with holes in them
@@ -79,7 +79,7 @@ public class AnnotatedPackagesSearcher implements QueryExecutor<PsiPackage, Anno
}
}
PsiSearchHelper helper = psiManager.getSearchHelper();
PsiSearchHelper helper = PsiSearchHelper.SERVICE.getInstance(psiManager.getProject());
final GlobalSearchScope infoFilesFilter = new PackageInfoFilesOnly();
GlobalSearchScope infoFiles =
@@ -20,7 +20,6 @@ import com.intellij.openapi.help.HelpManager;
import com.intellij.openapi.progress.ProgressManager;
import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiJavaCodeReferenceElement;
import com.intellij.psi.PsiManager;
import com.intellij.psi.PsiMethod;
import com.intellij.psi.PsiSubstitutor;
import com.intellij.psi.search.GlobalSearchScope;
@@ -57,7 +56,7 @@ public class InlineMethodDialog extends InlineOptionsDialog {
private void initOccurrencesNumber(PsiMethod method) {
final ProgressManager progressManager = ProgressManager.getInstance();
final PsiSearchHelper searchHelper = method.getManager().getSearchHelper();
final PsiSearchHelper searchHelper = PsiSearchHelper.SERVICE.getInstance(method.getProject());
final GlobalSearchScope scope = GlobalSearchScope.projectScope(method.getProject());
final boolean isCheapToSearch =
searchHelper.isCheapEnoughToSearch(method.getName(), scope, null, progressManager.getProgressIndicator()) != PsiSearchHelper.SearchCostResult.TOO_MANY_OCCURRENCES;
@@ -145,7 +145,7 @@ public abstract class TurnRefsToSuperProcessorBase extends BaseRefactoringProces
super(project);
mySuperClassName = superClassName;
myManager = PsiManager.getInstance(project);
mySearchHelper = myManager.getSearchHelper();
mySearchHelper = PsiSearchHelper.SERVICE.getInstance(myManager.getProject());
myManager = PsiManager.getInstance(myProject);
myReplaceInstanceOf = replaceInstanceOf;
}
@@ -670,7 +670,7 @@ public class SystemBuilder {
final PsiElement declarationScope = parameter.getDeclarationScope();
if (declarationScope instanceof PsiMethod) {
final PsiMethod method = (PsiMethod)declarationScope;
final PsiSearchHelper helper = myManager.getSearchHelper();
final PsiSearchHelper helper = PsiSearchHelper.SERVICE.getInstance(myManager.getProject());
SearchScope scope = getScope(helper, method);
for (PsiReference ref : ReferencesSearch.search(method, scope, true)) {
@@ -914,7 +914,7 @@ public class SystemBuilder {
}
public ReductionSystem build(final HashSet<PsiElement> victims) {
final PsiSearchHelper helper = myManager.getSearchHelper();
final PsiSearchHelper helper = PsiSearchHelper.SERVICE.getInstance(myManager.getProject());
ReductionSystem system = new ReductionSystem(myProject, victims, myTypes, myTypeVariableFactory, mySettings);
@@ -20,7 +20,6 @@ import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Computable;
import com.intellij.openapi.util.UserDataHolderBase;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.search.PsiSearchHelper;
import com.intellij.psi.util.CachedValuesManager;
import com.intellij.psi.util.PsiModificationTracker;
import com.intellij.util.IncorrectOperationException;
@@ -113,16 +112,6 @@ public abstract class PsiManager extends UserDataHolderBase {
*/
public abstract void removePsiTreeChangeListener(@NotNull PsiTreeChangeListener listener);
/**
* Returns the search helper for the project, which provides low-level search and
* find usages functionality. It can be used to perform operations like finding references
* to an element, finding overriding / inheriting elements, finding to do items and so on.
*
* @return the search helper instance.
*/
@NotNull
public abstract PsiSearchHelper getSearchHelper();
/**
* Returns the modification tracker for the project, which can be used to get the PSI
* modification count value.
@@ -15,7 +15,9 @@
*/
package com.intellij.psi.search;
import com.intellij.openapi.components.ServiceManager;
import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.psi.PsiReference;
@@ -30,6 +32,15 @@ import org.jetbrains.annotations.Nullable;
* @see com.intellij.psi.PsiManager#getSearchHelper()
*/
public interface PsiSearchHelper extends PsiTodoSearchHelper {
class SERVICE {
private SERVICE() {
}
public static PsiSearchHelper getInstance(Project project) {
return ServiceManager.getService(project, PsiSearchHelper.class);
}
}
/**
* Searches the specified scope for comments containing the specified identifier.
*
@@ -1,7 +1,6 @@
package com.intellij.psi.search;
import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiManager;
import com.intellij.psi.PsiReference;
import com.intellij.util.AbstractQuery;
import com.intellij.util.Processor;
@@ -21,6 +20,6 @@ public class SearchRequestQuery extends AbstractQuery<PsiReference> {
@Override
protected boolean processResults(@NotNull Processor<PsiReference> consumer) {
return PsiManager.getInstance(myProject).getSearchHelper().processRequests(myRequests, consumer);
return PsiSearchHelper.SERVICE.getInstance(myProject).processRequests(myRequests, consumer);
}
}
@@ -69,7 +69,7 @@ public class ReferencesSearch extends ExtensibleQueryFactory<PsiReference, Refer
public SearchScope getEffectiveSearchScope () {
if (!myIgnoreAccessScope) {
SearchScope accessScope = myElementToSearch.getManager().getSearchHelper().getUseScope(myElementToSearch);
SearchScope accessScope = PsiSearchHelper.SERVICE.getInstance(myElementToSearch.getProject()).getUseScope(myElementToSearch);
return myScope.intersectWith(accessScope);
}
else {
@@ -716,8 +716,7 @@ public class GeneralHighlightingPass extends ProgressableTextEditorHighlightingP
@NotNull ProperTextRange priorityRange,
@NotNull Collection<HighlightInfo> result,
@NotNull Collection<HighlightInfo> outsideResult) {
PsiManager psiManager = file.getManager();
PsiSearchHelper helper = psiManager.getSearchHelper();
PsiSearchHelper helper = PsiSearchHelper.SERVICE.getInstance(file.getProject());
TodoItem[] todoItems = helper.findTodoItems(file, startOffset, endOffset);
if (todoItems.length == 0) return;
@@ -21,6 +21,7 @@ import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.psi.PsiElement;
import com.intellij.psi.search.LocalSearchScope;
import com.intellij.psi.search.PsiSearchHelper;
import com.intellij.ui.SimpleColoredComponent;
import com.intellij.ui.SimpleTextAttributes;
import com.intellij.usageView.UsageViewUtil;
@@ -51,7 +52,7 @@ public class CommonFindUsagesDialog extends AbstractFindUsagesDialog {
@Override
protected boolean isInFileOnly() {
return super.isInFileOnly() ||
myPsiElement != null && myPsiElement.getManager().getSearchHelper().getUseScope(myPsiElement)instanceof LocalSearchScope;
myPsiElement != null && PsiSearchHelper.SERVICE.getInstance(myPsiElement.getProject()).getUseScope(myPsiElement)instanceof LocalSearchScope;
}
protected JPanel createFindWhatPanel() {
@@ -46,10 +46,7 @@ import com.intellij.openapi.util.*;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.wm.StatusBar;
import com.intellij.psi.*;
import com.intellij.psi.search.LocalSearchScope;
import com.intellij.psi.search.SearchRequestCollector;
import com.intellij.psi.search.SearchScope;
import com.intellij.psi.search.SearchSession;
import com.intellij.psi.search.*;
import com.intellij.psi.util.PsiUtilBase;
import com.intellij.ui.LightweightHint;
import com.intellij.ui.content.Content;
@@ -431,11 +428,12 @@ public class FindUsagesManager implements JDOMExternalizable {
return scopeFile != null ? scopeFile.getProject() : !elements.isEmpty() ? elements.get(0).getProject() : handler.getProject();
}
});
PsiManager.getInstance(project).getSearchHelper().processRequests(options.fastTrack, new ReadActionProcessor<PsiReference>() {
public boolean processInReadAction(final PsiReference ref) {
return usageInfoProcessor.process(new UsageInfo(ref));
}
});
PsiSearchHelper.SERVICE.getInstance(project)
.processRequests(options.fastTrack, new ReadActionProcessor<PsiReference>() {
public boolean processInReadAction(final PsiReference ref) {
return usageInfoProcessor.process(new UsageInfo(ref));
}
});
}
finally {
options.fastTrack = null;
@@ -99,7 +99,7 @@ public abstract class TodoTreeBuilder extends AbstractTreeBuilder {
myFile2Highlighter = new HashMap<VirtualFile, EditorHighlighter>();
PsiManager psiManager = PsiManager.getInstance(myProject);
mySearchHelper = psiManager.getSearchHelper();
mySearchHelper = PsiSearchHelper.SERVICE.getInstance(myProject);
psiManager.addPsiTreeChangeListener(new MyPsiTreeChangeListener());
myFileStatusListener = new MyFileStatusListener();
@@ -23,7 +23,6 @@ import com.intellij.ide.util.treeView.NodeDescriptor;
import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiDocumentManager;
import com.intellij.psi.PsiFile;
import com.intellij.psi.PsiManager;
import com.intellij.psi.search.PsiSearchHelper;
import com.intellij.psi.search.PsiTodoSearchHelper;
import com.intellij.psi.search.TodoPattern;
@@ -55,8 +54,7 @@ public abstract class TodoTreeStructure extends AbstractTreeStructureBase implem
super(project);
myArePackagesShown=true;
mySummaryElement=new ToDoSummary();
PsiManager psiManager = PsiManager.getInstance(project);
mySearchHelper= psiManager.getSearchHelper();
mySearchHelper= PsiSearchHelper.SERVICE.getInstance(project);
}
final void setTreeBuilder(TodoTreeBuilder builder){
@@ -81,7 +81,7 @@ public class TodoCheckinHandlerWorker {
myTodoFilter = todoFilter;
myIncludePattern = includePattern;
myPsiManager = PsiManager.getInstance(project);
mySearchHelper = myPsiManager.getSearchHelper();
mySearchHelper = PsiSearchHelper.SERVICE.getInstance(project);
myAddedOrEditedTodos = new ArrayList<TodoItem>();
myInChangedTodos = new ArrayList<TodoItem>();
mySkipped = new SmartList<Pair<FilePath,String>>();
@@ -47,13 +47,11 @@ import com.intellij.psi.impl.cache.impl.CompositeCacheManager;
import com.intellij.psi.impl.cache.impl.IndexCacheManagerImpl;
import com.intellij.psi.impl.file.impl.FileManager;
import com.intellij.psi.impl.file.impl.FileManagerImpl;
import com.intellij.psi.impl.search.PsiSearchHelperImpl;
import com.intellij.psi.impl.source.PostprocessReformattingAspect;
import com.intellij.psi.impl.source.PsiFileImpl;
import com.intellij.psi.impl.source.resolve.ResolveCache;
import com.intellij.psi.impl.source.tree.injected.InjectedLanguageManagerImpl;
import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil;
import com.intellij.psi.search.PsiSearchHelper;
import com.intellij.psi.util.CachedValuesManager;
import com.intellij.psi.util.PsiModificationTracker;
import com.intellij.refactoring.move.moveFilesOrDirectories.MoveFilesOrDirectoriesUtil;
@@ -78,7 +76,6 @@ public class PsiManagerImpl extends PsiManagerEx implements ProjectComponent {
private final MessageBus myMessageBus;
private final FileManager myFileManager;
private final PsiSearchHelperImpl mySearchHelper;
private final CacheManager myCacheManager;
private final PsiModificationTrackerImpl myModificationTracker;
private final ResolveCache myResolveCache;
@@ -122,7 +119,6 @@ public class PsiManagerImpl extends PsiManagerEx implements ProjectComponent {
myFileManager = isProjectDefault ? new EmptyFileManager(this) : new FileManagerImpl(this, fileTypeManager, fileDocumentManager,
projectRootManagerEx);
mySearchHelper = new PsiSearchHelperImpl(this);
final CompositeCacheManager cacheManager = new CompositeCacheManager();
if (isProjectDefault) {
cacheManager.addCacheManager(new EmptyCacheManager());
@@ -695,11 +691,6 @@ public class PsiManagerImpl extends PsiManagerEx implements ProjectComponent {
myMessageBus.syncPublisher(ANY_PSI_CHANGE_TOPIC).afterPsiChanged(isPhysical);
}
@NotNull
public PsiSearchHelper getSearchHelper() {
return mySearchHelper;
}
@NotNull
public PsiModificationTracker getModificationTracker() {
return myModificationTracker;
@@ -52,6 +52,7 @@ import com.intellij.psi.*;
import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil;
import com.intellij.psi.search.LocalSearchScope;
import com.intellij.psi.search.ProjectScope;
import com.intellij.psi.search.PsiSearchHelper;
import com.intellij.psi.search.SearchScope;
import com.intellij.psi.search.searches.ReferencesSearch;
import com.intellij.psi.util.PsiTreeUtil;
@@ -181,7 +182,7 @@ public class VariableInplaceRenamer {
@Nullable
protected PsiElement checkLocalScope() {
final SearchScope searchScope = myElementToRename.getManager().getSearchHelper().getUseScope(myElementToRename);
final SearchScope searchScope = PsiSearchHelper.SERVICE.getInstance(myElementToRename.getProject()).getUseScope(myElementToRename);
if (searchScope instanceof LocalSearchScope) {
final PsiElement[] elements = ((LocalSearchScope)searchScope).getScope();
return PsiTreeUtil.findCommonParent(elements);
@@ -27,7 +27,6 @@ import com.intellij.lang.ParserDefinition;
import com.intellij.openapi.util.TextRange;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.psi.PsiManager;
import com.intellij.psi.PsiReference;
import com.intellij.psi.search.*;
import com.intellij.usageView.UsageInfo;
@@ -60,7 +59,7 @@ public class TextOccurrencesUtil {
@NotNull GlobalSearchScope searchScope,
@NotNull final Processor<UsageInfo> processor,
@NotNull final UsageInfoFactory factory) {
PsiSearchHelper helper = element.getManager().getSearchHelper();
PsiSearchHelper helper = PsiSearchHelper.SERVICE.getInstance(element.getProject());
helper.processUsagesInNonJavaFiles(element, stringToSearch, new PsiNonJavaFileReferenceProcessor() {
public boolean process(PsiFile psiFile, int startOffset, int endOffset) {
@@ -93,10 +92,9 @@ public class TextOccurrencesUtil {
@NotNull final String stringToSearch,
final boolean ignoreReferences,
@NotNull final PairProcessor<PsiElement, TextRange> processor) {
PsiManager manager = element.getManager();
PsiSearchHelper helper = manager.getSearchHelper();
SearchScope scope = element.getManager().getSearchHelper().getUseScope(element);
scope = scope.intersectWith(GlobalSearchScope.projectScope(manager.getProject()));
PsiSearchHelper helper = PsiSearchHelper.SERVICE.getInstance(element.getProject());
SearchScope scope = PsiSearchHelper.SERVICE.getInstance(element.getProject()).getUseScope(element);
scope = scope.intersectWith(GlobalSearchScope.projectScope(element.getProject()));
Processor<PsiElement> commentOrLiteralProcessor = new Processor<PsiElement>() {
public boolean process(PsiElement literal) {
return processTextIn(literal, stringToSearch, ignoreReferences, processor);
@@ -73,6 +73,9 @@
<projectService serviceInterface="com.intellij.pom.references.PomService"
serviceImplementation="com.intellij.pom.references.PomServiceImpl"/>
<projectService serviceInterface="com.intellij.psi.search.PsiSearchHelper"
serviceImplementation="com.intellij.psi.impl.search.PsiSearchHelperImpl"/>
<projectService serviceInterface="com.intellij.codeInsight.lookup.LookupManager"
serviceImplementation="com.intellij.codeInsight.lookup.impl.LookupManagerImpl"/>
@@ -288,8 +288,7 @@ public class DeclareCollectionAsInterfaceInspection extends BaseInspection {
}
final ProgressManager progressManager =
ProgressManager.getInstance();
final PsiManager manager = element.getManager();
final PsiSearchHelper searchHelper = manager.getSearchHelper();
final PsiSearchHelper searchHelper = PsiSearchHelper.SERVICE.getInstance(element.getProject());
final GlobalSearchScope scope =
GlobalSearchScope.projectScope(element.getProject());
return searchHelper.isCheapEnoughToSearch(name, scope, null,
@@ -209,8 +209,7 @@ public class StaticMethodOnlyUsedInOneClassInspection
public PsiClass getUsageClass(final PsiMethod method) {
final ProgressManager progressManager =
ProgressManager.getInstance();
final PsiManager manager = method.getManager();
final PsiSearchHelper searchHelper = manager.getSearchHelper();
final PsiSearchHelper searchHelper = PsiSearchHelper.SERVICE.getInstance(method.getProject());
final String name = method.getName();
final GlobalSearchScope scope =
GlobalSearchScope.allScope(method.getProject());
@@ -18,7 +18,6 @@ package com.siyeh.ig.maturity;
import com.intellij.openapi.util.TextRange;
import com.intellij.psi.PsiComment;
import com.intellij.psi.PsiFile;
import com.intellij.psi.PsiManager;
import com.intellij.psi.search.PsiSearchHelper;
import com.intellij.psi.search.TodoItem;
@@ -29,8 +28,7 @@ public class TodoUtil{
public static boolean isTodoComment(PsiComment comment){
final PsiFile file = comment.getContainingFile();
final PsiManager psiManager = comment.getManager();
final PsiSearchHelper searchHelper = psiManager.getSearchHelper();
final PsiSearchHelper searchHelper = PsiSearchHelper.SERVICE.getInstance(comment.getProject());
final TodoItem[] todoItems = searchHelper.findTodoItems(file);
for(final TodoItem todoItem : todoItems){
final TextRange commentTextRange = comment.getTextRange();
@@ -67,7 +67,7 @@ public abstract class AnnotationBasedInstrumentingCompiler implements ClassInstr
final Project project = context.getProject();
final Set<InstrumentationItem> result = new HashSet<InstrumentationItem>();
final PsiSearchHelper searchHelper = PsiManager.getInstance(context.getProject()).getSearchHelper();
final PsiSearchHelper searchHelper = PsiSearchHelper.SERVICE.getInstance(context.getProject());
DumbService.getInstance(project).waitForSmartMode();
@@ -100,7 +100,7 @@ public class GrAliasedImportedElementSearcher extends QueryExecutorBase<PsiRefer
}
return element.getManager().getSearchHelper().processRequests(collector, consumer);
return PsiSearchHelper.SERVICE.getInstance(element.getProject()).processRequests(collector, consumer);
}
@Nullable
@@ -201,7 +201,7 @@ public class GroovyConstructorUsagesSearcher extends QueryExecutorBase<PsiRefere
if (gppScope instanceof GlobalSearchScope) {
String name = currentTarget.getName();
if (currentTarget.getManager().getSearchHelper().isCheapEnoughToSearch(name, (GlobalSearchScope)gppScope, null, null) ==
if (PsiSearchHelper.SERVICE.getInstance(currentTarget.getProject()).isCheapEnoughToSearch(name, (GlobalSearchScope)gppScope, null, null) ==
PsiSearchHelper.SearchCostResult.ZERO_OCCURRENCES) {
return;
}
@@ -100,7 +100,7 @@ public class DuplicateStringLiteralInspection extends BaseLocalInspectionTool {
final String stringToFind = (String)value;
if (stringToFind.length() == 0) return;
final GlobalSearchScope scope = GlobalSearchScope.projectScope(originalExpression.getProject());
final PsiSearchHelper searchHelper = holder.getFile().getManager().getSearchHelper();
final PsiSearchHelper searchHelper = PsiSearchHelper.SERVICE.getInstance(holder.getFile().getProject());
final List<String> words = StringUtil.getWordsIn(stringToFind);
if (words.isEmpty()) return;
// put longer strings first
@@ -146,7 +146,7 @@ public class DuplicatePropertyInspection extends GlobalSimpleInspectionTool {
private void checkFile(final PsiFile file, final InspectionManager manager, GlobalInspectionContextImpl context, final RefManager refManager, final ProblemDescriptionsProcessor processor) {
if (!(file instanceof PropertiesFile)) return;
if (!context.isToCheckMember(file, this)) return;
final PsiSearchHelper searchHelper = file.getManager().getSearchHelper();
final PsiSearchHelper searchHelper = PsiSearchHelper.SERVICE.getInstance(file.getProject());
final PropertiesFile propertiesFile = (PropertiesFile)file;
final List<IProperty> properties = propertiesFile.getProperties();
Module module = ModuleUtil.findModuleForPsiElement(file);
@@ -24,10 +24,7 @@ import com.intellij.openapi.module.Module;
import com.intellij.openapi.module.ModuleUtil;
import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.openapi.progress.ProgressManager;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiElementVisitor;
import com.intellij.psi.PsiFile;
import com.intellij.psi.PsiReference;
import com.intellij.psi.*;
import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.psi.search.PsiSearchHelper;
import com.intellij.psi.search.searches.ReferencesSearch;
@@ -57,7 +54,7 @@ public class UnusedPropertyInspection extends PropertySuppressableInspectionBase
Module module = ModuleUtil.findModuleForPsiElement(file);
if (module == null) return super.buildVisitor(holder, isOnTheFly, session);
final GlobalSearchScope searchScope = GlobalSearchScope.moduleWithDependentsScope(module);
final PsiSearchHelper searchHelper = file.getManager().getSearchHelper();
final PsiSearchHelper searchHelper = PsiSearchHelper.SERVICE.getInstance(file.getProject());
return new PsiElementVisitor() {
@Override
public void visitElement(PsiElement element) {
@@ -34,6 +34,7 @@ import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.*;
import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.psi.search.PsiNonJavaFileReferenceProcessor;
import com.intellij.psi.search.PsiSearchHelper;
import com.intellij.psi.util.PsiClassUtil;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.psi.xml.XmlAttribute;
@@ -90,13 +91,13 @@ public class UndeclaredTestInspection extends BaseJavaLocalInspectionTool {
}
for (final String name : names) {
final boolean[] found = new boolean[]{false};
PsiManager.getInstance(project).getSearchHelper()
PsiSearchHelper.SERVICE.getInstance(project)
.processUsagesInNonJavaFiles(name, new PsiNonJavaFileReferenceProcessor() {
public boolean process(final PsiFile file, final int startOffset, final int endOffset) {
if (file.findReferenceAt(startOffset) != null) {
if (packageQName.endsWith(name)) { //special package tag required
final XmlTag tag = PsiTreeUtil.getParentOfType(file.findElementAt(startOffset), XmlTag.class);
if (tag == null || !tag.getName().equals("package")){
if (tag == null || !tag.getName().equals("package")) {
return true;
}
final XmlAttribute attribute = tag.getAttribute("name");