当前位置: 首页>>代码示例>>C#>>正文


C# ICSharpFile.ToTreeNode方法代码示例

本文整理汇总了C#中ICSharpFile.ToTreeNode方法的典型用法代码示例。如果您正苦于以下问题:C# ICSharpFile.ToTreeNode方法的具体用法?C# ICSharpFile.ToTreeNode怎么用?C# ICSharpFile.ToTreeNode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ICSharpFile的用法示例。


在下文中一共展示了ICSharpFile.ToTreeNode方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Execute

        /// <summary>
        /// Execute comments processing for declarations.
        /// </summary>
        /// <param name="options">
        /// The <see cref="OrderingOptions"/> to use.
        /// </param>
        /// <param name="file">
        /// The <see cref="ICSharpFile"/> to use.
        /// </param>
        public void Execute(DocumentationOptions options, ICSharpFile file)
        {
            StyleCopTrace.In(options, file);

            Param.RequireNotNull(options, "options");
            Param.RequireNotNull(file, "file");

            foreach (ICSharpNamespaceDeclaration namespaceDeclaration in file.NamespaceDeclarations)
            {
                this.ProcessCSharpTypeDeclarations(options, file, namespaceDeclaration.TypeDeclarations);
            }

            this.ProcessCSharpTypeDeclarations(options, file, file.TypeDeclarations);

            bool fixSingleLineCommentsOption = options.SA1626SingleLineCommentsMustNotUseDocumentationStyleSlashes;

            if (fixSingleLineCommentsOption)
            {
                this.SwapDocCommentsToSingleLineComments(file.ToTreeNode().FirstChild);
            }

            this.UpdateFileHeader(options, file);
            StyleCopTrace.Out();
        }
开发者ID:transformersprimeabcxyz,项目名称:_TO-FIRST-stylecop,代码行数:33,代码来源:DocumentationRules.cs

示例2: SwapFileHeaderNode

        private static void SwapFileHeaderNode(ICSharpFile file, string newHeader)
        {
            ITreeRange existingHeaderRange = Utils.GetFileHeaderTreeRange(file);

            using (WriteLockCookie.Create(file.IsPhysical()))
            {
                ICommentNode newCommentNode;

                if (existingHeaderRange.IsEmpty)
                {
                    // existing header missing so add on a new line for our new header
                    newHeader += Environment.NewLine;

                    IWhitespaceNode node = file.ToTreeNode().FirstChild as IWhitespaceNode;
                    bool insertNewLine = true;
                    while (node != null)
                    {
                        if (node.IsNewLine)
                        {
                            insertNewLine = false;
                            break;
                        }

                        node = node.NextSibling as IWhitespaceNode;
                    }

                    if (insertNewLine)
                    {
                        newHeader += Environment.NewLine;
                    }

                    newCommentNode =
                        (ICommentNode)
                        CSharpTokenType.END_OF_LINE_COMMENT.Create(new JB::JetBrains.Text.StringBuffer(newHeader), new TreeOffset(0), new TreeOffset(newHeader.Length));

                    LowLevelModificationUtil.AddChildBefore(file.ToTreeNode().FirstChild, new ITreeNode[] { newCommentNode });
                }
                else
                {
                    ITokenNode lastToken = (ITokenNode)existingHeaderRange.Last;
                    ITokenNode nextToken = lastToken.GetNextToken();
                    if (nextToken != null)
                    {
                        ITokenNode nextNextToken = nextToken.GetNextToken();
                        if (nextNextToken != null)
                        {
                            ITokenNode nextNextNextToken = nextNextToken.GetNextToken();

                            if (!nextToken.IsNewLine() || !nextNextToken.IsNewLine())
                            {
                                newHeader += Environment.NewLine;
                            }

                            if (nextNextNextToken.GetTokenType() == CSharpTokenType.PP_SHARP && nextToken.IsNewLine() && nextNextToken.IsNewLine())
                            {
                                newHeader += Environment.NewLine;
                            }

                            newCommentNode =
                                (ICommentNode)
                                CSharpTokenType.END_OF_LINE_COMMENT.Create(
                                    new JB::JetBrains.Text.StringBuffer(newHeader), new TreeOffset(0), new TreeOffset(newHeader.Length));

                            LowLevelModificationUtil.ReplaceChildRange(existingHeaderRange.First, existingHeaderRange.Last, new ITreeNode[] { newCommentNode });
                        }
                    }
                }
            }
        }
