Click here to Skip to main content
15,895,667 members
Articles / Programming Languages / C#

Code Spelling Checker Extension for Visual Studio 2010 (VSX)

Rate me:
Please Sign up or sign in to vote.
4.98/5 (43 votes)
7 Apr 2010CPOL6 min read 111.6K   2.4K   74  
Building a spelling checker for source code as an extension for Visual Studio 2010
using System;


namespace DigitalSamurai.SpellSharp.InputProcessing
{
    public abstract partial class Processor<TLexicalElements>
    {
        public class TokenNode
        {
            private Func<Token> getNext;

            public Token Token { get; private set; }
            public TokenNode Previous { get; private set; }

            #region public TokenNode Next { get (jit); }
            private TokenNode _Next;

            public TokenNode Next
            {
                get
                {
                    if (_Next == null)
                    {
                        _Next = Create (getNext, this);
                    }

                    return _Next;
                }
            }
            #endregion


            private TokenNode (Func<Token> getNext, Token token, TokenNode previous)
            {
                this.getNext = getNext;
                Token = token;
                Previous = previous;
            }


            public static TokenNode Create (Func<Token> getNext)
            {
                if (getNext == null)
                {
                    throw new ArgumentNullException ("getNext");
                }

                return Create (getNext, null);
            }

            private static TokenNode Create (Func<Token> getNext, TokenNode previous)
            {
                var token = getNext ();
                if (token == null)
                {
                    return null;
                }

                return new TokenNode (getNext, token, previous);
            }
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Netherlands Netherlands
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions