Browse Source

Fixed vb.net syntax coloring bug

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@1480 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Mike Krüger 19 years ago
parent
commit
406e362462
  1. 2
      src/Libraries/ICSharpCode.TextEditor/Project/Resources/Mode.xsd
  2. 2
      src/Libraries/ICSharpCode.TextEditor/Project/Resources/VBNET-Mode.xshd
  3. 4
      src/Libraries/ICSharpCode.TextEditor/Project/Src/Document/HighlightingStrategy/DefaultHighlightingStrategy.cs
  4. 23
      src/Libraries/ICSharpCode.TextEditor/Project/Src/Document/HighlightingStrategy/Span.cs
  5. 10
      src/Libraries/ICSharpCode.TextEditor/Project/Src/Document/LineManager/LineSegment.cs

2
src/Libraries/ICSharpCode.TextEditor/Project/Resources/Mode.xsd

@ -94,6 +94,7 @@ @@ -94,6 +94,7 @@
<xsd:complexType name="Begin">
<xsd:simpleContent>
<xsd:extension base="xsd:string">
<xsd:attribute name="singleword" type="xsd:boolean" />
<!-- The default rendering style for the Begin symbol. If not specified
the defaul rendering style for the span will be used. -->
<xsd:attribute name="bold" type="xsd:boolean" />
@ -108,6 +109,7 @@ @@ -108,6 +109,7 @@
<xsd:complexType name="End">
<xsd:simpleContent>
<xsd:extension base="xsd:string">
<xsd:attribute name="singleword" type="xsd:boolean" />
<!-- The default rendering style for the End symbol. If not specified
the defaul rendering style for the span will be used. -->
<xsd:attribute name="bold" type="xsd:boolean" />

2
src/Libraries/ICSharpCode.TextEditor/Project/Resources/VBNET-Mode.xshd

@ -39,7 +39,7 @@ @@ -39,7 +39,7 @@
</Span>
<Span name = "LINECOMMENT" bold = "false" italic = "false" color = "Green" stopateol = "true">
<Begin>REM</Begin>
<Begin singleword="true">REM@C</Begin>
</Span>
<KeyWords name = "DataTypes" bold="false" italic="false" color="#6F002F">

4
src/Libraries/ICSharpCode.TextEditor/Project/Src/Document/HighlightingStrategy/DefaultHighlightingStrategy.cs

@ -342,7 +342,7 @@ namespace ICSharpCode.TextEditor.Document @@ -342,7 +342,7 @@ namespace ICSharpCode.TextEditor.Document
// Check if the span state has changed, if so we must re-render the next line
// This check may seem utterly complicated but I didn't want to introduce any function calls
// or alllocations here for perf reasons.
// or allocations here for perf reasons.
if(currentLine.HighlightSpanStack != currentSpanStack) {
if (currentLine.HighlightSpanStack == null) {
processNextLine = false;
@ -618,7 +618,7 @@ namespace ICSharpCode.TextEditor.Document @@ -618,7 +618,7 @@ namespace ICSharpCode.TextEditor.Document
// check for SPAN BEGIN
if (activeRuleSet != null) {
foreach (Span span in activeRuleSet.Spans) {
if (currentLine.MatchExpr(span.Begin, i, document, activeRuleSet.IgnoreCase)) {
if ((!span.IsBeginSingleWord || currentLength == 0) && currentLine.MatchExpr(span.Begin, i, document, activeRuleSet.IgnoreCase)) {
PushCurWord(document, ref markNext, words);
string regex = currentLine.GetRegString(span.Begin, i, document);

23
src/Libraries/ICSharpCode.TextEditor/Project/Src/Document/HighlightingStrategy/Span.cs

@ -31,6 +31,8 @@ namespace ICSharpCode.TextEditor.Document @@ -31,6 +31,8 @@ namespace ICSharpCode.TextEditor.Document
HighlightRuleSet ruleSet = null;
bool noEscapeSequences = false;
bool ignoreCase = false;
bool isBeginSingleWord = false;
bool isEndSingleWord = false;
internal HighlightRuleSet RuleSet {
get {
@ -56,6 +58,18 @@ namespace ICSharpCode.TextEditor.Document @@ -56,6 +58,18 @@ namespace ICSharpCode.TextEditor.Document
}
}
public bool IsBeginSingleWord {
get {
return isBeginSingleWord;
}
}
public bool IsEndSingleWord {
get {
return isEndSingleWord;
}
}
public HighlightColor Color {
get {
return color;
@ -128,9 +142,18 @@ namespace ICSharpCode.TextEditor.Document @@ -128,9 +142,18 @@ namespace ICSharpCode.TextEditor.Document
begin = span["Begin"].InnerText.ToCharArray();
beginColor = new HighlightColor(span["Begin"], color);
if (span["Begin"].HasAttribute("singleword")) {
this.isBeginSingleWord = Boolean.Parse(span["Begin"].GetAttribute("singleword"));
}
if (span["End"] != null) {
end = span["End"].InnerText.ToCharArray();
endColor = new HighlightColor(span["End"], color);
if (span["End"].HasAttribute("singleword")) {
this.isEndSingleWord = Boolean.Parse(span["End"].GetAttribute("singleword"));
}
}
}
}

10
src/Libraries/ICSharpCode.TextEditor/Project/Src/Document/LineManager/LineSegment.cs

@ -168,6 +168,16 @@ namespace ICSharpCode.TextEditor.Document @@ -168,6 +168,16 @@ namespace ICSharpCode.TextEditor.Document
++i;
if (i < expr.Length) {
switch (expr[i]) {
case 'C': // match whitespace or punctuation
if (index + j == this.Offset || index + j >= this.Offset + this.Length) {
// nothing (EOL or SOL)
} else {
char ch = document.GetCharAt(this.Offset + index + j);
if (!Char.IsWhiteSpace(ch) && !Char.IsPunctuation(ch)) {
return false;
}
}
break;
case '!': // don't match the following expression
{
StringBuilder whatmatch = new StringBuilder();

Loading…
Cancel
Save