本文整理汇总了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);
}
}
}
示例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);
}
}
}