public void Execute(Action<DaemonStageResult> commiter)
        {
            var consumer = new DefaultHighlightingConsumer(this, settingsStore);

            foreach (IFile psiFile in DaemonProcess.SourceFile.EnumeratePsiFiles())
            {
                psiFile.ProcessChildren<ITypeDeclaration>(declaration =>
                {
                    if (declaration.DeclaredElement == null) // type is not (yet) declared
                    {
                        return;
                    }

                    RegistrationInfo registrationInfo = cachedComponentRegistrations.FirstOrDefault(c => c.Registration.IsSatisfiedBy(declaration.DeclaredElement));
                    if (registrationInfo != null)
                    {
                        consumer.AddHighlighting(new RegisteredByContainerHighlighting(registrationInfo),
                                                 declaration.GetNameDocumentRange(),
                                                 registrationInfo.GetRegistrationFile());

                        typeUsageManager.MarkTypeAsUsed(declaration);
                    }
                });
            }

            commiter(new DaemonStageResult(consumer.Highlightings));
        }
        public void Execute(Action<DaemonStageResult> commiter)
        {
            var consumer = new DefaultHighlightingConsumer(this, settingsStore);

            foreach (IFile psiFile in EnumeratePsiFiles())
            {
                ProcessFile(psiFile, consumer);
            }

            commiter(new DaemonStageResult(consumer.Highlightings));
        }
Beispiel #3
0
            public void Execute(Action <DaemonStageResult> committer)
            {
                var services = DaemonProcess.SourceFile.GetPsiServices();

                services.Files.AssertAllDocumentAreCommitted();

                var factory  = new ShaderLabCodeFoldingProcessFactory();
                var consumer = new DefaultHighlightingConsumer(this, mySettings);

                myFile.ProcessDescendants(factory.CreateProcessor(), consumer);

                var foldings = CodeFoldingUtil.AppendRangeWithOverlappingResolve(consumer.Highlightings);

                committer(new DaemonStageResult(foldings));
            }
        public void Execute(Action<DaemonStageResult> committer)
        {
            MarkModulesAsUsed(collectUsagesStageProcess);

            var consumer = new DefaultHighlightingConsumer(this, settingsStore);
            var referenceProcessor = new RecursiveReferenceProcessor<IMvcReference>(reference =>
            {
                InterruptableActivityCookie.CheckAndThrow();
                IHighlighting highlighting;
                switch (reference.MvcKind)
                {
                    case MvcKind.Area:
                        highlighting = CheckArea(reference);
                        break;
                    case MvcKind.Controller:
                        highlighting = CheckResolved(reference, _ => (IHighlighting)new MvcControllerHighlighting(_));
                        break;
                    case MvcKind.Action:
                        highlighting = CheckResolved(reference, _ => (IHighlighting)new MvcActionHighlighting(_));
                        break;
                    case MvcKind.View:
                    case MvcKind.PartialView:
                    case MvcKind.Master:
                    case MvcKind.DisplayTemplate:
                    case MvcKind.EditorTemplate:
                    case MvcKind.Template:
                        highlighting = CheckResolved(reference,
                            _ => (IHighlighting)new MvcViewHighlighting((IMvcViewReference)_));
                        break;
                    default:
                        highlighting = null;
                        break;
                }
                if (highlighting == null)
                {
                    return;
                }
                consumer.AddHighlighting(highlighting, GetMvcReferenceHighlightingRange(reference),
                    reference.GetTreeNode().GetContainingFile());
            });

            foreach (IFile file in DaemonProcess.SourceFile.EnumerateDominantPsiFiles())
            {
                file.ProcessDescendants(referenceProcessor);
            }

            committer(new DaemonStageResult(consumer.Highlightings));
        }
