Exemplo n.º 1
0
        public void Execute(Action <DaemonStageResult> action)
        {
            IPsiModule module = _file.GetPsiModule();

            ResXSettings settings = _settingsStore.GetKey <ResXSettings>(SettingsOptimization.OptimizeDefault);

            IAttributesSet             moduleAttributes = _file.GetSolution().GetPsiServices().Symbols.GetModuleAttributes(module);
            string                     defaultResXDic   = "en-US";
            IList <IAttributeInstance> attributes       = moduleAttributes
                                                          .GetAttributeInstances(new ClrTypeName(typeof(NeutralResourcesLanguageAttribute).FullName), false);

            if (attributes != null &&
                attributes.Count > 0 &&
                attributes[0].PositionParameter(0).ConstantValue.Value != null)
            {
                defaultResXDic = attributes[0].PositionParameter(0).ConstantValue.Value.ToString();
            }

#if RESHARPER20173
            var consumer = new DefaultHighlightingConsumer(_daemonProcess.SourceFile);
#else
            var consumer = new DefaultHighlightingConsumer(this, _settingsStore);
#endif

            ISpellChecker checker = SpellCheckManager.GetSpellChecker(_settingsStore, _file, defaultResXDic);
            if (checker != null)
            {
                foreach (IXmlToken token in getStringsToCheck())
                {
                    WordLexer lexer = new WordLexer(token.GetText());
                    lexer.Start();
                    while (lexer.TokenType != null)
                    {
                        if (SpellCheckUtil.ShouldSpellCheck(lexer.TokenText, settings.CompiledWordsToIgnore) &&
                            !checker.TestWord(lexer.TokenText, false))
                        {
                            DocumentRange docRange  = token.GetDocumentRange();
                            TextRange     textRange = new TextRange(docRange.TextRange.StartOffset + lexer.TokenStart,
                                                                    docRange.TextRange.StartOffset + lexer.TokenEnd);
                            DocumentRange range = new DocumentRange(docRange.Document, textRange);

                            ResXSpellHighlighting highlighting =
                                new ResXSpellHighlighting(lexer.TokenText, _file, checker, range, _settingsStore);

                            consumer.AddHighlighting(highlighting, range);
                        }
                        lexer.Advance();
                    }
                }
            }

            action(new DaemonStageResult(consumer.Highlightings));
        }
Exemplo n.º 2
0
 public ResXQuickFix(ResXSpellHighlighting highlighting)
 {
     _highlighting = highlighting;
 }