/// <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, 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;
            }

            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()));
            }
        }
Example #2
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);
        }