本文整理汇总了C#中AstNode.Clone方法的典型用法代码示例。如果您正苦于以下问题:C# AstNode.Clone方法的具体用法?C# AstNode.Clone怎么用?C# AstNode.Clone使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AstNode
的用法示例。
在下文中一共展示了AstNode.Clone方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CloneWithReplacementAnnotation
public static AstNode CloneWithReplacementAnnotation(AstNode node, AstNode replacedNode)
{
var newNode = node.Clone();
AddReplacementAnnotation(newNode, replacedNode);
return newNode;
}
示例2: AddIssue
void AddIssue(AstNode node)
{
var title = ctx.TranslateString ("Remove redundant assignment");
var variableInitializer = node as VariableInitializer;
if (variableInitializer != null) {
if (new SearchInvocationsVisitor ().ContainsInvocations (variableInitializer.Initializer))
return;
AddIssue (variableInitializer.Initializer, title,
script => {
var replacement = (VariableInitializer)node.Clone ();
replacement.Initializer = Expression.Null;
script.Replace (node, replacement);
});
}
var assignmentExpr = node.Parent as AssignmentExpression;
if (assignmentExpr == null)
return;
if (assignmentExpr.Parent is ExpressionStatement) {
AddIssue (assignmentExpr.Parent, title, script => script.Remove (assignmentExpr.Parent));
} else {
AddIssue (assignmentExpr.Left.StartLocation, assignmentExpr.OperatorToken.EndLocation, title,
script => script.Replace (assignmentExpr, assignmentExpr.Right.Clone ()));
}
}