开发者ID:transformersprimeabcxyz,项目名称:_TO-FIRST-stylecop,代码行数:69,代码来源:FileHeader.cs

示例3: Execute

        /// <summary>
        /// Executes the cleanup rules.
        /// </summary>
        /// <param name="options">
        /// The options.
        /// </param>
        /// <param name="file">
        /// The file to process.
        /// </param>
        public void Execute(ReadabilityOptions options, ICSharpFile file)
        {
            StyleCopTrace.In(options, file);
            bool dontPrefixCallsWithBaseUnlessLocalImplementationExists = options.SA1100DoNotPrefixCallsWithBaseUnlessLocalImplementationExists;
            bool codeMustNotContainEmptyStatements = options.SA1106CodeMustNotContainEmptyStatements;
            bool blockStatementsMustNotContainEmbeddedComments = options.SA1108BlockStatementsMustNotContainEmbeddedComments;
            bool blockStatementsMustNotContainEmbeddedRegions = options.SA1109BlockStatementsMustNotContainEmbeddedRegions;
            bool commentsMustContainText = options.SA1120CommentsMustContainText;
            bool useBuiltInTypeAlias = options.SA1121UseBuiltInTypeAlias;
            bool useStringEmptyForEmptyStrings = options.SA1122UseStringEmptyForEmptyStrings;
            bool dontPlaceRegionsWithinElements = options.SA1123DoNotPlaceRegionsWithinElements;
            bool codeMustNotContainEmptyRegions = options.SA1124CodeMustNotContainEmptyRegions;

            if (dontPlaceRegionsWithinElements)
            {
                this.DoNotPlaceRegionsWithinElements(file.ToTreeNode().FirstChild);
            }

            if (blockStatementsMustNotContainEmbeddedComments)
            {
                this.BlockStatementsMustNotContainEmbeddedComments(file.ToTreeNode().FirstChild);
            }

            if (blockStatementsMustNotContainEmbeddedRegions)
            {
                this.BlockStatementsMustNotContainEmbeddedRegions(file.ToTreeNode().FirstChild);
            }

            if (codeMustNotContainEmptyStatements)
            {
                this.CodeMustNotContainEmptyStatements(file.ToTreeNode().FirstChild);
            }

            if (codeMustNotContainEmptyRegions)
            {
                this.CodeMustNotContainEmptyRegions(file.ToTreeNode().FirstChild);
            }

            if (useStringEmptyForEmptyStrings)
            {
                this.ReplaceEmptyStringsWithStringDotEmpty(file.ToTreeNode().FirstChild);
            }

            if (useBuiltInTypeAlias)
            {
                SwapToBuiltInTypeAlias(file.ToTreeNode().FirstChild);
            }

            if (commentsMustContainText)
            {
                RemoveEmptyComments(file.ToTreeNode().FirstChild);
            }

            if (dontPrefixCallsWithBaseUnlessLocalImplementationExists)
            {
                this.DoNotPrefixCallsWithBaseUnlessLocalImplementationExists(file.ToTreeNode().FirstChild);
            }

            StyleCopTrace.Out();
        }
开发者ID:transformersprimeabcxyz,项目名称:_TO-FIRST-stylecop,代码行数:69,代码来源:ReadabilityRules.cs

示例4: Execute

        /// <summary>
        /// Implement the Execute method.
        /// </summary>
        /// <param name="options">
        /// The options.
        /// </param>
        /// <param name="file">
        /// The file to use.
        /// </param>
        public void Execute(SpacingOptions options, ICSharpFile file)
        {
            StyleCopTrace.In(options, file);

            Param.RequireNotNull(options, "options");
            Param.RequireNotNull(file, "file");

            bool commasMustBeSpacedCorrectly = options.SA1001CommasMustBeSpacedCorrectly;
            bool singleLineCommentsMustBeginWithSingleSpace = options.SA1005SingleLineCommentsMustBeginWithSingleSpace;
            bool preprocessorKeywordsMustNotBePrecededBySpace = options.SA1006PreprocessorKeywordsMustNotBePrecededBySpace;
            bool negativeSignsMustBeSpacedCorrectly = options.SA1021NegativeSignsMustBeSpacedCorrectly;
            bool positiveSignsMustBeSpacedCorrectly = options.SA1022PositiveSignsMustBeSpacedCorrectly;
            bool codeMustNotContainMultipleWhitespaceInARow = options.SA1025CodeMustNotContainMultipleWhitespaceInARow;

            if (codeMustNotContainMultipleWhitespaceInARow)
            {
                this.CodeMustNotContainMultipleWhitespaceInARow(file.ToTreeNode().FirstChild);
            }

            if (commasMustBeSpacedCorrectly)
            {
                this.CommasMustBeSpacedCorrectly(file.ToTreeNode().FirstChild);
            }

            if (singleLineCommentsMustBeginWithSingleSpace)
            {
                this.SingleLineCommentsMustBeginWithSingleSpace(file.ToTreeNode().FirstChild);
            }

            if (preprocessorKeywordsMustNotBePrecededBySpace)
            {
                this.PreprocessorKeywordsMustNotBePrecededBySpace(file.ToTreeNode().FirstChild);
            }

            if (negativeSignsMustBeSpacedCorrectly)
            {
                this.NegativeAndPositiveSignsMustBeSpacedCorrectly(file.ToTreeNode().FirstChild, CSharpTokenType.MINUS);
            }

            if (positiveSignsMustBeSpacedCorrectly)
            {
                this.NegativeAndPositiveSignsMustBeSpacedCorrectly(file.ToTreeNode().FirstChild, CSharpTokenType.PLUS);
            }

            StyleCopTrace.Out();
        }
开发者ID:transformersprimeabcxyz,项目名称:_TO-FIRST-stylecop,代码行数:55,代码来源:SpacingRules.cs

示例5: GetFileHeaderTreeRange

        /// <summary>
        /// Gets the file header of the provided file.
        /// </summary>
        /// <param name="file">
        /// The file to get the header for.
        /// </param>
        /// <returns>
        /// The ITreeRange of the header or TreeRange.Empty if there is no header.
        /// </returns>
        public static ITreeRange GetFileHeaderTreeRange(ICSharpFile file)
        {
            ITreeNode node = file.ToTreeNode().FirstChild;
            while ((node is ITokenNode) && node.IsWhitespace())
            {
                node = node.NextSibling;
            }

            if (node is ICommentNode)
            {
                ITreeNode start = node;
                ICommentNode lastComment = node as ICommentNode;
                while ((node = node.NextSibling) != null)
                {
                    if (!(node is ITokenNode) || !node.IsWhitespace())
                    {
                        if (node is ICSharpCommentNode)
                        {
                            ICSharpCommentNode n = node as ICSharpCommentNode;
                            if (n.CommentType == CommentType.END_OF_LINE_COMMENT)
                            {
                                lastComment = (ICommentNode)node;
                            }
                        }
                        else
                        {
                            if (lastComment == null || !(start is ICommentNode))
                            {
                                break;
                            }

                            return new TreeRange(start, lastComment);
                        }
                    }
                }
            }

            return TreeRange.Empty;
        }
开发者ID:transformersprimeabcxyz,项目名称:_TO-FIRST-stylecop,代码行数:48,代码来源:Utils.cs

