Cheaper ProgressManager.checkCanceled(). Mostly, it's call to abstract method eliminated.

This commit is contained in:
Maxim Shafirov
2009-10-21 20:14:09 +04:00
parent 1e7add8432
commit 262efbdb0a
66 changed files with 165 additions and 161 deletions
@@ -19,25 +19,25 @@
*/
package com.intellij.compiler.impl.javaCompiler.eclipse;
import com.intellij.compiler.OutputParser;
import com.intellij.compiler.impl.javaCompiler.FileObject;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.compiler.CompileContext;
import com.intellij.openapi.compiler.CompilerBundle;
import com.intellij.openapi.compiler.CompilerMessageCategory;
import com.intellij.openapi.compiler.CompileContext;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.fileEditor.FileDocumentManager;
import com.intellij.openapi.progress.ProcessCanceledException;
import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.openapi.progress.ProgressManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Computable;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.vfs.LocalFileSystem;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.vfs.VirtualFileManager;
import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.openapi.progress.ProcessCanceledException;
import com.intellij.openapi.progress.ProgressManager;
import org.eclipse.jdt.core.compiler.IProblem;
import org.eclipse.jdt.core.compiler.InvalidInputException;
import org.eclipse.jdt.internal.compiler.*;
@@ -164,7 +164,7 @@ public class EclipseCompilerDriver {
}
public boolean processMessageLine(final OutputParser.Callback callback, final String outputDir, Project project) {
ProgressManager.getInstance().checkCanceled();
ProgressManager.checkCanceled();
CompilationResult result;
try {
result = myCompilationResults.take();
@@ -243,7 +243,7 @@ public class EclipseCompilerDriver {
public char[] getContents() {
final String fileName = String.valueOf(getFileName());
try {
ProgressManager.getInstance().checkCanceled();
ProgressManager.checkCanceled();
return FileUtil.loadFileText(new File(fileName), myDefaultEncoding);
}
catch (IOException e) {
@@ -56,7 +56,7 @@ public class CompilerPathsEx extends CompilerPaths {
}
protected void acceptDirectory(final VirtualFile file, final String fileRoot, final String filePath) {
ProgressManager.getInstance().checkCanceled();
ProgressManager.checkCanceled();
final VirtualFile[] children = file.getChildren();
for (final VirtualFile child : children) {
final String name = child.getName();
@@ -255,7 +255,7 @@ public class CodeInsightUtil {
return new Processor<PsiClass>() {
public boolean process(final PsiClass inheritor) {
ProgressManager.getInstance().checkCanceled();
ProgressManager.checkCanceled();
return ApplicationManager.getApplication().runReadAction(new Computable<Boolean>() {
public Boolean compute() {
@@ -178,7 +178,7 @@ public class AllClassesGetter {
private static String getPackagePrefix(final PsiElement context, final int offset) {
final String fileText = ApplicationManager.getApplication().runReadAction(new Computable<String>() {
public String compute() {
ProgressManager.getInstance().checkCanceled();
ProgressManager.checkCanceled();
return context.getContainingFile().getText();
}
});
@@ -200,7 +200,7 @@ public class AllClassesGetter {
//noinspection AutoUnboxing
return ApplicationManager.getApplication().runReadAction(new Computable<Boolean>() {
public Boolean compute() {
ProgressManager.getInstance().checkCanceled();
ProgressManager.checkCanceled();
if (!context.isValid() || !psiClass.isValid()) return false;
@@ -146,7 +146,7 @@ public class JavaLineMarkerProvider implements LineMarkerProvider, DumbAware {
Set<PsiMethod> methods = new HashSet<PsiMethod>();
for (PsiElement element : elements) {
ProgressManager.getInstance().checkCanceled();
ProgressManager.checkCanceled();
if (element instanceof PsiMethod) {
final PsiMethod method = (PsiMethod)element;
if (PsiUtil.canBeOverriden(method)) {
@@ -183,7 +183,7 @@ public class JavaLineMarkerProvider implements LineMarkerProvider, DumbAware {
final Set<PsiMethod> overridden = new HashSet<PsiMethod>();
Set<PsiClass> classes = new THashSet<PsiClass>();
for (PsiMethod method : methods) {
ProgressManager.getInstance().checkCanceled();
ProgressManager.checkCanceled();
final PsiClass parentClass = method.getContainingClass();
if (!"java.lang.Object".equals(parentClass.getQualifiedName())) {
classes.add(parentClass);
@@ -47,8 +47,8 @@ import com.intellij.openapi.progress.ProcessCanceledException;
import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.openapi.progress.ProgressManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.roots.ProjectRootManager;
import com.intellij.openapi.roots.ProjectFileIndex;
import com.intellij.openapi.roots.ProjectRootManager;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.profile.codeInspection.InspectionProjectProfileManager;
import com.intellij.psi.*;
@@ -229,7 +229,7 @@ public class PostHighlightingPass extends TextEditorHighlightingPass {
return;
}
for (PsiElement element : elements) {
ProgressManager.getInstance().checkCanceled();
ProgressManager.checkCanceled();
if (unusedSymbolEnabled && element instanceof PsiIdentifier) {
PsiIdentifier identifier = (PsiIdentifier)element;
@@ -241,7 +241,7 @@ public class PostHighlightingPass extends TextEditorHighlightingPass {
else if (unusedImportEnabled && element instanceof PsiImportList) {
final PsiImportStatementBase[] imports = ((PsiImportList)element).getAllImportStatements();
for (PsiImportStatementBase statement : imports) {
ProgressManager.getInstance().checkCanceled();
ProgressManager.checkCanceled();
final HighlightInfo info = processImport(statement, unusedImportKey);
if (info != null) {
result.add(info);
@@ -318,7 +318,7 @@ public class PostHighlightingPass extends TextEditorHighlightingPass {
private boolean isImplicitUsage(final PsiModifierListOwner element) {
if (UnusedSymbolLocalInspection.isInjected(element, myUnusedSymbolInspection)) return true;
for (ImplicitUsageProvider provider : myImplicitUsageProviders) {
ProgressManager.getInstance().checkCanceled();
ProgressManager.checkCanceled();
if (provider.isImplicitUsage(element)) {
return true;
}
@@ -329,7 +329,7 @@ public class PostHighlightingPass extends TextEditorHighlightingPass {
private boolean isImplicitRead(final PsiVariable element) {
for(ImplicitUsageProvider provider: myImplicitUsageProviders) {
ProgressManager.getInstance().checkCanceled();
ProgressManager.checkCanceled();
if (provider.isImplicitRead(element)) {
return true;
}
@@ -339,7 +339,7 @@ public class PostHighlightingPass extends TextEditorHighlightingPass {
private boolean isImplicitWrite(final PsiVariable element) {
for(ImplicitUsageProvider provider: myImplicitUsageProviders) {
ProgressManager.getInstance().checkCanceled();
ProgressManager.checkCanceled();
if (provider.isImplicitWrite(element)) {
return true;
}
@@ -25,8 +25,8 @@ import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.progress.ProgressManager;
import com.intellij.openapi.project.DumbAware;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.project.IndexNotReadyException;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Pair;
import com.intellij.openapi.util.TextRange;
import com.intellij.pom.java.LanguageLevel;
@@ -334,7 +334,7 @@ public class HighlightVisitorImpl extends JavaElementVisitor implements Highligh
}
@Override public void visitExpression(PsiExpression expression) {
ProgressManager.getInstance().checkCanceled(); // visitLiteralExpression is invoked very often in array initializers
ProgressManager.checkCanceled(); // visitLiteralExpression is invoked very often in array initializers
super.visitExpression(expression);
if (myHolder.add(HighlightUtil.checkMustBeBoolean(expression))) return;
@@ -21,7 +21,6 @@ import com.intellij.codeInsight.daemon.QuickFixBundle;
import static com.intellij.codeInsight.daemon.impl.quickfix.CreateClassKind.*;
import com.intellij.codeInsight.intention.impl.CreateClassDialog;
import com.intellij.codeInsight.lookup.LookupElement;
import com.intellij.codeInsight.lookup.LookupItem;
import com.intellij.codeInsight.lookup.LookupItemUtil;
import com.intellij.codeInsight.template.*;
import com.intellij.ide.fileTemplates.FileTemplate;
@@ -714,7 +713,7 @@ public class CreateFromUsageUtils {
ExpectedTypesProvider provider = ExpectedTypesProvider.getInstance(manager.getProject());
JavaPsiFacade facade = JavaPsiFacade.getInstance(manager.getProject());
for (int i = 0; i < Math.min(MAX_GUESSED_MEMBERS_COUNT, members.length); i++) {
ProgressManager.getInstance().checkCanceled();
ProgressManager.checkCanceled();
PsiMember member = members[i];
PsiClass aClass = member.getContainingClass();
if (aClass instanceof PsiAnonymousClass) continue;
@@ -20,13 +20,13 @@ import com.intellij.codeInsight.completion.JavaCompletionUtil;
import com.intellij.codeInsight.daemon.QuickFixBundle;
import com.intellij.codeInsight.intention.IntentionAction;
import com.intellij.ide.util.MethodCellRenderer;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.command.CommandProcessor;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.progress.ProgressManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.popup.PopupChooserBuilder;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.psi.*;
import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.psi.search.PsiShortNamesCache;
@@ -94,7 +94,7 @@ public class StaticImportMethodFix implements IntentionAction {
PsiMethod[] methods = cache.getMethodsByNameIfNotMoreThan(name, scope, 20);
List<PsiMethod> applicableList = new ArrayList<PsiMethod>();
for (PsiMethod method : methods) {
ProgressManager.getInstance().checkCanceled();
ProgressManager.checkCanceled();
PsiClass aClass = method.getContainingClass();
if (aClass != null && JavaCompletionUtil.isInExcludedPackage(aClass)) continue;
if (!method.hasModifierProperty(PsiModifier.STATIC)) continue;
@@ -71,7 +71,7 @@ public class JavaFoldingBuilder extends FoldingBuilderEx implements DumbAware {
PsiClass[] classes = file.getClasses();
for (PsiClass aClass : classes) {
ProgressManager.getInstance().checkCanceled();
ProgressManager.checkCanceled();
addElementsToFold(result, aClass, document, true, quick);
}
@@ -99,7 +99,7 @@ public class JavaFoldingBuilder extends FoldingBuilderEx implements DumbAware {
PsiElement[] children = aClass.getChildren();
for (PsiElement child : children) {
ProgressManager.getInstance().checkCanceled();
ProgressManager.checkCanceled();
if (child instanceof PsiMethod) {
PsiMethod method = (PsiMethod)child;
@@ -94,7 +94,7 @@ class ControlFlowAnalyzer extends JavaElementVisitor {
private boolean myRecursionStopper = false;
private void addInstruction(Instruction instruction) {
ProgressManager.getInstance().checkCanceled();
ProgressManager.checkCanceled();
if (!myRecursionStopper) {
myRecursionStopper = true;
@@ -124,7 +124,7 @@ public class DataFlowRunner {
final long before = System.currentTimeMillis();
while (!queue.isEmpty()) {
if (!unitTestMode && System.currentTimeMillis() - before > timeLimit) return RunnerResult.TOO_COMPLEX;
ProgressManager.getInstance().checkCanceled();
ProgressManager.checkCanceled();
DfaInstructionState instructionState = queue.remove(0);
if (LOG.isDebugEnabled()) {
@@ -686,7 +686,7 @@ public class DfaMemoryStateImpl implements DfaMemoryState {
for (int i = 0; i < varClass.size(); i++) {
if ((++interruptCount & 0xf) == 0) {
ProgressManager.getInstance().checkCanceled();
ProgressManager.checkCanceled();
}
int cl = varClass.get(i);
DfaValue value = myFactory.getValue(cl);
@@ -382,7 +382,7 @@ public class JavaFindUsagesHandler extends FindUsagesHandler{
progress.setText(FindBundle.message("find.searching.for.references.to.class.progress", aClass.getName()));
}
for (PsiFile file : files) {
ProgressManager.getInstance().checkCanceled();
ProgressManager.checkCanceled();
ReferencesSearch.search(aClass, new LocalSearchScope(file), false).forEach(new ReadActionProcessor<PsiReference>() {
public boolean processInReadAction(final PsiReference psiReference) {
return addResult(results, psiReference, options, aClass);
@@ -22,8 +22,8 @@ import com.intellij.openapi.progress.ProgressManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Comparing;
import com.intellij.psi.*;
import com.intellij.psi.jsp.JspFile;
import com.intellij.psi.jsp.JavaJspElementVisitor;
import com.intellij.psi.jsp.JspFile;
import com.intellij.psi.tree.IElementType;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.psi.util.PsiUtil;
@@ -202,7 +202,7 @@ class ControlFlowAnalyzer extends JavaJspElementVisitor {
// register all sub ranges
for (Map.Entry<PsiElement, ControlFlowSubRange> entry : mySubRanges.entrySet()) {
ProgressManager.getInstance().checkCanceled();
ProgressManager.checkCanceled();
ControlFlowSubRange subRange = entry.getValue();
PsiElement element = entry.getKey();
myControlFlowFactory.registerSubRange(element, subRange, myEvaluateConstantIfConfition, myPolicy);
@@ -211,13 +211,13 @@ class ControlFlowAnalyzer extends JavaJspElementVisitor {
private void startElement(PsiElement element) {
for (PsiElement child = element.getFirstChild(); child != null; child = child.getNextSibling()) {
ProgressManager.getInstance().checkCanceled();
ProgressManager.checkCanceled();
if (child instanceof PsiErrorElement && !Comparing.strEqual(((PsiErrorElement)child).getErrorDescription(), JavaErrorMessages.message("expected.semicolon"))) {
// do not perform control flow analysis for incomplete code
throw new AnalysisCanceledSoftException(element);
}
}
ProgressManager.getInstance().checkCanceled();
ProgressManager.checkCanceled();
myCurrentFlow.startElement(element);
generateUncheckedExceptionJumpsIfNeeded(element, true);
@@ -249,7 +249,7 @@ class ControlFlowAnalyzer extends JavaJspElementVisitor {
}
for (int i = myUnhandledExceptionCatchBlocks.size() - 1; i >= 0; i--) {
ProgressManager.getInstance().checkCanceled();
ProgressManager.checkCanceled();
PsiElement block = myUnhandledExceptionCatchBlocks.get(i);
// cannot jump to outer catch blocks (belonging to outer try stmt) if current try{} has finally block
if (block == null) {
@@ -286,7 +286,7 @@ class ControlFlowAnalyzer extends JavaJspElementVisitor {
//}
Collection<PsiClassType> unhandledExceptions = ExceptionUtil.collectUnhandledExceptions(element, element.getParent());
for (PsiClassType unhandledException : unhandledExceptions) {
ProgressManager.getInstance().checkCanceled();
ProgressManager.checkCanceled();
generateThrow(unhandledException, element);
}
}
@@ -294,7 +294,7 @@ class ControlFlowAnalyzer extends JavaJspElementVisitor {
private void generateThrow(PsiClassType unhandledException, PsiElement throwingElement) {
final List<PsiElement> catchBlocks = findThrowToBlocks(unhandledException);
for (PsiElement block : catchBlocks) {
ProgressManager.getInstance().checkCanceled();
ProgressManager.checkCanceled();
ConditionalThrowToInstruction instruction = new ConditionalThrowToInstruction(0);
myCurrentFlow.addInstruction(instruction);
if (!patchCheckedThrowInstructionIfInsideFinally(instruction, throwingElement, block)) {
@@ -352,7 +352,7 @@ class ControlFlowAnalyzer extends JavaJspElementVisitor {
int prevOffset = myCurrentFlow.getSize();
PsiElement[] children = codeFragment.getChildren();
for (PsiElement child : children) {
ProgressManager.getInstance().checkCanceled();
ProgressManager.checkCanceled();
child.accept(this);
}
@@ -372,7 +372,7 @@ class ControlFlowAnalyzer extends JavaJspElementVisitor {
int prevOffset = myCurrentFlow.getSize();
PsiStatement[] statements = block.getStatements();
for (PsiStatement statement : statements) {
ProgressManager.getInstance().checkCanceled();
ProgressManager.checkCanceled();
statement.accept(this);
}
@@ -482,7 +482,7 @@ class ControlFlowAnalyzer extends JavaJspElementVisitor {
int pc = myCurrentFlow.getSize();
PsiElement[] elements = statement.getDeclaredElements();
for (PsiElement element : elements) {
ProgressManager.getInstance().checkCanceled();
ProgressManager.checkCanceled();
if (element instanceof PsiClass) {
element.accept(this);
}
@@ -568,7 +568,7 @@ class ControlFlowAnalyzer extends JavaJspElementVisitor {
expression.accept(this);
for (PsiParameter catchParameter : myCatchParameters) {
ProgressManager.getInstance().checkCanceled();
ProgressManager.checkCanceled();
PsiType type = catchParameter.getType();
if (type instanceof PsiClassType) {
generateThrow((PsiClassType)type, statement);
@@ -581,7 +581,7 @@ class ControlFlowAnalyzer extends JavaJspElementVisitor {
startElement(statement);
PsiExpression[] expressions = statement.getExpressionList().getExpressions();
for (PsiExpression expr : expressions) {
ProgressManager.getInstance().checkCanceled();
ProgressManager.checkCanceled();
expr.accept(this);
}
finishElement(statement);
@@ -849,7 +849,7 @@ class ControlFlowAnalyzer extends JavaJspElementVisitor {
PsiStatement[] statements = body.getStatements();
PsiSwitchLabelStatement defaultLabel = null;
for (PsiStatement aStatement : statements) {
ProgressManager.getInstance().checkCanceled();
ProgressManager.checkCanceled();
if (aStatement instanceof PsiSwitchLabelStatement) {
if (((PsiSwitchLabelStatement)aStatement).isDefaultCase()) {
defaultLabel = (PsiSwitchLabelStatement)aStatement;
@@ -911,7 +911,7 @@ class ControlFlowAnalyzer extends JavaJspElementVisitor {
}
else {
for (int i = 0; i < blocks.size(); i++) {
ProgressManager.getInstance().checkCanceled();
ProgressManager.checkCanceled();
element = blocks.get(i);
BranchingInstruction instruction = i == blocks.size() - 1
? new ThrowToInstruction(0)
@@ -943,7 +943,7 @@ class ControlFlowAnalyzer extends JavaJspElementVisitor {
private List<PsiElement> findThrowToBlocks(PsiClassType throwType) {
List<PsiElement> blocks = new ArrayList<PsiElement>();
for (int i = myCatchParameters.size() - 1; i >= 0; i--) {
ProgressManager.getInstance().checkCanceled();
ProgressManager.checkCanceled();
PsiParameter parameter = myCatchParameters.get(i);
final PsiType type = parameter.getType();
PsiClass catchedClass = PsiUtil.resolveClassInType(type);
@@ -1004,7 +1004,7 @@ class ControlFlowAnalyzer extends JavaJspElementVisitor {
int catchNum = Math.min(catchBlocks.length, catchBlockParameters.length);
myUnhandledExceptionCatchBlocks.push(null);
for (int i = catchNum - 1; i >= 0; i--) {
ProgressManager.getInstance().checkCanceled();
ProgressManager.checkCanceled();
myCatchParameters.push(catchBlockParameters[i]);
myCatchBlocks.push(catchBlocks[i]);
@@ -1044,7 +1044,7 @@ class ControlFlowAnalyzer extends JavaJspElementVisitor {
}
for (int i = catchNum - 1; i >= 0; i--) {
ProgressManager.getInstance().checkCanceled();
ProgressManager.checkCanceled();
if (myPolicy.isParameterAccepted(catchBlockParameters[i])) {
generateWriteInstruction(catchBlockParameters[i]);
}
@@ -1114,7 +1114,7 @@ class ControlFlowAnalyzer extends JavaJspElementVisitor {
// checked exception throwing completion. need to dispatch to the correct catch clause
final List<PsiElement> unhandledExceptionCatchBlocks = finallyBlockToUnhandledExceptions.remove(finallyBlock);
for (int i = 0; unhandledExceptionCatchBlocks != null && i < unhandledExceptionCatchBlocks.size(); i++) {
ProgressManager.getInstance().checkCanceled();
ProgressManager.checkCanceled();
PsiElement catchBlock = unhandledExceptionCatchBlocks.get(i);
final ReturnInstruction returnInstruction = new ReturnInstruction(0, myStack, callInstruction);
@@ -1192,7 +1192,7 @@ class ControlFlowAnalyzer extends JavaJspElementVisitor {
@Override public void visitExpressionList(PsiExpressionList list) {
PsiExpression[] expressions = list.getExpressions();
for (final PsiExpression expression : expressions) {
ProgressManager.getInstance().checkCanceled();
ProgressManager.checkCanceled();
myStartStatementStack.pushStatement(expression, false);
myEndStatementStack.pushStatement(expression, false);
@@ -1219,7 +1219,7 @@ class ControlFlowAnalyzer extends JavaJspElementVisitor {
PsiExpression[] initializers = expression.getInitializers();
for (PsiExpression initializer : initializers) {
ProgressManager.getInstance().checkCanceled();
ProgressManager.checkCanceled();
initializer.accept(this);
}
@@ -1374,7 +1374,7 @@ class ControlFlowAnalyzer extends JavaJspElementVisitor {
PsiElement[] children = element.getChildren();
for (PsiElement child : children) {
ProgressManager.getInstance().checkCanceled();
ProgressManager.checkCanceled();
child.accept(this);
}
@@ -1427,7 +1427,7 @@ class ControlFlowAnalyzer extends JavaJspElementVisitor {
int pc = myCurrentFlow.getSize();
PsiElement[] children = expression.getChildren();
for (PsiElement child : children) {
ProgressManager.getInstance().checkCanceled();
ProgressManager.checkCanceled();
child.accept(this);
}
generateCheckedExceptionJumps(expression);
@@ -1543,7 +1543,7 @@ class ControlFlowAnalyzer extends JavaJspElementVisitor {
List<PsiVariable> array = new ArrayList<PsiVariable>();
addUsedVariables(array, aClass);
for (PsiVariable var : array) {
ProgressManager.getInstance().checkCanceled();
ProgressManager.checkCanceled();
generateReadInstruction(var);
}
finishElement(aClass);
@@ -1561,7 +1561,7 @@ class ControlFlowAnalyzer extends JavaJspElementVisitor {
PsiElement[] children = scope.getChildren();
for (PsiElement child : children) {
ProgressManager.getInstance().checkCanceled();
ProgressManager.checkCanceled();
addUsedVariables(array, child);
}
}
@@ -153,7 +153,7 @@ public class DefUseUtil {
Set<PsiVariable> readVariables = new THashSet<PsiVariable>();
for (int i = 0; i < instructions.size(); i++) {
Instruction instruction = instructions.get(i);
ProgressManager.getInstance().checkCanceled();
ProgressManager.checkCanceled();
if (instruction instanceof WriteVariableInstruction) {
WriteVariableInstruction writeInstruction = (WriteVariableInstruction)instruction;
PsiElement context = flow.getElement(i);
@@ -189,7 +189,7 @@ public class DefUseUtil {
queue.add(outerState);
while (!queue.isEmpty()) {
ProgressManager.getInstance().checkCanceled();
ProgressManager.checkCanceled();
InstructionState state = queue.remove(0);
state.markVisited();
@@ -173,7 +173,7 @@ class PsiShortNamesCacheImpl extends PsiShortNamesCache {
});
for (T member : members) {
ProgressManager.getInstance().checkCanceled();
ProgressManager.checkCanceled();
if (!scope.contains(member.getContainingFile().getVirtualFile())) continue;
if (!set.add(member)) continue;
@@ -69,14 +69,14 @@ public class AllClassesSearchExecutor implements QueryExecutor<PsiClass, AllClas
for (final String name : names) {
if (!parameters.nameMatches(name)) continue;
ProgressManager.getInstance().checkCanceled();
ProgressManager.checkCanceled();
final PsiClass[] classes = ApplicationManager.getApplication().runReadAction(new Computable<PsiClass[]>() {
public PsiClass[] compute() {
return cache.getClassesByName(name, scope);
}
});
for (PsiClass psiClass : classes) {
ProgressManager.getInstance().checkCanceled();
ProgressManager.checkCanceled();
if (!processor.process(psiClass)) {
return false;
}
@@ -105,4 +105,4 @@ public class AllClassesSearchExecutor implements QueryExecutor<PsiClass, AllClas
return !stopped[0];
}
}
}
@@ -73,7 +73,7 @@ public class JavaDirectInheritorsSearcher implements QueryExecutor<PsiClass, Dir
});
for (PsiReferenceList referenceList : candidates) {
ProgressManager.getInstance().checkCanceled();
ProgressManager.checkCanceled();
PsiClass candidate = (PsiClass)referenceList.getParent();
if (!consumer.process(candidate)) return false;
}
@@ -86,7 +86,7 @@ public class JavaDirectInheritorsSearcher implements QueryExecutor<PsiClass, Dir
});
for (PsiAnonymousClass candidate : anonymousCandidates) {
ProgressManager.getInstance().checkCanceled();
ProgressManager.checkCanceled();
if (!consumer.process(candidate)) return false;
}
@@ -21,8 +21,8 @@ import com.intellij.openapi.util.NotNullLazyValue;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiPackage;
import com.intellij.psi.PsiReference;
import com.intellij.psi.xml.XmlTag;
import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.psi.xml.XmlTag;
import org.jetbrains.annotations.NotNull;
import java.util.*;
@@ -88,7 +88,7 @@ public class JavaClassListReferenceProvider extends JavaClassReferenceProvider {
return true;
}
}.getAllReferences()));
ProgressManager.getInstance().checkCanceled();
ProgressManager.checkCanceled();
}
}
return results.toArray(new PsiReference[results.size()]);
@@ -248,7 +248,7 @@ public class InlineUtil {
public void run() {
ReferencesSearch.search(method).forEach(new Processor<PsiReference>() {
public boolean process(final PsiReference psiReference) {
ProgressManager.getInstance().checkCanceled();
ProgressManager.checkCanceled();
if (getTailCallType(psiReference) == TailCallType.None) {
nonTailCallUsages.add(psiReference);
return false;
@@ -204,7 +204,7 @@ public class ClassInheritorsSearch extends ExtensibleQueryFactory<PsiClass, Clas
stack.push(baseClass);
final GlobalSearchScope scope = GlobalSearchScope.allScope(baseClass.getProject());
while (!stack.isEmpty()) {
ProgressManager.getInstance().checkCanceled();
ProgressManager.checkCanceled();
final PsiClass psiClass = stack.pop();
if (!processed.add(psiClass)) continue;
@@ -25,7 +25,7 @@ import com.intellij.psi.templateLanguages.OuterLanguageElement;
*/
public abstract class PsiElementVisitor {
public void visitElement(PsiElement element) {
ProgressManager.getInstance().checkCanceled();
ProgressManager.checkCanceled();
}
public void visitFile(PsiFile file) {
@@ -39,7 +39,7 @@ public abstract class PsiRecursiveElementVisitor extends PsiElementVisitor {
public void visitElement(final PsiElement element) {
level++;
if (level < MAX_LEVEL_DEPTH) {
ProgressManager.getInstance().checkCanceled();
ProgressManager.checkCanceled();
element.acceptChildren(this);
}
@@ -40,7 +40,7 @@ public abstract class PsiRecursiveElementWalkingVisitor extends PsiElementVisito
}
public void visitElement(final PsiElement element) {
ProgressManager.getInstance().checkCanceled();
ProgressManager.checkCanceled();
myWalkingState.elementStarted(element);
}
@@ -468,7 +468,7 @@ public class TextPainter implements Printable {
private boolean drawString(Graphics2D g, int end, int colNumber, Point2D position, Rectangle2D clip, Color backColor,
Color underscoredColor) {
ProgressManager.getInstance().checkCanceled();
ProgressManager.checkCanceled();
if (myOffset >= end)
return true;
char[] text = myDocument.getCharsSequence().toString().toCharArray(); //TODO: Make drawTabbedString work with CharSequence instead.
@@ -267,7 +267,7 @@ public class CompletionProgressIndicator extends ProgressIndicatorBase implement
public synchronized void addItem(final LookupElement item) {
if (!isRunning()) return;
ProgressManager.getInstance().checkCanceled();
ProgressManager.checkCanceled();
final boolean unitTestMode = ApplicationManager.getApplication().isUnitTestMode();
if (!unitTestMode) {
@@ -40,9 +40,9 @@ import com.intellij.psi.impl.source.resolve.reference.impl.providers.FileInfoMan
import com.intellij.psi.impl.source.resolve.reference.impl.providers.FileReference;
import com.intellij.psi.impl.source.resolve.reference.impl.providers.FileReferenceOwner;
import com.intellij.psi.impl.source.resolve.reference.impl.providers.PsiFileSystemItemUtil;
import com.intellij.psi.search.FilenameIndex;
import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.psi.search.ProjectScope;
import com.intellij.psi.search.FilenameIndex;
import com.intellij.util.*;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -132,7 +132,7 @@ public class FilePathCompletionContributor extends CompletionContributor {
final GlobalSearchScope scope = ProjectScope.getProjectScope(project);
for (final String name : resultNames) {
ProgressManager.getInstance().checkCanceled();
ProgressManager.checkCanceled();
final PsiFile[] files = ApplicationManager.getApplication().runReadAction(new Computable<PsiFile[]>() {
public PsiFile[] compute() {
@@ -80,7 +80,7 @@ public class CollectHighlightsUtil {
PsiElement child = element.getFirstChild();
if (child != null) {
ProgressManager.getInstance().checkCanceled();
ProgressManager.checkCanceled();
// composite element
while (child != null) {
if (offset > endOffset) break;
@@ -35,8 +35,8 @@ import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.openapi.progress.ProgressManager;
import com.intellij.openapi.project.DumbAware;
import com.intellij.openapi.project.DumbService;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.project.IndexNotReadyException;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.TextRange;
import com.intellij.psi.*;
import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil;
@@ -101,7 +101,7 @@ public class LineMarkersPass extends ProgressableTextEditorHighlightingPass impl
public void addLineMarkers(List<PsiElement> elements, final List<LineMarkerProvider> providers, final List<LineMarkerInfo> result) throws ProcessCanceledException {
ApplicationManager.getApplication().assertReadAccessAllowed();
for (PsiElement element : elements) {
ProgressManager.getInstance().checkCanceled();
ProgressManager.checkCanceled();
for (LineMarkerProvider provider: providers) {
LineMarkerInfo info = provider.getLineMarkerInfo(element);
@@ -166,4 +166,4 @@ public class LineMarkersPass extends ProgressableTextEditorHighlightingPass impl
// do not show progress of visible highlighters update
return myUpdateAll ? super.getProgress() : -1;
}
}
}
@@ -84,13 +84,13 @@ public class ShowAutoImportPass extends TextEditorHighlightingPass {
int caretOffset = myEditor.getCaretModel().getOffset();
for (int i = visibleHighlights.size() - 1; i >= 0; i--) {
ProgressManager.getInstance().checkCanceled();
ProgressManager.checkCanceled();
HighlightInfo info = visibleHighlights.get(i);
if (info.startOffset <= caretOffset && showAddImportHint(info)) return;
}
for (int i = 0; i < visibleHighlights.size(); i++) {
ProgressManager.getInstance().checkCanceled();
ProgressManager.checkCanceled();
HighlightInfo info = visibleHighlights.get(i);
if (info.startOffset > caretOffset && showAddImportHint(info)) return;
}
@@ -134,4 +134,4 @@ public class ShowAutoImportPass extends TextEditorHighlightingPass {
hintText += " " + KeymapUtil.getFirstKeyboardShortcutText(ActionManager.getInstance().getAction(IdeActions.ACTION_SHOW_INTENTION_ACTIONS));
return hintText;
}
}
}
@@ -86,7 +86,7 @@ class UpdateFoldRegionsOperation implements Runnable {
List<FoldRegion> newRegions = arrayList();
for (final Map.Entry<PsiElement, FoldingDescriptor> entry : myElementsToFoldMap.entrySet()) {
ProgressManager.getInstance().checkCanceled();
ProgressManager.checkCanceled();
PsiElement element = entry.getKey();
final FoldingDescriptor descriptor = entry.getValue();
FoldingGroup group = descriptor.getGroup();
@@ -437,7 +437,7 @@ public class WolfTheProblemSolverImpl extends WolfTheProblemSolver {
}
}
for (final Condition<VirtualFile> filter : myFilters) {
ProgressManager.getInstance().checkCanceled();
ProgressManager.checkCanceled();
if (filter.value(virtualFile)) {
return true;
}
@@ -623,7 +623,7 @@ public class GlobalInspectionContextImpl implements GlobalInspectionContext {
public void incrementJobDoneAmount(JobDescriptor job, String message) {
if (myProgressIndicator == null) return;
ProgressManager.getInstance().checkCanceled();
ProgressManager.checkCanceled();
int old = job.getDoneAmount();
job.setDoneAmount(old + 1);
@@ -167,7 +167,7 @@ public class InspectionToolRegistrar {
ensureInitialized();
InspectionTool[] tools = new InspectionTool[myInspectionToolFactories.size()];
for(int i=0; i<tools.length; i++) {
ProgressManager.getInstance().checkCanceled();
ProgressManager.checkCanceled();
tools [i] = myInspectionToolFactories.get(i).create();
}
buildInspectionIndex(tools);
@@ -87,7 +87,7 @@ public class HTMLExporter {
final String fullPath = folder + File.separator + fileName;
if (indicator != null) {
ProgressManager.getInstance().checkCanceled();
ProgressManager.checkCanceled();
indicator.setText(InspectionsBundle.message("inspection.export.generating.html.for", fullPath));
}
@@ -183,7 +183,7 @@ public class StubBasedPsiElementBase<T extends StubElement> extends ASTDelegateP
}
public T getStub() {
ProgressManager.getInstance().checkCanceled(); // Hope, this is called often
ProgressManager.checkCanceled(); // Hope, this is called often
return myStub;
}
@@ -105,7 +105,7 @@ public class PomReferenceServiceImpl extends PomReferenceService {
}
private List<PomReference> getReferencesFromProviders(PsiElement context, final Integer offset) {
ProgressManager.getInstance().checkCanceled();
ProgressManager.checkCanceled();
assert context.isValid() : "Invalid context: " + context;
final List<Trinity<PomReferenceProvider, ProcessingContext, Double>> providers = getPairsByElement(context, offset);
@@ -54,7 +54,7 @@ public class VfsIndexer {
}
private static void _writeFileIndex(DataOutputStream out, VirtualFile file, VirtualFileFilter filter, List<VirtualFile> result) throws IOException {
ProgressManager.getInstance().checkCanceled();
ProgressManager.checkCanceled();
result.add(file);
if (out != null){
@@ -101,7 +101,7 @@ public class VfsIndexer {
}
private static void _readFileIndex(DataInputStream in, VirtualFile file, VirtualFileFilter filter, List<VirtualFile> result) throws IOException {
ProgressManager.getInstance().checkCanceled();
ProgressManager.checkCanceled();
result.add(file);
int childrenCount = in.readInt();
@@ -196,7 +196,7 @@ public class PsiDirectoryImpl extends PsiElementBase implements PsiDirectory {
public boolean processChildren(PsiElementProcessor<PsiFileSystemItem> processor) {
checkValid();
ProgressManager.getInstance().checkCanceled();
ProgressManager.checkCanceled();
for (VirtualFile vFile : myFile.getChildren()) {
if (processor instanceof PsiFileSystemItemProcessor &&
@@ -24,13 +24,13 @@ import com.intellij.openapi.util.Key;
import com.intellij.openapi.util.UserDataCache;
import com.intellij.patterns.ElementPattern;
import com.intellij.psi.PsiElement;
import com.intellij.psi.util.CachedValue;
import com.intellij.psi.util.CachedValueProvider;
import com.intellij.psi.filters.ElementFilter;
import com.intellij.psi.filters.position.PatternFilter;
import com.intellij.psi.meta.MetaDataContributor;
import com.intellij.psi.meta.MetaDataRegistrar;
import com.intellij.psi.meta.PsiMetaData;
import com.intellij.psi.util.CachedValue;
import com.intellij.psi.util.CachedValueProvider;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -110,7 +110,7 @@ public class MetaRegistry extends MetaDataRegistrar {
@Nullable
public static PsiMetaData getMetaBase(final PsiElement element) {
ProgressManager.getInstance().checkCanceled();
ProgressManager.checkCanceled();
return ourCachedMetaCache.get(META_DATA_KEY, element, null).getValue();
}
@@ -61,7 +61,7 @@ public class CachesBasedRefSearcher implements QueryExecutor<PsiReference, Refer
final TextOccurenceProcessor processor = new TextOccurenceProcessor() {
public boolean execute(PsiElement element, int offsetInElement) {
ProgressManager.getInstance().checkCanceled();
ProgressManager.checkCanceled();
if (DEBUG) {
System.out.println("!!! About to check "+element);
}
@@ -188,7 +188,7 @@ public class IndexPatternSearcher implements QueryExecutor<IndexPatternOccurrenc
Processor<IndexPatternOccurrence> consumer) {
Pattern pattern = indexPattern.getPattern();
if (pattern != null) {
ProgressManager.getInstance().checkCanceled();
ProgressManager.checkCanceled();
CharSequence input = new CharSequenceSubSequence(chars, commentStart, commentEnd);
Matcher matcher = pattern.matcher(input);
@@ -209,7 +209,7 @@ public class IndexPatternSearcher implements QueryExecutor<IndexPatternOccurrenc
}
}
ProgressManager.getInstance().checkCanceled();
ProgressManager.checkCanceled();
}
}
return true;
@@ -124,7 +124,7 @@ public class LowLevelSearchUtil {
final PsiElement scope,
final StringSearcher searcher,
final boolean ignoreInjectedPsi) {
ProgressManager.getInstance().checkCanceled();
ProgressManager.checkCanceled();
PsiFile file = scope.getContainingFile();
final CharSequence buffer = file.getViewProvider().getContents();
@@ -262,7 +262,7 @@ public class PsiSearchHelperImpl implements PsiSearchHelper {
PsiElement[] psiRoots = file.getPsiRoots();
Set<PsiElement> processed = new HashSet<PsiElement>(psiRoots.length * 2, (float)0.5);
for (PsiElement psiRoot : psiRoots) {
ProgressManager.getInstance().checkCanceled();
ProgressManager.checkCanceled();
if (!processed.add(psiRoot)) continue;
if (!LowLevelSearchUtil.processElementsContainingWordInElement(processor, psiRoot, searcher, false)) {
canceled.set(true);
@@ -99,7 +99,7 @@ public class ResolveCache {
Map<? super TRef,Reference<TResult>>[] maps,
boolean needToPreventRecursion,
boolean incompleteCode) {
ProgressManager.getInstance().checkCanceled();
ProgressManager.checkCanceled();
int clearCountOnStart = myClearCount.intValue();
@@ -18,11 +18,12 @@ package com.intellij.psi.impl.source.resolve.reference;
import com.intellij.codeInsight.completion.LegacyCompletionContributor;
import com.intellij.openapi.components.ServiceManager;
import com.intellij.openapi.extensions.Extensions;
import com.intellij.openapi.progress.ProgressManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Trinity;
import com.intellij.openapi.extensions.Extensions;
import com.intellij.patterns.*;
import com.intellij.pom.references.PomReferenceProvider;
import com.intellij.psi.*;
import com.intellij.psi.filters.ElementFilter;
import com.intellij.psi.filters.position.FilterPattern;
@@ -30,7 +31,6 @@ import com.intellij.util.*;
import com.intellij.util.containers.ConcurrentWeakHashMap;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.containers.MultiMap;
import com.intellij.pom.references.PomReferenceProvider;
import gnu.trove.THashSet;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -216,7 +216,7 @@ public class ReferenceProvidersRegistry extends PsiReferenceRegistrar {
}
public static PsiReference[] getReferencesFromProviders(PsiElement context, @NotNull Class clazz){
ProgressManager.getInstance().checkCanceled();
ProgressManager.checkCanceled();
assert context.isValid() : "Invalid context: " + context;
final List<Trinity<PsiReferenceProvider, ProcessingContext, Double>> providers = getInstance(context.getProject()).getPairsByElement(context, clazz);
@@ -278,7 +278,7 @@ public abstract class CompositePsiElement extends CompositeElement implements Ps
}
public PsiElement getPsi() {
ProgressManager.getInstance().checkCanceled(); // We hope this method is being called often enough to cancel daemon processes smoothly
ProgressManager.checkCanceled(); // We hope this method is being called often enough to cancel daemon processes smoothly
return this;
}
@@ -283,7 +283,7 @@ public class LazyParseablePsiElement extends LazyParseableElement implements Psi
}
public PsiElement getPsi() {
ProgressManager.getInstance().checkCanceled(); // We hope this method is being called often enough to cancel daemon processes smoothly
ProgressManager.checkCanceled(); // We hope this method is being called often enough to cancel daemon processes smoothly
return this;
}
@@ -38,7 +38,16 @@ public abstract class ProgressManager {
public abstract ProgressIndicator getProgressIndicator();
public abstract void checkCanceled() throws ProcessCanceledException;
protected 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
if (ourNeedToCheckCancel) {
ourNeedToCheckCancel = false;
getInstance().doCheckCanceled();
}
}
protected abstract void doCheckCanceled() throws ProcessCanceledException;
@Deprecated
public abstract void registerFunComponentProvider(ProgressFunComponentProvider provider);
@@ -46,7 +46,6 @@ public class ProgressManagerImpl extends ProgressManager {
private final AtomicInteger myCurrentProgressCount = new AtomicInteger(0);
private final AtomicInteger myCurrentModalProgressCount = new AtomicInteger(0);
private static volatile boolean ourNeedToCheckCancel = false;
private static volatile int ourLockedCheckCounter = 0;
private final List<ProgressFunComponentProvider> myFunComponentProviders = new ArrayList<ProgressFunComponentProvider>();
@NonNls private static final String NAME = "Progress Cancel Checker";
@@ -68,28 +67,25 @@ public class ProgressManagerImpl extends ProgressManager {
}
}
public void checkCanceled() {
// Q: how about 2 cancelable progresses in time??
if (ourNeedToCheckCancel) { // smart optimization!
ourNeedToCheckCancel = false;
final ProgressIndicator progress = getProgressIndicator();
if (progress != null) {
try {
progress.checkCanceled();
}
catch (ProcessCanceledException e) {
if (Thread.holdsLock(PsiLock.LOCK)) {
ourLockedCheckCounter++;
if (ourLockedCheckCounter > 10) {
ourLockedCheckCounter = 0;
ourNeedToCheckCancel = true;
}
}
else {
@Override
protected void doCheckCanceled() throws ProcessCanceledException {
final ProgressIndicator progress = getProgressIndicator();
if (progress != null) {
try {
progress.checkCanceled();
}
catch (ProcessCanceledException e) {
if (Thread.holdsLock(PsiLock.LOCK)) {
ourLockedCheckCounter++;
if (ourLockedCheckCounter > 10) {
ourLockedCheckCounter = 0;
progress.checkCanceled();
ourNeedToCheckCancel = true;
}
}
else {
ourLockedCheckCounter = 0;
progress.checkCanceled();
}
}
}
}
@@ -26,8 +26,8 @@ import com.intellij.openapi.progress.ProcessCanceledException;
import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.openapi.progress.ProgressManager;
import com.intellij.openapi.progress.Task;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.project.DumbModeAction;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.MessageType;
import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.util.Disposer;
@@ -38,13 +38,13 @@ import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.wm.ToolWindow;
import com.intellij.openapi.wm.ToolWindowId;
import com.intellij.openapi.wm.ToolWindowManager;
import com.intellij.psi.PsiElement;
import com.intellij.ui.content.Content;
import com.intellij.usageView.UsageViewBundle;
import com.intellij.usages.*;
import com.intellij.usages.rules.PsiElementUsage;
import com.intellij.util.Processor;
import com.intellij.util.ui.RangeBlinker;
import com.intellij.psi.PsiElement;
import com.intellij.xml.util.XmlStringUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -213,7 +213,7 @@ public class UsageViewManagerImpl extends UsageViewManager {
public void checkSearchCanceled() throws ProcessCanceledException {
if (searchHasBeenCancelled()) throw new ProcessCanceledException();
ProgressManager.getInstance().checkCanceled();
ProgressManager.checkCanceled();
}
private class SearchForUsagesRunnable implements Runnable {
@@ -221,7 +221,7 @@ public class ChangeDiffRequest implements ChangeRequestChain {
@NotNull
private DiffContent createContent(final ContentRevision revision) {
ProgressManager.getInstance().checkCanceled();
ProgressManager.checkCanceled();
if (revision == null) return new SimpleContent("");
if (revision instanceof CurrentContentRevision) {
final CurrentContentRevision current = (CurrentContentRevision)revision;
@@ -364,7 +364,7 @@ public class AntTypeDefImpl extends AntTaskImpl implements AntTypeDef {
if (classname == null || name == null || name.length() == 0) {
return null;
}
ProgressManager.getInstance().checkCanceled();
ProgressManager.checkCanceled();
final List<URL> urls = getClassPathUrls();
Class clazz = null;
final ClassLoader loader = getClassLoader(urls);
@@ -15,10 +15,11 @@
*/
package com.intellij.cvsSupport2.cvsoperations.common;
import com.intellij.CvsBundle;
import com.intellij.cvsSupport2.CvsUtil;
import com.intellij.cvsSupport2.application.CvsEntriesManager;
import com.intellij.cvsSupport2.connections.CvsEnvironment;
import com.intellij.cvsSupport2.util.CvsVfsUtil;
import com.intellij.cvsSupport2.CvsUtil;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.openapi.progress.ProgressManager;
@@ -27,7 +28,6 @@ import com.intellij.openapi.roots.ProjectRootManager;
import com.intellij.openapi.vcs.FilePath;
import com.intellij.openapi.vfs.VfsUtil;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.CvsBundle;
import java.io.File;
import java.util.*;
@@ -139,13 +139,13 @@ public class FindAllRoots {
private void setText(final String text) {
if (myProgress == null) return;
myProgress.setText(text);
ProgressManager.getInstance().checkCanceled();
ProgressManager.checkCanceled();
}
private void setText2(final String text) {
if (myProgress == null) return;
myProgress.setText2(text);
ProgressManager.getInstance().checkCanceled();
ProgressManager.checkCanceled();
}
private void process(VirtualFile root) {
@@ -174,7 +174,7 @@ public class FindAllRoots {
private void setFraction() {
if (myProgress == null) return;
myProgress.setFraction((double)myProcessedFiles / (double)mySuitableFiles);
ProgressManager.getInstance().checkCanceled();
ProgressManager.checkCanceled();
}
public Collection<File> getDirectoriesToBeUpdated() {
@@ -15,6 +15,7 @@
*/
package com.intellij.cvsSupport2.cvsoperations.javacvsSpecificImpls;
import com.intellij.CvsBundle;
import com.intellij.cvsSupport2.application.CvsEntriesManager;
import com.intellij.cvsSupport2.config.CvsApplicationLevelConfiguration;
import com.intellij.cvsSupport2.cvsstatuses.CvsStatusProvider;
@@ -24,7 +25,6 @@ import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.openapi.progress.ProgressManager;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.CvsBundle;
import org.netbeans.lib.cvsclient.admin.AdminReader;
import org.netbeans.lib.cvsclient.admin.Entry;
import org.netbeans.lib.cvsclient.admin.IAdminReader;
@@ -47,7 +47,7 @@ public class AdminReaderOnCache implements IAdminReader {
private final CvsEntriesManager myCvsEntriesManager = CvsEntriesManager.getInstance();
public Entry getEntry(final AbstractFileObject fileObject, final ICvsFileSystem cvsFileSystem) throws IOException {
ProgressManager.getInstance().checkCanceled();
ProgressManager.checkCanceled();
setProgressText(CvsBundle.message("progress.text.scanning.directory", cvsFileSystem.getLocalFileSystem().getFile(fileObject.getParent()).getAbsolutePath()));
File file = cvsFileSystem.getAdminFileSystem().getFile(fileObject);
Entry result = myCvsEntriesManager.getEntryFor(CvsVfsUtil.findFileByIoFile(file.getParentFile()), file.getName());
@@ -67,7 +67,7 @@ public class AdminReaderOnCache implements IAdminReader {
public Collection<Entry> getEntries(final DirectoryObject directoryObject, final ICvsFileSystem cvsFileSystem) throws IOException {
setProgressText(CvsBundle.message("progress.text.scanning.directory", cvsFileSystem.getLocalFileSystem().getFile(directoryObject).getAbsolutePath()));
ProgressManager.getInstance().checkCanceled();
ProgressManager.checkCanceled();
File parent = cvsFileSystem.getAdminFileSystem().getFile(directoryObject);
Collection<Entry> entries = myCvsEntriesManager.getEntriesIn(CvsVfsUtil.findFileByIoFile(parent));
ArrayList<Entry> copy = new ArrayList<Entry>();
@@ -19,14 +19,14 @@ import com.intellij.compiler.ant.*;
import com.intellij.compiler.ant.taskdefs.PatternSetRef;
import com.intellij.compiler.ant.taskdefs.Property;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.progress.ProgressManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.roots.ContentIterator;
import com.intellij.openapi.roots.ModuleRootManager;
import com.intellij.openapi.roots.ModuleFileIndex;
import com.intellij.openapi.roots.ModuleRootManager;
import com.intellij.openapi.roots.libraries.Library;
import com.intellij.openapi.util.Pair;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.progress.ProgressManager;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.plugins.groovy.GroovyFileType;
import org.jetbrains.plugins.groovy.GroovyFileTypeLoader;
@@ -109,7 +109,7 @@ public class GroovyAntCustomCompilerProvider extends ChunkCustomCompilerExtensio
final Set<String> scriptExtensions = GroovyFileTypeLoader.getCustomGroovyScriptExtensions();
final ContentIterator groovyFileSearcher = new ContentIterator() {
public boolean processFile(VirtualFile fileOrDir) {
ProgressManager.getInstance().checkCanceled();
ProgressManager.checkCanceled();
if (isCompilableGroovyFile(fileOrDir, scriptExtensions)) {
return false;
}
@@ -168,7 +168,7 @@ public class GroovyDslFileIndex extends ScalarIndexExtension<String> {
try {
while (count > 0) {
ProgressManager.getInstance().checkCanceled();
ProgressManager.checkCanceled();
final Pair<GroovyFile, GroovyDslExecutor> pair = queue.poll(20, TimeUnit.MILLISECONDS);
if (pair != null) {
final GroovyDslExecutor executor = pair.second;
@@ -18,9 +18,9 @@ package com.intellij.psi.impl.search;
import com.intellij.lang.properties.psi.Property;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.fileTypes.StdFileTypes;
import com.intellij.openapi.progress.ProgressManager;
import com.intellij.openapi.util.Computable;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.progress.ProgressManager;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiManager;
import com.intellij.psi.PsiReference;
@@ -57,13 +57,13 @@ public class PropertyReferenceViaLastWordSearcher implements QueryExecutor<PsiRe
final PsiSearchHelper helper = PsiManager.getInstance(refElement.getProject()).getSearchHelper();
final TextOccurenceProcessor processor = new TextOccurenceProcessor() {
public boolean execute(PsiElement element, int offsetInElement) {
ProgressManager.getInstance().checkCanceled();
ProgressManager.checkCanceled();
final PsiReference[] refs = element.getReferences();
for (PsiReference ref : refs) {
if (ref.getRangeInElement().contains(offsetInElement) && ref.isReferenceTo(refElement)) {
return consumer.process(ref);
}
ProgressManager.getInstance().checkCanceled();
ProgressManager.checkCanceled();
}
return true;
}
@@ -371,7 +371,7 @@ public class SvnBranchConfiguration {
logClient.doList(branchesUrl, SVNRevision.UNDEFINED, SVNRevision.HEAD, false, new ISVNDirEntryHandler() {
public void handleDirEntry(final SVNDirEntry dirEntry) throws SVNException {
if (underProgress) {
ProgressManager.getInstance().checkCanceled();
ProgressManager.checkCanceled();
}
final SVNURL currentUrl = dirEntry.getURL();
if (! branchesUrl.equals(currentUrl)) {
@@ -73,7 +73,7 @@ public class ResolveAction extends BasicAction {
if (file.isDirectory()) {
ProjectLevelVcsManager.getInstance(project).iterateVcsRoot(file, new Processor<FilePath>() {
public boolean process(final FilePath filePath) {
ProgressManager.getInstance().checkCanceled();
ProgressManager.checkCanceled();
VirtualFile fileOrDir = filePath.getVirtualFile();
if (fileOrDir != null && !fileOrDir.isDirectory() && isEnabled(project, activeVcs, fileOrDir) && !fileList.contains(fileOrDir)) {
fileList.add(fileOrDir);
@@ -128,7 +128,7 @@ public class FormReferencesSearcher implements QueryExecutor<PsiReference, Refer
List<PsiFile> files = FormClassIndex.findFormsBoundToClass(manager.getProject(), name, scope);
for (PsiFile file : files) {
ProgressManager.getInstance().checkCanceled();
ProgressManager.checkCanceled();
if (file.getFileType() != StdFileTypes.GUI_DESIGNER_FORM) continue;
if (!processReferences(processor, file, name, element, filterScope)) return false;
@@ -156,7 +156,7 @@ public class FormReferencesSearcher implements QueryExecutor<PsiReference, Refer
final List<PsiFile> files = FormClassIndex.findFormsBoundToClass(containingClass, scope);
for (PsiFile file : files) {
ProgressManager.getInstance().checkCanceled();
ProgressManager.checkCanceled();
if (file.getFileType() != StdFileTypes.GUI_DESIGNER_FORM) continue;
if (!processReferences(processor, file, fieldName, field, filterScope)) return false;
@@ -237,7 +237,7 @@ public class FormReferencesSearcher implements QueryExecutor<PsiReference, Refer
PsiFile[] files = fileSet.toArray(new PsiFile[fileSet.size()]);
for (PsiFile file : files) {
ProgressManager.getInstance().checkCanceled();
ProgressManager.checkCanceled();
if (file.getFileType() != StdFileTypes.GUI_DESIGNER_FORM) continue;
if (!processReferences(processor, file, name, property, filterScope)) return false;
@@ -261,7 +261,7 @@ public class FormReferencesSearcher implements QueryExecutor<PsiReference, Refer
PsiFile[] files = manager.getCacheManager().getFilesWithWord(baseName, UsageSearchContext.IN_PLAIN_TEXT, scope, true);
for (PsiFile file : files) {
ProgressManager.getInstance().checkCanceled();
ProgressManager.checkCanceled();
if (file.getFileType() != StdFileTypes.GUI_DESIGNER_FORM) continue;
if (!processReferences(processor, file, baseName, propFile, filterScope)) return false;
@@ -311,7 +311,7 @@ public abstract class DomInvocationHandler<T extends AbstractDomChildDescription
}
public boolean isValid() {
ProgressManager.getInstance().checkCanceled();
ProgressManager.checkCanceled();
final DomParentStrategy parentStrategy = getParentStrategy();
if (!parentStrategy.isValid()) {
return false;
@@ -406,12 +406,12 @@ public abstract class DomInvocationHandler<T extends AbstractDomChildDescription
}
public void accept(final DomElementVisitor visitor) {
ProgressManager.getInstance().checkCanceled();
ProgressManager.checkCanceled();
myManager.getVisitorDescription(visitor.getClass()).acceptElement(visitor, getProxy());
}
public void acceptChildren(DomElementVisitor visitor) {
ProgressManager.getInstance().checkCanceled();
ProgressManager.checkCanceled();
final DomElement element = getProxy();
for (final AbstractDomChildrenDescription description : getGenericInfo().getChildrenDescriptions()) {
for (final DomElement value : description.getValues(element)) {
@@ -206,7 +206,7 @@ public class DomUtil {
}
ProgressManager.getInstance().checkCanceled();
ProgressManager.checkCanceled();
if (parent instanceof GenericAttributeValue) return Collections.emptyList();
@@ -24,8 +24,8 @@ import com.intellij.lang.folding.LanguageFolding;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.progress.ProgressManager;
import com.intellij.openapi.util.TextRange;
import com.intellij.openapi.project.DumbAware;
import com.intellij.openapi.util.TextRange;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiWhiteSpace;
import com.intellij.psi.tree.TokenSet;
@@ -34,8 +34,8 @@ import com.intellij.xml.util.XmlTagUtil;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.List;
import java.util.Arrays;
import java.util.List;
/**
* Created by IntelliJ IDEA.
@@ -96,7 +96,7 @@ public class XmlFoldingBuilder implements FoldingBuilder, DumbAware {
final PsiElement[] children = tag.getChildren();
for (PsiElement child : children) {
ProgressManager.getInstance().checkCanceled();
ProgressManager.checkCanceled();
if (child instanceof XmlTag || child instanceof XmlConditionalSection) {
addElementsToFold(foldings, (XmlElement)child, document);
@@ -108,7 +108,7 @@ public class XmlFoldingBuilder implements FoldingBuilder, DumbAware {
final PsiElement[] grandChildren = child.getChildren();
for (PsiElement grandChild : grandChildren) {
ProgressManager.getInstance().checkCanceled();
ProgressManager.checkCanceled();
if (grandChild instanceof XmlComment) {
addToFold(foldings, grandChild, document);
@@ -116,7 +116,7 @@ public class XmlTagImpl extends XmlElementImpl implements XmlTag {
@NotNull
public PsiReference[] getReferences() {
ProgressManager.getInstance().checkCanceled();
ProgressManager.checkCanceled();
final ASTNode startTagName = XmlChildRole.START_TAG_NAME_FINDER.findChild(this);
if (startTagName == null) return PsiReference.EMPTY_ARRAY;
final ASTNode endTagName = XmlChildRole.CLOSING_TAG_NAME_FINDER.findChild(this);