always mark this pass as up-to-date after apply; use dirty region LINE_MARKERS for LineMarkerPass to avoid confusion when GHP is finished and applied but LMP doesn't start because region was marked up-to-date already.

This commit is contained in:
Alexey Kudravtsev
2016-08-23 14:53:46 +03:00
parent ef6f4687e2
commit 6b15153548
4 changed files with 17 additions and 15 deletions
@@ -126,6 +126,7 @@ import com.intellij.util.io.storage.HeavyProcessLatch;
import com.intellij.util.ui.UIUtil;
import com.intellij.xml.util.CheckDtdReferencesInspection;
import gnu.trove.THashSet;
import org.intellij.lang.annotations.Language;
import org.jetbrains.annotations.Nls;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
@@ -1423,10 +1424,11 @@ public class DaemonRespondToChangesTest extends DaemonAnalyzerTestCase {
public void testLIPGetAllParentsAfterCodeBlockModification() throws Throwable {
@Language("JAVA")
String text = "class LQF {\n" +
" int f;\n" +
" public void me() {\n" +
" <caret>\n" +
" //<caret>\n" +
" }\n" +
"}";
configureByText(StdFileTypes.JAVA, text);
@@ -1476,12 +1478,12 @@ public class DaemonRespondToChangesTest extends DaemonAnalyzerTestCase {
// inside code block modification
visitedElements.clear();
type("//");
backspace();
backspace();
infos = highlightErrors();
assertEmpty(infos);
PsiMethod method = ((PsiJavaFile)myFile).getClasses()[0].getMethods()[0];
List<PsiElement> methodAndParents =
CollectHighlightsUtil.getElementsInRange(myFile, method.getTextRange().getStartOffset(), method.getTextRange().getEndOffset(), true);
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2015 JetBrains s.r.o.
* Copyright 2000-2016 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -107,6 +107,7 @@ public class FileStatusMap implements Disposable {
setDirtyScope(Pass.UPDATE_ALL, WHOLE_FILE_DIRTY_MARKER);
setDirtyScope(Pass.EXTERNAL_TOOLS, WHOLE_FILE_DIRTY_MARKER);
setDirtyScope(Pass.LOCAL_INSPECTIONS, WHOLE_FILE_DIRTY_MARKER);
setDirtyScope(Pass.LINE_MARKERS, WHOLE_FILE_DIRTY_MARKER);
TextEditorHighlightingPassRegistrarEx registrar = (TextEditorHighlightingPassRegistrarEx) TextEditorHighlightingPassRegistrar.getInstance(project);
for(DirtyScopeTrackingHighlightingPassFactory factory: registrar.getDirtyScopeTrackingFactories()) {
setDirtyScope(factory.getPassId(), WHOLE_FILE_DIRTY_MARKER);
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2015 JetBrains s.r.o.
* Copyright 2000-2016 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -51,19 +51,14 @@ public class LineMarkersPassFactory extends AbstractProjectComponent implements
@Override
@Nullable
public TextEditorHighlightingPass createHighlightingPass(@NotNull PsiFile file, @NotNull final Editor editor) {
TextRange restrictRange = calculateRangeToProcessForSyntaxPass(editor);
TextRange restrictRange = FileStatusMap.getDirtyTextRange(editor, Pass.LINE_MARKERS);
Document document = editor.getDocument();
if (restrictRange == null) return new ProgressableTextEditorHighlightingPass.EmptyPass(myProject, document);
ProperTextRange visibleRange = VisibleHighlightingPassFactory.calculateVisibleRange(editor);
return new LineMarkersPass(myProject, file, document, expandRangeToCoverWholeLines(document, visibleRange), expandRangeToCoverWholeLines(document, restrictRange));
}
@Nullable
private static TextRange calculateRangeToProcessForSyntaxPass(Editor editor) {
return FileStatusMap.getDirtyTextRange(editor, Pass.UPDATE_ALL);
}
static TextRange expandRangeToCoverWholeLines(@NotNull Document document, TextRange textRange) {
private static TextRange expandRangeToCoverWholeLines(@NotNull Document document, TextRange textRange) {
if (textRange == null) return null;
return MarkupModelImpl.roundToLineBoundaries(document, textRange.getStartOffset(), textRange.getEndOffset());
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2015 JetBrains s.r.o.
* Copyright 2000-2016 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -492,10 +492,15 @@ class PassExecutorService implements Disposable {
log(updateProgress, pass, " is canceled during apply, sorry");
return;
}
Document document = pass.getDocument();
try {
if (fileEditor.getComponent().isDisplayable() || ApplicationManager.getApplication().isUnitTestMode()) {
log(updateProgress, pass, " Applied");
pass.applyInformationToEditor();
FileStatusMap fileStatusMap = DaemonCodeAnalyzerEx.getInstanceEx(myProject).getFileStatusMap();
if (document != null) {
fileStatusMap.markFileUpToDate(document, pass.getId());
}
log(updateProgress, pass, " Applied");
}
}
catch (ProcessCanceledException e) {
@@ -503,7 +508,6 @@ class PassExecutorService implements Disposable {
throw e;
}
catch (RuntimeException e) {
Document document = pass.getDocument();
VirtualFile file = document == null ? null : FileDocumentManager.getInstance().getFile(document);
FileType fileType = file == null ? null : file.getFileType();
String message = "Exception while applying information to " + fileEditor + "("+fileType+")";