示例6: Execute

        /// <summary>
        /// The Execute method.
        /// </summary>
        /// <param name="options">
        /// The options.
        /// </param>
        /// <param name="file">
        /// The file.
        /// </param>
        public void Execute(MaintainabilityOptions options, ICSharpFile file)
        {
            StyleCopTrace.In(options, file);

            bool statementMustNotUseUnnecessaryParenthesis = options.SA1119StatementMustNotUseUnnecessaryParenthesis;

            if (statementMustNotUseUnnecessaryParenthesis)
            {
                RemoveUnnecessaryParenthesisFromStatements(file.ToTreeNode().FirstChild);
            }

            StyleCopTrace.Out();
        }
开发者ID:transformersprimeabcxyz,项目名称:_TO-FIRST-stylecop,代码行数:22,代码来源:MaintainabilityRules.cs

示例7: Execute

        /// <summary>
        /// The Execute method.
        /// </summary>
        /// <param name="options">
        /// The options.
        /// </param>
        /// <param name="file">
        /// The file.
        /// </param>
        public void Execute(LayoutOptions options, ICSharpFile file)
        {
            StyleCopTrace.In(options, file);

            Param.RequireNotNull(options, "options");
            Param.RequireNotNull(file, "file");

            bool curlyBracketsForMultiLineStatementsMustNotShareLine = options.SA1500CurlyBracketsForMultiLineStatementsMustNotShareLine;
            bool openingCurlyBracketsMustNotBePrecededByBlankLine = options.SA1509OpeningCurlyBracketsMustNotBePrecededByBlankLine;
            bool chainedStatementBlocksMustNotBePrecededByBlankLine = options.SA1510ChainedStatementBlocksMustNotBePrecededByBlankLine;
            bool whileDoFooterMustNotBePrecededByBlankLine = options.SA1511WhileDoFooterMustNotBePrecededByBlankLine;
            bool singleLineCommentsMustNotBeFollowedByBlankLine = options.SA1512SingleLineCommentsMustNotBeFollowedByBlankLine;
            bool closingCurlyBracketMustBeFollowedByBlankLine = options.SA1513ClosingCurlyBracketMustBeFollowedByBlankLine;
            bool elementDocumentationHeadersMustBePrecededByBlankLine = options.SA1514ElementDocumentationHeaderMustBePrecededByBlankLine;
            bool singleLineCommentsMustBeProceededByBlankLine = options.SA1515SingleLineCommentMustBeProceededByBlankLine;

            if (singleLineCommentsMustBeProceededByBlankLine)
            {
                this.CommentsMustBePreceededByBlankLine(file.ToTreeNode().FirstChild);
            }

            if (singleLineCommentsMustNotBeFollowedByBlankLine)
            {
                this.CommentsMustNotBeFollowedByBlankLine(file.ToTreeNode().FirstChild);
            }

            if (closingCurlyBracketMustBeFollowedByBlankLine)
            {
                ClosingCurlyBracketMustBeFollowedByBlankLine(file.ToTreeNode().FirstChild);
            }

            if (whileDoFooterMustNotBePrecededByBlankLine)
            {
                this.WhileDoFooterMustNotBePrecededByBlankLine(file.ToTreeNode().FirstChild);
            }

            if (chainedStatementBlocksMustNotBePrecededByBlankLine)
            {
                this.ChainedStatementBlocksMustNotBePrecededByBlankLine(file.ToTreeNode().FirstChild);
            }

            if (openingCurlyBracketsMustNotBePrecededByBlankLine)
            {
                this.OpeningCurlyBracketsMustNotBePrecededByBlankLine(file.ToTreeNode().FirstChild);
            }

            if (elementDocumentationHeadersMustBePrecededByBlankLine)
            {
                this.ElementDocumentationHeadersMustBePrecededByBlankLine(file.ToTreeNode().FirstChild);
            }

            if (curlyBracketsForMultiLineStatementsMustNotShareLine)
            {
                this.CurlyBracketsForMultiLineStatementsMustNotShareLine(file.ToTreeNode().FirstChild);
            }

            StyleCopTrace.Out();
        }
开发者ID:transformersprimeabcxyz,项目名称:_TO-FIRST-stylecop,代码行数:67,代码来源:LayoutRules.cs


注:本文中的ICSharpFile.ToTreeNode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。