diff --git a/NRefactory/ICSharpCode.NRefactory.VB/Ast/Enums.cs b/NRefactory/ICSharpCode.NRefactory.VB/Ast/Enums.cs index dce53fb2d..3d6e42369 100644 --- a/NRefactory/ICSharpCode.NRefactory.VB/Ast/Enums.cs +++ b/NRefactory/ICSharpCode.NRefactory.VB/Ast/Enums.cs @@ -118,7 +118,7 @@ namespace ICSharpCode.NRefactory.VB.Ast /// /// Specifies the ordering direction of a QueryExpressionOrdering node. /// - public enum QueryExpressionOrderingDirection + public enum QueryOrderingDirection { None, Ascending, @@ -129,7 +129,7 @@ namespace ICSharpCode.NRefactory.VB.Ast /// Specifies the partition type for a VB.NET /// query expression. /// - public enum QueryExpressionPartitionType + public enum PartitionKind { Take, TakeWhile, diff --git a/NRefactory/ICSharpCode.NRefactory.VB/Ast/Expressions/CollectionRangeVariableDeclaration.cs b/NRefactory/ICSharpCode.NRefactory.VB/Ast/Expressions/CollectionRangeVariableDeclaration.cs new file mode 100644 index 000000000..1e2fb7643 --- /dev/null +++ b/NRefactory/ICSharpCode.NRefactory.VB/Ast/Expressions/CollectionRangeVariableDeclaration.cs @@ -0,0 +1,42 @@ +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) + +using System; +using System.Collections.Generic; + +namespace ICSharpCode.NRefactory.VB.Ast +{ + /// + /// Identifier As Type In Expression + /// + public class CollectionRangeVariableDeclaration : AstNode + { + public static readonly Role CollectionRangeVariableDeclarationRole = new Role("CollectionRangeVariableDeclaration"); + + public VariableIdentifier Identifier { + get { return GetChildByRole(VariableIdentifier.VariableIdentifierRole); } + set { SetChildByRole(VariableIdentifier.VariableIdentifierRole, value); } + } + + public AstType Type { + get { return GetChildByRole(Roles.Type); } + set { SetChildByRole(Roles.Type, value); } + } + + public Expression Expression { + get { return GetChildByRole (Roles.Expression); } + set { SetChildByRole (Roles.Expression, value); } + } + + public override S AcceptVisitor(IAstVisitor visitor, T data) + { + return visitor.VisitCollectionRangeVariableDeclaration(this, data); + } + + protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) + { + CollectionRangeVariableDeclaration o = other as CollectionRangeVariableDeclaration; + return o != null && this.Identifier.DoMatch(o.Identifier, match) && this.Type.DoMatch(o.Type, match) && this.Expression.DoMatch(o.Expression, match); + } + } +} diff --git a/NRefactory/ICSharpCode.NRefactory.VB/Ast/Expressions/QueryExpression.cs b/NRefactory/ICSharpCode.NRefactory.VB/Ast/Expressions/QueryExpression.cs index 19cf4db4e..235035034 100644 --- a/NRefactory/ICSharpCode.NRefactory.VB/Ast/Expressions/QueryExpression.cs +++ b/NRefactory/ICSharpCode.NRefactory.VB/Ast/Expressions/QueryExpression.cs @@ -53,7 +53,240 @@ namespace ICSharpCode.NRefactory.VB.Ast public class FromQueryOperator : QueryOperator { + public AstNodeCollection Variables { + get { return GetChildrenByRole (CollectionRangeVariableDeclaration.CollectionRangeVariableDeclarationRole); } + } + + protected internal override bool DoMatch(AstNode other, ICSharpCode.NRefactory.PatternMatching.Match match) + { + throw new NotImplementedException(); + } + + public override S AcceptVisitor(IAstVisitor visitor, T data) + { + return visitor.VisitFromQueryOperator(this, data); + } + } + + public class AggregateQueryOperator : QueryOperator + { + public CollectionRangeVariableDeclaration Variable { + get { return GetChildByRole(CollectionRangeVariableDeclaration.CollectionRangeVariableDeclarationRole); } + set { SetChildByRole(CollectionRangeVariableDeclaration.CollectionRangeVariableDeclarationRole, value); } + } + + public AstNodeCollection SubQueryOperators { + get { return GetChildrenByRole(QueryOperatorRole); } + } + + public AstNodeCollection IntoExpressions { + get { return GetChildrenByRole(VariableInitializer.VariableInitializerRole); } + } + + protected internal override bool DoMatch(AstNode other, ICSharpCode.NRefactory.PatternMatching.Match match) + { + throw new NotImplementedException(); + } + + public override S AcceptVisitor(IAstVisitor visitor, T data) + { + return visitor.VisitAggregateQueryOperator(this, data); + } + } + + public class SelectQueryOperator : QueryOperator + { + public AstNodeCollection Variables { + get { return GetChildrenByRole(VariableInitializer.VariableInitializerRole); } + } + + protected internal override bool DoMatch(AstNode other, ICSharpCode.NRefactory.PatternMatching.Match match) + { + throw new NotImplementedException(); + } + + public override S AcceptVisitor(IAstVisitor visitor, T data) + { + return visitor.VisitSelectQueryOperator(this, data); + } + } + + public class DistinctQueryOperator : QueryOperator + { + protected internal override bool DoMatch(AstNode other, ICSharpCode.NRefactory.PatternMatching.Match match) + { + throw new NotImplementedException(); + } + + public override S AcceptVisitor(IAstVisitor visitor, T data) + { + return visitor.VisitDistinctQueryOperator(this, data); + } + } + + public class WhereQueryOperator : QueryOperator + { + public Expression Condition { + get { return GetChildByRole (Roles.Expression); } + set { SetChildByRole (Roles.Expression, value); } + } + + protected internal override bool DoMatch(AstNode other, ICSharpCode.NRefactory.PatternMatching.Match match) + { + throw new NotImplementedException(); + } + + public override S AcceptVisitor(IAstVisitor visitor, T data) + { + return visitor.VisitWhereQueryOperator(this, data); + } + } + + public class OrderExpression : AstNode + { + public static readonly Role OrderExpressionRole = new Role("OrderExpression"); + + public Expression Expression { + get { return GetChildByRole (Roles.Expression); } + set { SetChildByRole (Roles.Expression, value); } + } + + public QueryOrderingDirection Direction { get; set; } + + protected internal override bool DoMatch(AstNode other, ICSharpCode.NRefactory.PatternMatching.Match match) + { + throw new NotImplementedException(); + } + + public override S AcceptVisitor(IAstVisitor visitor, T data) + { + return visitor.VisitOrderExpression(this, data); + } + } + + public class OrderByQueryOperator : QueryOperator + { + public AstNodeCollection Expressions { + get { return GetChildrenByRole(OrderExpression.OrderExpressionRole); } + } + + protected internal override bool DoMatch(AstNode other, ICSharpCode.NRefactory.PatternMatching.Match match) + { + throw new NotImplementedException(); + } + + public override S AcceptVisitor(IAstVisitor visitor, T data) + { + return visitor.VisitOrderByQueryOperator(this, data); + } + } + + public class PartitionQueryOperator : QueryOperator + { + public PartitionKind Kind { get; set; } + + public Expression Expression { + get { return GetChildByRole (Roles.Expression); } + set { SetChildByRole (Roles.Expression, value); } + } + + protected internal override bool DoMatch(AstNode other, ICSharpCode.NRefactory.PatternMatching.Match match) + { + throw new NotImplementedException(); + } + + public override S AcceptVisitor(IAstVisitor visitor, T data) + { + return visitor.VisitPartitionQueryOperator(this, data); + } + } + + public class LetQueryOperator : QueryOperator + { + public AstNodeCollection Variables { + get { return GetChildrenByRole(VariableInitializer.VariableInitializerRole); } + } + + protected internal override bool DoMatch(AstNode other, ICSharpCode.NRefactory.PatternMatching.Match match) + { + throw new NotImplementedException(); + } + + public override S AcceptVisitor(IAstVisitor visitor, T data) + { + return visitor.VisitLetQueryOperator(this, data); + } + } + + public class GroupByQueryOperator : QueryOperator + { + public static readonly Role GroupExpressionRole = new Role("GroupExpression"); + public static readonly Role ByExpressionRole = new Role("ByExpression"); + public static readonly Role IntoExpressionRole = new Role("IntoExpression"); + + public AstNodeCollection GroupExpressions { + get { return GetChildrenByRole(GroupExpressionRole); } + } + + public AstNodeCollection ByExpressions { + get { return GetChildrenByRole(ByExpressionRole); } + } + + public AstNodeCollection IntoExpressions { + get { return GetChildrenByRole(IntoExpressionRole); } + } + + protected internal override bool DoMatch(AstNode other, ICSharpCode.NRefactory.PatternMatching.Match match) + { + throw new NotImplementedException(); + } + + public override S AcceptVisitor(IAstVisitor visitor, T data) + { + return visitor.VisitGroupByQueryOperator(this, data); + } + } + + public class JoinQueryOperator : QueryOperator + { + #region Null + public new static readonly JoinQueryOperator Null = new NullJoinQueryOperator(); + + sealed class NullJoinQueryOperator : JoinQueryOperator + { + public override bool IsNull { + get { + return true; + } + } + + public override S AcceptVisitor (IAstVisitor visitor, T data) + { + return default (S); + } + + protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) + { + return other == null || other.IsNull; + } + } + #endregion + public static readonly Role JoinQueryOperatorRole = new Role("JoinQueryOperator", JoinQueryOperator.Null); + + public CollectionRangeVariableDeclaration JoinVariable { + get { return GetChildByRole(CollectionRangeVariableDeclaration.CollectionRangeVariableDeclarationRole); } + set { SetChildByRole(CollectionRangeVariableDeclaration.CollectionRangeVariableDeclarationRole, value); } + } + + public JoinQueryOperator SubJoinQuery { + get { return GetChildByRole(JoinQueryOperatorRole); } + set { SetChildByRole(JoinQueryOperatorRole, value); } + } + + public AstNodeCollection JoinConditions { + get { return GetChildrenByRole(JoinCondition.JoinConditionRole); } + } protected internal override bool DoMatch(AstNode other, ICSharpCode.NRefactory.PatternMatching.Match match) { @@ -61,8 +294,55 @@ namespace ICSharpCode.NRefactory.VB.Ast } public override S AcceptVisitor(IAstVisitor visitor, T data) + { + return visitor.VisitJoinQueryOperator(this, data); + } + } + + public class JoinCondition : AstNode + { + public static readonly Role JoinConditionRole = new Role("JoinCondition"); + + public static readonly Role LeftExpressionRole = BinaryOperatorExpression.LeftExpressionRole; + public static readonly Role RightExpressionRole = BinaryOperatorExpression.RightExpressionRole; + + public Expression Left { + get { return GetChildByRole (LeftExpressionRole); } + set { SetChildByRole (LeftExpressionRole, value); } + } + + public Expression Right { + get { return GetChildByRole (RightExpressionRole); } + set { SetChildByRole (RightExpressionRole, value); } + } + + protected internal override bool DoMatch(AstNode other, ICSharpCode.NRefactory.PatternMatching.Match match) + { + throw new NotImplementedException(); + } + + public override S AcceptVisitor(IAstVisitor visitor, T data) + { + return visitor.VisitJoinCondition(this, data); + } + } + + public class GroupJoinQueryOperator : JoinQueryOperator + { + public static readonly Role IntoExpressionRole = GroupByQueryOperator.IntoExpressionRole; + + public AstNodeCollection IntoExpressions { + get { return GetChildrenByRole(IntoExpressionRole); } + } + + protected internal override bool DoMatch(AstNode other, ICSharpCode.NRefactory.PatternMatching.Match match) { throw new NotImplementedException(); } + + public override S AcceptVisitor(IAstVisitor visitor, T data) + { + return visitor.VisitGroupJoinQueryOperator(this, data); + } } } diff --git a/NRefactory/ICSharpCode.NRefactory.VB/Ast/Expressions/VariableInitializer.cs b/NRefactory/ICSharpCode.NRefactory.VB/Ast/Expressions/VariableInitializer.cs index 49acf4a3c..f73833de4 100644 --- a/NRefactory/ICSharpCode.NRefactory.VB/Ast/Expressions/VariableInitializer.cs +++ b/NRefactory/ICSharpCode.NRefactory.VB/Ast/Expressions/VariableInitializer.cs @@ -11,6 +11,8 @@ namespace ICSharpCode.NRefactory.VB.Ast /// public class VariableInitializer : AstNode { + public static readonly Role VariableInitializerRole = new Role("VariableInitializer"); + public VariableIdentifier Identifier { get { return GetChildByRole(VariableIdentifier.VariableIdentifierRole); } set { SetChildByRole(VariableIdentifier.VariableIdentifierRole, value); } @@ -38,7 +40,7 @@ namespace ICSharpCode.NRefactory.VB.Ast protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) { VariableInitializer o = other as VariableInitializer; - return o != null && this.Identifier.DoMatch(o.Identifier, match) && this.Expression.DoMatch(o.Expression, match); + return o != null && this.Identifier.DoMatch(o.Identifier, match) && this.Type.DoMatch(o.Type, match) && this.Expression.DoMatch(o.Expression, match); } } } diff --git a/NRefactory/ICSharpCode.NRefactory.VB/IAstVisitor.cs b/NRefactory/ICSharpCode.NRefactory.VB/IAstVisitor.cs index 7b8b1401d..c24e2b617 100644 --- a/NRefactory/ICSharpCode.NRefactory.VB/IAstVisitor.cs +++ b/NRefactory/ICSharpCode.NRefactory.VB/IAstVisitor.cs @@ -115,5 +115,21 @@ namespace ICSharpCode.NRefactory.VB { S VisitEmptyExpression(EmptyExpression emptyExpression, T data); S VisitAnonymousObjectCreationExpression(AnonymousObjectCreationExpression anonymousObjectCreationExpression, T data); + + S VisitCollectionRangeVariableDeclaration(CollectionRangeVariableDeclaration collectionRangeVariableDeclaration, T data); + + S VisitFromQueryOperator(FromQueryOperator fromQueryOperator, T data); + S VisitAggregateQueryOperator(AggregateQueryOperator aggregateQueryOperator, T data); + S VisitSelectQueryOperator(SelectQueryOperator selectQueryOperator, T data); + S VisitDistinctQueryOperator(DistinctQueryOperator distinctQueryOperator, T data); + S VisitWhereQueryOperator(WhereQueryOperator whereQueryOperator, T data); + S VisitOrderExpression(OrderExpression orderExpression, T data); + S VisitOrderByQueryOperator(OrderByQueryOperator orderByQueryOperator, T data); + S VisitPartitionQueryOperator(PartitionQueryOperator partitionQueryOperator, T data); + S VisitLetQueryOperator(LetQueryOperator letQueryOperator, T data); + S VisitGroupByQueryOperator(GroupByQueryOperator groupByQueryOperator, T data); + S VisitJoinQueryOperator(JoinQueryOperator joinQueryOperator, T data); + S VisitJoinCondition(JoinCondition joinCondition, T data); + S VisitGroupJoinQueryOperator(GroupJoinQueryOperator groupJoinQueryOperator, T data); } } diff --git a/NRefactory/ICSharpCode.NRefactory.VB/ICSharpCode.NRefactory.VB.csproj b/NRefactory/ICSharpCode.NRefactory.VB/ICSharpCode.NRefactory.VB.csproj index f5bf9db7a..136c0a5cc 100644 --- a/NRefactory/ICSharpCode.NRefactory.VB/ICSharpCode.NRefactory.VB.csproj +++ b/NRefactory/ICSharpCode.NRefactory.VB/ICSharpCode.NRefactory.VB.csproj @@ -54,6 +54,7 @@ + diff --git a/NRefactory/ICSharpCode.NRefactory.VB/OutputVisitor/OutputVisitor.cs b/NRefactory/ICSharpCode.NRefactory.VB/OutputVisitor/OutputVisitor.cs index 6b6139f10..88d001350 100644 --- a/NRefactory/ICSharpCode.NRefactory.VB/OutputVisitor/OutputVisitor.cs +++ b/NRefactory/ICSharpCode.NRefactory.VB/OutputVisitor/OutputVisitor.cs @@ -2427,5 +2427,219 @@ namespace ICSharpCode.NRefactory.VB return EndNode(anonymousObjectCreationExpression); } + + public object VisitCollectionRangeVariableDeclaration(CollectionRangeVariableDeclaration collectionRangeVariableDeclaration, object data) + { + StartNode(collectionRangeVariableDeclaration); + + collectionRangeVariableDeclaration.Identifier.AcceptVisitor(this, data); + if (!collectionRangeVariableDeclaration.Type.IsNull) { + WriteKeyword("As"); + collectionRangeVariableDeclaration.Type.AcceptVisitor(this, data); + } + WriteKeyword("In"); + collectionRangeVariableDeclaration.Expression.AcceptVisitor(this, data); + + return EndNode(collectionRangeVariableDeclaration); + } + + public object VisitFromQueryOperator(FromQueryOperator fromQueryOperator, object data) + { + StartNode(fromQueryOperator); + + WriteKeyword("From"); + WriteCommaSeparatedList(fromQueryOperator.Variables); + + return EndNode(fromQueryOperator); + } + + public object VisitAggregateQueryOperator(AggregateQueryOperator aggregateQueryOperator, object data) + { + StartNode(aggregateQueryOperator); + + WriteKeyword("Aggregate"); + aggregateQueryOperator.Variable.AcceptVisitor(this, data); + + foreach (var operators in aggregateQueryOperator.SubQueryOperators) { + operators.AcceptVisitor(this, data); + } + + WriteKeyword("Into"); + WriteCommaSeparatedList(aggregateQueryOperator.IntoExpressions); + + return EndNode(aggregateQueryOperator); + } + + public object VisitSelectQueryOperator(SelectQueryOperator selectQueryOperator, object data) + { + StartNode(selectQueryOperator); + + WriteKeyword("Select"); + WriteCommaSeparatedList(selectQueryOperator.Variables); + + return EndNode(selectQueryOperator); + } + + public object VisitDistinctQueryOperator(DistinctQueryOperator distinctQueryOperator, object data) + { + StartNode(distinctQueryOperator); + + WriteKeyword("Distinct"); + + return EndNode(distinctQueryOperator); + } + + public object VisitWhereQueryOperator(WhereQueryOperator whereQueryOperator, object data) + { + StartNode(whereQueryOperator); + + WriteKeyword("Where"); + whereQueryOperator.Condition.AcceptVisitor(this, data); + + return EndNode(whereQueryOperator); + } + + public object VisitPartitionQueryOperator(PartitionQueryOperator partitionQueryOperator, object data) + { + StartNode(partitionQueryOperator); + + switch (partitionQueryOperator.Kind) { + case PartitionKind.Take: + WriteKeyword("Take"); + break; + case PartitionKind.TakeWhile: + WriteKeyword("Take"); + WriteKeyword("While"); + break; + case PartitionKind.Skip: + WriteKeyword("Skip"); + break; + case PartitionKind.SkipWhile: + WriteKeyword("Skip"); + WriteKeyword("While"); + break; + default: + throw new Exception("Invalid value for PartitionKind"); + } + + partitionQueryOperator.Expression.AcceptVisitor(this, data); + + return EndNode(partitionQueryOperator); + } + + public object VisitOrderExpression(OrderExpression orderExpression, object data) + { + StartNode(orderExpression); + + orderExpression.Expression.AcceptVisitor(this, data); + + switch (orderExpression.Direction) { + case QueryOrderingDirection.None: + break; + case QueryOrderingDirection.Ascending: + WriteKeyword("Ascending"); + break; + case QueryOrderingDirection.Descending: + WriteKeyword("Descending"); + break; + default: + throw new Exception("Invalid value for QueryExpressionOrderingDirection"); + } + + return EndNode(orderExpression); + } + + public object VisitOrderByQueryOperator(OrderByQueryOperator orderByQueryOperator, object data) + { + StartNode(orderByQueryOperator); + + WriteKeyword("Order"); + WriteKeyword("By"); + WriteCommaSeparatedList(orderByQueryOperator.Expressions); + + return EndNode(orderByQueryOperator); + } + + public object VisitLetQueryOperator(LetQueryOperator letQueryOperator, object data) + { + StartNode(letQueryOperator); + + WriteKeyword("Let"); + WriteCommaSeparatedList(letQueryOperator.Variables); + + return EndNode(letQueryOperator); + } + + public object VisitGroupByQueryOperator(GroupByQueryOperator groupByQueryOperator, object data) + { + StartNode(groupByQueryOperator); + + WriteKeyword("Group"); + WriteCommaSeparatedList(groupByQueryOperator.GroupExpressions); + WriteKeyword("By"); + WriteCommaSeparatedList(groupByQueryOperator.ByExpressions); + WriteKeyword("Into"); + WriteCommaSeparatedList(groupByQueryOperator.IntoExpressions); + + return EndNode(groupByQueryOperator); + } + + public object VisitJoinQueryOperator(JoinQueryOperator joinQueryOperator, object data) + { + StartNode(joinQueryOperator); + + WriteKeyword("Join"); + joinQueryOperator.JoinVariable.AcceptVisitor(this, data); + if (!joinQueryOperator.SubJoinQuery.IsNull) { + joinQueryOperator.SubJoinQuery.AcceptVisitor(this, data); + } + WriteKeyword("On"); + bool first = true; + foreach (var cond in joinQueryOperator.JoinConditions) { + if (first) + first = false; + else + WriteKeyword("And"); + cond.AcceptVisitor(this, data); + } + + return EndNode(joinQueryOperator); + } + + public object VisitJoinCondition(JoinCondition joinCondition, object data) + { + StartNode(joinCondition); + + joinCondition.Left.AcceptVisitor(this, data); + WriteKeyword("Equals"); + joinCondition.Right.AcceptVisitor(this, data); + + return EndNode(joinCondition); + } + + public object VisitGroupJoinQueryOperator(GroupJoinQueryOperator groupJoinQueryOperator, object data) + { + StartNode(groupJoinQueryOperator); + + WriteKeyword("Group"); + WriteKeyword("Join"); + groupJoinQueryOperator.JoinVariable.AcceptVisitor(this, data); + if (!groupJoinQueryOperator.SubJoinQuery.IsNull) { + groupJoinQueryOperator.SubJoinQuery.AcceptVisitor(this, data); + } + WriteKeyword("On"); + bool first = true; + foreach (var cond in groupJoinQueryOperator.JoinConditions) { + if (first) + first = false; + else + WriteKeyword("And"); + cond.AcceptVisitor(this, data); + } + WriteKeyword("Into"); + WriteCommaSeparatedList(groupJoinQueryOperator.IntoExpressions); + + return EndNode(groupJoinQueryOperator); + } } } diff --git a/NRefactory/ICSharpCode.NRefactory.VB/Visitors/CSharpToVBConverterVisitor.cs b/NRefactory/ICSharpCode.NRefactory.VB/Visitors/CSharpToVBConverterVisitor.cs index b53ea5e30..f1c6e3949 100644 --- a/NRefactory/ICSharpCode.NRefactory.VB/Visitors/CSharpToVBConverterVisitor.cs +++ b/NRefactory/ICSharpCode.NRefactory.VB/Visitors/CSharpToVBConverterVisitor.cs @@ -235,6 +235,12 @@ namespace ICSharpCode.NRefactory.VB.Visitors case ICSharpCode.NRefactory.CSharp.BinaryOperatorType.ShiftRight: op = BinaryOperatorType.ShiftRight; break; + case ICSharpCode.NRefactory.CSharp.BinaryOperatorType.NullCoalescing: + var nullCoalescing = new ConditionalExpression { + ConditionExpression = left, + FalseExpression = right + }; + return EndNode(binaryOperatorExpression, nullCoalescing); default: throw new Exception("Invalid value for BinaryOperatorType: " + binaryOperatorExpression.Operator); } @@ -635,7 +641,16 @@ namespace ICSharpCode.NRefactory.VB.Visitors public AstNode VisitQueryFromClause(CSharp.QueryFromClause queryFromClause, object data) { - throw new NotImplementedException(); + var op = new FromQueryOperator(); + op.Variables.Add( + new CollectionRangeVariableDeclaration { + Identifier = new VariableIdentifier { Name = queryFromClause.Identifier }, + Type = (AstType)queryFromClause.Type.AcceptVisitor(this, data), + Expression = (Expression)queryFromClause.Expression.AcceptVisitor(this, data) + } + ); + + return EndNode(queryFromClause, op); } public AstNode VisitQueryLetClause(CSharp.QueryLetClause queryLetClause, object data) @@ -655,22 +670,45 @@ namespace ICSharpCode.NRefactory.VB.Visitors public AstNode VisitQueryOrderClause(CSharp.QueryOrderClause queryOrderClause, object data) { - throw new NotImplementedException(); + var op = new OrderByQueryOperator(); + + ConvertNodes(queryOrderClause.Orderings, op.Expressions); + + return EndNode(queryOrderClause, op); } public AstNode VisitQueryOrdering(CSharp.QueryOrdering queryOrdering, object data) { - throw new NotImplementedException(); + var expr = new OrderExpression(); + + expr.Direction = (QueryOrderingDirection)queryOrdering.Direction; + expr.Expression = (Expression)queryOrdering.Expression.AcceptVisitor(this, data); + + return EndNode(queryOrdering, expr); } + int selectVarCount = 0; + public AstNode VisitQuerySelectClause(CSharp.QuerySelectClause querySelectClause, object data) { - throw new NotImplementedException(); + var op = new SelectQueryOperator(); + + op.Variables.Add( + new VariableInitializer { + Identifier = new VariableIdentifier { Name = "SelectVar" + selectVarCount }, + Expression = (Expression)querySelectClause.Expression.AcceptVisitor(this, data) + }); + + return EndNode(querySelectClause, op); } public AstNode VisitQueryGroupClause(CSharp.QueryGroupClause queryGroupClause, object data) { + var op = new GroupByQueryOperator(); + throw new NotImplementedException(); + + return EndNode(queryGroupClause, op); } public AstNode VisitAttribute(CSharp.Attribute attribute, object data)