/// <summary>
 /// Creates a new DocumentHighlighter instance.
 /// </summary>
 public DocumentHighlighter(ReadOnlyDocument document, IHighlightingDefinition definition)
 {
     if (document == null)
     {
         throw new ArgumentNullException("document");
     }
     if (definition == null)
     {
         throw new ArgumentNullException("definition");
     }
     this.document   = document;
     this.definition = definition;
     this.engine     = new HighlightingEngine(definition.MainRuleSet);
     InvalidateHighlighting();
 }
 /// <summary>
 /// Creates a new DocumentHighlighter instance.
 /// </summary>
 public DocumentHighlighter(TextDocument document, IHighlightingDefinition definition)
 {
     if (document == null)
     {
         throw new ArgumentNullException("document");
     }
     if (definition == null)
     {
         throw new ArgumentNullException("definition");
     }
     this.document   = document;
     this.definition = definition;
     this.engine     = new HighlightingEngine(definition.MainRuleSet);
     document.VerifyAccess();
     weakLineTracker = WeakLineTracker.Register(document, this);
     InvalidateSpanStacks();
 }