本文整理汇总了C#中AstNode.GetNodeAt方法的典型用法代码示例。如果您正苦于以下问题:C# AstNode.GetNodeAt方法的具体用法?C# AstNode.GetNodeAt怎么用?C# AstNode.GetNodeAt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AstNode
的用法示例。
在下文中一共展示了AstNode.GetNodeAt方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateAction
static CodeAction CreateAction(RefactoringContext context, AstNode createFromNode, string methodName, AstType returnType, IEnumerable<ParameterDeclaration> parameters, bool createInOtherType, bool isStatic, ResolveResult targetResolveResult)
{
return new CodeAction(context.TranslateString("Create method"), script => {
var throwStatement = new ThrowStatement();
var decl = new MethodDeclaration {
ReturnType = returnType,
Name = methodName,
Body = new BlockStatement {
throwStatement
}
};
decl.Parameters.AddRange(parameters);
if (isStatic)
decl.Modifiers |= Modifiers.Static;
if (createInOtherType) {
if (targetResolveResult.Type.Kind == TypeKind.Interface) {
decl.Body = null;
decl.Modifiers = Modifiers.None;
} else {
decl.Modifiers |= Modifiers.Public;
}
script
.InsertWithCursor(context.TranslateString("Create method"), targetResolveResult.Type.GetDefinition(), (s, c) => {
throwStatement.Expression = new ObjectCreateExpression(c.CreateShortType("System", "NotImplementedException"));
return decl;
})
.ContinueScript (s => s.Select(throwStatement));
return;
} else {
throwStatement.Expression = new ObjectCreateExpression(context.CreateShortType("System", "NotImplementedException"));
}
script
.InsertWithCursor(context.TranslateString("Create method"), Script.InsertPosition.Before, decl)
.ContinueScript (() => script.Select(throwStatement));
}, createFromNode.GetNodeAt(context.Location));
}