本文整理汇总了C#中CodeFormattingOptions.Append方法的典型用法代码示例。如果您正苦于以下问题:C# CodeFormattingOptions.Append方法的具体用法?C# CodeFormattingOptions.Append怎么用?C# CodeFormattingOptions.Append使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CodeFormattingOptions
的用法示例。
在下文中一共展示了CodeFormattingOptions.Append方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AppendCodeString
internal override void AppendCodeString(StringBuilder res, PythonAst ast, CodeFormattingOptions format) {
Target.AppendCodeString(res, ast, format);
format.Append(
res,
format.SpaceBeforeIndexBracket,
" ",
"",
this.GetProceedingWhiteSpace(ast)
);
res.Append('[');
_index.AppendCodeString(
res,
ast,
format,
format.SpaceWithinIndexBrackets != null ? format.SpaceWithinIndexBrackets.Value ? " " : "" : null
);
if (!this.IsMissingCloseGrouping(ast)) {
format.Append(
res,
format.SpaceWithinIndexBrackets,
" ",
"",
this.GetSecondWhiteSpace(ast)
);
res.Append(']');
}
}
示例2: AppendCodeStringStmt
internal override void AppendCodeStringStmt(StringBuilder res, PythonAst ast, CodeFormattingOptions format) {
var lhs = this.GetListWhiteSpace(ast);
for (int i = 0; i < Left.Count; i++) {
if (lhs != null && i != 0) {
format.Append(
res,
format.SpacesAroundAssignmentOperator,
" ",
"",
lhs[i - 1]
);
res.Append("=");
}
Left[i].AppendCodeString(
res,
ast,
format,
i != 0 && format.SpacesAroundAssignmentOperator != null ?
format.SpacesAroundAssignmentOperator.Value ? " " : "" :
null
);
}
if (lhs != null) {
format.Append(
res,
format.SpacesAroundAssignmentOperator,
" ",
"",
lhs[lhs.Length - 1]
);
}
res.Append("=");
Right.AppendCodeString(
res,
ast,
format,
format.SpacesAroundAssignmentOperator != null ?
format.SpacesAroundAssignmentOperator.Value ? " " : "" :
null
);
}
示例3: AppendCodeString
internal override void AppendCodeString(StringBuilder res, PythonAst ast, CodeFormattingOptions format) {
format.ReflowComment(res, this.GetProceedingWhiteSpace(ast));
res.Append('(');
_expression.AppendCodeString(
res,
ast,
format,
format.SpacesWithinParenthesisExpression != null ? format.SpacesWithinParenthesisExpression.Value ? " " : "" : null
);
if (!this.IsMissingCloseGrouping(ast)) {
format.Append(
res,
format.SpacesWithinParenthesisExpression,
" ",
"",
this.GetSecondWhiteSpace(ast)
);
res.Append(')');
}
}
示例4: AppendCodeStringStmt
internal override void AppendCodeStringStmt(StringBuilder res, PythonAst ast, CodeFormattingOptions format) {
var decorateWhiteSpace = this.GetNamesWhiteSpace(ast);
if (Decorators != null) {
Decorators.AppendCodeString(res, ast, format);
}
format.ReflowComment(res, this.GetProceedingWhiteSpaceDefaultNull(ast));
if (IsCoroutine) {
res.Append("async");
res.Append(NodeAttributes.GetWhiteSpace(this, ast, WhitespaceAfterAsync));
}
res.Append("def");
var name = this.GetVerbatimImage(ast) ?? Name;
if (!String.IsNullOrEmpty(name)) {
res.Append(this.GetSecondWhiteSpace(ast));
res.Append(name);
if (!this.IsIncompleteNode(ast)) {
format.Append(
res,
format.SpaceBeforeFunctionDeclarationParen,
" ",
"",
this.GetThirdWhiteSpaceDefaultNull(ast)
);
res.Append('(');
if (Parameters.Count != 0) {
var commaWhiteSpace = this.GetListWhiteSpace(ast);
ParamsToString(res,
ast,
commaWhiteSpace,
format,
format.SpaceWithinFunctionDeclarationParens != null ?
format.SpaceWithinFunctionDeclarationParens.Value ? " " : "" :
null
);
}
string namedOnly = this.GetExtraVerbatimText(ast);
if (namedOnly != null) {
res.Append(namedOnly);
}
if (!this.IsMissingCloseGrouping(ast)) {
format.Append(
res,
Parameters.Count != 0 ?
format.SpaceWithinFunctionDeclarationParens :
format.SpaceWithinEmptyParameterList,
" ",
"",
this.GetFourthWhiteSpaceDefaultNull(ast)
);
res.Append(')');
}
if (ReturnAnnotation != null) {
format.Append(
res,
format.SpaceAroundAnnotationArrow,
" ",
"",
this.GetFifthWhiteSpace(ast)
);
res.Append("->");
_returnAnnotation.AppendCodeString(
res,
ast,
format,
format.SpaceAroundAnnotationArrow != null ?
format.SpaceAroundAnnotationArrow.Value ? " " : "" :
null
);
}
if (Body != null) {
Body.AppendCodeString(res, ast, format);
}
}
}
}
示例5: AppendCodeStringStmt
internal override void AppendCodeStringStmt(StringBuilder res, PythonAst ast, CodeFormattingOptions format) {
if (Decorators != null) {
Decorators.AppendCodeString(res, ast, format);
}
format.ReflowComment(res, this.GetProceedingWhiteSpace(ast));
res.Append("class");
res.Append(this.GetSecondWhiteSpace(ast));
res.Append(this.GetVerbatimImage(ast) ?? Name);
if (!this.IsAltForm(ast)) {
format.Append(
res,
format.SpaceBeforeClassDeclarationParen,
" ",
"",
this.GetThirdWhiteSpace(ast)
);
res.Append('(');
}
if (Bases.Count != 0) {
ListExpression.AppendItems(
res,
ast,
format,
"",
"",
this,
this.Bases.Count,
(i, sb) => {
if(format.SpaceWithinClassDeclarationParens != null && i == 0) {
// need to remove any leading whitespace which was preserved for
// the 1st param, and then force the correct whitespace.
Bases[i].AppendCodeString(sb, ast, format, format.SpaceWithinClassDeclarationParens.Value ? " " : "");
} else {
Bases[i].AppendCodeString(sb, ast, format);
}
}
);
} else if (!this.IsAltForm(ast)) {
if (format.SpaceWithinEmptyBaseClassList != null && format.SpaceWithinEmptyBaseClassList.Value) {
res.Append(' ');
}
}
if (!this.IsAltForm(ast) && !this.IsMissingCloseGrouping(ast)) {
if (Bases.Count != 0 ||
format.SpaceWithinEmptyBaseClassList == null ||
!String.IsNullOrWhiteSpace(this.GetFourthWhiteSpace(ast))) {
format.Append(
res,
format.SpaceWithinClassDeclarationParens,
" ",
"",
this.GetFourthWhiteSpace(ast)
);
}
res.Append(')');
}
_body.AppendCodeString(res, ast, format);
}
示例6: BinaryToCodeString
internal static void BinaryToCodeString(StringBuilder res, PythonAst ast, CodeFormattingOptions format, Expression node, Expression left, Expression right, string op1, string op2 = null) {
left.AppendCodeString(res, ast, format);
format.Append(
res,
format.SpacesAroundBinaryOperators,
" ",
Char.IsLetter(op1[0]) ? " " : "", // spaces required for is not, not in, etc...
node.GetProceedingWhiteSpace(ast)
);
if (op2 == null) {
res.Append(op1);
right.AppendCodeString(
res,
ast,
format,
format.SpacesAroundBinaryOperators != null ?
format.SpacesAroundBinaryOperators.Value ?
" " :
(Char.IsLetter(op1[0]) ? " " : "") :
null
);
} else {
Debug.Assert(Char.IsLetter(op1[0]));
res.Append(op1);
res.Append(node.GetSecondWhiteSpace(ast));
res.Append(op2);
right.AppendCodeString(res, ast, format, format.SpacesAroundBinaryOperators != null ? " " : null); // force single space if setting is on or off
}
}
示例7: AppendCodeString
internal override void AppendCodeString(StringBuilder res, PythonAst ast, CodeFormattingOptions format) {
_target.AppendCodeString(res, ast, format);
format.Append(
res,
format.SpaceBeforeCallParen,
" ",
"",
this.GetProceedingWhiteSpaceDefaultNull(ast)
);
res.Append('(');
if (_args.Length == 0) {
if (format.SpaceWithinEmptyCallArgumentList != null && format.SpaceWithinEmptyCallArgumentList.Value) {
res.Append(' ');
}
} else {
var listWhiteSpace = this.GetListWhiteSpace(ast);
for (int i = 0; i < _args.Length; i++) {
if (i > 0) {
if (listWhiteSpace != null) {
res.Append(listWhiteSpace[i - 1]);
}
res.Append(',');
} else if (format.SpaceWithinCallParens != null) {
_args[i].AppendCodeString(res, ast, format, format.SpaceWithinCallParens.Value ? " " : "");
continue;
}
_args[i].AppendCodeString(res, ast, format);
}
if (listWhiteSpace != null && listWhiteSpace.Length == _args.Length) {
// trailing comma
res.Append(listWhiteSpace[listWhiteSpace.Length - 1]);
res.Append(",");
}
}
if (!this.IsMissingCloseGrouping(ast)) {
if (Args.Count != 0 ||
format.SpaceWithinEmptyCallArgumentList == null ||
!String.IsNullOrWhiteSpace(this.GetSecondWhiteSpaceDefaultNull(ast))) {
format.Append(
res,
format.SpaceWithinCallParens,
" ",
"",
this.GetSecondWhiteSpaceDefaultNull(ast)
);
}
res.Append(')');
}
}
示例8: AppendCodeString
internal override void AppendCodeString(StringBuilder res, PythonAst ast, CodeFormattingOptions format, string leadingWhiteSpace) {
string kwOnlyText = this.GetExtraVerbatimText(ast);
if (kwOnlyText != null) {
if (leadingWhiteSpace != null) {
res.Append(leadingWhiteSpace);
res.Append(kwOnlyText.TrimStart());
leadingWhiteSpace = null;
} else {
res.Append(kwOnlyText);
}
}
switch (Kind) {
case ParameterKind.Dictionary:
res.Append(leadingWhiteSpace ?? this.GetProceedingWhiteSpace(ast));
res.Append("**");
res.Append(this.GetSecondWhiteSpace(ast));
res.Append(this.GetVerbatimImage(ast) ?? _name);
AppendAnnotation(res, ast, format);
break;
case ParameterKind.List:
res.Append(leadingWhiteSpace ?? this.GetProceedingWhiteSpace(ast));
res.Append('*');
res.Append(this.GetSecondWhiteSpace(ast));
res.Append(this.GetVerbatimImage(ast) ?? _name);
AppendAnnotation(res, ast, format);
break;
case ParameterKind.Normal:
if (this.IsAltForm(ast)) {
res.Append(leadingWhiteSpace ?? this.GetProceedingWhiteSpace(ast));
res.Append('(');
res.Append(this.GetThirdWhiteSpace(ast));
res.Append(this.GetVerbatimImage(ast) ?? _name);
if (!this.IsMissingCloseGrouping(ast)) {
res.Append(this.GetSecondWhiteSpace(ast));
res.Append(')');
}
} else {
res.Append(leadingWhiteSpace ?? this.GetProceedingWhiteSpaceDefaultNull(ast));
res.Append(this.GetVerbatimImage(ast) ?? _name);
AppendAnnotation(res, ast, format);
}
break;
case ParameterKind.KeywordOnly:
res.Append(leadingWhiteSpace ?? this.GetProceedingWhiteSpace(ast));
res.Append(this.GetVerbatimImage(ast) ?? _name);
AppendAnnotation(res, ast, format);
break;
default: throw new InvalidOperationException();
}
if (_defaultValue != null) {
format.Append(
res,
format.SpaceAroundDefaultValueEquals,
" ",
"",
this.GetSecondWhiteSpace(ast)
);
res.Append('=');
if (format.SpaceAroundDefaultValueEquals != null) {
_defaultValue.AppendCodeString(res, ast, format, format.SpaceAroundDefaultValueEquals.Value ? " " : "");
} else {
_defaultValue.AppendCodeString(res, ast, format);
}
}
}