Beispiel #5
0
        private void ProcessFile(IFile psiFile, DefaultHighlightingConsumer consumer)
        {
            foreach (var declaration in psiFile.ThisAndDescendants <ITypeDeclaration>())
            {
                if (declaration.DeclaredElement == null) // type is not (yet) declared
                {
                    return;
                }

                RegistrationInfo registrationInfo = patternManager.GetRegistrationsForFile(psiFile.GetSourceFile()).
                                                    FirstOrDefault(c => c.Registration.IsSatisfiedBy(declaration.DeclaredElement));
                if (registrationInfo != null)
                {
                    consumer.AddHighlighting(new RegisteredByContainerHighlighting(registrationInfo), declaration.GetNameDocumentRange(), psiFile);
                }
            }
        }
        private void ProcessFile(IFile psiFile, DefaultHighlightingConsumer consumer)
        {
            foreach (var declaration in psiFile.ThisAndDescendants<ITypeDeclaration>())
            {
                if (declaration.DeclaredElement == null) // type is not (yet) declared
                {
                    return;
                }

                RegistrationInfo registrationInfo = patternManager.GetRegistrationsForFile(psiFile.GetSourceFile()).
                                                                   FirstOrDefault(c => c.Registration.IsSatisfiedBy(declaration.DeclaredElement));
                if (registrationInfo != null)
                {
                    consumer.AddHighlighting(new RegisteredByContainerHighlighting(registrationInfo), declaration.GetNameDocumentRange(), psiFile);
                }
            }
        }
Beispiel #7
0
        public void Execute(Action <DaemonStageResult> commiter)
        {
            var sourceFile = File.PhysicalPsiSourceFile;

            if (sourceFile == null)
            {
                return;
            }
            var consumer = new DefaultHighlightingConsumer(sourceFile);

            File.ProcessDescendants(this, consumer);
            var solution = File.GetSolution();
            var relevantHighlightings = consumer
                                        .Highlightings
                                        .Where(info => info.Range.Document.GetPsiSourceFile(solution) == sourceFile);

            commiter(new DaemonStageResult(relevantHighlightings.ToArray()));
        }
Beispiel #8
0
        /// <summary>
        /// Execute this stage of the process.
        /// </summary>
        /// <param name="commiter">The function to call when we've finished the stage to report the results.</param>
        public void Execute(Action <DaemonStageResult> commiter)
        {
            IFile file = _daemonProcess.SourceFile.GetTheOnlyPsiFile(CSharpLanguage.Instance);

            if (file == null)
            {
                return;
            }

            StringSettings stringSettings = _settingsStore.GetKey <StringSettings>(SettingsOptimization.OptimizeDefault);


            if (!_daemonProcess.FullRehighlightingRequired)
            {
                return;
            }

            CommentAnalyzer commentAnalyzer = new CommentAnalyzer(_solution, _settingsStore);
            IdentifierSpellCheckAnalyzer identifierAnalyzer = new IdentifierSpellCheckAnalyzer(_solution, _settingsStore, _daemonProcess.SourceFile);

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

            foreach (var classMemberDeclaration in file.Descendants <IClassMemberDeclaration>())
            {
                CheckMember(classMemberDeclaration, consumer, commentAnalyzer, identifierAnalyzer);
            }

            if (_daemonProcess.InterruptFlag)
            {
                return;
            }
            try
            {
                commiter(new DaemonStageResult(consumer.Highlightings));
            } catch
            {
                // Do nothing if it doesn't work.
            }
        }
