mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge remote branch 'origin/master'
This commit is contained in:
@@ -31,7 +31,7 @@ public abstract class ModuleRootManager implements ModuleRootModel {
|
||||
* @param module the module for which the root manager is requested.
|
||||
* @return the root manager instance.
|
||||
*/
|
||||
public static ModuleRootManager getInstance(Module module) {
|
||||
public static ModuleRootManager getInstance(@NotNull Module module) {
|
||||
return module.getComponent(ModuleRootManager.class);
|
||||
}
|
||||
|
||||
|
||||
@@ -28,9 +28,7 @@ import com.intellij.openapi.progress.ProcessCanceledException;
|
||||
import com.intellij.openapi.progress.ProgressIndicator;
|
||||
import com.intellij.openapi.progress.ProgressManager;
|
||||
import com.intellij.openapi.roots.FileIndexFacade;
|
||||
import com.intellij.openapi.util.Computable;
|
||||
import com.intellij.openapi.util.Ref;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.openapi.util.*;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.*;
|
||||
@@ -46,10 +44,11 @@ import com.intellij.util.CommonProcessors;
|
||||
import com.intellij.util.Processor;
|
||||
import com.intellij.util.SmartList;
|
||||
import com.intellij.util.containers.CollectionFactory;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.containers.MultiMap;
|
||||
import com.intellij.util.indexing.FileBasedIndex;
|
||||
import com.intellij.util.text.StringSearcher;
|
||||
import gnu.trove.THashSet;
|
||||
import gnu.trove.TIntHashSet;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -352,8 +351,7 @@ public class PsiSearchHelperImpl implements PsiSearchHelper {
|
||||
searchContext,
|
||||
caseSensitively,
|
||||
text,
|
||||
new CommonProcessors.CollectProcessor<VirtualFile>(result),
|
||||
progress
|
||||
new CommonProcessors.CollectProcessor<VirtualFile>(result)
|
||||
);
|
||||
LOG.assertTrue(success);
|
||||
return result;
|
||||
@@ -364,81 +362,34 @@ public class PsiSearchHelperImpl implements PsiSearchHelper {
|
||||
}
|
||||
|
||||
public boolean processFilesWithText(@NotNull final GlobalSearchScope scope,
|
||||
final short searchContext,
|
||||
final boolean caseSensitively,
|
||||
@NotNull String text,
|
||||
@NotNull final Processor<VirtualFile> processor,
|
||||
@Nullable ProgressIndicator progress) {
|
||||
List<String> words = StringUtil.getWordsIn(text);
|
||||
if (words.isEmpty()) return true;
|
||||
Collections.sort(words, new Comparator<String>() {
|
||||
final short searchContext,
|
||||
final boolean caseSensitively,
|
||||
@NotNull String text,
|
||||
@NotNull final Processor<VirtualFile> processor) {
|
||||
final ArrayList<IdIndexEntry> entries = getWordEntries(text, caseSensitively);
|
||||
if (entries.isEmpty()) return true;
|
||||
|
||||
final Collection<VirtualFile> fileSet = ApplicationManager.getApplication().runReadAction(new Computable<Collection<VirtualFile>>() {
|
||||
@Override
|
||||
public int compare(String o1, String o2) {
|
||||
return o2.length() - o1.length();
|
||||
public Collection<VirtualFile> compute() {
|
||||
final CommonProcessors.CollectProcessor<VirtualFile> collectProcessor = new CommonProcessors.CollectProcessor<VirtualFile>();
|
||||
FileBasedIndex.getInstance().processFilesContainingAllKeys(IdIndex.NAME, entries, scope, new Condition<Integer>() {
|
||||
@Override
|
||||
public boolean value(Integer integer) {
|
||||
return (integer.intValue() & searchContext) != 0;
|
||||
}
|
||||
}, collectProcessor);
|
||||
return collectProcessor.getResults();
|
||||
}
|
||||
});
|
||||
final Set<VirtualFile> fileSet;
|
||||
CacheManager cacheManager = CacheManager.SERVICE.getInstance(myManager.getProject());
|
||||
|
||||
if (words.size() > 1) {
|
||||
fileSet = new THashSet<VirtualFile>();
|
||||
Set<VirtualFile> copy = new THashSet<VirtualFile>();
|
||||
for (int i = 0; i < words.size() - 1; i++) {
|
||||
if (progress != null) {
|
||||
progress.checkCanceled();
|
||||
}
|
||||
else {
|
||||
ProgressManager.checkCanceled();
|
||||
}
|
||||
final String word = words.get(i);
|
||||
final int finalI = i;
|
||||
cacheManager.collectVirtualFilesWithWord(new CommonProcessors.CollectProcessor<VirtualFile>(i != 0 ? copy:fileSet) {
|
||||
@Override
|
||||
protected boolean accept(VirtualFile virtualFile) {
|
||||
return finalI == 0 || fileSet.contains(virtualFile);
|
||||
}
|
||||
}, word, searchContext, scope, caseSensitively);
|
||||
if (i != 0) {
|
||||
fileSet.retainAll(copy);
|
||||
}
|
||||
copy.clear();
|
||||
if (fileSet.isEmpty()) break;
|
||||
final FileIndexFacade index = FileIndexFacade.getInstance(myManager.getProject());
|
||||
return ContainerUtil.process(fileSet, new ReadActionProcessor<VirtualFile>() {
|
||||
@Override
|
||||
public boolean processInReadAction(VirtualFile virtualFile) {
|
||||
return !IndexCacheManagerImpl.shouldBeFound(scope, virtualFile, index) || processor.process(virtualFile);
|
||||
}
|
||||
if (fileSet.isEmpty()) return true;
|
||||
}
|
||||
else {
|
||||
fileSet = null;
|
||||
}
|
||||
|
||||
final String lastWord = words.get(words.size() - 1);
|
||||
if (processor instanceof CommonProcessors.CollectProcessor) {
|
||||
final CommonProcessors.CollectProcessor collectProcessor = (CommonProcessors.CollectProcessor)processor;
|
||||
return cacheManager.collectVirtualFilesWithWord(new CommonProcessors.CollectProcessor<VirtualFile>(collectProcessor.getResults()) {
|
||||
@Override
|
||||
public boolean process(VirtualFile virtualFile) {
|
||||
if (fileSet == null || fileSet.contains(virtualFile)) return collectProcessor.process(virtualFile);
|
||||
return true;
|
||||
}
|
||||
}, lastWord, searchContext, scope, caseSensitively);
|
||||
} else {
|
||||
THashSet<VirtualFile> files = new THashSet<VirtualFile>();
|
||||
cacheManager.collectVirtualFilesWithWord(new CommonProcessors.CollectProcessor<VirtualFile>(files) {
|
||||
@Override
|
||||
protected boolean accept(VirtualFile virtualFile) {
|
||||
return fileSet == null || fileSet.contains(virtualFile);
|
||||
}
|
||||
}, lastWord, searchContext, scope, caseSensitively);
|
||||
ReadActionProcessor<VirtualFile> readActionProcessor = new ReadActionProcessor<VirtualFile>() {
|
||||
@Override
|
||||
public boolean processInReadAction(VirtualFile virtualFile) {
|
||||
return processor.process(virtualFile);
|
||||
}
|
||||
};
|
||||
for(VirtualFile file:files) {
|
||||
if (!readActionProcessor.process(file)) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -725,31 +676,57 @@ public class PsiSearchHelperImpl implements PsiSearchHelper {
|
||||
ProgressIndicator progress) {
|
||||
final FileIndexFacade index = FileIndexFacade.getInstance(myManager.getProject());
|
||||
final MultiMap<VirtualFile, RequestWithProcessor> result = createMultiMap();
|
||||
for (Set<IdIndexEntry> key : singles.keySet()) {
|
||||
for (final Set<IdIndexEntry> key : singles.keySet()) {
|
||||
if (key.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
final Collection<RequestWithProcessor> data = singles.get(key);
|
||||
GlobalSearchScope commonScope = uniteScopes(data);
|
||||
final GlobalSearchScope commonScope = uniteScopes(data);
|
||||
|
||||
MultiMap<VirtualFile, RequestWithProcessor> intersection = null;
|
||||
if (key.size() == 1) {
|
||||
result.putAllValues(findFilesWithIndexEntry(key.iterator().next(), index, data, commonScope, progress));
|
||||
continue;
|
||||
}
|
||||
|
||||
boolean first = true;
|
||||
for (IdIndexEntry entry : key) {
|
||||
final MultiMap<VirtualFile, RequestWithProcessor> local = findFilesWithIndexEntry(entry, index, data, commonScope, progress);
|
||||
if (first) {
|
||||
intersection = local;
|
||||
first = false;
|
||||
final Collection<VirtualFile> fileSet = ApplicationManager.getApplication().runReadAction(new Computable<Collection<VirtualFile>>() {
|
||||
@Override
|
||||
public Collection<VirtualFile> compute() {
|
||||
final CommonProcessors.CollectProcessor<VirtualFile> processor = new CommonProcessors.CollectProcessor<VirtualFile>();
|
||||
FileBasedIndex.getInstance().processFilesContainingAllKeys(IdIndex.NAME, key, commonScope, null, processor);
|
||||
return processor.getResults();
|
||||
}
|
||||
else {
|
||||
intersection.keySet().retainAll(local.keySet());
|
||||
for (VirtualFile file : intersection.keySet()) {
|
||||
intersection.get(file).retainAll(local.get(file));
|
||||
}
|
||||
});
|
||||
|
||||
for (final VirtualFile file : fileSet) {
|
||||
if (progress != null) {
|
||||
progress.checkCanceled();
|
||||
}
|
||||
for (final IdIndexEntry entry : key) {
|
||||
ApplicationManager.getApplication().runReadAction(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
FileBasedIndex.getInstance().processValues(IdIndex.NAME, entry, file, new FileBasedIndex.ValueProcessor<Integer>() {
|
||||
@Override
|
||||
public boolean process(VirtualFile file, Integer value) {
|
||||
if (IndexCacheManagerImpl.shouldBeFound(commonScope, file, index)) {
|
||||
int mask = value.intValue();
|
||||
for (RequestWithProcessor single : data) {
|
||||
final PsiSearchRequest request = single.request;
|
||||
if ((mask & request.searchContext) != 0 && ((GlobalSearchScope)request.searchScope).contains(file)) {
|
||||
result.putValue(file, single);
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}, commonScope);
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
result.putAllValues(intersection);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -853,24 +830,59 @@ public class PsiSearchHelperImpl implements PsiSearchHelper {
|
||||
|
||||
@Override
|
||||
public SearchCostResult isCheapEnoughToSearch(@NotNull String name,
|
||||
@NotNull GlobalSearchScope scope,
|
||||
@NotNull final GlobalSearchScope scope,
|
||||
@Nullable final PsiFile fileToIgnoreOccurencesIn,
|
||||
@Nullable ProgressIndicator progress) {
|
||||
|
||||
final ArrayList<IdIndexEntry> keys = getWordEntries(name, true);
|
||||
if (keys.isEmpty()) return SearchCostResult.ZERO_OCCURRENCES;
|
||||
|
||||
final TIntHashSet set = ApplicationManager.getApplication().runReadAction(new NullableComputable<TIntHashSet>() {
|
||||
@Override
|
||||
public TIntHashSet compute() {
|
||||
return FileBasedIndex.getInstance().collectFileIdsContainingAllKeys(IdIndex.NAME, keys, scope, null);
|
||||
}
|
||||
});
|
||||
|
||||
if (set == null || set.size() > 1000) {
|
||||
return SearchCostResult.TOO_MANY_OCCURRENCES;
|
||||
}
|
||||
|
||||
final AtomicInteger count = new AtomicInteger();
|
||||
if (!processFilesWithText(scope, UsageSearchContext.ANY, true, name, new CommonProcessors.CollectProcessor<VirtualFile> (Collections.<VirtualFile>emptyList()) {
|
||||
|
||||
final FileIndexFacade index = FileIndexFacade.getInstance(myManager.getProject());
|
||||
final Processor<VirtualFile> processor = new Processor<VirtualFile>() {
|
||||
private final VirtualFile fileToIgnoreOccurencesInVirtualFile =
|
||||
fileToIgnoreOccurencesIn != null ? fileToIgnoreOccurencesIn.getVirtualFile():null;
|
||||
fileToIgnoreOccurencesIn != null ? fileToIgnoreOccurencesIn.getVirtualFile() : null;
|
||||
|
||||
@Override
|
||||
public boolean process(VirtualFile file) {
|
||||
if (file == fileToIgnoreOccurencesInVirtualFile) return true;
|
||||
int value = count.incrementAndGet();
|
||||
if (!IndexCacheManagerImpl.shouldBeFound(scope, file, index)) return true;
|
||||
final int value = count.incrementAndGet();
|
||||
return value < 10;
|
||||
}
|
||||
}, progress)) {
|
||||
};
|
||||
final boolean cheap = ApplicationManager.getApplication().runReadAction(new NullableComputable<Boolean>() {
|
||||
@Override
|
||||
public Boolean compute() {
|
||||
return FileBasedIndex.processVirtualFiles(set, scope, processor);
|
||||
}
|
||||
});
|
||||
|
||||
if (!cheap) {
|
||||
return SearchCostResult.TOO_MANY_OCCURRENCES;
|
||||
}
|
||||
|
||||
return count.get() == 0 ? SearchCostResult.ZERO_OCCURRENCES : SearchCostResult.FEW_OCCURRENCES;
|
||||
}
|
||||
|
||||
private static ArrayList<IdIndexEntry> getWordEntries(String name, boolean caseSensitively) {
|
||||
List<String> words = StringUtil.getWordsIn(name);
|
||||
final ArrayList<IdIndexEntry> keys = new ArrayList<IdIndexEntry>();
|
||||
for (String word : words) {
|
||||
keys.add(new IdIndexEntry(word, caseSensitively));
|
||||
}
|
||||
return keys;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,10 +58,7 @@ import com.intellij.psi.impl.source.PsiFileImpl;
|
||||
import com.intellij.psi.search.EverythingGlobalScope;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.psi.stubs.SerializationManager;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.CommonProcessors;
|
||||
import com.intellij.util.Processor;
|
||||
import com.intellij.util.SmartList;
|
||||
import com.intellij.util.*;
|
||||
import com.intellij.util.concurrency.Semaphore;
|
||||
import com.intellij.util.containers.ConcurrentHashSet;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
@@ -73,6 +70,7 @@ import com.intellij.util.messages.MessageBus;
|
||||
import com.intellij.util.messages.MessageBusConnection;
|
||||
import gnu.trove.TIntHashSet;
|
||||
import gnu.trove.TIntIterator;
|
||||
import gnu.trove.TIntProcedure;
|
||||
import gnu.trove.TObjectIntHashMap;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -318,7 +316,12 @@ public class FileBasedIndex implements ApplicationComponent {
|
||||
ShutDownTracker.getInstance().registerShutdownTask(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
performShutdown();
|
||||
ShutDownTracker.invokeAndWait(ApplicationManager.getApplication().isUnitTestMode(), false, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
performShutdown();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
//FileUtil.createIfDoesntExist(workInProgressFile);
|
||||
@@ -854,14 +857,16 @@ public class FileBasedIndex implements ApplicationComponent {
|
||||
}
|
||||
|
||||
|
||||
|
||||
private <K, V> boolean processValuesImpl(final ID<K, V> indexId, final K dataKey, boolean ensureValueProcessedOnce,
|
||||
@Nullable final VirtualFile restrictToFile, ValueProcessor<V> processor,
|
||||
final GlobalSearchScope filter) {
|
||||
|
||||
|
||||
private <K, V, R> R processExceptions(final ID<K, V> indexId,
|
||||
@Nullable final VirtualFile restrictToFile,
|
||||
final GlobalSearchScope filter,
|
||||
ThrowableConvertor<UpdatableIndex<K, V, FileContent>, R, StorageException> computable) {
|
||||
try {
|
||||
final UpdatableIndex<K, V, FileContent> index = getIndex(indexId);
|
||||
if (index == null) {
|
||||
return true;
|
||||
return null;
|
||||
}
|
||||
final Project project = filter.getProject();
|
||||
//assert project != null : "GlobalSearchScope#getProject() should be not-null for all index queries";
|
||||
@@ -869,6 +874,33 @@ public class FileBasedIndex implements ApplicationComponent {
|
||||
|
||||
try {
|
||||
index.getReadLock().lock();
|
||||
return computable.convert(index);
|
||||
}
|
||||
finally {
|
||||
index.getReadLock().unlock();
|
||||
}
|
||||
}
|
||||
catch (StorageException e) {
|
||||
scheduleRebuild(indexId, e);
|
||||
}
|
||||
catch (RuntimeException e) {
|
||||
final Throwable cause = getCauseToRebuildIndex(e);
|
||||
if (cause != null) {
|
||||
scheduleRebuild(indexId, cause);
|
||||
}
|
||||
else {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private <K, V> boolean processValuesImpl(final ID<K, V> indexId, final K dataKey, final boolean ensureValueProcessedOnce,
|
||||
@Nullable final VirtualFile restrictToFile, final ValueProcessor<V> processor,
|
||||
final GlobalSearchScope filter) {
|
||||
ThrowableConvertor<UpdatableIndex<K, V, FileContent>, Boolean, StorageException> keyProcessor = new ThrowableConvertor<UpdatableIndex<K, V, FileContent>, Boolean, StorageException>() {
|
||||
@Override
|
||||
public Boolean convert(UpdatableIndex<K, V, FileContent> index) throws StorageException {
|
||||
final ValueContainer<V> container = index.getData(dataKey);
|
||||
|
||||
boolean shouldContinue = true;
|
||||
@@ -876,7 +908,7 @@ public class FileBasedIndex implements ApplicationComponent {
|
||||
if (restrictToFile != null) {
|
||||
if (restrictToFile instanceof VirtualFileWithId) {
|
||||
final int restrictedFileId = getFileId(restrictToFile);
|
||||
for (final Iterator<V> valueIt = container.getValueIterator(); valueIt.hasNext();) {
|
||||
for (final Iterator<V> valueIt = container.getValueIterator(); valueIt.hasNext(); ) {
|
||||
final V value = valueIt.next();
|
||||
if (container.isAssociated(value, restrictedFileId)) {
|
||||
shouldContinue = processor.process(restrictToFile, value);
|
||||
@@ -908,23 +940,79 @@ public class FileBasedIndex implements ApplicationComponent {
|
||||
}
|
||||
return shouldContinue;
|
||||
}
|
||||
finally {
|
||||
index.getReadLock().unlock();
|
||||
}
|
||||
};
|
||||
final Boolean result = processExceptions(indexId, restrictToFile, filter, keyProcessor);
|
||||
return result == null || result.booleanValue();
|
||||
}
|
||||
|
||||
public <K, V> void processFilesContainingAllKeys(final ID<K, V> indexId,
|
||||
final Collection<K> dataKeys,
|
||||
final GlobalSearchScope filter,
|
||||
@Nullable Condition<V> valueChecker,
|
||||
final Processor<VirtualFile> processor) {
|
||||
final TIntHashSet set = collectFileIdsContainingAllKeys(indexId, dataKeys, filter, valueChecker);
|
||||
if (set != null) {
|
||||
processVirtualFiles(set, filter, processor);
|
||||
}
|
||||
catch (StorageException e) {
|
||||
scheduleRebuild(indexId, e);
|
||||
}
|
||||
catch (RuntimeException e) {
|
||||
final Throwable cause = getCauseToRebuildIndex(e);
|
||||
if (cause != null) {
|
||||
scheduleRebuild(indexId, cause);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public <K, V> TIntHashSet collectFileIdsContainingAllKeys(final ID<K, V> indexId,
|
||||
final Collection<K> dataKeys,
|
||||
final GlobalSearchScope filter,
|
||||
@Nullable final Condition<V> valueChecker) {
|
||||
final ThrowableConvertor<UpdatableIndex<K, V, FileContent>, TIntHashSet, StorageException> convertor =
|
||||
new ThrowableConvertor<UpdatableIndex<K, V, FileContent>, TIntHashSet, StorageException>() {
|
||||
@Nullable
|
||||
@Override
|
||||
public TIntHashSet convert(UpdatableIndex<K, V, FileContent> index) throws StorageException {
|
||||
TIntHashSet mainIntersection = null;
|
||||
|
||||
for (K dataKey : dataKeys) {
|
||||
ProgressManager.checkCanceled();
|
||||
TIntHashSet copy = new TIntHashSet();
|
||||
final ValueContainer<V> container = index.getData(dataKey);
|
||||
|
||||
for (final Iterator<V> valueIt = container.getValueIterator(); valueIt.hasNext(); ) {
|
||||
final V value = valueIt.next();
|
||||
if (valueChecker != null && !valueChecker.value(value)) {
|
||||
continue;
|
||||
}
|
||||
for (final ValueContainer.IntIterator inputIdsIterator = container.getInputIdsIterator(value); inputIdsIterator.hasNext(); ) {
|
||||
final int id = inputIdsIterator.next();
|
||||
if (mainIntersection == null || mainIntersection.contains(id)) {
|
||||
copy.add(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mainIntersection = copy;
|
||||
if (mainIntersection.isEmpty()) {
|
||||
return new TIntHashSet();
|
||||
}
|
||||
}
|
||||
|
||||
return mainIntersection;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
return processExceptions(indexId, null, filter, convertor);
|
||||
}
|
||||
|
||||
public static boolean processVirtualFiles(TIntHashSet ids, final GlobalSearchScope filter, final Processor<VirtualFile> processor) {
|
||||
final PersistentFS fs = (PersistentFS)ManagingFS.getInstance();
|
||||
return ids.forEach(new TIntProcedure() {
|
||||
@Override
|
||||
public boolean execute(int id) {
|
||||
ProgressManager.checkCanceled();
|
||||
VirtualFile file = IndexInfrastructure.findFileByIdIfCached(fs, id);
|
||||
if (file != null && filter.accept(file)) {
|
||||
return processor.process(file);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
public static @Nullable Throwable getCauseToRebuildIndex(RuntimeException e) {
|
||||
|
||||
+1
-1
@@ -285,7 +285,7 @@ public class ApplicationImpl extends ComponentManagerImpl implements Application
|
||||
if (isDisposed() || isDisposeInProgress()) {
|
||||
return;
|
||||
}
|
||||
ShutDownTracker.invokeAndWait(isUnitTestMode(), new Runnable() {
|
||||
ShutDownTracker.invokeAndWait(isUnitTestMode(), true, new Runnable() {
|
||||
public void run() {
|
||||
if (ApplicationManager.getApplication() != ApplicationImpl.this) return;
|
||||
try {
|
||||
|
||||
+4
-4
@@ -70,6 +70,7 @@ public class PersistentFS extends ManagingFS implements ApplicationComponent {
|
||||
private final MessageBus myEventsBus;
|
||||
|
||||
private final Map<String, VirtualFileSystemEntry> myRoots = new HashMap<String, VirtualFileSystemEntry>();
|
||||
private final Map<Integer, VirtualFileSystemEntry> myRootsById = new HashMap<Integer, VirtualFileSystemEntry>();
|
||||
private VirtualFileSystemEntry myFakeRoot;
|
||||
private final Object INPUT_LOCK = new Object();
|
||||
|
||||
@@ -770,6 +771,7 @@ public class PersistentFS extends ManagingFS implements ApplicationComponent {
|
||||
|
||||
if (basePath.length() > 0) {
|
||||
myRoots.put(rootUrl, root);
|
||||
myRootsById.put(root.getId(), root);
|
||||
}
|
||||
else {
|
||||
myFakeRoot = root;
|
||||
@@ -861,10 +863,7 @@ public class PersistentFS extends ManagingFS implements ApplicationComponent {
|
||||
final int parentId = getParent(id);
|
||||
if (parentId == 0) {
|
||||
synchronized (LOCK) {
|
||||
for (NewVirtualFile root : myRoots.values()) {
|
||||
if (root.getId() == id) return root;
|
||||
}
|
||||
return null;
|
||||
return myRootsById.get(id);
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -992,6 +991,7 @@ public class PersistentFS extends ManagingFS implements ApplicationComponent {
|
||||
else {
|
||||
synchronized (LOCK) {
|
||||
myRoots.remove(file.getUrl());
|
||||
myRootsById.remove(id);
|
||||
try {
|
||||
FSRecords.deleteRootRecord(id);
|
||||
}
|
||||
|
||||
@@ -735,7 +735,7 @@ public abstract class LightPlatformTestCase extends UsefulTestCase implements Da
|
||||
ShutDownTracker.getInstance().registerShutdownTask(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
ShutDownTracker.invokeAndWait(true, new Runnable() {
|
||||
ShutDownTracker.invokeAndWait(true, true, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
ApplicationManager.getApplication().runWriteAction(new Runnable() {
|
||||
|
||||
@@ -133,7 +133,26 @@ public class ShutDownTracker implements Runnable {
|
||||
return list.isEmpty()? null : list.removeLast();
|
||||
}
|
||||
|
||||
public static void invokeAndWait(boolean timed, final Runnable runnable) {
|
||||
public static void invokeAndWait(boolean timed, boolean edt, final Runnable runnable) {
|
||||
if (!edt) {
|
||||
if (!timed) {
|
||||
runnable.run();
|
||||
}
|
||||
|
||||
final Semaphore semaphore = new Semaphore();
|
||||
semaphore.down();
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
runnable.run();
|
||||
semaphore.up();
|
||||
}
|
||||
}).start();
|
||||
semaphore.waitFor(1000);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (timed) {
|
||||
final Semaphore semaphore = new Semaphore();
|
||||
semaphore.down();
|
||||
|
||||
+5
@@ -45,6 +45,11 @@ import java.util.List;
|
||||
*/
|
||||
public class GroovyConstructorNamedArgumentsInspection extends BaseInspection {
|
||||
|
||||
@Override
|
||||
public boolean isEnabledByDefault() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BaseInspectionVisitor buildVisitor() {
|
||||
return new MyVisitor();
|
||||
|
||||
+4
@@ -28,6 +28,10 @@ import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrCondit
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression;
|
||||
|
||||
public class GroovyConditionalWithIdenticalBranchesInspection extends BaseInspection {
|
||||
@Override
|
||||
public boolean isEnabledByDefault() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String getDisplayName() {
|
||||
|
||||
+4
@@ -28,6 +28,10 @@ import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrIfStatement;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrStatement;
|
||||
|
||||
public class GroovyIfStatementWithIdenticalBranchesInspection extends BaseInspection {
|
||||
@Override
|
||||
public boolean isEnabledByDefault() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String getDisplayName() {
|
||||
|
||||
+4
@@ -25,6 +25,10 @@ import org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrOpenBlock;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.params.GrParameter;
|
||||
|
||||
public class GroovyUnusedCatchParameterInspection extends BaseInspection {
|
||||
@Override
|
||||
public boolean isEnabledByDefault() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Nls
|
||||
@NotNull
|
||||
|
||||
+4
@@ -32,6 +32,10 @@ import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrMe
|
||||
|
||||
public class GroovyAccessToStaticFieldLockedOnInstanceInspection
|
||||
extends BaseInspection {
|
||||
@Override
|
||||
public boolean isEnabledByDefault() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Nls
|
||||
@NotNull
|
||||
|
||||
+4
@@ -29,6 +29,10 @@ import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpres
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrReferenceExpression;
|
||||
|
||||
public class GroovySynchronizationOnNonFinalFieldInspection extends BaseInspection {
|
||||
@Override
|
||||
public boolean isEnabledByDefault() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Nls
|
||||
@NotNull
|
||||
|
||||
+4
@@ -28,6 +28,10 @@ import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrRefere
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.literals.GrLiteral;
|
||||
|
||||
public class GroovySynchronizationOnVariableInitializedWithLiteralInspection extends BaseInspection {
|
||||
@Override
|
||||
public boolean isEnabledByDefault() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Nls
|
||||
@NotNull
|
||||
|
||||
+5
@@ -26,6 +26,11 @@ import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrMe
|
||||
|
||||
public class GroovyUnsynchronizedMethodOverridesSynchronizedMethodInspection extends BaseInspection {
|
||||
|
||||
@Override
|
||||
public boolean isEnabledByDefault() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Nls
|
||||
@NotNull
|
||||
public String getGroupDisplayName() {
|
||||
|
||||
+4
@@ -31,6 +31,10 @@ import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public class GroovyDuplicateSwitchBranchInspection extends BaseInspection {
|
||||
@Override
|
||||
public boolean isEnabledByDefault() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Nls
|
||||
@NotNull
|
||||
|
||||
@@ -345,6 +345,9 @@ public class TestPackage extends TestObject {
|
||||
catch (IOException e) {
|
||||
LOG.info(e);
|
||||
}
|
||||
catch (Throwable e) {
|
||||
LOG.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+2
-1
@@ -25,6 +25,7 @@ import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.progress.ProcessCanceledException;
|
||||
import com.intellij.openapi.project.IndexNotReadyException;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.psi.PsiClass;
|
||||
|
||||
import javax.swing.text.BadLocationException;
|
||||
@@ -101,7 +102,7 @@ public class JUnitConfigurationModel {
|
||||
testObject != JUnitConfiguration.TEST_DIRECTORY) {
|
||||
try {
|
||||
data.METHOD_NAME = getJUnitTextValue(METHOD);
|
||||
final PsiClass testClass = JUnitUtil.findPsiClass(className, module, myProject);
|
||||
final PsiClass testClass = !myProject.isDefault() && !StringUtil.isEmptyOrSpaces(className) ? JUnitUtil.findPsiClass(className, module, myProject) : null;
|
||||
if (testClass != null && testClass.isValid()) {
|
||||
data.setMainClass(testClass);
|
||||
}
|
||||
|
||||
@@ -24,12 +24,18 @@ 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.*;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiElementVisitor;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.PsiReference;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.psi.search.PsiSearchHelper;
|
||||
import com.intellij.psi.search.searches.ReferencesSearch;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author cdr
|
||||
*/
|
||||
@@ -69,7 +75,17 @@ public class UnusedPropertyInspection extends PropertySuppressableInspectionBase
|
||||
|
||||
String name = property.getName();
|
||||
if (name == null) return;
|
||||
PsiSearchHelper.SearchCostResult cheapEnough = searchHelper.isCheapEnoughToSearch(name, searchScope, file, original);
|
||||
|
||||
final List<String> words = StringUtil.getWordsIn(name);
|
||||
if (words.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
final String lastWord = words.get(words.size() - 1);
|
||||
PsiSearchHelper.SearchCostResult cheapEnough = searchHelper.isCheapEnoughToSearch(lastWord, searchScope, file, original);
|
||||
if (cheapEnough == PsiSearchHelper.SearchCostResult.TOO_MANY_OCCURRENCES) return;
|
||||
|
||||
cheapEnough = searchHelper.isCheapEnoughToSearch(name, searchScope, file, original);
|
||||
if (cheapEnough == PsiSearchHelper.SearchCostResult.TOO_MANY_OCCURRENCES) return;
|
||||
|
||||
final PsiReference usage = cheapEnough == PsiSearchHelper.SearchCostResult.ZERO_OCCURRENCES ? null :
|
||||
|
||||
+3
@@ -96,6 +96,9 @@ public class SearchingForTestsTask extends Task.Backgroundable {
|
||||
catch (IOException e) {
|
||||
LOG.info(e);
|
||||
}
|
||||
catch (Throwable e) {
|
||||
LOG.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -118,7 +118,7 @@ public class TestNGConfigurationModel
|
||||
if (TestType.METHOD == type)
|
||||
data.METHOD_NAME = getText(TestType.METHOD);
|
||||
|
||||
PsiClass psiClass = JUnitUtil.findPsiClass(className, module, getProject());
|
||||
PsiClass psiClass = !getProject().isDefault() && !StringUtil.isEmptyOrSpaces(className) ? JUnitUtil.findPsiClass(className, module, getProject()) : null;
|
||||
if (psiClass != null && psiClass.isValid())
|
||||
data.setMainClass(psiClass);
|
||||
else
|
||||
|
||||
@@ -252,7 +252,7 @@ public class FormReferencesSearcher implements QueryExecutor<PsiReference, Refer
|
||||
}
|
||||
};
|
||||
((PsiSearchHelperImpl)PsiSearchHelper.SERVICE.getInstance(project)).processFilesWithText(
|
||||
scope, UsageSearchContext.IN_PLAIN_TEXT, true, name, collector, null
|
||||
scope, UsageSearchContext.IN_PLAIN_TEXT, true, name, collector
|
||||
);
|
||||
|
||||
for (final VirtualFile vfile:collector.getResults()) {
|
||||
|
||||
Reference in New Issue
Block a user