call allHighlightsForRangeAreProduced((0,3)) even in case of runVisitors() called for visible element with range (0,3) which generated some info, then runVisitors() called for the the file with range (0,3).

This commit is contained in:
Alexey Kudravtsev
2016-12-14 12:05:58 +03:00
parent 7eadc40a19
commit caa5ca99ec
2 changed files with 18 additions and 14 deletions
+1 -1
View File
@@ -64,7 +64,7 @@
<expected>OK</expected>
</test>
<test verify="false">
<pattern><![CDATA[<warning descr="Empty group">(|)</warning>\n]]></pattern>
<pattern><![CDATA[<warning descr="Empty group">(|)</warning>]]></pattern>
<expected>OK</expected>
</test>
<test verify="false">
@@ -295,12 +295,16 @@ public class GeneralHighlightingPass extends ProgressableTextEditorHighlightingP
final int chunkSize = Math.max(1, (elements1.size()+elements2.size()) / 100); // one percent precision is enough
boolean success = analyzeByVisitors(visitors, holder, 0, () -> {
runVisitors(elements1, ranges1, chunkSize, progress, skipParentsSet, holder, insideResult, outsideResult, forceHighlightParents, visitors);
Stack<TextRange> nestedRange = new Stack<>();
Stack<List<HighlightInfo>> nestedInfos = new Stack<>();
runVisitors(elements1, ranges1, chunkSize, progress, skipParentsSet, holder, insideResult, outsideResult, forceHighlightParents, visitors,
nestedRange, nestedInfos);
final TextRange priorityIntersection = myPriorityRange.intersection(myRestrictRange);
if ((!elements1.isEmpty() || !insideResult.isEmpty()) && priorityIntersection != null) { // do not apply when there were no elements to highlight
myHighlightInfoProcessor.highlightsInsideVisiblePartAreProduced(myHighlightingSession, insideResult, myPriorityRange, myRestrictRange, getId());
}
runVisitors(elements2, ranges2, chunkSize, progress, skipParentsSet, holder, insideResult, outsideResult, forceHighlightParents, visitors);
runVisitors(elements2, ranges2, chunkSize, progress, skipParentsSet, holder, insideResult, outsideResult, forceHighlightParents, visitors,
nestedRange, nestedInfos);
});
List<HighlightInfo> postInfos = new ArrayList<>(holder.size());
// there can be extra highlights generated in PostHighlightVisitor
@@ -330,17 +334,17 @@ public class GeneralHighlightingPass extends ProgressableTextEditorHighlightingP
}
private void runVisitors(@NotNull List<PsiElement> elements,
@NotNull List<ProperTextRange> ranges,
int chunkSize,
@NotNull ProgressIndicator progress,
@NotNull Set<PsiElement> skipParentsSet,
@NotNull HighlightInfoHolder holder,
@NotNull List<HighlightInfo> insideResult,
@NotNull List<HighlightInfo> outsideResult,
boolean forceHighlightParents,
@NotNull HighlightVisitor[] visitors) {
Stack<TextRange> nestedRange = new Stack<>();
Stack<List<HighlightInfo>> nestedInfos = new Stack<>();
@NotNull List<ProperTextRange> ranges,
int chunkSize,
@NotNull ProgressIndicator progress,
@NotNull Set<PsiElement> skipParentsSet,
@NotNull HighlightInfoHolder holder,
@NotNull List<HighlightInfo> insideResult,
@NotNull List<HighlightInfo> outsideResult,
boolean forceHighlightParents,
@NotNull HighlightVisitor[] visitors,
@NotNull Stack<TextRange> nestedRange,
@NotNull Stack<List<HighlightInfo>> nestedInfos) {
boolean failed = false;
int nextLimit = chunkSize;
for (int i = 0; i < elements.size(); i++) {