Browse Source

Add pattern matching for query expressions.

Pattern matching should now work for the complete C# AST.
newNRvisualizers
Daniel Grunwald 15 years ago
parent
commit
60d4fe9d0f
  1. 59
      ICSharpCode.NRefactory/CSharp/Ast/Expressions/QueryExpression.cs

59
ICSharpCode.NRefactory/CSharp/Ast/Expressions/QueryExpression.cs

@ -54,12 +54,6 @@ namespace ICSharpCode.NRefactory.CSharp @@ -54,12 +54,6 @@ namespace ICSharpCode.NRefactory.CSharp
public override NodeType NodeType {
get { return NodeType.QueryClause; }
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
QueryClause o = other as QueryClause;
throw new NotImplementedException();
}
}
/// <summary>
@ -103,6 +97,12 @@ namespace ICSharpCode.NRefactory.CSharp @@ -103,6 +97,12 @@ namespace ICSharpCode.NRefactory.CSharp
{
return visitor.VisitQueryContinuationClause (this, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
QueryContinuationClause o = other as QueryContinuationClause;
return o != null && MatchString(this.Identifier, o.Identifier) && this.PrecedingQuery.DoMatch(o.PrecedingQuery, match);
}
}
public class QueryFromClause : QueryClause
@ -133,6 +133,13 @@ namespace ICSharpCode.NRefactory.CSharp @@ -133,6 +133,13 @@ namespace ICSharpCode.NRefactory.CSharp
{
return visitor.VisitQueryFromClause (this, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
QueryFromClause o = other as QueryFromClause;
return o != null && this.Type.DoMatch(o.Type, match) && MatchString(this.Identifier, o.Identifier)
&& this.Expression.DoMatch(o.Expression, match);
}
}
public class QueryLetClause : QueryClause
@ -163,6 +170,12 @@ namespace ICSharpCode.NRefactory.CSharp @@ -163,6 +170,12 @@ namespace ICSharpCode.NRefactory.CSharp
{
return visitor.VisitQueryLetClause (this, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
QueryLetClause o = other as QueryLetClause;
return o != null && MatchString(this.Identifier, o.Identifier) && this.Expression.DoMatch(o.Expression, match);
}
}
@ -181,6 +194,12 @@ namespace ICSharpCode.NRefactory.CSharp @@ -181,6 +194,12 @@ namespace ICSharpCode.NRefactory.CSharp
{
return visitor.VisitQueryWhereClause (this, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
QueryWhereClause o = other as QueryWhereClause;
return o != null && this.Condition.DoMatch(o.Condition, match);
}
}
/// <summary>
@ -266,6 +285,16 @@ namespace ICSharpCode.NRefactory.CSharp @@ -266,6 +285,16 @@ namespace ICSharpCode.NRefactory.CSharp
{
return visitor.VisitQueryJoinClause (this, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
QueryJoinClause o = other as QueryJoinClause;
return o != null && this.IsGroupJoin == o.IsGroupJoin
&& this.Type.DoMatch(o.Type, match) && MatchString(this.JoinIdentifier, o.JoinIdentifier)
&& this.InExpression.DoMatch(o.InExpression, match) && this.OnExpression.DoMatch(o.OnExpression, match)
&& this.EqualsExpression.DoMatch(o.EqualsExpression, match)
&& MatchString(this.IntoIdentifier, o.IntoIdentifier);
}
}
public class QueryOrderClause : QueryClause
@ -284,6 +313,12 @@ namespace ICSharpCode.NRefactory.CSharp @@ -284,6 +313,12 @@ namespace ICSharpCode.NRefactory.CSharp
{
return visitor.VisitQueryOrderClause (this, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
QueryOrderClause o = other as QueryOrderClause;
return o != null && this.Orderings.DoMatch(o.Orderings, match);
}
}
public class QueryOrdering : AstNode
@ -340,6 +375,12 @@ namespace ICSharpCode.NRefactory.CSharp @@ -340,6 +375,12 @@ namespace ICSharpCode.NRefactory.CSharp
{
return visitor.VisitQuerySelectClause (this, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
QuerySelectClause o = other as QuerySelectClause;
return o != null && this.Expression.DoMatch(o.Expression, match);
}
}
public class QueryGroupClause : QueryClause
@ -371,5 +412,11 @@ namespace ICSharpCode.NRefactory.CSharp @@ -371,5 +412,11 @@ namespace ICSharpCode.NRefactory.CSharp
{
return visitor.VisitQueryGroupClause (this, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
QueryGroupClause o = other as QueryGroupClause;
return o != null && this.Projection.DoMatch(o.Projection, match) && this.Key.DoMatch(o.Key, match);
}
}
}
Loading…
Cancel
Save