Beispiel #9
0
        public override void Execute(Action <DaemonStageResult> commiter)
        {
            Action globalHighlighter = () =>
            {
                var consumer = new DefaultHighlightingConsumer(this, this.mySettingsStore);
                this.File.ProcessThisAndDescendants(new GlobalProcessor(this, consumer));
                commiter(
                    new DaemonStageResult(consumer.Highlightings)
                {
                    Layer = 1
                });
            };

            using (var fibers = this.DaemonProcess.CreateFibers())
            {
                fibers.EnqueueJob(globalHighlighter);
            }

            commiter(new DaemonStageResult(EmptyArray <HighlightingInfo> .Instance));
        }
    public override void Execute(Action<DaemonStageResult> commiter)
    {
      Action globalHighlighter = () =>
      {
        var consumer = new DefaultHighlightingConsumer(this, mySettingsStore);
        File.ProcessThisAndDescendants(new GlobalProcessor(this, consumer));
        commiter(new DaemonStageResult(consumer.Highlightings) { Layer = 1 });
      };

      using (IMultiCoreFibers fibers = DaemonProcess.CreateFibers())
      {
        // highlgiht global space
        //if (DaemonProcess.FullRehighlightingRequired)
        fibers.EnqueueJob(globalHighlighter);
      }

      // remove all old highlightings
      //if (DaemonProcess.FullRehighlightingRequired)
      commiter(new DaemonStageResult(EmptyArray<HighlightingInfo>.Instance));
    }
        public override void Execute(Action<DaemonStageResult> commiter)
        {
            Action globalHighlighter = () =>
            {
                var consumer = new DefaultHighlightingConsumer(this, this.mySettingsStore);
                this.File.ProcessThisAndDescendants(new GlobalProcessor(this, consumer));
                commiter(
                    new DaemonStageResult(consumer.Highlightings)
                        {
                            Layer = 1
                        });
            };

            using (var fibers = this.DaemonProcess.CreateFibers())
            {
                fibers.EnqueueJob(globalHighlighter);
            }

            commiter(new DaemonStageResult(EmptyArray<HighlightingInfo>.Instance));
        }
Beispiel #12
0
        private void CheckMember(IClassMemberDeclaration declaration,
                                 DefaultHighlightingConsumer consumer, CommentAnalyzer commentAnalyzer, IdentifierSpellCheckAnalyzer identifierAnalyzer)
        {
            if (declaration is IConstructorDeclaration && declaration.IsStatic)
            {
                // TODO: probably need to put this somewhere in settings.
                //Static constructors have no visibility so not clear how to check them.
                return;
            }


            // Documentation doesn't work properly on multiple declarations (as of R# 6.1) so see if we can get it from the parent
            XmlNode                    docNode = null;
            IDocCommentBlock           commentBlock;
            IMultipleDeclarationMember multipleDeclarationMember = declaration as IMultipleDeclarationMember;

            if (multipleDeclarationMember != null)
            {
                // get the parent
                IMultipleDeclaration multipleDeclaration = multipleDeclarationMember.MultipleDeclaration;

                // Now ask for the actual comment block
                commentBlock = SharedImplUtil.GetDocCommentBlockNode(multipleDeclaration);

                if (commentBlock != null)
                {
                    docNode = commentBlock.GetXML(null);
                }
            }
            else
            {
                commentBlock = SharedImplUtil.GetDocCommentBlockNode(declaration);

                docNode = declaration.GetXMLDoc(false);
            }

            commentAnalyzer.CheckMemberHasComment(declaration, docNode, consumer);
            commentAnalyzer.CheckCommentSpelling(declaration, commentBlock, consumer, true);
            identifierAnalyzer.CheckMemberSpelling(declaration, consumer, true);
        }
        public static void CheckString(ICSharpLiteralExpression literalExpression,
                                       DefaultHighlightingConsumer consumer, StringSettings settings, ISolution _solution, IContextBoundSettingsStore _settingsStore, IDaemonProcess _daemonProcess = null)
        {
            //ConstantValue val = literalExpression.ConstantValue;

            // Ignore it unless it's something we're re-evalutating
            if (_daemonProcess != null && !_daemonProcess.IsRangeInvalidated(literalExpression.GetDocumentRange()))
            {
                return;
            }

            ITokenNode tokenNode = literalExpression.Literal;

            if (tokenNode == null)
            {
                return;
            }

            if (tokenNode.GetTokenType() == CSharpTokenType.STRING_LITERAL_VERBATIM)
            {
                if (settings.IgnoreVerbatimStrings)
                {
                    return;
                }
            }
            else if (tokenNode.GetTokenType() != CSharpTokenType.STRING_LITERAL_REGULAR)
            {
                return;
            }

            ISpellChecker spellChecker = SpellCheckManager.GetSpellChecker(_settingsStore, _solution, settings.DictionaryNames);

            StringSpellChecker.SpellCheck(
                literalExpression.GetDocumentRange()
                .Document,
                tokenNode,
                spellChecker,
                _solution, consumer, _settingsStore, settings);
        }
        public override void Execute(Action <DaemonStageResult> committer)
        {
            Action globalHighlighter = () =>
            {
                var consumer = new DefaultHighlightingConsumer(this, mySettingsStore);
                File.ProcessThisAndDescendants(new GlobalProcessor(this, consumer));
                committer(new DaemonStageResult(consumer.Highlightings)
                {
                    Layer = 1
                });
            };

            using (var fibers = DaemonProcess.CreateFibers())
            {
                // highlight global space
                //if (DaemonProcess.FullRehighlightingRequired)
                fibers.EnqueueJob(globalHighlighter);
            }

            // remove all old highlightings
            //if (DaemonProcess.FullRehighlightingRequired)
            committer(new DaemonStageResult(EmptyArray <HighlightingInfo> .Instance));
        }
    public void Execute(Action<DaemonStageResult> committer)
    {
      var nitraFile = ReSharperSolution.XXLanguageXXSolution.GetNitraFile(_daemonProcess.SourceFile);
      if (nitraFile == null)
        return;
      var messages  = nitraFile.GetCompilerMessages();

      var highlightingInfos = new List<HighlightingInfo>(messages.Length);
      var consumer = new DefaultHighlightingConsumer(this, _settings);

      foreach (var message in messages)
      {
        if (_daemonProcess.InterruptFlag)
          return;

        var highlighting = new NitraError(message);
        consumer.ConsumeHighlighting(new HighlightingInfo(highlighting.DocumentRange, highlighting));
        //highlightingInfos.Add(new HighlightingInfo(highlighting.DocumentRange, highlighting));
      }

      committer(new DaemonStageResult(consumer.Highlightings));
      //committer(new DaemonStageResult(highlightingInfos));
    }
