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


C# CodeFormattingOptions.GetNextLineProceedingText方法代码示例

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


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

示例1: AppendCodeStringStmt

        internal override void AppendCodeStringStmt(StringBuilder res, PythonAst ast, CodeFormattingOptions format) {
            // SuiteStatement comes in 3 forms:
            //  1. The body of a if/else/while/for/etc... where there's an opening colon
            //  2. A set of semi-colon separated items
            //  3. A top-level group of statements in a top-level PythonAst node.
            var itemWhiteSpace = this.GetListWhiteSpace(ast);
            var colonWhiteSpace = this.GetProceedingWhiteSpaceDefaultNull(ast);
            if (this.IsAltForm(ast)) {
                // suite statement in top-level PythonAst, we have no colons or other delimiters
                foreach (var statement in _statements) {
                    statement.AppendCodeString(res, ast, format);
                }
            } else if (itemWhiteSpace != null) {
                if (format.BreakMultipleStatementsPerLine) {
                    string leadingWhiteSpace = "";
                    for (int i = 0; i < _statements.Length; i++) {
                        if (i == 0) {
                            StringBuilder tmp = new StringBuilder();
                            _statements[i].AppendCodeString(tmp, ast, format);  
                            var stmt = tmp.ToString();
                            res.Append(stmt);

                            // figure out the whitespace needed for the next statement based upon the current statement
                            for (int curChar = 0; curChar < stmt.Length; curChar++) {
                                if (!char.IsWhiteSpace(stmt[curChar])) {
                                    leadingWhiteSpace = format.GetNextLineProceedingText(stmt.Substring(0, curChar));
                                    break;
                                }
                            }
                        } else {
                            _statements[i].AppendCodeString(res, ast, format, leadingWhiteSpace);
                        }
                    }
                } else {
                    // form 2, semi-colon seperated list.
                    for (int i = 0; i < _statements.Length; i++) {
                        if (i > 0) {
                            if (i - 1 < itemWhiteSpace.Length) {
                                res.Append(itemWhiteSpace[i - 1]);
                            }
                            res.Append(';');
                        }
                        _statements[i].AppendCodeString(res, ast, format);
                    }
                }

                if (itemWhiteSpace != null && itemWhiteSpace.Length == _statements.Length && _statements.Length != 0) {
                    // trailing semi-colon
                    if (!format.RemoveTrailingSemicolons) {
                        res.Append(itemWhiteSpace[itemWhiteSpace.Length - 1]);
                        res.Append(";");
                    }
                }
            } else {
                // 3rd form, suite statement as the body of a class/function, we include the colon.
                if (colonWhiteSpace != null) {
                    res.Append(colonWhiteSpace);
                }
                res.Append(':');
                
                foreach (var statement in _statements) {
                    statement.AppendCodeString(res, ast, format);
                }
            }
        }
开发者ID:wenh123,项目名称:PTVS,代码行数:65,代码来源:SuiteStatement.cs

示例2: AppendCodeStringStmt

        internal override void AppendCodeStringStmt(StringBuilder res, PythonAst ast, CodeFormattingOptions format) {
            var asNameWhiteSpace = this.GetNamesWhiteSpace(ast);
            if (format.ReplaceMultipleImportsWithMultipleStatements) {
                var proceeding = this.GetProceedingWhiteSpace(ast);
                var additionalProceeding = format.GetNextLineProceedingText(proceeding);
                
                for (int i = 0, asIndex = 0; i < _names.Length; i++) {
                    if (i == 0) {
                        format.ReflowComment(res, proceeding) ;
                    } else {
                        res.Append(additionalProceeding);
                    }
                    res.Append("import");

                    _names[i].AppendCodeString(res, ast, format);
                    AppendAs(res, ast, format, asNameWhiteSpace, i, ref asIndex);
                }
                return;
            } else {
                format.ReflowComment(res, this.GetProceedingWhiteSpace(ast));
                res.Append("import");

                var itemWhiteSpace = this.GetListWhiteSpace(ast);
                for (int i = 0, asIndex = 0; i < _names.Length; i++) {
                    if (i > 0 && itemWhiteSpace != null) {
                        res.Append(itemWhiteSpace[i - 1]);
                        res.Append(',');
                    }

                    _names[i].AppendCodeString(res, ast, format);
                    AppendAs(res, ast, format, asNameWhiteSpace, i, ref asIndex);
                }
            }
        }
开发者ID:omnimark,项目名称:PTVS,代码行数:34,代码来源:ImportStatement.cs


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