more checkcanceled

This commit is contained in:
Alexey Kudravtsev
2011-04-19 19:08:05 +04:00
parent 1b402a7b06
commit 7f84ec2f8e
2 changed files with 4 additions and 0 deletions
@@ -46,6 +46,7 @@ import com.intellij.openapi.fileTypes.SyntaxHighlighter;
import com.intellij.openapi.fileTypes.SyntaxHighlighterFactory;
import com.intellij.openapi.progress.ProcessCanceledException;
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;
@@ -498,6 +499,7 @@ public class GeneralHighlightingPass extends ProgressableTextEditorHighlightingP
final TextAttributes defaultAttrs = myGlobalScheme.getAttributes(HighlighterColors.TEXT);
for (Trinity<IElementType, PsiLanguageInjectionHost, TextRange> token : tokens) {
ProgressManager.checkCanceled();
IElementType tokenType = token.getFirst();
PsiLanguageInjectionHost injectionHost = token.getSecond();
TextRange textRange = token.getThird();
@@ -304,11 +304,13 @@ public class InjectedLanguageUtil {
PsiFile hostPsiFile = documentManager.getPsiFile(hostDocument);
assert hostPsiFile != null;
for (RangeMarker rangeMarker : injected) {
ProgressManager.checkCanceled();
PsiElement element = rangeMarker.isValid() ? hostPsiFile.findElementAt(rangeMarker.getStartOffset()) : null;
if (element == null) {
injected.remove(rangeMarker);
continue;
}
ProgressManager.checkCanceled();
// it is here reparse happens and old file contents replaced
enumerate(element, hostPsiFile, new PsiLanguageInjectionHost.InjectedPsiVisitor() {
public void visit(@NotNull PsiFile injectedPsi, @NotNull List<PsiLanguageInjectionHost.Shred> places) {