Beispiel #16
0
        private void CheckWordSpelling(IClassMemberDeclaration decl, Range wordRange,
                                       DefaultHighlightingConsumer consumer, DocumentRange range)
        {
            // If we dont have a spell checker then go no further
            if (this._xmlDocumentationSpellChecker == null)
            {
                return;
            }

            // First check the whole word range.
            if (!SpellCheckUtil.ShouldSpellCheck(wordRange.Word, _xmlDocumentationSettings.CompiledWordsToIgnore) ||
                this._xmlDocumentationSpellChecker.TestWord(wordRange.Word, true))
            {
                return;
            }

            // We are checking this word and the whole range doesn't spell anything so try breaking the word into bits.
            CamelHumpLexer camelHumpLexer = new CamelHumpLexer(wordRange.Word, 0, wordRange.Word.Length);

            foreach (LexerToken humpToken in camelHumpLexer)
            {
                if (SpellCheckUtil.ShouldSpellCheck(humpToken.Value, _xmlDocumentationSettings.CompiledWordsToIgnore) &&
                    !this._xmlDocumentationSpellChecker.TestWord(humpToken.Value, true))
                {
                    consumer.AddHighlighting(
                        new WordIsNotInDictionaryHighlight(
                            wordRange.Word,
                            range,
                            humpToken,
                            _solution,
                            this._xmlDocumentationSpellChecker,
                            _settingsStore),
                        range);
                    break;
                }
            }
        }
Beispiel #17
0
        /// <summary>
        /// Execute this stage of the process.
        /// </summary>
        /// <param name="commiter">The function to call when we've finished the stage to report the results.</param>
        public void Execute(Action <DaemonStageResult> commiter)
        {
            //var highlightings = new List<HighlightingInfo>();
            IHighlightingConsumer highlightingConsumer = new DefaultHighlightingConsumer(
                this, _settingsStore);

            IFile file = _daemonProcess.SourceFile.GetTheOnlyPsiFile(CSharpLanguage.Instance);

            if (file == null)
            {
                return;
            }

            if (!_daemonProcess.FullRehighlightingRequired)
            {
                return;
            }

            var commentAnalyzer    = new CommentAnalyzer(_solution, _settingsStore);
            var identifierAnalyzer = new IdentifierSpellCheckAnalyzer(_solution, _settingsStore, _daemonProcess.SourceFile);

            file.ProcessChildren <IClassMemberDeclaration>(
                declaration => CheckMember(
                    declaration, highlightingConsumer, commentAnalyzer, identifierAnalyzer));

            if (_daemonProcess.InterruptFlag)
            {
                return;
            }
            try
            {
                commiter(new DaemonStageResult(highlightingConsumer.Highlightings));
            } catch
            {
                // Do nothing if it doesn't work.
            }
        }
