mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
ProgressManager -> ProgressIndicatorProvider
This commit is contained in:
@@ -33,6 +33,8 @@ public abstract class ProgressIndicatorProvider {
|
||||
|
||||
protected abstract void doCheckCanceled() throws ProcessCanceledException;
|
||||
|
||||
public abstract NonCancelableSection startNonCancelableSection();
|
||||
|
||||
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
|
||||
|
||||
@@ -22,7 +22,7 @@ package com.intellij.extapi.psi;
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.intellij.lang.Language;
|
||||
import com.intellij.openapi.progress.NonCancelableSection;
|
||||
import com.intellij.openapi.progress.ProgressManager;
|
||||
import com.intellij.openapi.progress.ProgressIndicatorProvider;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.psi.PsiElement;
|
||||
@@ -67,7 +67,7 @@ public class StubBasedPsiElementBase<T extends StubElement> extends ASTDelegateP
|
||||
synchronized (file.getStubLock()) {
|
||||
node = myNode;
|
||||
if (node == null) {
|
||||
NonCancelableSection criticalSection = ProgressManager.getInstance().startNonCancelableSection();
|
||||
NonCancelableSection criticalSection = ProgressIndicatorProvider.getInstance().startNonCancelableSection();
|
||||
try {
|
||||
if (!file.isValid()) throw new PsiInvalidElementAccessException(this);
|
||||
FileElement treeElement = file.getTreeElement();
|
||||
@@ -194,7 +194,7 @@ public class StubBasedPsiElementBase<T extends StubElement> extends ASTDelegateP
|
||||
}
|
||||
|
||||
public T getStub() {
|
||||
ProgressManager.checkCanceled(); // Hope, this is called often
|
||||
ProgressIndicatorProvider.checkCanceled(); // Hope, this is called often
|
||||
return myStub;
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ package com.intellij.lang.impl;
|
||||
import com.intellij.lang.*;
|
||||
import com.intellij.lexer.Lexer;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.progress.ProgressManager;
|
||||
import com.intellij.openapi.progress.ProgressIndicatorProvider;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.Key;
|
||||
@@ -187,7 +187,7 @@ public class PsiBuilderImpl extends UserDataHolderBase implements PsiBuilder {
|
||||
int i = 0;
|
||||
int offset = 0;
|
||||
while (true) {
|
||||
ProgressManager.checkCanceled();
|
||||
ProgressIndicatorProvider.checkCanceled();
|
||||
IElementType type = myLexer.getTokenType();
|
||||
if (type == null) break;
|
||||
|
||||
@@ -630,7 +630,7 @@ public class PsiBuilderImpl extends UserDataHolderBase implements PsiBuilder {
|
||||
}
|
||||
myTokenTypeChecked = false;
|
||||
myCurrentLexeme++;
|
||||
ProgressManager.checkCanceled();
|
||||
ProgressIndicatorProvider.checkCanceled();
|
||||
}
|
||||
|
||||
private void skipWhitespace() {
|
||||
@@ -946,7 +946,7 @@ public class PsiBuilderImpl extends UserDataHolderBase implements PsiBuilder {
|
||||
final MyTreeStructure treeStructure = new MyTreeStructure(newRoot, null);
|
||||
final MyComparator comparator = new MyComparator(getUserDataUnprotected(CUSTOM_COMPARATOR), treeStructure);
|
||||
|
||||
BlockSupportImpl.diffTrees(oldRoot, builder, comparator, treeStructure, ProgressManager.getInstance().getProgressIndicator());
|
||||
BlockSupportImpl.diffTrees(oldRoot, builder, comparator, treeStructure, ProgressIndicatorProvider.getInstance().getProgressIndicator());
|
||||
return diffLog;
|
||||
}
|
||||
|
||||
@@ -1102,7 +1102,7 @@ public class PsiBuilderImpl extends UserDataHolderBase implements PsiBuilder {
|
||||
private int insertLeaves(int curToken, int lastIdx, final CompositeElement curNode) {
|
||||
lastIdx = Math.min(lastIdx, myLexemeCount);
|
||||
while (curToken < lastIdx) {
|
||||
ProgressManager.checkCanceled();
|
||||
ProgressIndicatorProvider.checkCanceled();
|
||||
final int start = myLexStarts[curToken];
|
||||
final int end = myLexStarts[curToken + 1];
|
||||
if (start < end || myLexTypes[curToken] instanceof ILeafElementType) { // Empty token. Most probably a parser directive like indent/dedent in Python
|
||||
@@ -1162,7 +1162,7 @@ public class PsiBuilderImpl extends UserDataHolderBase implements PsiBuilder {
|
||||
}
|
||||
|
||||
public ThreeState deepEqual(final ASTNode oldNode, final LighterASTNode newNode) {
|
||||
ProgressManager.checkCanceled();
|
||||
ProgressIndicatorProvider.checkCanceled();
|
||||
|
||||
boolean oldIsErrorElement = oldNode instanceof PsiErrorElement;
|
||||
boolean newIsErrorElement = newNode.getTokenType() == TokenType.ERROR_ELEMENT;
|
||||
|
||||
@@ -24,7 +24,7 @@ import com.intellij.openapi.components.ProjectComponent;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.fileEditor.FileDocumentManager;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.progress.ProgressManager;
|
||||
import com.intellij.openapi.progress.ProgressIndicatorProvider;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.roots.ProjectFileIndex;
|
||||
import com.intellij.openapi.startup.StartupManager;
|
||||
@@ -186,13 +186,13 @@ public class PsiManagerImpl extends PsiManagerEx implements ProjectComponent {
|
||||
|
||||
@NotNull
|
||||
public ResolveCache getResolveCache() {
|
||||
ProgressManager.checkCanceled(); // We hope this method is being called often enough to cancel daemon processes smoothly
|
||||
ProgressIndicatorProvider.checkCanceled(); // We hope this method is being called often enough to cancel daemon processes smoothly
|
||||
return myResolveCache;
|
||||
}
|
||||
|
||||
|
||||
public boolean areElementsEquivalent(PsiElement element1, PsiElement element2) {
|
||||
ProgressManager.checkCanceled(); // We hope this method is being called often enough to cancel daemon processes smoothly
|
||||
ProgressIndicatorProvider.checkCanceled(); // We hope this method is being called often enough to cancel daemon processes smoothly
|
||||
|
||||
if (element1 == element2) return true;
|
||||
if (element1 == null || element2 == null) {
|
||||
@@ -237,7 +237,7 @@ public class PsiManagerImpl extends PsiManagerEx implements ProjectComponent {
|
||||
}
|
||||
|
||||
public PsiDirectory findDirectory(@NotNull VirtualFile file) {
|
||||
ProgressManager.checkCanceled();
|
||||
ProgressIndicatorProvider.checkCanceled();
|
||||
|
||||
return myFileManager.findDirectory(file);
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ package com.intellij.psi.impl.source.resolve;
|
||||
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.progress.ProgressManager;
|
||||
import com.intellij.openapi.progress.ProgressIndicatorProvider;
|
||||
import com.intellij.openapi.util.Computable;
|
||||
import com.intellij.openapi.util.RecursionGuard;
|
||||
import com.intellij.openapi.util.RecursionManager;
|
||||
@@ -104,7 +104,7 @@ public class ResolveCache {
|
||||
@NotNull Map<? super TRef,Reference<TResult>>[] maps,
|
||||
boolean needToPreventRecursion,
|
||||
final boolean incompleteCode, boolean poly) {
|
||||
ProgressManager.checkCanceled();
|
||||
ProgressIndicatorProvider.checkCanceled();
|
||||
ApplicationManager.getApplication().assertReadAccessAllowed();
|
||||
|
||||
int clearCountOnStart = myClearCount.intValue();
|
||||
|
||||
+2
-2
@@ -19,7 +19,7 @@ package com.intellij.psi.impl.source.resolve.reference;
|
||||
import com.intellij.lang.Language;
|
||||
import com.intellij.lang.LanguageExtension;
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
import com.intellij.openapi.progress.ProgressManager;
|
||||
import com.intellij.openapi.progress.ProgressIndicatorProvider;
|
||||
import com.intellij.openapi.project.IndexNotReadyException;
|
||||
import com.intellij.openapi.util.Trinity;
|
||||
import com.intellij.patterns.ElementPattern;
|
||||
@@ -108,7 +108,7 @@ public class ReferenceProvidersRegistry {
|
||||
}
|
||||
|
||||
public static PsiReference[] getReferencesFromProviders(PsiElement context, @NotNull PsiReferenceService.Hints hints) {
|
||||
ProgressManager.checkCanceled();
|
||||
ProgressIndicatorProvider.checkCanceled();
|
||||
assert context.isValid() : "Invalid context: " + context;
|
||||
|
||||
ReferenceProvidersRegistry registry = getInstance();
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
package com.intellij.psi.impl.source.text;
|
||||
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.intellij.openapi.progress.ProgressManager;
|
||||
import com.intellij.openapi.progress.ProgressIndicatorProvider;
|
||||
import com.intellij.pom.tree.events.impl.TreeChangeEventImpl;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFile;
|
||||
@@ -29,7 +29,6 @@ import com.intellij.psi.impl.source.tree.CompositeElement;
|
||||
import com.intellij.psi.impl.source.tree.FileElement;
|
||||
import com.intellij.psi.impl.source.tree.TreeElement;
|
||||
import com.intellij.psi.impl.source.tree.TreeUtil;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import com.intellij.util.diff.DiffTreeChangeBuilder;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -45,7 +44,7 @@ public class DiffLog implements DiffTreeChangeBuilder<ASTNode,ASTNode> {
|
||||
|
||||
private abstract static class LogEntry {
|
||||
protected LogEntry() {
|
||||
ProgressManager.checkCanceled();
|
||||
ProgressIndicatorProvider.checkCanceled();
|
||||
}
|
||||
abstract void doActualPsiChange(@NotNull PsiFile file, @NotNull ASTDiffBuilder astDiffBuilder);
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
package com.intellij.psi.impl.source.tree;
|
||||
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.intellij.openapi.progress.ProgressManager;
|
||||
import com.intellij.openapi.progress.ProgressIndicatorProvider;
|
||||
import com.intellij.psi.tree.TokenSet;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -38,7 +38,7 @@ public class AstBufferUtil {
|
||||
((TreeElement)element).acceptTree(new RecursiveTreeElementWalkingVisitor(false) {
|
||||
@Override
|
||||
public void visitLeaf(LeafElement element) {
|
||||
ProgressManager.checkCanceled();
|
||||
ProgressIndicatorProvider.checkCanceled();
|
||||
if (element instanceof ForeignLeafPsiElement ||
|
||||
skipTypes != null && skipTypes.contains(element.getElementType())) {
|
||||
return;
|
||||
|
||||
@@ -21,7 +21,7 @@ import com.intellij.extapi.psi.ASTDelegatePsiElement;
|
||||
import com.intellij.lang.*;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.progress.ProgressManager;
|
||||
import com.intellij.openapi.progress.ProgressIndicatorProvider;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.pom.tree.events.ChangeInfo;
|
||||
import com.intellij.pom.tree.events.TreeChangeEvent;
|
||||
@@ -723,7 +723,7 @@ public class CompositeElement extends TreeElement {
|
||||
}
|
||||
|
||||
public final PsiElement getPsi() {
|
||||
ProgressManager.checkCanceled(); // We hope this method is being called often enough to cancel daemon processes smoothly
|
||||
ProgressIndicatorProvider.checkCanceled(); // We hope this method is being called often enough to cancel daemon processes smoothly
|
||||
|
||||
PsiElement wrapper = myWrapper;
|
||||
if (wrapper != null) return wrapper;
|
||||
@@ -810,7 +810,7 @@ public class CompositeElement extends TreeElement {
|
||||
|
||||
@Override
|
||||
public void visitComposite(CompositeElement composite) {
|
||||
ProgressManager.checkCanceled(); // we can safely interrupt creating children PSI any moment
|
||||
ProgressIndicatorProvider.checkCanceled(); // we can safely interrupt creating children PSI any moment
|
||||
if (composite.myWrapper != null) {
|
||||
// someone else 've managed to create the PSI in the meantime. Abandon our attempts to cache everything.
|
||||
stopWalking();
|
||||
|
||||
@@ -22,8 +22,7 @@ import com.intellij.lang.Language;
|
||||
import com.intellij.navigation.ItemPresentation;
|
||||
import com.intellij.navigation.NavigationItem;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.progress.ProgressIndicator;
|
||||
import com.intellij.openapi.progress.ProgressManager;
|
||||
import com.intellij.openapi.progress.ProgressIndicatorProvider;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.pom.Navigatable;
|
||||
import com.intellij.psi.*;
|
||||
@@ -87,10 +86,7 @@ public class LeafPsiElement extends LeafElement implements PsiElement, Navigatio
|
||||
}
|
||||
|
||||
private void invalid() {
|
||||
final ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator();
|
||||
if (indicator != null) {
|
||||
indicator.checkCanceled();
|
||||
}
|
||||
ProgressIndicatorProvider.checkCanceled();
|
||||
|
||||
final StringBuilder builder = new StringBuilder();
|
||||
TreeElement element = this;
|
||||
|
||||
@@ -37,6 +37,11 @@ public abstract class ProgressManager {
|
||||
protected void doCheckCanceled() throws ProcessCanceledException {
|
||||
ProgressManager.ourInstance.doCheckCanceled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NonCancelableSection startNonCancelableSection() {
|
||||
return ProgressManager.ourInstance.startNonCancelableSection();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user