Ejemplo n.º 1
0
        private void CheckMember(
            IClassMemberDeclaration declaration,
            IHighlightingConsumer highlightingConsumer,
            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;
            IDocCommentBlockNode commentBlock;
            var 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, highlightingConsumer);
            commentAnalyzer.CheckCommentSpelling(declaration, commentBlock, highlightingConsumer, true);
            identifierAnalyzer.CheckMemberSpelling(declaration, highlightingConsumer, true);
        }
Ejemplo n.º 2
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.
            }
        }
Ejemplo n.º 3
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.
            }
        }