From 5fc5d7c16c96038e41bf8e37c2f64509bc0d86c9 Mon Sep 17 00:00:00 2001 From: Daniel Grunwald Date: Wed, 9 Mar 2011 10:58:48 +0100 Subject: [PATCH] AstNode: add Invoke() methods to AstType (builds InvocationExpression for static methods) --- .../CSharp/Ast/AstType.cs | 24 +++++++++++++++++++ .../CSharp/Ast/PatternMatching/Pattern.cs | 5 ++++ 2 files changed, 29 insertions(+) diff --git a/NRefactory/ICSharpCode.NRefactory/CSharp/Ast/AstType.cs b/NRefactory/ICSharpCode.NRefactory/CSharp/Ast/AstType.cs index a35204e3c..5582b9012 100644 --- a/NRefactory/ICSharpCode.NRefactory/CSharp/Ast/AstType.cs +++ b/NRefactory/ICSharpCode.NRefactory/CSharp/Ast/AstType.cs @@ -53,6 +53,30 @@ namespace ICSharpCode.NRefactory.CSharp return new TypeReferenceExpression { Type = this }.Member(memberName); } + /// + /// Builds an invocation expression using this type as target. + /// + public InvocationExpression Invoke(string methodName, IEnumerable arguments) + { + return new TypeReferenceExpression { Type = this }.Invoke(methodName, arguments); + } + + /// + /// Builds an invocation expression using this type as target. + /// + public InvocationExpression Invoke(string methodName, params Expression[] arguments) + { + return new TypeReferenceExpression { Type = this }.Invoke(methodName, arguments); + } + + /// + /// Builds an invocation expression using this type as target. + /// + public InvocationExpression Invoke(string methodName, IEnumerable typeArguments, IEnumerable arguments) + { + return new TypeReferenceExpression { Type = this }.Invoke(methodName, typeArguments, arguments); + } + public static AstType Create(Type type) { switch (Type.GetTypeCode(type)) { diff --git a/NRefactory/ICSharpCode.NRefactory/CSharp/Ast/PatternMatching/Pattern.cs b/NRefactory/ICSharpCode.NRefactory/CSharp/Ast/PatternMatching/Pattern.cs index 85fd861bb..ed2122d19 100644 --- a/NRefactory/ICSharpCode.NRefactory/CSharp/Ast/PatternMatching/Pattern.cs +++ b/NRefactory/ICSharpCode.NRefactory/CSharp/Ast/PatternMatching/Pattern.cs @@ -34,6 +34,11 @@ namespace ICSharpCode.NRefactory.CSharp.PatternMatching return p != null ? new TypePlaceholder(p) : null; } + public AstType ToType() + { + return new TypePlaceholder(this); + } + public static implicit operator Expression(Pattern p) { return p != null ? new ExpressionPlaceholder(p) : null;