Source

Resharper Spell Checker / ReSpeller / Highlightings / IdentifierTypoHighlighting.cs

Full commit
using JetBrains.ReSharper.Daemon;
using JetBrains.ReSharper.Psi.Tree;
using ReSpeller.SpellEngine;

namespace ReSpeller.Highlightings
{
  [ConfigurableSeverityHighlighting(SeverityId,
    "CSHARP,VBASIC,Razor,ASPX,ASXX", OverlapResolve = OverlapResolveKind.NONE,
    ToolTipFormatString = ToolTipFormatString)]
  public class IdentifierTypoHighlighting : IHighlighting
  {
    internal const string SeverityId = "IdentifierTypo";
    private const string ToolTipFormatString = "Typo in identifier: \"{0}\"";
    private readonly ITreeNode myTreeNode;
    private readonly IDeclaration myDeclaration;
    private readonly bool myIsNamespace;
    private readonly TextPart myWrongPart;

    public IdentifierTypoHighlighting(ITreeNode treeNode, IDeclaration declaration, TextPart wrongPart, bool isNamespace)
    {
      myTreeNode = treeNode;
      myDeclaration = declaration;
      myWrongPart = wrongPart;
      myIsNamespace = isNamespace;
    }

    public bool IsNamespace
    {
      get { return myIsNamespace; }
    }

    public IDeclaration Declaration
    {
      get { return myDeclaration; }
    }

    public TextPart WrongPart
    {
      get { return myWrongPart; }
    }

    #region IHighlighting Members

    public string ToolTip
    {
      get { return string.Format(ToolTipFormatString, myWrongPart.Text); }
    }

    public string ErrorStripeToolTip
    {
      get { return string.Format(ToolTipFormatString, myWrongPart.Text); }
    }

    public int NavigationOffsetPatch
    {
      get { return 0; }
    }

    public ITreeNode TreeNode
    {
      get { return myTreeNode; }
    }

    public bool IsValid()
    {
      return true;
    }

    #endregion
  }
}