Source

Resharper Spell Checker / ReSpeller / Highlightings / IdentifierTypoHighlighting.cs

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

namespace ReSpeller.Highlightings
{
  [ConfigurableSeverityHighlighting(SeverityId,
    "CSHARP,VBASIC,Razor,ASPX,ASXX,XAML", 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 IDeclaredElement myDeclaredElement;
    private readonly bool myIsNamespace;
    private readonly TextPart myWrongPart;

    public IdentifierTypoHighlighting(ITreeNode treeNode, IDeclaration declaration, IDeclaredElement declaredElement, TextPart wrongPart, bool isNamespace,
      List<TextPart> innerNameParts, string prefix, string suffix)
    {
      InnerNameParts = innerNameParts;
      Prefix = prefix;
      Suffix = suffix;
      myTreeNode = treeNode;
      myDeclaration = declaration;
      myDeclaredElement = declaredElement;
      myWrongPart = wrongPart;
      myIsNamespace = isNamespace;
    }

    public List<TextPart> InnerNameParts { get; private set; }
    public string Prefix { get; private set; }
    public string Suffix { get; private set; }

    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 IDeclaredElement DeclaredElement
    {
      get { return myDeclaredElement; }
    }

    public bool IsValid()
    {
      return true;
    }

    #endregion
  }
}