diff --git a/src/Libraries/ICSharpCode.TextEditor/Project/Src/Document/HighlightingStrategy/DefaultHighlightingStrategy.cs b/src/Libraries/ICSharpCode.TextEditor/Project/Src/Document/HighlightingStrategy/DefaultHighlightingStrategy.cs index 3e8f6e4be9..027b706311 100644 --- a/src/Libraries/ICSharpCode.TextEditor/Project/Src/Document/HighlightingStrategy/DefaultHighlightingStrategy.cs +++ b/src/Libraries/ICSharpCode.TextEditor/Project/Src/Document/HighlightingStrategy/DefaultHighlightingStrategy.cs @@ -13,7 +13,7 @@ using System.Windows.Forms; namespace ICSharpCode.TextEditor.Document { - public class DefaultHighlightingStrategy : IHighlightingStrategy + public class DefaultHighlightingStrategy : IHighlightingStrategyUsingRuleSets { string name; List rules = new List(); @@ -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"); } } } diff --git a/src/Libraries/ICSharpCode.TextEditor/Project/Src/Document/HighlightingStrategy/HighlightRuleSet.cs b/src/Libraries/ICSharpCode.TextEditor/Project/Src/Document/HighlightingStrategy/HighlightRuleSet.cs index f0a8729005..3459a37d76 100644 --- a/src/Libraries/ICSharpCode.TextEditor/Project/Src/Document/HighlightingStrategy/HighlightRuleSet.cs +++ b/src/Libraries/ICSharpCode.TextEditor/Project/Src/Document/HighlightingStrategy/HighlightRuleSet.cs @@ -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 } } - internal IHighlightingStrategy Highlighter { - get { - return highlighter; - } - set { - highlighter = value; - } - } + internal IHighlightingStrategyUsingRuleSets Highlighter; public LookupTable KeyWords { get { diff --git a/src/Libraries/ICSharpCode.TextEditor/Project/Src/Document/HighlightingStrategy/IHighlightingStrategy.cs b/src/Libraries/ICSharpCode.TextEditor/Project/Src/Document/HighlightingStrategy/IHighlightingStrategy.cs index 77888dd88b..fdac3dbb86 100644 --- a/src/Libraries/ICSharpCode.TextEditor/Project/Src/Document/HighlightingStrategy/IHighlightingStrategy.cs +++ b/src/Libraries/ICSharpCode.TextEditor/Project/Src/Document/HighlightingStrategy/IHighlightingStrategy.cs @@ -40,26 +40,29 @@ namespace ICSharpCode.TextEditor.Document /// /// Gets the color of an Environment element. /// - HighlightColor GetColorFor(string name); + HighlightColor GetColorFor(string name); /// /// Used internally, do not call /// - HighlightRuleSet GetRuleSet(Span span); + void MarkTokens(IDocument document, List lines); /// /// Used internally, do not call /// - HighlightColor GetColor(IDocument document, LineSegment keyWord, int index, int length); - + void MarkTokens(IDocument document); + } + + public interface IHighlightingStrategyUsingRuleSets : IHighlightingStrategy + { /// /// Used internally, do not call /// - void MarkTokens(IDocument document, List lines); + HighlightRuleSet GetRuleSet(Span span); /// /// Used internally, do not call /// - void MarkTokens(IDocument document); + HighlightColor GetColor(IDocument document, LineSegment keyWord, int index, int length); } }