示例#1
0
        private static DeclaredElementInstance FindElementFromVarKeyword([NotNull] ITreeNode varKeyword, [NotNull] IFile file, out TextRange sourceRange)
        {
            sourceRange = TextRange.InvalidRange;

            var multipleLocalVariableDeclaration = varKeyword.Parent as IMultipleLocalVariableDeclaration;

            if (multipleLocalVariableDeclaration == null)
            {
                return(null);
            }

            IMultipleDeclarationMember member = multipleLocalVariableDeclaration.DeclaratorsEnumerable.FirstOrDefault();

            if (member == null)
            {
                return(null);
            }

            var type = member.Type as IDeclaredType;

            if (type == null)
            {
                return(null);
            }

            ITypeElement typeElement = type.GetTypeElement();

            if (typeElement == null)
            {
                return(null);
            }

            sourceRange = file.GetDocumentRange(varKeyword.GetTreeTextRange()).TextRange;
            return(new DeclaredElementInstance(typeElement, type.GetSubstitution()));
        }
示例#2
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);
        }