Browse Source

Fix InvalidOperationException in semantic highlighter.

pull/32/merge
Daniel Grunwald 13 years ago
parent
commit
b2e8ef2a13
  1. 9
      src/AddIns/BackendBindings/CSharpBinding/Project/Src/CSharpSemanticHighlighter.cs

9
src/AddIns/BackendBindings/CSharpBinding/Project/Src/CSharpSemanticHighlighter.cs

@ -340,8 +340,13 @@ namespace CSharpBinding
int endOffset = lineStartOffset + (end.Line == lineNumber ? end.Column - 1 : line.DocumentLine.Length); int endOffset = lineStartOffset + (end.Line == lineNumber ? end.Column - 1 : line.DocumentLine.Length);
if (line.Sections.Count > 0) { if (line.Sections.Count > 0) {
HighlightedSection prevSection = line.Sections.Last(); HighlightedSection prevSection = line.Sections.Last();
if (startOffset < prevSection.Offset + prevSection.Length) if (startOffset < prevSection.Offset + prevSection.Length) {
throw new InvalidOperationException("Cannot create unordered highlighting section"); // The mcs parser sometimes creates strange ASTs with duplicate nodes
// when there are syntax errors (e.g. "int A() public static void Main() {}"),
// so we'll silently ignore duplicate colorization.
return;
//throw new InvalidOperationException("Cannot create unordered highlighting section");
}
} }
line.Sections.Add(new HighlightedSection { line.Sections.Add(new HighlightedSection {
Offset = startOffset, Offset = startOffset,

Loading…
Cancel
Save