Beispiel #18
0
        public void CheckCommentSpelling(IClassMemberDeclaration decl, [CanBeNull] IDocCommentBlock docNode,
                                         DefaultHighlightingConsumer consumer, bool spellCheck)
        {
            if (docNode == null)
            {
                return;
            }

            IFile file = decl.GetContainingFile();

            if (file == null)
            {
                return;
            }

            foreach (Range wordRange in this.GetWordsFromXmlComment(docNode))
            {
                DocumentRange range = file.GetDocumentRange(wordRange.TreeTextRange);
                string        word  = wordRange.Word;

                if (decl.DeclaredName != word)
                {
                    if ((IdentifierResolver.IsIdentifier(decl, _solution, word, _identifierSettings.IdentifierLookupScope) ||
                         IdentifierResolver.IsKeyword(decl, _solution, word)) &&
                        IdentifierResolver.AnalyzeForMetaTagging(word, _xmlDocumentationSettings.CompiledWordsToIgnoreForMetatagging))
                    {
                        consumer.AddHighlighting(
                            new CanBeSurroundedWithMetatagsHighlight(word, range, decl, _solution),
                            range);
                    }
                    else if (spellCheck)
                    {
                        this.CheckWordSpelling(decl, wordRange, consumer, range);
                    }
                }
            }
        }
        /// <summary>
        /// Execute this stage of the process.
        /// </summary>
        /// <param name="commiter">The function to call when we've finished the stage to report the results.</param>
        public void Execute(Action <DaemonStageResult> commiter)
        {
            IFile file = this._daemonProcess.SourceFile.GetTheOnlyPsiFile(CSharpLanguage.Instance);

            if (file == null)
            {
                return;
            }

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

            StringSettings stringSettings = this._settingsStore.GetKey <StringSettings>(SettingsOptimization.OptimizeDefault);

            foreach (var literalExpression in file.Descendants <ICSharpLiteralExpression>())
            {
                CheckString(literalExpression, consumer, stringSettings, _solution, _settingsStore, _daemonProcess);
            }

            foreach (var literalExpression in file.Descendants <IInterpolatedStringExpression>())
            {
                CheckString(literalExpression, consumer, stringSettings, _solution, _settingsStore, _daemonProcess);
            }

            try
            {
                commiter(new DaemonStageResult(consumer.Highlightings));
            }
            catch
            {
                // Do nothing if it doesn't work.
            }
        }
        public void CheckComment(ICSharpCommentNode commentNode,
                                 DefaultHighlightingConsumer consumer, CommentSettings settings)
        {
            // Ignore it unless it's something we're re-evalutating
            if (!_daemonProcess.IsRangeInvalidated(commentNode.GetDocumentRange()))
            {
                return;
            }

            // Only look for ones that are not doc comments
            if (commentNode.CommentType != CommentType.END_OF_LINE_COMMENT &&
                commentNode.CommentType != CommentType.MULTILINE_COMMENT)
            {
                return;
            }

            ISpellChecker spellChecker = SpellCheckManager.GetSpellChecker(_settingsStore, _solution, settings.DictionaryNames);

            SpellCheck(
                commentNode.GetDocumentRange().Document,
                commentNode,
                spellChecker,
                _solution, consumer, _settingsStore, settings);
        }
        /// <summary>
        /// Execute this stage of the process.
        /// </summary>
        /// <param name="commiter">The function to call when we've finished the stage to report the results.</param>
        public void Execute(Action <DaemonStageResult> commiter)
        {
            IFile file = _daemonProcess.SourceFile.GetTheOnlyPsiFile(CSharpLanguage.Instance);

            if (file == null)
            {
                return;
            }

            var highlightingConsumer = new DefaultHighlightingConsumer(this, _settingsStore);
            var commentSettings      = _settingsStore.GetKey <CommentSettings>(SettingsOptimization.OptimizeDefault);

            file.ProcessChildren <ICSharpCommentNode>(commentNode
                                                      => CheckComment(commentNode, highlightingConsumer, commentSettings));

            try
            {
                commiter(new DaemonStageResult(highlightingConsumer.Highlightings));
            }
            catch
            {
                // Do nothing if it doesn't work.
            }
        }
        public static void SpellCheck(IDocument document, ITokenNode token, ISpellChecker spellChecker,
                                      ISolution solution, DefaultHighlightingConsumer consumer, IContextBoundSettingsStore settingsStore, StringSettings settings)
        {
            if (spellChecker == null)
            {
                return;
            }

            string buffer    = unescape(token.GetText());
            ILexer wordLexer = new WordLexer(buffer);

            wordLexer.Start();
            while (wordLexer.TokenType != null)
            {
                string tokenText = wordLexer.GetCurrTokenText();
                if (SpellCheckUtil.ShouldSpellCheck(tokenText, settings.CompiledWordsToIgnore) &&
                    !spellChecker.TestWord(tokenText, true))
                {
                    IClassMemberDeclaration containingElement =
                        token.GetContainingNode <IClassMemberDeclaration>(false);
                    if (containingElement == null ||
                        !IdentifierResolver.IsIdentifier(containingElement, solution, tokenText))
                    {
                        CamelHumpLexer camelHumpLexer = new CamelHumpLexer(buffer, wordLexer.TokenStart, wordLexer.TokenEnd);
                        foreach (LexerToken humpToken in camelHumpLexer)
                        {
                            if (SpellCheckUtil.ShouldSpellCheck(humpToken.Value, settings.CompiledWordsToIgnore) &&
                                !spellChecker.TestWord(humpToken.Value, true))
                            {
                                //int start = token.GetTreeStartOffset().Offset + wordLexer.TokenStart;
                                //int end = start + tokenText.Length;

                                //TextRange range = new TextRange(start, end);
                                //DocumentRange documentRange = new DocumentRange(document, range);

                                DocumentRange documentRange =
                                    token.GetContainingFile().TranslateRangeForHighlighting(token.GetTreeTextRange());
                                documentRange = documentRange.ExtendLeft(-wordLexer.TokenStart);
                                documentRange = documentRange.ExtendRight(-1 * (documentRange.GetText().Length - tokenText.Length));

                                TextRange textRange = new TextRange(humpToken.Start - wordLexer.TokenStart,
                                                                    humpToken.End - wordLexer.TokenStart);

                                //string word = document.GetText(range);
                                string word = documentRange.GetText();
                                consumer.AddHighlighting(
                                    new StringSpellCheckHighlighting(
                                        word,
                                        documentRange,
                                        humpToken.Value,
                                        textRange,
                                        solution,
                                        spellChecker,
                                        settingsStore),
                                    documentRange);
                                break;
                            }
                        }
                    }
                }
                wordLexer.Advance();
            }
        }
 public TestFileAnalysisElementProcessor(TestFileAnalysisDaemonStageProcess stageProcess, IDaemonProcess process, IContextBoundSettingsStore settings)
 {
     _highlightingConsumer = new FilteringHighlightingConsumer(stageProcess.File.GetSourceFile(), stageProcess.File);
     _process  = process;
     _settings = settings;
 }
