Source

Resharper Spell Checker / ReSpeller / Analyzers / CommentTypoAnalyzer.cs

Full commit
using JetBrains.Application;
using JetBrains.DocumentModel;
using JetBrains.ReSharper.Daemon;
using JetBrains.ReSharper.Daemon.Stages;
using JetBrains.ReSharper.Daemon.Stages.Dispatcher;
using JetBrains.ReSharper.Psi;
using JetBrains.ReSharper.Psi.Tree;
using ReSpeller.Highlightings;
using ReSpeller.SpellEngine;

namespace ReSpeller.Analyzers
{
  [ElementProblemAnalyzer(new[] { typeof(IComment) })]
  public class CommentTypoAnalyzer : ElementProblemAnalyzer<IComment>
  {
    private readonly ISpellChecker myChecker = Shell.Instance.GetComponent<ISpellChecker>();

    protected override void Run(IComment element, ElementProblemAnalyzerData data, IHighlightingConsumer consumer)
    {
      TreeTextRange treeTextRange = element.GetCommentRange();
      DocumentRange commentRange = element.GetContainingFile().TranslateRangeForHighlighting(treeTextRange);
      if (!treeTextRange.IsValid() || !commentRange.IsValid())
        return;
      AnalyzerHelper.GenerateRangeBasedHighlightings(myChecker, consumer, element.GetContainingFile(), commentRange, 
        range => new CommentTypoHighlighting(range));
    }
  }
}