mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-13 09:19:13 +07:00
Code tolerates null ProgressIndicatorProvider
This commit is contained in:
+1
-1
@@ -58,7 +58,7 @@ public class ClassInheritorsSearch extends ExtensibleQueryFactory<PsiClass, Clas
|
||||
|
||||
LOG.assertTrue(searchScope != null);
|
||||
|
||||
ProgressIndicator progress = ProgressIndicatorProvider.getInstance().getProgressIndicator();
|
||||
ProgressIndicator progress = ProgressIndicatorProvider.getGlobalProgressIndicator();
|
||||
if (progress != null) {
|
||||
progress.pushState();
|
||||
String className = ApplicationManager.getApplication().runReadAction(new Computable<String>() {
|
||||
|
||||
+1
-1
@@ -66,7 +66,7 @@ public class AllClassesSearchExecutor implements QueryExecutor<PsiClass, AllClas
|
||||
}
|
||||
});
|
||||
|
||||
final ProgressIndicator indicator = ProgressIndicatorProvider.getInstance().getProgressIndicator();
|
||||
final ProgressIndicator indicator = ProgressIndicatorProvider.getGlobalProgressIndicator();
|
||||
if (indicator != null) {
|
||||
indicator.checkCanceled();
|
||||
}
|
||||
|
||||
@@ -305,7 +305,7 @@ public class ClsFileImpl extends ClsRepositoryPsiElement<PsiClassHolderFileStub>
|
||||
final ASTNode mirrorTreeElement = SourceTreeToPsiMap.psiElementToTree(mirror);
|
||||
|
||||
//IMPORTANT: do not take lock too early - FileDocumentManager.getInstance().saveToString() can run write action...
|
||||
final NonCancelableSection section = ProgressIndicatorProvider.getInstance().startNonCancelableSection();
|
||||
final NonCancelableSection section = ProgressIndicatorProvider.startNonCancelableSectionIfSupported();
|
||||
try {
|
||||
setMirror((TreeElement)mirrorTreeElement);
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.intellij.openapi.progress;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
@@ -33,8 +34,23 @@ public abstract class ProgressIndicatorProvider {
|
||||
|
||||
protected abstract void doCheckCanceled() throws ProcessCanceledException;
|
||||
|
||||
@Nullable
|
||||
public static ProgressIndicator getGlobalProgressIndicator() {
|
||||
return ourInstance != null ? ourInstance.getProgressIndicator() : null;
|
||||
}
|
||||
|
||||
public abstract NonCancelableSection startNonCancelableSection();
|
||||
|
||||
@NotNull
|
||||
public static NonCancelableSection startNonCancelableSectionIfSupported() {
|
||||
return ourInstance != null ? ourInstance.startNonCancelableSection() : new NonCancelableSection() {
|
||||
@Override
|
||||
public void done() {
|
||||
// do nothing
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static boolean ourNeedToCheckCancel = false;
|
||||
public static void checkCanceled() throws ProcessCanceledException {
|
||||
// smart optimization! There's a thread started in ProgressManagerImpl, that set's this flag up once in 10 milliseconds
|
||||
|
||||
@@ -125,25 +125,7 @@ public class CoreApplicationEnvironment {
|
||||
registerApplicationExtensionPoint(ContentBasedFileSubstitutor.EP_NAME, ContentBasedFileSubstitutor.class);
|
||||
registerExtensionPoint(Extensions.getRootArea(), BinaryFileStubBuilders.EP_NAME, FileTypeExtensionPoint.class);
|
||||
|
||||
ProgressIndicatorProvider.ourInstance = new ProgressIndicatorProvider() {
|
||||
@Override
|
||||
public ProgressIndicator getProgressIndicator() {
|
||||
return new EmptyProgressIndicator();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doCheckCanceled() throws ProcessCanceledException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public NonCancelableSection startNonCancelableSection() {
|
||||
return new NonCancelableSection() {
|
||||
@Override
|
||||
public void done() {
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
ProgressIndicatorProvider.ourInstance = createProgressIndicatorProvider();
|
||||
|
||||
myApplication.registerService(JobLauncher.class, new JobLauncher() {
|
||||
@Override
|
||||
@@ -194,6 +176,28 @@ public class CoreApplicationEnvironment {
|
||||
|
||||
}
|
||||
|
||||
protected ProgressIndicatorProvider createProgressIndicatorProvider() {
|
||||
return new ProgressIndicatorProvider() {
|
||||
@Override
|
||||
public ProgressIndicator getProgressIndicator() {
|
||||
return new EmptyProgressIndicator();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doCheckCanceled() throws ProcessCanceledException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public NonCancelableSection startNonCancelableSection() {
|
||||
return new NonCancelableSection() {
|
||||
@Override
|
||||
public void done() {
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
protected VirtualFileSystem createJarFileSystem() {
|
||||
return new CoreJarFileSystem();
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ public class StubBasedPsiElementBase<T extends StubElement> extends ASTDelegateP
|
||||
synchronized (file.getStubLock()) {
|
||||
node = myNode;
|
||||
if (node == null) {
|
||||
NonCancelableSection criticalSection = ProgressIndicatorProvider.getInstance().startNonCancelableSection();
|
||||
NonCancelableSection criticalSection = ProgressIndicatorProvider.startNonCancelableSectionIfSupported();
|
||||
try {
|
||||
if (!file.isValid()) throw new PsiInvalidElementAccessException(this);
|
||||
FileElement treeElement = file.getTreeElement();
|
||||
|
||||
@@ -1053,8 +1053,7 @@ public class PsiBuilderImpl extends UserDataHolderBase implements PsiBuilder, AS
|
||||
final MyTreeStructure treeStructure = new MyTreeStructure(newRoot, null);
|
||||
final MyComparator comparator = new MyComparator(getUserDataUnprotected(CUSTOM_COMPARATOR), treeStructure);
|
||||
|
||||
final ProgressIndicatorProvider provider = ProgressIndicatorProvider.getInstance();
|
||||
final ProgressIndicator indicator = provider != null ? provider.getProgressIndicator() : null;
|
||||
final ProgressIndicator indicator = ProgressIndicatorProvider.getGlobalProgressIndicator();
|
||||
BlockSupportImpl.diffTrees(oldRoot, builder, comparator, treeStructure, indicator);
|
||||
return diffLog;
|
||||
}
|
||||
|
||||
+1
-2
@@ -230,8 +230,7 @@ public abstract class ComponentManagerImpl extends UserDataHolderBase implements
|
||||
|
||||
@Nullable
|
||||
protected static ProgressIndicator getProgressIndicator() {
|
||||
final ProgressIndicatorProvider progressManager = ProgressIndicatorProvider.getInstance();
|
||||
return progressManager != null ? progressManager.getProgressIndicator() : null;
|
||||
return ProgressIndicatorProvider.getGlobalProgressIndicator();
|
||||
}
|
||||
|
||||
protected double getPercentageOfComponentsLoaded() {
|
||||
|
||||
@@ -119,7 +119,7 @@ public class PsiSearchHelperImpl implements PsiSearchHelper {
|
||||
if (text.length() == 0) {
|
||||
throw new IllegalArgumentException("Cannot search for elements with empty text");
|
||||
}
|
||||
final ProgressIndicator progress = ProgressIndicatorProvider.getInstance().getProgressIndicator();
|
||||
final ProgressIndicator progress = ProgressIndicatorProvider.getGlobalProgressIndicator();
|
||||
if (searchScope instanceof GlobalSearchScope) {
|
||||
StringSearcher searcher = new StringSearcher(text, caseSensitively, true);
|
||||
|
||||
@@ -344,7 +344,7 @@ public class PsiSearchHelperImpl implements PsiSearchHelper {
|
||||
if (qName.length() == 0) {
|
||||
throw new IllegalArgumentException("Cannot search for elements with empty text");
|
||||
}
|
||||
final ProgressIndicator progress = ProgressIndicatorProvider.getInstance().getProgressIndicator();
|
||||
final ProgressIndicator progress = ProgressIndicatorProvider.getGlobalProgressIndicator();
|
||||
|
||||
int dotIndex = qName.lastIndexOf('.');
|
||||
int dollarIndex = qName.lastIndexOf('$');
|
||||
@@ -487,7 +487,7 @@ public class PsiSearchHelperImpl implements PsiSearchHelper {
|
||||
|
||||
appendCollectorsFromQueryRequests(collectors);
|
||||
|
||||
ProgressIndicator progress = ProgressIndicatorProvider.getInstance().getProgressIndicator();
|
||||
ProgressIndicator progress = ProgressIndicatorProvider.getGlobalProgressIndicator();
|
||||
do {
|
||||
final MultiMap<Set<IdIndexEntry>, RequestWithProcessor> globals = new MultiMap<Set<IdIndexEntry>, RequestWithProcessor>();
|
||||
final List<Computable<Boolean>> customs = ContainerUtil.newArrayList();
|
||||
|
||||
+1
-1
@@ -199,7 +199,7 @@ public abstract class ModuleManagerImpl extends ModuleManager implements Project
|
||||
|
||||
protected void loadModules(final ModuleModelImpl moduleModel) {
|
||||
if (myModulePaths != null && myModulePaths.size() > 0) {
|
||||
final ProgressIndicator progressIndicator = myProject.isDefault() ? null : ProgressIndicatorProvider.getInstance().getProgressIndicator();
|
||||
final ProgressIndicator progressIndicator = myProject.isDefault() ? null : ProgressIndicatorProvider.getGlobalProgressIndicator();
|
||||
if (progressIndicator != null) {
|
||||
progressIndicator.setText("Loading modules...");
|
||||
progressIndicator.setText2("");
|
||||
|
||||
+1
-2
@@ -634,8 +634,7 @@ public class DirectoryIndexImpl extends DirectoryIndex {
|
||||
}
|
||||
|
||||
protected void doInitialize(boolean reverseAllSets/* for testing order independence*/) {
|
||||
final ProgressIndicatorProvider progressIndicatorProvider = ProgressIndicatorProvider.getInstance();
|
||||
ProgressIndicator progress = progressIndicatorProvider == null ? null : progressIndicatorProvider.getProgressIndicator();
|
||||
ProgressIndicator progress = ProgressIndicatorProvider.getGlobalProgressIndicator();
|
||||
if (progress == null) progress = new EmptyProgressIndicator();
|
||||
|
||||
progress.pushState();
|
||||
|
||||
Reference in New Issue
Block a user