Browse Source

AstNode: add Invoke() methods to AstType (builds InvocationExpression for static methods)

pull/100/head
Daniel Grunwald 15 years ago
parent
commit
5fc5d7c16c
  1. 24
      NRefactory/ICSharpCode.NRefactory/CSharp/Ast/AstType.cs
  2. 5
      NRefactory/ICSharpCode.NRefactory/CSharp/Ast/PatternMatching/Pattern.cs

24
NRefactory/ICSharpCode.NRefactory/CSharp/Ast/AstType.cs

@ -53,6 +53,30 @@ namespace ICSharpCode.NRefactory.CSharp @@ -53,6 +53,30 @@ namespace ICSharpCode.NRefactory.CSharp
return new TypeReferenceExpression { Type = this }.Member(memberName);
}
/// <summary>
/// Builds an invocation expression using this type as target.
/// </summary>
public InvocationExpression Invoke(string methodName, IEnumerable<Expression> arguments)
{
return new TypeReferenceExpression { Type = this }.Invoke(methodName, arguments);
}
/// <summary>
/// Builds an invocation expression using this type as target.
/// </summary>
public InvocationExpression Invoke(string methodName, params Expression[] arguments)
{
return new TypeReferenceExpression { Type = this }.Invoke(methodName, arguments);
}
/// <summary>
/// Builds an invocation expression using this type as target.
/// </summary>
public InvocationExpression Invoke(string methodName, IEnumerable<AstType> typeArguments, IEnumerable<Expression> arguments)
{
return new TypeReferenceExpression { Type = this }.Invoke(methodName, typeArguments, arguments);
}
public static AstType Create(Type type)
{
switch (Type.GetTypeCode(type)) {

5
NRefactory/ICSharpCode.NRefactory/CSharp/Ast/PatternMatching/Pattern.cs

@ -34,6 +34,11 @@ namespace ICSharpCode.NRefactory.CSharp.PatternMatching @@ -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;

Loading…
Cancel
Save