Browse Source

Moved IHighlightingStrategy.GetRuleSet and IHighlightingStrategy.GetColor into a separate interface.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@3036 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 18 years ago
parent
commit
5f1c768d62
  1. 15
      src/Libraries/ICSharpCode.TextEditor/Project/Src/Document/HighlightingStrategy/DefaultHighlightingStrategy.cs
  2. 10
      src/Libraries/ICSharpCode.TextEditor/Project/Src/Document/HighlightingStrategy/HighlightRuleSet.cs
  3. 15
      src/Libraries/ICSharpCode.TextEditor/Project/Src/Document/HighlightingStrategy/IHighlightingStrategy.cs

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

@ -13,7 +13,7 @@ using System.Windows.Forms; @@ -13,7 +13,7 @@ using System.Windows.Forms;
namespace ICSharpCode.TextEditor.Document
{
public class DefaultHighlightingStrategy : IHighlightingStrategy
public class DefaultHighlightingStrategy : IHighlightingStrategyUsingRuleSets
{
string name;
List<HighlightRuleSet> rules = new List<HighlightRuleSet>();
@ -174,17 +174,16 @@ namespace ICSharpCode.TextEditor.Document @@ -174,17 +174,16 @@ namespace ICSharpCode.TextEditor.Document
void ResolveExternalReferences()
{
foreach (HighlightRuleSet ruleSet in Rules) {
ruleSet.Highlighter = this;
if (ruleSet.Reference != null) {
IHighlightingStrategy highlighter = HighlightingManager.Manager.FindHighlighter (ruleSet.Reference);
if (highlighter != null) {
ruleSet.Highlighter = highlighter;
} else {
ruleSet.Highlighter = this;
if (highlighter == null)
throw new HighlightingDefinitionInvalidException("The mode defintion " + ruleSet.Reference + " which is refered from the " + this.Name + " mode definition could not be found");
}
} else {
ruleSet.Highlighter = this;
if (highlighter is IHighlightingStrategyUsingRuleSets)
ruleSet.Highlighter = (IHighlightingStrategyUsingRuleSets)highlighter;
else
throw new HighlightingDefinitionInvalidException("The mode defintion " + ruleSet.Reference + " which is refered from the " + this.Name + " mode definition does not implement IHighlightingStrategyUsingRuleSets");
}
}
}

10
src/Libraries/ICSharpCode.TextEditor/Project/Src/Document/HighlightingStrategy/HighlightRuleSet.cs

@ -19,7 +19,6 @@ namespace ICSharpCode.TextEditor.Document @@ -19,7 +19,6 @@ namespace ICSharpCode.TextEditor.Document
ArrayList spans = new ArrayList();
LookupTable prevMarkers;
LookupTable nextMarkers;
IHighlightingStrategy highlighter = null;
char escapeCharacter;
bool ignoreCase = false;
@ -35,14 +34,7 @@ namespace ICSharpCode.TextEditor.Document @@ -35,14 +34,7 @@ namespace ICSharpCode.TextEditor.Document
}
}
internal IHighlightingStrategy Highlighter {
get {
return highlighter;
}
set {
highlighter = value;
}
}
internal IHighlightingStrategyUsingRuleSets Highlighter;
public LookupTable KeyWords {
get {

15
src/Libraries/ICSharpCode.TextEditor/Project/Src/Document/HighlightingStrategy/IHighlightingStrategy.cs

@ -40,26 +40,29 @@ namespace ICSharpCode.TextEditor.Document @@ -40,26 +40,29 @@ namespace ICSharpCode.TextEditor.Document
/// <remarks>
/// Gets the color of an Environment element.
/// </remarks>
HighlightColor GetColorFor(string name);
HighlightColor GetColorFor(string name);
/// <remarks>
/// Used internally, do not call
/// </remarks>
HighlightRuleSet GetRuleSet(Span span);
void MarkTokens(IDocument document, List<LineSegment> lines);
/// <remarks>
/// Used internally, do not call
/// </remarks>
HighlightColor GetColor(IDocument document, LineSegment keyWord, int index, int length);
void MarkTokens(IDocument document);
}
public interface IHighlightingStrategyUsingRuleSets : IHighlightingStrategy
{
/// <remarks>
/// Used internally, do not call
/// </remarks>
void MarkTokens(IDocument document, List<LineSegment> lines);
HighlightRuleSet GetRuleSet(Span span);
/// <remarks>
/// Used internally, do not call
/// </remarks>
void MarkTokens(IDocument document);
HighlightColor GetColor(IDocument document, LineSegment keyWord, int index, int length);
}
}

Loading…
Cancel
Save