Пример #1
0
        public void CheckMemberSpelling(
            IDeclaration declaration,
            IHighlightingConsumer highlightingConsumer,
            bool spellCheck)
        {
            if (this._identifierSpellChecker == null || !spellCheck)
            {
                return;
            }

            if (declaration is IIndexerDeclaration ||
                declaration is IDestructorDeclaration ||
                declaration is IAccessorDeclaration ||
                declaration is IConstructorDeclaration ||
                (declaration.DeclaredName.Contains(".") && !(declaration is INamespaceDeclaration)))
            {
                return;
            }

            /*if (ComplexMatchEvaluator.IsMatch(declaration, _settings.IdentifiersToSpellCheck,
             *      _settings.IdentifiersNotToSpellCheck, true) == null)
             * {
             *  return null;
             * }*/

            HashSet <string> localNames = getLocalNames(declaration);

            CamelHumpLexer lexer =
                new CamelHumpLexer(declaration.DeclaredName, 0, declaration.DeclaredName.Length);

            foreach (LexerToken token in lexer)
            {
                string val      = token.Value;
                string lowerVal = val.ToLower();
                //val.Length > MAX_LENGTH_TO_SKIP &&
                if (
                    !IsAbbreviation(val) &&
                    SpellCheckUtil.ShouldSpellCheck(val, _identifierSettings.CompiledWordsToIgnore) &&
                    !localNames.Contains(lowerVal) &&
                    !this._identifierSpellChecker.TestWord(val, false))
                {
                    bool found = false;
                    foreach (string entry in localNames)
                    {
                        if (entry.StartsWith(lowerVal))
                        {
                            found = true;
                            break;
                        }
                    }

                    if (!found)
                    {
                        var highlighting = new IdentifierSpellCheckHighlighting(
                            declaration, token, _solution, this._identifierSpellChecker, _settingsStore);

                        var file  = declaration.GetContainingFile();
                        var range = declaration.GetNameDocumentRange();
                        highlightingConsumer.AddHighlighting(highlighting, range, file);
                    }
                }
            }
        }
Пример #2
0
 public IdentifierSpellCheckQuickFix(IdentifierSpellCheckHighlighting highlighting)
 {
     _highlighting = highlighting;
 }