Beispiel #24
0
        /// <summary>
        /// Check that the given declaration has an xml documentation comment.
        /// </summary>
        /// <param name="declaration">The declaration to check</param>
        /// <param name="docNode">The documentation node to check.</param>
        /// <param name="consumer">The list of highlights (errors) that were found - add to this any new issues</param>
        public void CheckMemberHasComment(IClassMemberDeclaration declaration, [CanBeNull] XmlNode docNode,
                                          DefaultHighlightingConsumer consumer)
        {
            // Only process this one if its range is invalid.
            //if (!_daemonProcess.IsRangeInvalidated(declaration.GetDocumentRange())) return;

            // Check if the parent doco is null
            if (_xmlDocumentationSettings.SuppressIfBaseHasComment)
            {
                if (docNode == null && declaration.GetXMLDoc(true) != null)
                {
                    return;
                }
            }


            if (docNode != null)
            {
                return;
            }

            //check if project should be ignored

            if (ShouldIgnoreProject(declaration.GetProject()?.Name))
            {
                return;
            }

            Match[] publicMembers = new[]
            {
                new Match(
                    Declaration.Any, AccessLevels.Public | AccessLevels.Protected | AccessLevels.ProtectedInternal)
            };


            Match[] internalMembers = new[] { new Match(Declaration.Any, AccessLevels.Internal) };

            Match[] privateMembers = new[] { new Match(Declaration.Any, AccessLevels.Private) };

            Match match          = ComplexMatchEvaluator.IsMatch(declaration, privateMembers, null, true);
            IFile containingFile = declaration.GetContainingFile();

            if (match != null)
            {
                consumer.AddHighlighting(
                    new PrivateMemberMissingXmlCommentHighlighting(declaration, match),
                    containingFile.TranslateRangeForHighlighting(declaration.GetNameRange()));
                return;
            }

            match = ComplexMatchEvaluator.IsMatch(declaration, internalMembers, null, true);
            if (match != null)
            {
                consumer.AddHighlighting(
                    new InternalMemberMissingXmlCommentHighlighting(declaration, match),
                    containingFile.TranslateRangeForHighlighting(declaration.GetNameRange()));
                return;
            }

            match = ComplexMatchEvaluator.IsMatch(declaration, publicMembers, null, true);
            if (match != null)
            {
                consumer.AddHighlighting(
                    new PublicMemberMissingXmlCommentHighlighting(declaration, match),
                    containingFile.TranslateRangeForHighlighting(declaration.GetNameRange()));
            }
        }
        public void CheckMemberSpelling(IDeclaration declaration, DefaultHighlightingConsumer consumer, 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 containingFile = declaration.GetContainingFile();
                        consumer.AddHighlighting(
                            new IdentifierSpellCheckHighlighting(
                                declaration,
                                token,
                                _solution,
                                this._identifierSpellChecker,
                                _settingsStore),
                            containingFile.TranslateRangeForHighlighting(declaration.GetNameRange()));
                    }
                }
            }
        }
