mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-05 01:50:56 +07:00
decouple PsiManager from CacheManager
This commit is contained in:
@@ -65,6 +65,7 @@ import com.intellij.profile.codeInspection.InspectionProfileManager;
|
||||
import com.intellij.profile.codeInspection.InspectionProjectProfileManager;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.JavaPsiFacadeEx;
|
||||
import com.intellij.psi.impl.cache.CacheManager;
|
||||
import com.intellij.psi.impl.search.IndexPatternBuilder;
|
||||
import com.intellij.psi.impl.source.resolve.reference.ReferenceProvidersRegistry;
|
||||
import com.intellij.psi.impl.source.tree.TreeElement;
|
||||
@@ -289,7 +290,7 @@ public abstract class DaemonAnalyzerTestCase extends CodeInsightTestCase {
|
||||
|
||||
//to initialize caches
|
||||
if (!DumbService.isDumb(getProject())) {
|
||||
myPsiManager.getCacheManager().getFilesWithWord("XXX", UsageSearchContext.IN_COMMENTS, GlobalSearchScope.allScope(myProject), true);
|
||||
CacheManager.SERVICE.getInstance(myProject).getFilesWithWord("XXX", UsageSearchContext.IN_COMMENTS, GlobalSearchScope.allScope(myProject), true);
|
||||
}
|
||||
final JavaPsiFacadeEx facade = getJavaFacade();
|
||||
if (facade != null) {
|
||||
|
||||
@@ -26,7 +26,6 @@ import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.ApplicationNamesInfo;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.colors.TextAttributesKey;
|
||||
import com.intellij.openapi.fileEditor.FileDocumentManager;
|
||||
import com.intellij.openapi.fileEditor.FileEditor;
|
||||
import com.intellij.openapi.fileTypes.FileTypeManager;
|
||||
@@ -49,7 +48,6 @@ import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.openapi.util.registry.Registry;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.util.text.TrigramBuilder;
|
||||
import com.intellij.openapi.vcs.FileStatus;
|
||||
import com.intellij.openapi.vfs.JarFileSystem;
|
||||
import com.intellij.openapi.vfs.LocalFileSystem;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
@@ -57,7 +55,6 @@ import com.intellij.openapi.vfs.VirtualFileFilter;
|
||||
import com.intellij.openapi.wm.ToolWindowId;
|
||||
import com.intellij.openapi.wm.ToolWindowManager;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.PsiManagerEx;
|
||||
import com.intellij.psi.impl.cache.CacheManager;
|
||||
import com.intellij.psi.search.*;
|
||||
import com.intellij.usageView.UsageInfo;
|
||||
@@ -444,7 +441,7 @@ public class FindInProjectUtil {
|
||||
}
|
||||
|
||||
PsiManager pm = PsiManager.getInstance(project);
|
||||
CacheManager cacheManager = ((PsiManagerEx)pm).getCacheManager();
|
||||
CacheManager cacheManager = CacheManager.SERVICE.getInstance(project);
|
||||
SearchScope customScope = findModel.getCustomScope();
|
||||
@NotNull GlobalSearchScope scope = psiDirectory != null
|
||||
? GlobalSearchScopes.directoryScope(psiDirectory, true)
|
||||
|
||||
@@ -23,23 +23,17 @@ import com.intellij.openapi.util.Computable;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.EmptyCacheManager;
|
||||
import com.intellij.psi.impl.PsiManagerEx;
|
||||
import com.intellij.psi.impl.PsiModificationTrackerImpl;
|
||||
import com.intellij.psi.impl.PsiTreeChangeEventImpl;
|
||||
import com.intellij.psi.impl.cache.CacheManager;
|
||||
import com.intellij.psi.impl.file.impl.FileManager;
|
||||
import com.intellij.psi.impl.source.resolve.ResolveCache;
|
||||
import com.intellij.psi.util.PsiModificationTracker;
|
||||
import com.intellij.util.CachedValuesManagerImpl;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import com.intellij.util.ThrowableRunnable;
|
||||
import gnu.trove.THashMap;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class MockPsiManager extends PsiManagerEx {
|
||||
@@ -47,7 +41,6 @@ public class MockPsiManager extends PsiManagerEx {
|
||||
private final Map<VirtualFile,PsiDirectory> myDirectories = new THashMap<VirtualFile, PsiDirectory>();
|
||||
private MockFileManager myMockFileManager;
|
||||
private PsiModificationTrackerImpl myPsiModificationTracker;
|
||||
private final CacheManager myCacheManager = new EmptyCacheManager();
|
||||
private ResolveCache myResolveCache;
|
||||
|
||||
public MockPsiManager() {
|
||||
@@ -105,15 +98,6 @@ public class MockPsiManager extends PsiManagerEx {
|
||||
return myPsiModificationTracker;
|
||||
}
|
||||
|
||||
public void moveFile(@NotNull PsiFile file, @NotNull PsiDirectory newParentDir) throws IncorrectOperationException {
|
||||
}
|
||||
|
||||
public void moveDirectory(@NotNull PsiDirectory dir, @NotNull PsiDirectory newParentDir) throws IncorrectOperationException {
|
||||
}
|
||||
|
||||
public void checkMove(@NotNull PsiElement element, @NotNull PsiElement newContainer) throws IncorrectOperationException {
|
||||
}
|
||||
|
||||
public void startBatchFilesProcessingMode() {
|
||||
}
|
||||
|
||||
@@ -151,25 +135,10 @@ public class MockPsiManager extends PsiManagerEx {
|
||||
return r.compute();
|
||||
}
|
||||
|
||||
public void registerLanguageInjector(@NotNull LanguageInjector injector) {
|
||||
}
|
||||
|
||||
public void registerLanguageInjector(@NotNull LanguageInjector injector, Disposable parentDisposable) {
|
||||
}
|
||||
|
||||
public void unregisterLanguageInjector(@NotNull LanguageInjector injector) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dropFileCaches(@NotNull PsiFile file) {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public List<LanguageInjector> getLanguageInjectors() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
public boolean isBatchFilesProcessingMode() {
|
||||
return false;
|
||||
}
|
||||
@@ -214,9 +183,6 @@ public class MockPsiManager extends PsiManagerEx {
|
||||
return myMockFileManager;
|
||||
}
|
||||
|
||||
public void invalidateFile(@NotNull final PsiFile file) {
|
||||
}
|
||||
|
||||
public void beforeChildRemoval(@NotNull final PsiTreeChangeEventImpl event) {
|
||||
}
|
||||
|
||||
@@ -227,9 +193,4 @@ public class MockPsiManager extends PsiManagerEx {
|
||||
@Override
|
||||
public void beforeChildAddition(@NotNull PsiTreeChangeEventImpl event) {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public CacheManager getCacheManager() {
|
||||
return myCacheManager;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,54 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @author max
|
||||
*/
|
||||
package com.intellij.psi.impl;
|
||||
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.impl.cache.CacheManager;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.psi.search.IndexPattern;
|
||||
import com.intellij.psi.search.IndexPatternProvider;
|
||||
import com.intellij.util.Processor;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class EmptyCacheManager implements CacheManager {
|
||||
@NotNull
|
||||
public PsiFile[] getFilesWithWord(@NotNull String word, short occurenceMask, @NotNull GlobalSearchScope scope, final boolean caseSensitive) {
|
||||
return PsiFile.EMPTY_ARRAY;
|
||||
}
|
||||
|
||||
public boolean processFilesWithWord(@NotNull Processor<PsiFile> processor, @NotNull String word, short occurenceMask, @NotNull GlobalSearchScope scope,
|
||||
final boolean caseSensitively) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public PsiFile[] getFilesWithTodoItems() {
|
||||
return PsiFile.EMPTY_ARRAY;
|
||||
}
|
||||
|
||||
public int getTodoCount(@NotNull VirtualFile file, final IndexPatternProvider patternProvider) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int getTodoCount(@NotNull VirtualFile file, IndexPattern pattern) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -16,9 +16,7 @@
|
||||
package com.intellij.psi.impl;
|
||||
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.PsiManager;
|
||||
import com.intellij.psi.impl.cache.CacheManager;
|
||||
import com.intellij.psi.impl.file.impl.FileManager;
|
||||
import com.intellij.psi.impl.source.resolve.ResolveCache;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -55,9 +53,6 @@ public abstract class PsiManagerEx extends PsiManager {
|
||||
|
||||
public abstract void beforeChildReplacement(@NotNull PsiTreeChangeEventImpl event);
|
||||
|
||||
@NotNull
|
||||
public abstract CacheManager getCacheManager();
|
||||
|
||||
public abstract void beforeChange(boolean isPhysical);
|
||||
|
||||
public abstract void afterChange(boolean isPhysical);
|
||||
|
||||
@@ -38,9 +38,7 @@ import com.intellij.openapi.util.Key;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.vfs.VirtualFileFilter;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.cache.CacheManager;
|
||||
import com.intellij.psi.impl.cache.impl.CacheUtil;
|
||||
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.source.PostprocessReformattingAspect;
|
||||
@@ -67,7 +65,6 @@ public class PsiManagerImpl extends PsiManagerEx implements ProjectComponent {
|
||||
private final MessageBus myMessageBus;
|
||||
|
||||
private final FileManager myFileManager;
|
||||
private final CacheManager myCacheManager;
|
||||
private final PsiModificationTrackerImpl myModificationTracker;
|
||||
private final ResolveCache myResolveCache;
|
||||
|
||||
@@ -102,8 +99,6 @@ public class PsiManagerImpl extends PsiManagerEx implements ProjectComponent {
|
||||
myFileManager = isProjectDefault ? new EmptyFileManager(this) : new FileManagerImpl(this, fileTypeManager, fileDocumentManager,
|
||||
projectRootManagerEx);
|
||||
|
||||
myCacheManager = isProjectDefault ? new EmptyCacheManager() : new IndexCacheManagerImpl(this);
|
||||
|
||||
myModificationTracker = new PsiModificationTrackerImpl(myProject);
|
||||
myTreeChangePreprocessors.add(myModificationTracker);
|
||||
myResolveCache = new ResolveCache(messageBus);
|
||||
@@ -244,14 +239,6 @@ public class PsiManagerImpl extends PsiManagerEx implements ProjectComponent {
|
||||
return myFileManager;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public CacheManager getCacheManager() {
|
||||
if (myIsDisposed) {
|
||||
LOG.error("Project is already disposed.");
|
||||
}
|
||||
return myCacheManager;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public ResolveCache getResolveCache() {
|
||||
ProgressManager.checkCanceled(); // We hope this method is being called often enough to cancel daemon processes smoothly
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
package com.intellij.psi.impl.cache;
|
||||
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
@@ -25,6 +27,15 @@ import com.intellij.util.Processor;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public interface CacheManager {
|
||||
class SERVICE {
|
||||
private SERVICE() {
|
||||
}
|
||||
|
||||
public static CacheManager getInstance(Project project) {
|
||||
return ServiceManager.getService(project, CacheManager.class);
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull PsiFile[] getFilesWithWord(@NotNull String word, short occurenceMask, @NotNull GlobalSearchScope scope, final boolean caseSensitively);
|
||||
|
||||
boolean processFilesWithWord(@NotNull Processor<PsiFile> processor,@NotNull String word, short occurenceMask, @NotNull GlobalSearchScope scope, final boolean caseSensitively);
|
||||
|
||||
@@ -65,6 +65,9 @@ public class IndexCacheManagerImpl implements CacheManager{
|
||||
|
||||
@NotNull
|
||||
public PsiFile[] getFilesWithWord(@NotNull final String word, final short occurenceMask, @NotNull final GlobalSearchScope scope, final boolean caseSensitively) {
|
||||
if (myProject.isDefault()) {
|
||||
return PsiFile.EMPTY_ARRAY;
|
||||
}
|
||||
CommonProcessors.CollectProcessor<PsiFile> processor = new CommonProcessors.CollectProcessor<PsiFile>();
|
||||
processFilesWithWord(processor, word, occurenceMask, scope, caseSensitively);
|
||||
return processor.getResults().isEmpty() ? PsiFile.EMPTY_ARRAY : processor.toArray(PsiFile.EMPTY_ARRAY);
|
||||
@@ -75,6 +78,9 @@ public class IndexCacheManagerImpl implements CacheManager{
|
||||
}
|
||||
|
||||
public boolean processFilesWithWord(@NotNull final Processor<PsiFile> psiFileProcessor, @NotNull final String word, final short occurrenceMask, @NotNull final GlobalSearchScope scope, final boolean caseSensitively) {
|
||||
if (myProject.isDefault()) {
|
||||
return true;
|
||||
}
|
||||
final Set<VirtualFile> vFiles = new THashSet<VirtualFile>();
|
||||
final GlobalSearchScope projectScope = GlobalSearchScope.allScope(myProject);
|
||||
try {
|
||||
@@ -130,12 +136,15 @@ public class IndexCacheManagerImpl implements CacheManager{
|
||||
|
||||
@NotNull
|
||||
public PsiFile[] getFilesWithTodoItems() {
|
||||
if (myProject.isDefault()) {
|
||||
return PsiFile.EMPTY_ARRAY;
|
||||
}
|
||||
final FileBasedIndex fileBasedIndex = FileBasedIndex.getInstance();
|
||||
final Set<PsiFile> allFiles = new HashSet<PsiFile>();
|
||||
final ProjectFileIndex projectFileIndex = ProjectRootManager.getInstance(myProject).getFileIndex();
|
||||
for (IndexPattern indexPattern : CacheUtil.getIndexPatterns()) {
|
||||
final Collection<VirtualFile> files = fileBasedIndex.getContainingFiles(
|
||||
TodoIndex.NAME,
|
||||
TodoIndex.NAME,
|
||||
new TodoIndexEntry(indexPattern.getPatternString(), indexPattern.isCaseSensitive()), GlobalSearchScope.allScope(myProject));
|
||||
ApplicationManager.getApplication().runReadAction(new Runnable() {
|
||||
public void run() {
|
||||
@@ -148,12 +157,15 @@ public class IndexCacheManagerImpl implements CacheManager{
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
return allFiles.isEmpty() ? PsiFile.EMPTY_ARRAY : PsiUtilBase.toPsiFileArray(allFiles);
|
||||
}
|
||||
|
||||
public int getTodoCount(@NotNull final VirtualFile file, final IndexPatternProvider patternProvider) {
|
||||
if (myProject.isDefault()) {
|
||||
return 0;
|
||||
}
|
||||
if (file instanceof VirtualFileWindow) return -1;
|
||||
final FileBasedIndex fileBasedIndex = FileBasedIndex.getInstance();
|
||||
int count = 0;
|
||||
@@ -164,6 +176,9 @@ public class IndexCacheManagerImpl implements CacheManager{
|
||||
}
|
||||
|
||||
public int getTodoCount(@NotNull final VirtualFile file, final IndexPattern pattern) {
|
||||
if (myProject.isDefault()) {
|
||||
return 0;
|
||||
}
|
||||
if (file instanceof VirtualFileWindow) return -1;
|
||||
return fetchCount(FileBasedIndex.getInstance(), file, pattern);
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
package com.intellij.psi.impl.search;
|
||||
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.impl.PsiManagerEx;
|
||||
import com.intellij.psi.impl.cache.CacheManager;
|
||||
import com.intellij.psi.search.IndexPattern;
|
||||
import com.intellij.psi.search.IndexPatternProvider;
|
||||
import com.intellij.psi.search.searches.IndexPatternSearch;
|
||||
@@ -31,13 +31,13 @@ class IndexPatternSearchImpl extends IndexPatternSearch {
|
||||
}
|
||||
|
||||
protected int getOccurrencesCountImpl(PsiFile file, IndexPatternProvider provider) {
|
||||
int count = ((PsiManagerEx)file.getManager()).getCacheManager().getTodoCount(file.getVirtualFile(), provider);
|
||||
int count = CacheManager.SERVICE.getInstance(file.getProject()).getTodoCount(file.getVirtualFile(), provider);
|
||||
if (count != -1) return count;
|
||||
return search(file, provider).findAll().size();
|
||||
}
|
||||
|
||||
protected int getOccurrencesCountImpl(PsiFile file, IndexPattern pattern) {
|
||||
int count = ((PsiManagerEx)file.getManager()).getCacheManager().getTodoCount(file.getVirtualFile(), pattern);
|
||||
int count = CacheManager.SERVICE.getInstance(file.getProject()).getTodoCount(file.getVirtualFile(), pattern);
|
||||
if (count != -1) return count;
|
||||
return search(file, pattern).findAll().size();
|
||||
}
|
||||
|
||||
@@ -29,7 +29,6 @@ import com.intellij.openapi.progress.ProgressManager;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.PsiManagerEx;
|
||||
import com.intellij.psi.impl.cache.CacheManager;
|
||||
import com.intellij.psi.search.IndexPattern;
|
||||
import com.intellij.psi.search.IndexPatternOccurrence;
|
||||
@@ -60,7 +59,7 @@ public class IndexPatternSearcher implements QueryExecutor<IndexPatternOccurrenc
|
||||
return true;
|
||||
}
|
||||
|
||||
final CacheManager cacheManager = ((PsiManagerEx)file.getManager()).getCacheManager();
|
||||
final CacheManager cacheManager = CacheManager.SERVICE.getInstance(file.getProject());
|
||||
final IndexPatternProvider patternProvider = queryParameters.getPatternProvider();
|
||||
int count = patternProvider != null
|
||||
? cacheManager.getTodoCount(virtualFile, patternProvider)
|
||||
|
||||
@@ -35,6 +35,7 @@ import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.PsiManagerEx;
|
||||
import com.intellij.psi.impl.cache.CacheManager;
|
||||
import com.intellij.psi.impl.cache.impl.IndexCacheManagerImpl;
|
||||
import com.intellij.psi.impl.cache.impl.id.IdIndex;
|
||||
import com.intellij.psi.impl.cache.impl.id.IdIndexEntry;
|
||||
@@ -85,7 +86,7 @@ public class PsiSearchHelperImpl implements PsiSearchHelper {
|
||||
|
||||
@NotNull
|
||||
public PsiFile[] findFilesWithTodoItems() {
|
||||
return myManager.getCacheManager().getFilesWithTodoItems();
|
||||
return CacheManager.SERVICE.getInstance(myManager.getProject()).getFilesWithTodoItems();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -114,13 +115,13 @@ public class PsiSearchHelperImpl implements PsiSearchHelper {
|
||||
}
|
||||
|
||||
public int getTodoItemsCount(@NotNull PsiFile file) {
|
||||
int count = myManager.getCacheManager().getTodoCount(file.getVirtualFile(), TodoIndexPatternProvider.getInstance());
|
||||
int count = CacheManager.SERVICE.getInstance(myManager.getProject()).getTodoCount(file.getVirtualFile(), TodoIndexPatternProvider.getInstance());
|
||||
if (count != -1) return count;
|
||||
return findTodoItems(file).length;
|
||||
}
|
||||
|
||||
public int getTodoItemsCount(@NotNull PsiFile file, @NotNull TodoPattern pattern) {
|
||||
int count = myManager.getCacheManager().getTodoCount(file.getVirtualFile(), pattern.getIndexPattern());
|
||||
int count = CacheManager.SERVICE.getInstance(myManager.getProject()).getTodoCount(file.getVirtualFile(), pattern.getIndexPattern());
|
||||
if (count != -1) return count;
|
||||
TodoItem[] items = findTodoItems(file);
|
||||
count = 0;
|
||||
@@ -349,7 +350,7 @@ public class PsiSearchHelperImpl implements PsiSearchHelper {
|
||||
ProgressManager.checkCanceled();
|
||||
}
|
||||
final String word = words.get(i);
|
||||
myManager.getCacheManager().processFilesWithWord(new CommonProcessors.CollectProcessor<PsiFile>(copy), word, searchContext, scope, caseSensitively);
|
||||
CacheManager.SERVICE.getInstance(myManager.getProject()).processFilesWithWord(new CommonProcessors.CollectProcessor<PsiFile>(copy), word, searchContext, scope, caseSensitively);
|
||||
if (i == 0) {
|
||||
fileSet.addAll(copy);
|
||||
}
|
||||
@@ -364,21 +365,22 @@ public class PsiSearchHelperImpl implements PsiSearchHelper {
|
||||
else {
|
||||
fileSet = null;
|
||||
}
|
||||
return myManager.getCacheManager().processFilesWithWord(new Processor<PsiFile>() {
|
||||
return CacheManager.SERVICE.getInstance(myManager.getProject()).processFilesWithWord(new Processor<PsiFile>() {
|
||||
public boolean process(PsiFile psiFile) {
|
||||
if (fileSet != null && !fileSet.contains(psiFile)) {
|
||||
return true;
|
||||
}
|
||||
return processor.process(psiFile);
|
||||
}
|
||||
}, words.get(words.size()-1), searchContext, scope, caseSensitively);
|
||||
}, words.get(words.size() - 1), searchContext, scope, caseSensitively);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public PsiFile[] findFilesWithPlainTextWords(@NotNull String word) {
|
||||
return myManager.getCacheManager().getFilesWithWord(word,
|
||||
UsageSearchContext.IN_PLAIN_TEXT,
|
||||
GlobalSearchScope.projectScope(myManager.getProject()), true);
|
||||
return CacheManager.SERVICE.getInstance(myManager.getProject()).getFilesWithWord(word,
|
||||
UsageSearchContext.IN_PLAIN_TEXT,
|
||||
GlobalSearchScope.projectScope(myManager.getProject()),
|
||||
true);
|
||||
}
|
||||
|
||||
|
||||
@@ -407,7 +409,7 @@ public class PsiSearchHelperImpl implements PsiSearchHelper {
|
||||
final GlobalSearchScope theSearchScope = searchScope;
|
||||
PsiFile[] files = ApplicationManager.getApplication().runReadAction(new Computable<PsiFile[]>() {
|
||||
public PsiFile[] compute() {
|
||||
return myManager.getCacheManager().getFilesWithWord(wordToSearch, UsageSearchContext.IN_PLAIN_TEXT, theSearchScope, true);
|
||||
return CacheManager.SERVICE.getInstance(myManager.getProject()).getFilesWithWord(wordToSearch, UsageSearchContext.IN_PLAIN_TEXT, theSearchScope, true);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -462,20 +464,20 @@ public class PsiSearchHelperImpl implements PsiSearchHelper {
|
||||
}
|
||||
|
||||
public void processAllFilesWithWord(@NotNull String word, @NotNull GlobalSearchScope scope, @NotNull Processor<PsiFile> processor, final boolean caseSensitively) {
|
||||
myManager.getCacheManager().processFilesWithWord(processor,word, UsageSearchContext.IN_CODE, scope, caseSensitively);
|
||||
CacheManager.SERVICE.getInstance(myManager.getProject()).processFilesWithWord(processor, word, UsageSearchContext.IN_CODE, scope, caseSensitively);
|
||||
}
|
||||
|
||||
public void processAllFilesWithWordInText(@NotNull final String word, @NotNull final GlobalSearchScope scope, @NotNull final Processor<PsiFile> processor,
|
||||
final boolean caseSensitively) {
|
||||
myManager.getCacheManager().processFilesWithWord(processor,word, UsageSearchContext.IN_PLAIN_TEXT, scope, caseSensitively);
|
||||
CacheManager.SERVICE.getInstance(myManager.getProject()).processFilesWithWord(processor, word, UsageSearchContext.IN_PLAIN_TEXT, scope, caseSensitively);
|
||||
}
|
||||
|
||||
public void processAllFilesWithWordInComments(@NotNull String word, @NotNull GlobalSearchScope scope, @NotNull Processor<PsiFile> processor) {
|
||||
myManager.getCacheManager().processFilesWithWord(processor, word, UsageSearchContext.IN_COMMENTS, scope, true);
|
||||
CacheManager.SERVICE.getInstance(myManager.getProject()).processFilesWithWord(processor, word, UsageSearchContext.IN_COMMENTS, scope, true);
|
||||
}
|
||||
|
||||
public void processAllFilesWithWordInLiterals(@NotNull String word, @NotNull GlobalSearchScope scope, @NotNull Processor<PsiFile> processor) {
|
||||
myManager.getCacheManager().processFilesWithWord(processor, word, UsageSearchContext.IN_STRINGS, scope, true);
|
||||
CacheManager.SERVICE.getInstance(myManager.getProject()).processFilesWithWord(processor, word, UsageSearchContext.IN_STRINGS, scope, true);
|
||||
}
|
||||
|
||||
private static class RequestWithProcessor {
|
||||
|
||||
@@ -273,6 +273,9 @@
|
||||
<projectService serviceInterface="com.intellij.ide.util.TreeFileChooserFactory"
|
||||
serviceImplementation="com.intellij.ide.util.TreeFileChooserFactoryImpl"/>
|
||||
|
||||
<projectService serviceInterface="com.intellij.psi.impl.cache.CacheManager"
|
||||
serviceImplementation="com.intellij.psi.impl.cache.impl.IndexCacheManagerImpl"/>
|
||||
|
||||
<colorSettingsPage implementation="com.intellij.openapi.options.colors.pages.GeneralColorsPage" id="general"/>
|
||||
<colorSettingsPage implementation="com.intellij.openapi.options.colors.pages.ANSIColoredConsoleColorsPage" id="general"/>
|
||||
<colorSettingsPage implementation="com.intellij.openapi.options.colors.pages.CustomColorsPage" id="custom"/>
|
||||
|
||||
@@ -91,6 +91,7 @@ import com.intellij.profile.codeInspection.InspectionProjectProfileManager;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.codeStyle.CodeStyleSettingsManager;
|
||||
import com.intellij.psi.impl.PsiManagerImpl;
|
||||
import com.intellij.psi.impl.cache.CacheManager;
|
||||
import com.intellij.psi.impl.cache.impl.todo.TodoIndex;
|
||||
import com.intellij.psi.impl.source.PostprocessReformattingAspect;
|
||||
import com.intellij.psi.impl.source.PsiFileImpl;
|
||||
@@ -1315,7 +1316,7 @@ public class CodeInsightTestFixtureImpl extends BaseFixture implements CodeInsig
|
||||
((PsiFileImpl)myFile).calcTreeElement(); //to load text
|
||||
|
||||
//to initialize caches
|
||||
myPsiManager.getCacheManager().getFilesWithWord(XXX, UsageSearchContext.IN_COMMENTS, GlobalSearchScope.allScope(project), true);
|
||||
CacheManager.SERVICE.getInstance(project).getFilesWithWord(XXX, UsageSearchContext.IN_COMMENTS, GlobalSearchScope.allScope(project), true);
|
||||
|
||||
List<HighlightInfo> infos;
|
||||
try {
|
||||
|
||||
@@ -22,7 +22,7 @@ import com.intellij.openapi.util.Key;
|
||||
import com.intellij.patterns.compiler.PatternClassBean;
|
||||
import com.intellij.patterns.compiler.PatternCompilerFactory;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.PsiManagerEx;
|
||||
import com.intellij.psi.impl.cache.CacheManager;
|
||||
import com.intellij.psi.impl.search.LowLevelSearchUtil;
|
||||
import com.intellij.psi.impl.source.resolve.FileContextUtil;
|
||||
import com.intellij.psi.scope.PsiScopeProcessor;
|
||||
@@ -156,10 +156,11 @@ public class PatternEditorContextMembersProvider extends NonCodeMembersContribut
|
||||
}
|
||||
};
|
||||
final StringSearcher searcher = new StringSearcher("patternClass", true, true);
|
||||
((PsiManagerEx)beanClass.getManager()).getCacheManager().processFilesWithWord(new Processor<PsiFile>() {
|
||||
CacheManager.SERVICE.getInstance(beanClass.getProject()).processFilesWithWord(new Processor<PsiFile>() {
|
||||
@Override
|
||||
public boolean process(PsiFile psiFile) {
|
||||
LowLevelSearchUtil.processElementsContainingWordInElement(occurenceProcessor, psiFile, searcher, true, new EmptyProgressIndicator());
|
||||
LowLevelSearchUtil
|
||||
.processElementsContainingWordInElement(occurenceProcessor, psiFile, searcher, true, new EmptyProgressIndicator());
|
||||
return true;
|
||||
}
|
||||
}, searcher.getPattern(), UsageSearchContext.IN_FOREIGN_LANGUAGES, scope, searcher.isCaseSensitive());
|
||||
|
||||
@@ -9,6 +9,7 @@ import com.intellij.openapi.application.ReadAction;
|
||||
import com.intellij.openapi.fileTypes.StdFileTypes;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.progress.ProgressManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.roots.ProjectRootManager;
|
||||
import com.intellij.openapi.util.Computable;
|
||||
import com.intellij.openapi.util.NullableComputable;
|
||||
@@ -16,6 +17,7 @@ import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.PsiManagerImpl;
|
||||
import com.intellij.psi.impl.cache.CacheManager;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.psi.search.LocalSearchScope;
|
||||
import com.intellij.psi.search.SearchScope;
|
||||
@@ -230,7 +232,8 @@ public class FormReferencesSearcher implements QueryExecutor<PsiReference, Refer
|
||||
final GlobalSearchScope globalSearchScope,
|
||||
final LocalSearchScope filterScope) {
|
||||
|
||||
final GlobalSearchScope scope = GlobalSearchScope.projectScope(property.getProject()).intersectWith(globalSearchScope);
|
||||
final Project project = property.getProject();
|
||||
final GlobalSearchScope scope = GlobalSearchScope.projectScope(project).intersectWith(globalSearchScope);
|
||||
final PsiManagerImpl manager = (PsiManagerImpl)property.getManager();
|
||||
String name = ApplicationManager.getApplication().runReadAction(new Computable<String>() {
|
||||
@Override
|
||||
@@ -249,12 +252,14 @@ public class FormReferencesSearcher implements QueryExecutor<PsiReference, Refer
|
||||
final Set<PsiFile> fileSet = new HashSet<PsiFile>();
|
||||
ApplicationManager.getApplication().runReadAction(new Runnable() {
|
||||
public void run() {
|
||||
PsiFile[] filesWithWord = manager.getCacheManager().getFilesWithWord(words.get(0), UsageSearchContext.IN_PLAIN_TEXT, scope, true);
|
||||
PsiFile[] filesWithWord = CacheManager.SERVICE.getInstance(project).getFilesWithWord(words.get(0),
|
||||
UsageSearchContext.IN_PLAIN_TEXT, scope,
|
||||
true);
|
||||
ContainerUtil.addAll(fileSet, filesWithWord);
|
||||
for (int i = 1; i < words.size(); i++) {
|
||||
ProgressManager.checkCanceled();
|
||||
String word = words.get(i);
|
||||
PsiFile[] filesWithThisWord = manager.getCacheManager().getFilesWithWord(word, UsageSearchContext.IN_PLAIN_TEXT, scope, true);
|
||||
PsiFile[] filesWithThisWord = CacheManager.SERVICE.getInstance(project).getFilesWithWord(word, UsageSearchContext.IN_PLAIN_TEXT, scope, true);
|
||||
fileSet.retainAll(Arrays.asList(filesWithThisWord));
|
||||
if (fileSet.isEmpty()) break;
|
||||
}
|
||||
@@ -278,13 +283,14 @@ public class FormReferencesSearcher implements QueryExecutor<PsiReference, Refer
|
||||
|
||||
private static boolean processReferencesInUIForms(final Processor<PsiReference> processor, final PropertiesFile propFile, final GlobalSearchScope globalSearchScope,
|
||||
final LocalSearchScope filterScope) {
|
||||
GlobalSearchScope scope = GlobalSearchScope.projectScope(propFile.getProject()).intersectWith(globalSearchScope);
|
||||
final Project project = propFile.getProject();
|
||||
GlobalSearchScope scope = GlobalSearchScope.projectScope(project).intersectWith(globalSearchScope);
|
||||
PsiManagerImpl manager = (PsiManagerImpl)propFile.getContainingFile().getManager();
|
||||
final String baseName = propFile.getResourceBundle().getBaseName();
|
||||
manager.startBatchFilesProcessingMode();
|
||||
|
||||
try {
|
||||
PsiFile[] files = manager.getCacheManager().getFilesWithWord(baseName, UsageSearchContext.IN_PLAIN_TEXT, scope, true);
|
||||
PsiFile[] files = CacheManager.SERVICE.getInstance(project).getFilesWithWord(baseName, UsageSearchContext.IN_PLAIN_TEXT, scope, true);
|
||||
|
||||
for (PsiFile file : files) {
|
||||
ProgressManager.checkCanceled();
|
||||
|
||||
Reference in New Issue
Block a user