Browse Source

Add null node for VariableInitializer.

newNRvisualizers
Daniel Grunwald 14 years ago
parent
commit
d62f36694e
  1. 2
      ICSharpCode.NRefactory.CSharp/Ast/AstNode.cs
  2. 2
      ICSharpCode.NRefactory.CSharp/Ast/Statements/VariableDeclarationStatement.cs
  3. 23
      ICSharpCode.NRefactory.CSharp/Ast/TypeMembers/VariableInitializer.cs

2
ICSharpCode.NRefactory.CSharp/Ast/AstNode.cs

@ -671,7 +671,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -671,7 +671,7 @@ namespace ICSharpCode.NRefactory.CSharp
public static readonly Role<TypeParameterDeclaration> TypeParameter = new Role<TypeParameterDeclaration> ("TypeParameter");
public static readonly Role<AstType> TypeArgument = new Role<AstType> ("TypeArgument", CSharp.AstType.Null);
public readonly static Role<Constraint> Constraint = new Role<Constraint> ("Constraint");
public static readonly Role<VariableInitializer> Variable = new Role<VariableInitializer> ("Variable");
public static readonly Role<VariableInitializer> Variable = new Role<VariableInitializer> ("Variable", VariableInitializer.Null);
public static readonly Role<Statement> EmbeddedStatement = new Role<Statement> ("EmbeddedStatement", CSharp.Statement.Null);
public static readonly Role<CSharpTokenNode> Keyword = new Role<CSharpTokenNode> ("Keyword", CSharpTokenNode.Null);
public static readonly Role<CSharpTokenNode> InKeyword = new Role<CSharpTokenNode> ("InKeyword", CSharpTokenNode.Null);

2
ICSharpCode.NRefactory.CSharp/Ast/Statements/VariableDeclarationStatement.cs

@ -63,7 +63,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -63,7 +63,7 @@ namespace ICSharpCode.NRefactory.CSharp
public VariableInitializer GetVariable (string name)
{
return Variables.FirstOrDefault (vi => vi.Name == name);
return Variables.FirstOrNullObject (vi => vi.Name == name);
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data = default(T))

23
ICSharpCode.NRefactory.CSharp/Ast/TypeMembers/VariableInitializer.cs

@ -28,6 +28,29 @@ namespace ICSharpCode.NRefactory.CSharp @@ -28,6 +28,29 @@ namespace ICSharpCode.NRefactory.CSharp
{
public class VariableInitializer : AstNode
{
#region Null
public new static readonly VariableInitializer Null = new NullVariableInitializer ();
sealed class NullVariableInitializer : VariableInitializer
{
public override bool IsNull {
get {
return true;
}
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data = default(T))
{
return default (S);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
return other == null || other.IsNull;
}
}
#endregion
#region PatternPlaceholder
public static implicit operator VariableInitializer(PatternMatching.Pattern pattern)
{

Loading…
Cancel
Save