Beispiel #26
0
        /// <summary>
        /// The execute.
        /// </summary>
        /// <param name="committer">
        /// The committer.
        /// </param>
        public void Execute(Action <DaemonStageResult> committer)
        {
            StyleCopTrace.In();
            try
            {
                if (this.daemonProcess == null)
                {
                    return;
                }

                if (this.daemonProcess.InterruptFlag)
                {
                    return;
                }

                DaemonData daemonData;
                bool       shouldProcessNow;

                daemonData = this.file.UserData.GetOrCreateDataUnderLock(
                    DaemonDataKey,
                    () => new DaemonData(this.lifetime, this.threading, this.daemon, this.daemonProcess.Document));
                shouldProcessNow = daemonData.OnDaemonCalled();

                if (shouldProcessNow)
                {
                    Lifetime.Using(
                        apiLifetime =>
                    {
                        var runner = this.apiPool.GetInstance(apiLifetime).Runner;
                        runner.Execute(
                            this.daemonProcess.SourceFile.ToProjectFile(),
                            this.daemonProcess.Document,
                            this.file);

                        // This filters the highlights, based on "ReSharper disable" comments, etc.
                        var defaultConsumer   = new DefaultHighlightingConsumer(this.daemonProcess.SourceFile);
                        var filteringConsumer = new FilteringHighlightingConsumer(
                            defaultConsumer,
                            this.daemonProcess.SourceFile,
                            this.file,
                            this.settings);
                        foreach (var highlightingInfo in runner.ViolationHighlights)
                        {
                            filteringConsumer.ConsumeHighlighting(highlightingInfo);
                        }

                        committer(new DaemonStageResult(filteringConsumer.Highlightings));
                    });
                }
                else
                {
                    // NOTE: This wouldn't be necessary if the StyleCop analysis were more lightweight,
                    // e.g. by using ReSharper's ASTs rather than re-parsing the file on each change
                    daemonData.ScheduleReHighlight();
                }
            }
            catch (OperationCanceledException)
            {
            }

            StyleCopTrace.Out();
        }