diff --git a/ICSharpCode.Decompiler/Ast/CommentStatement.cs b/ICSharpCode.Decompiler/Ast/CommentStatement.cs
index fb36235bd..6f0135c72 100644
--- a/ICSharpCode.Decompiler/Ast/CommentStatement.cs
+++ b/ICSharpCode.Decompiler/Ast/CommentStatement.cs
@@ -4,6 +4,7 @@
using System;
using System.Linq;
using ICSharpCode.NRefactory.CSharp;
+using ICSharpCode.NRefactory.CSharp.PatternMatching;
namespace Decompiler
{
@@ -34,5 +35,11 @@ namespace Decompiler
cs.Remove();
}
}
+
+ protected override bool DoMatch(AstNode other, Match match)
+ {
+ CommentStatement o = other as CommentStatement;
+ return o != null && MatchString(comment, o.comment);
+ }
}
}
diff --git a/NRefactory/ICSharpCode.NRefactory/CSharp/Ast/Statements/CheckedStatement.cs b/NRefactory/ICSharpCode.NRefactory/CSharp/Ast/Statements/CheckedStatement.cs
index 1461a6407..d80dc6d57 100644
--- a/NRefactory/ICSharpCode.NRefactory/CSharp/Ast/Statements/CheckedStatement.cs
+++ b/NRefactory/ICSharpCode.NRefactory/CSharp/Ast/Statements/CheckedStatement.cs
@@ -1,4 +1,4 @@
-//
+//
// CheckedStatement.cs
//
// Author:
@@ -44,5 +44,11 @@ namespace ICSharpCode.NRefactory.CSharp
{
return visitor.VisitCheckedStatement (this, data);
}
+
+ protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
+ {
+ CheckedStatement o = other as CheckedStatement;
+ return o != null && this.Body.DoMatch(o.Body, match);
+ }
}
}
diff --git a/NRefactory/ICSharpCode.NRefactory/CSharp/Ast/Statements/ContinueStatement.cs b/NRefactory/ICSharpCode.NRefactory/CSharp/Ast/Statements/ContinueStatement.cs
index 7dc06c596..1de6b5d50 100644
--- a/NRefactory/ICSharpCode.NRefactory/CSharp/Ast/Statements/ContinueStatement.cs
+++ b/NRefactory/ICSharpCode.NRefactory/CSharp/Ast/Statements/ContinueStatement.cs
@@ -1,4 +1,4 @@
-//
+//
// ContinueStatement.cs
//
// Author:
@@ -39,5 +39,11 @@ namespace ICSharpCode.NRefactory.CSharp
{
return visitor.VisitContinueStatement (this, data);
}
+
+ protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
+ {
+ ContinueStatement o = other as ContinueStatement;
+ return o != null;
+ }
}
}
diff --git a/NRefactory/ICSharpCode.NRefactory/CSharp/Ast/Statements/DoWhileStatement.cs b/NRefactory/ICSharpCode.NRefactory/CSharp/Ast/Statements/DoWhileStatement.cs
index 51d5f4708..378fd43ab 100644
--- a/NRefactory/ICSharpCode.NRefactory/CSharp/Ast/Statements/DoWhileStatement.cs
+++ b/NRefactory/ICSharpCode.NRefactory/CSharp/Ast/Statements/DoWhileStatement.cs
@@ -1,4 +1,4 @@
-//
+//
// DoWhileStatement.cs
//
// Author:
@@ -68,6 +68,12 @@ namespace ICSharpCode.NRefactory.CSharp
{
return visitor.VisitDoWhileStatement (this, data);
}
+
+ protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
+ {
+ DoWhileStatement o = other as DoWhileStatement;
+ return o != null && this.EmbeddedStatement.DoMatch(o.EmbeddedStatement, match) && this.Condition.DoMatch(o.Condition, match);
+ }
}
}
diff --git a/NRefactory/ICSharpCode.NRefactory/CSharp/Ast/Statements/EmptyStatement.cs b/NRefactory/ICSharpCode.NRefactory/CSharp/Ast/Statements/EmptyStatement.cs
index 7a9528b86..3ee53863e 100644
--- a/NRefactory/ICSharpCode.NRefactory/CSharp/Ast/Statements/EmptyStatement.cs
+++ b/NRefactory/ICSharpCode.NRefactory/CSharp/Ast/Statements/EmptyStatement.cs
@@ -1,4 +1,4 @@
-//
+//
// EmptyStatement.cs
//
// Author:
@@ -52,5 +52,11 @@ namespace ICSharpCode.NRefactory.CSharp
{
return visitor.VisitEmptyStatement (this, data);
}
+
+ protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
+ {
+ EmptyStatement o = other as EmptyStatement;
+ return o != null;
+ }
}
}
diff --git a/NRefactory/ICSharpCode.NRefactory/CSharp/Ast/Statements/FixedStatement.cs b/NRefactory/ICSharpCode.NRefactory/CSharp/Ast/Statements/FixedStatement.cs
index d500c8dbf..b1b7759f0 100644
--- a/NRefactory/ICSharpCode.NRefactory/CSharp/Ast/Statements/FixedStatement.cs
+++ b/NRefactory/ICSharpCode.NRefactory/CSharp/Ast/Statements/FixedStatement.cs
@@ -63,5 +63,11 @@ namespace ICSharpCode.NRefactory.CSharp
{
return visitor.VisitFixedStatement (this, data);
}
+
+ protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
+ {
+ FixedStatement o = other as FixedStatement;
+ return o != null && this.Variables.DoMatch(o.Variables, match) && this.EmbeddedStatement.DoMatch(o.EmbeddedStatement, match);
+ }
}
}
diff --git a/NRefactory/ICSharpCode.NRefactory/CSharp/Ast/Statements/ForeachStatement.cs b/NRefactory/ICSharpCode.NRefactory/CSharp/Ast/Statements/ForeachStatement.cs
index ca75d6d0d..6caf3883e 100644
--- a/NRefactory/ICSharpCode.NRefactory/CSharp/Ast/Statements/ForeachStatement.cs
+++ b/NRefactory/ICSharpCode.NRefactory/CSharp/Ast/Statements/ForeachStatement.cs
@@ -1,4 +1,4 @@
-//
+//
// ForeachStatement.cs
//
// Author:
@@ -75,5 +75,12 @@ namespace ICSharpCode.NRefactory.CSharp
{
return visitor.VisitForeachStatement (this, data);
}
+
+ protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
+ {
+ ForeachStatement o = other as ForeachStatement;
+ return o != null && this.VariableType.DoMatch(o.VariableType, match) && MatchString(this.VariableName, o.VariableName)
+ && this.InExpression.DoMatch(o.InExpression, match) && this.EmbeddedStatement.DoMatch(o.EmbeddedStatement, match);
+ }
}
}
diff --git a/NRefactory/ICSharpCode.NRefactory/CSharp/Ast/Statements/GotoStatement.cs b/NRefactory/ICSharpCode.NRefactory/CSharp/Ast/Statements/GotoStatement.cs
index ee1784ad7..2eeeb0bc3 100644
--- a/NRefactory/ICSharpCode.NRefactory/CSharp/Ast/Statements/GotoStatement.cs
+++ b/NRefactory/ICSharpCode.NRefactory/CSharp/Ast/Statements/GotoStatement.cs
@@ -56,14 +56,6 @@ namespace ICSharpCode.NRefactory.CSharp
}
}
- ///
- /// Used for "goto case LabelExpression;"
- ///
- public Expression LabelExpression {
- get { return GetChildByRole (Roles.Expression); }
- set { SetChildByRole (Roles.Expression, value); }
- }
-
public CSharpTokenNode SemicolonToken {
get { return GetChildByRole (Roles.Semicolon); }
}
@@ -72,6 +64,12 @@ namespace ICSharpCode.NRefactory.CSharp
{
return visitor.VisitGotoStatement (this, data);
}
+
+ protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
+ {
+ GotoStatement o = other as GotoStatement;
+ return o != null && MatchString(this.Label, o.Label);
+ }
}
///
@@ -89,18 +87,6 @@ namespace ICSharpCode.NRefactory.CSharp
get { return GetChildByRole (CaseKeywordRole); }
}
- public string Label {
- get {
- return GetChildByRole (Roles.Identifier).Name;
- }
- set {
- if (string.IsNullOrEmpty(value))
- SetChildByRole(Roles.Identifier, null);
- else
- SetChildByRole(Roles.Identifier, new Identifier(value, AstLocation.Empty));
- }
- }
-
///
/// Used for "goto case LabelExpression;"
///
@@ -117,6 +103,12 @@ namespace ICSharpCode.NRefactory.CSharp
{
return visitor.VisitGotoCaseStatement (this, data);
}
+
+ protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
+ {
+ GotoCaseStatement o = other as GotoCaseStatement;
+ return o != null && this.LabelExpression.DoMatch(o.LabelExpression, match);
+ }
}
///
@@ -142,5 +134,11 @@ namespace ICSharpCode.NRefactory.CSharp
{
return visitor.VisitGotoDefaultStatement (this, data);
}
+
+ protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
+ {
+ GotoDefaultStatement o = other as GotoDefaultStatement;
+ return o != null;
+ }
}
}
diff --git a/NRefactory/ICSharpCode.NRefactory/CSharp/Ast/Statements/LabelStatement.cs b/NRefactory/ICSharpCode.NRefactory/CSharp/Ast/Statements/LabelStatement.cs
index da9dc5273..3ebdc3302 100644
--- a/NRefactory/ICSharpCode.NRefactory/CSharp/Ast/Statements/LabelStatement.cs
+++ b/NRefactory/ICSharpCode.NRefactory/CSharp/Ast/Statements/LabelStatement.cs
@@ -1,4 +1,4 @@
-//
+//
// LabelStatement.cs
//
// Author:
@@ -40,9 +40,19 @@ namespace ICSharpCode.NRefactory.CSharp
}
}
+ public CSharpTokenNode Colon {
+ get { return GetChildByRole (Roles.Colon); }
+ }
+
public override S AcceptVisitor (IAstVisitor visitor, T data)
{
return visitor.VisitLabelStatement (this, data);
}
+
+ protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
+ {
+ LabelStatement o = other as LabelStatement;
+ return o != null && MatchString(this.Label, o.Label);
+ }
}
}
diff --git a/NRefactory/ICSharpCode.NRefactory/CSharp/Ast/Statements/LockStatement.cs b/NRefactory/ICSharpCode.NRefactory/CSharp/Ast/Statements/LockStatement.cs
index 3866dbd17..7298e4f1d 100644
--- a/NRefactory/ICSharpCode.NRefactory/CSharp/Ast/Statements/LockStatement.cs
+++ b/NRefactory/ICSharpCode.NRefactory/CSharp/Ast/Statements/LockStatement.cs
@@ -1,4 +1,4 @@
-//
+//
// LockStatement.cs
//
// Author:
@@ -57,5 +57,11 @@ namespace ICSharpCode.NRefactory.CSharp
{
return visitor.VisitLockStatement (this, data);
}
+
+ protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
+ {
+ LockStatement o = other as LockStatement;
+ return o != null && this.Expression.DoMatch(o.Expression, match) && this.EmbeddedStatement.DoMatch(o.EmbeddedStatement, match);
+ }
}
}
diff --git a/NRefactory/ICSharpCode.NRefactory/CSharp/Ast/Statements/ReturnStatement.cs b/NRefactory/ICSharpCode.NRefactory/CSharp/Ast/Statements/ReturnStatement.cs
index 938fcb679..d8368d442 100644
--- a/NRefactory/ICSharpCode.NRefactory/CSharp/Ast/Statements/ReturnStatement.cs
+++ b/NRefactory/ICSharpCode.NRefactory/CSharp/Ast/Statements/ReturnStatement.cs
@@ -1,4 +1,4 @@
-//
+//
// ReturnStatement.cs
//
// Author:
@@ -48,5 +48,11 @@ namespace ICSharpCode.NRefactory.CSharp
{
return visitor.VisitReturnStatement (this, data);
}
+
+ protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
+ {
+ ReturnStatement o = other as ReturnStatement;
+ return o != null && this.Expression.DoMatch(o.Expression, match);
+ }
}
}
diff --git a/NRefactory/ICSharpCode.NRefactory/CSharp/Ast/Statements/Statement.cs b/NRefactory/ICSharpCode.NRefactory/CSharp/Ast/Statements/Statement.cs
index 1725255f4..0d678ff59 100644
--- a/NRefactory/ICSharpCode.NRefactory/CSharp/Ast/Statements/Statement.cs
+++ b/NRefactory/ICSharpCode.NRefactory/CSharp/Ast/Statements/Statement.cs
@@ -52,10 +52,5 @@ namespace ICSharpCode.NRefactory.CSharp
public override NodeType NodeType {
get { return NodeType.Statement; }
}
-
- protected internal override bool DoMatch(AstNode other, ICSharpCode.NRefactory.CSharp.PatternMatching.Match match)
- {
- throw new NotImplementedException();
- }
}
}
diff --git a/NRefactory/ICSharpCode.NRefactory/CSharp/Ast/Statements/SwitchStatement.cs b/NRefactory/ICSharpCode.NRefactory/CSharp/Ast/Statements/SwitchStatement.cs
index f8218d507..09b82be63 100644
--- a/NRefactory/ICSharpCode.NRefactory/CSharp/Ast/Statements/SwitchStatement.cs
+++ b/NRefactory/ICSharpCode.NRefactory/CSharp/Ast/Statements/SwitchStatement.cs
@@ -69,6 +69,12 @@ namespace ICSharpCode.NRefactory.CSharp
{
return visitor.VisitSwitchStatement (this, data);
}
+
+ protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
+ {
+ SwitchStatement o = other as SwitchStatement;
+ return o != null && this.Expression.DoMatch(o.Expression, match) && this.SwitchSections.DoMatch(o.SwitchSections, match);
+ }
}
public class SwitchSection : AstNode
diff --git a/NRefactory/ICSharpCode.NRefactory/CSharp/Ast/Statements/ThrowStatement.cs b/NRefactory/ICSharpCode.NRefactory/CSharp/Ast/Statements/ThrowStatement.cs
index 545dc6ac3..fc9f34237 100644
--- a/NRefactory/ICSharpCode.NRefactory/CSharp/Ast/Statements/ThrowStatement.cs
+++ b/NRefactory/ICSharpCode.NRefactory/CSharp/Ast/Statements/ThrowStatement.cs
@@ -1,4 +1,4 @@
-//
+//
// ThrowStatement.cs
//
// Author:
@@ -48,5 +48,11 @@ namespace ICSharpCode.NRefactory.CSharp
{
return visitor.VisitThrowStatement (this, data);
}
+
+ protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
+ {
+ ThrowStatement o = other as ThrowStatement;
+ return o != null && this.Expression.DoMatch(o.Expression, match);
+ }
}
}
diff --git a/NRefactory/ICSharpCode.NRefactory/CSharp/Ast/Statements/UncheckedStatement.cs b/NRefactory/ICSharpCode.NRefactory/CSharp/Ast/Statements/UncheckedStatement.cs
index ec55c0cbc..a0bef129e 100644
--- a/NRefactory/ICSharpCode.NRefactory/CSharp/Ast/Statements/UncheckedStatement.cs
+++ b/NRefactory/ICSharpCode.NRefactory/CSharp/Ast/Statements/UncheckedStatement.cs
@@ -1,4 +1,4 @@
-//
+//
// UncheckedStatement.cs
//
// Author:
@@ -44,5 +44,11 @@ namespace ICSharpCode.NRefactory.CSharp
{
return visitor.VisitUncheckedStatement (this, data);
}
+
+ protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
+ {
+ UncheckedStatement o = other as UncheckedStatement;
+ return o != null && this.Body.DoMatch(o.Body, match);
+ }
}
}
diff --git a/NRefactory/ICSharpCode.NRefactory/CSharp/Ast/Statements/UnsafeStatement.cs b/NRefactory/ICSharpCode.NRefactory/CSharp/Ast/Statements/UnsafeStatement.cs
index d9a45a860..c5ccb63af 100644
--- a/NRefactory/ICSharpCode.NRefactory/CSharp/Ast/Statements/UnsafeStatement.cs
+++ b/NRefactory/ICSharpCode.NRefactory/CSharp/Ast/Statements/UnsafeStatement.cs
@@ -1,4 +1,4 @@
-//
+//
// UnsafeStatement.cs
//
// Author:
@@ -44,5 +44,11 @@ namespace ICSharpCode.NRefactory.CSharp
{
return visitor.VisitUnsafeStatement (this, data);
}
+
+ protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
+ {
+ UnsafeStatement o = other as UnsafeStatement;
+ return o != null && this.Body.DoMatch(o.Body, match);
+ }
}
}
diff --git a/NRefactory/ICSharpCode.NRefactory/CSharp/Ast/Statements/WhileStatement.cs b/NRefactory/ICSharpCode.NRefactory/CSharp/Ast/Statements/WhileStatement.cs
index 9eec22b2f..01470b3ab 100644
--- a/NRefactory/ICSharpCode.NRefactory/CSharp/Ast/Statements/WhileStatement.cs
+++ b/NRefactory/ICSharpCode.NRefactory/CSharp/Ast/Statements/WhileStatement.cs
@@ -1,4 +1,4 @@
-//
+//
// WhileStatement.cs
//
// Author:
@@ -59,5 +59,11 @@ namespace ICSharpCode.NRefactory.CSharp
{
return visitor.VisitWhileStatement (this, data);
}
+
+ protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
+ {
+ WhileStatement o = other as WhileStatement;
+ return o != null && this.Condition.DoMatch(o.Condition, match) && this.EmbeddedStatement.DoMatch(o.EmbeddedStatement, match);
+ }
}
}
diff --git a/NRefactory/ICSharpCode.NRefactory/CSharp/Ast/Statements/YieldBreakStatement.cs b/NRefactory/ICSharpCode.NRefactory/CSharp/Ast/Statements/YieldBreakStatement.cs
index 2982dbf41..4c572615a 100644
--- a/NRefactory/ICSharpCode.NRefactory/CSharp/Ast/Statements/YieldBreakStatement.cs
+++ b/NRefactory/ICSharpCode.NRefactory/CSharp/Ast/Statements/YieldBreakStatement.cs
@@ -1,4 +1,4 @@
-//
+//
// YieldBreakStatement.cs
//
// Author:
@@ -50,5 +50,11 @@ namespace ICSharpCode.NRefactory.CSharp
{
return visitor.VisitYieldBreakStatement (this, data);
}
+
+ protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
+ {
+ YieldBreakStatement o = other as YieldBreakStatement;
+ return o != null;
+ }
}
}
diff --git a/NRefactory/ICSharpCode.NRefactory/CSharp/Ast/Statements/YieldStatement.cs b/NRefactory/ICSharpCode.NRefactory/CSharp/Ast/Statements/YieldStatement.cs
index 531d21ec5..001815f3a 100644
--- a/NRefactory/ICSharpCode.NRefactory/CSharp/Ast/Statements/YieldStatement.cs
+++ b/NRefactory/ICSharpCode.NRefactory/CSharp/Ast/Statements/YieldStatement.cs
@@ -1,4 +1,4 @@
-//
+//
// YieldStatement.cs
//
// Author:
@@ -55,5 +55,11 @@ namespace ICSharpCode.NRefactory.CSharp
{
return visitor.VisitYieldStatement (this, data);
}
+
+ protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
+ {
+ YieldStatement o = other as YieldStatement;
+ return o != null && this.Expression.DoMatch(o.Expression, match);
+ }
}
}