Browse Source

Fixed query expression tests.

Had to add a new node type: AnonymousTypeCreateExpression.
newNRvisualizers
Mike Krüger 15 years ago
parent
commit
ccd06a496c
  1. 16
      ICSharpCode.NRefactory.Tests/CSharp/Parser/Expression/QueryExpressionTests.cs
  2. 5
      ICSharpCode.NRefactory/CSharp/Ast/AstNode.cs
  3. 5
      ICSharpCode.NRefactory/CSharp/Ast/DepthFirstAstVisitor.cs
  4. 63
      ICSharpCode.NRefactory/CSharp/Ast/Expressions/AnonymousTypeCreateExpression.cs
  5. 3
      ICSharpCode.NRefactory/CSharp/Ast/Expressions/QueryExpression.cs
  6. 1
      ICSharpCode.NRefactory/CSharp/Ast/IAstVisitor.cs
  7. 22
      ICSharpCode.NRefactory/CSharp/OutputVisitor/OutputVisitor.cs
  8. 242
      ICSharpCode.NRefactory/CSharp/Parser/CSharpParser.cs
  9. 142
      ICSharpCode.NRefactory/CSharp/Parser/mcs/cs-parser.cs
  10. 10
      ICSharpCode.NRefactory/CSharp/Parser/mcs/cs-parser.jay
  11. 7
      ICSharpCode.NRefactory/CSharp/Parser/mcs/expression.cs
  12. 27
      ICSharpCode.NRefactory/CSharp/Parser/mcs/linq.cs
  13. 10
      ICSharpCode.NRefactory/CSharp/Parser/mcs/visit.cs
  14. 1
      ICSharpCode.NRefactory/ICSharpCode.NRefactory.csproj

16
ICSharpCode.NRefactory.Tests/CSharp/Parser/Expression/QueryExpressionTests.cs

@ -6,7 +6,7 @@ using NUnit.Framework;
namespace ICSharpCode.NRefactory.CSharp.Parser.Expression namespace ICSharpCode.NRefactory.CSharp.Parser.Expression
{ {
[TestFixture, Ignore("Query expressions not yet implemented")] [TestFixture]
public class QueryExpressionTests public class QueryExpressionTests
{ {
[Test] [Test]
@ -125,19 +125,17 @@ select new { c.Name, o.OrderID, o.Total }",
}, },
new QueryWhereClause { new QueryWhereClause {
Condition = new BinaryOperatorExpression { Condition = new BinaryOperatorExpression {
Left = new IdentifierExpression("c").Member("OrderDate").Member("Year"), Left = new IdentifierExpression("o").Member("OrderDate").Member("Year"),
Operator = BinaryOperatorType.Equality, Operator = BinaryOperatorType.Equality,
Right = new PrimitiveExpression(2005) Right = new PrimitiveExpression(2005)
} }
}, },
new QuerySelectClause { new QuerySelectClause {
Expression = new ObjectCreateExpression { Expression = new AnonymousTypeCreateExpression {
Initializer = new ArrayInitializerExpression { Initializer = {
Elements = { new IdentifierExpression("c").Member("Name"),
new IdentifierExpression("c").Member("Name"), new IdentifierExpression("o").Member("OrderID"),
new IdentifierExpression("o").Member("OrderID"), new IdentifierExpression("o").Member("Total")
new IdentifierExpression("o").Member("Total")
}
} }
} }
} }

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

@ -137,6 +137,7 @@ namespace ICSharpCode.NRefactory.CSharp
public AstNode Parent { public AstNode Parent {
get { return parent; } get { return parent; }
set { parent = value; }
} }
public Role Role { public Role Role {
@ -145,18 +146,22 @@ namespace ICSharpCode.NRefactory.CSharp
public AstNode NextSibling { public AstNode NextSibling {
get { return nextSibling; } get { return nextSibling; }
set { nextSibling = value; }
} }
public AstNode PrevSibling { public AstNode PrevSibling {
get { return prevSibling; } get { return prevSibling; }
set { prevSibling = value; }
} }
public AstNode FirstChild { public AstNode FirstChild {
get { return firstChild; } get { return firstChild; }
set { firstChild = value; }
} }
public AstNode LastChild { public AstNode LastChild {
get { return lastChild; } get { return lastChild; }
set { lastChild = value; }
} }
public IEnumerable<AstNode> Children { public IEnumerable<AstNode> Children {

5
ICSharpCode.NRefactory/CSharp/Ast/DepthFirstAstVisitor.cs

@ -440,6 +440,11 @@ namespace ICSharpCode.NRefactory.CSharp
return VisitChildren (objectCreateExpression, data); return VisitChildren (objectCreateExpression, data);
} }
public virtual S VisitAnonymousTypeCreateExpression(AnonymousTypeCreateExpression anonymousTypeCreateExpression, T data)
{
return VisitChildren (anonymousTypeCreateExpression, data);
}
public virtual S VisitArrayCreateExpression (ArrayCreateExpression arrayObjectCreateExpression, T data) public virtual S VisitArrayCreateExpression (ArrayCreateExpression arrayObjectCreateExpression, T data)
{ {
return VisitChildren (arrayObjectCreateExpression, data); return VisitChildren (arrayObjectCreateExpression, data);

63
ICSharpCode.NRefactory/CSharp/Ast/Expressions/AnonymousTypeCreateExpression.cs

@ -0,0 +1,63 @@
//
// AnonymousTypeCreateExpression.cs
//
// Author:
// Mike Krüger <mkrueger@novell.com>
//
// Copyright (c) 2011 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
namespace ICSharpCode.NRefactory.CSharp
{
/// <summary>
/// new { [ExpressionList] }
/// </summary>
public class AnonymousTypeCreateExpression : Expression
{
public CSharpTokenNode NewToken {
get { return GetChildByRole (Roles.Keyword); }
}
public CSharpTokenNode LParToken {
get { return GetChildByRole (Roles.LPar); }
}
public AstNodeCollection<Expression> Initializer {
get { return GetChildrenByRole (Roles.Expression); }
}
public CSharpTokenNode RParToken {
get { return GetChildByRole (Roles.RPar); }
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitAnonymousTypeCreateExpression (this, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
var o = other as AnonymousTypeCreateExpression;
return o != null && this.Initializer.DoMatch(o.Initializer, match);
}
}
}

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

@ -101,6 +101,9 @@ namespace ICSharpCode.NRefactory.CSharp
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{ {
QueryContinuationClause o = other as QueryContinuationClause; QueryContinuationClause o = other as QueryContinuationClause;
Console.WriteLine ("other: " + other);
Console.WriteLine (MatchString(this.Identifier, o.Identifier));
Console.WriteLine (this.PrecedingQuery.DoMatch(o.PrecedingQuery, match));
return o != null && MatchString(this.Identifier, o.Identifier) && this.PrecedingQuery.DoMatch(o.PrecedingQuery, match); return o != null && MatchString(this.Identifier, o.Identifier) && this.PrecedingQuery.DoMatch(o.PrecedingQuery, match);
} }
} }

1
ICSharpCode.NRefactory/CSharp/Ast/IAstVisitor.cs

@ -32,6 +32,7 @@ namespace ICSharpCode.NRefactory.CSharp
S VisitNamedArgumentExpression(NamedArgumentExpression namedArgumentExpression, T data); S VisitNamedArgumentExpression(NamedArgumentExpression namedArgumentExpression, T data);
S VisitNullReferenceExpression(NullReferenceExpression nullReferenceExpression, T data); S VisitNullReferenceExpression(NullReferenceExpression nullReferenceExpression, T data);
S VisitObjectCreateExpression(ObjectCreateExpression objectCreateExpression, T data); S VisitObjectCreateExpression(ObjectCreateExpression objectCreateExpression, T data);
S VisitAnonymousTypeCreateExpression(AnonymousTypeCreateExpression anonymousTypeCreateExpression, T data);
S VisitParenthesizedExpression(ParenthesizedExpression parenthesizedExpression, T data); S VisitParenthesizedExpression(ParenthesizedExpression parenthesizedExpression, T data);
S VisitPointerReferenceExpression(PointerReferenceExpression pointerReferenceExpression, T data); S VisitPointerReferenceExpression(PointerReferenceExpression pointerReferenceExpression, T data);
S VisitPrimitiveExpression(PrimitiveExpression primitiveExpression, T data); S VisitPrimitiveExpression(PrimitiveExpression primitiveExpression, T data);

22
ICSharpCode.NRefactory/CSharp/OutputVisitor/OutputVisitor.cs

@ -771,6 +771,25 @@ namespace ICSharpCode.NRefactory.CSharp
return EndNode(objectCreateExpression); return EndNode(objectCreateExpression);
} }
public object VisitAnonymousTypeCreateExpression(AnonymousTypeCreateExpression anonymousTypeCreateExpression, object data)
{
StartNode(anonymousTypeCreateExpression);
WriteKeyword("new");
Space();
LPar();
RPar();
Space();
OpenBrace(policy.AnonymousMethodBraceStyle);
foreach (AstNode node in anonymousTypeCreateExpression.Initializer) {
node.AcceptVisitor(this, null);
if (node.NextSibling != null)
Comma(node);
NewLine ();
}
CloseBrace(policy.AnonymousMethodBraceStyle);
return EndNode(anonymousTypeCreateExpression);
}
public object VisitParenthesizedExpression(ParenthesizedExpression parenthesizedExpression, object data) public object VisitParenthesizedExpression(ParenthesizedExpression parenthesizedExpression, object data)
{ {
StartNode(parenthesizedExpression); StartNode(parenthesizedExpression);
@ -1026,7 +1045,8 @@ namespace ICSharpCode.NRefactory.CSharp
if (first) { if (first) {
first = false; first = false;
} else { } else {
NewLine(); if (!(clause is QueryContinuationClause))
NewLine();
} }
clause.AcceptVisitor(this, data); clause.AcceptVisitor(this, data);
} }

242
ICSharpCode.NRefactory/CSharp/Parser/CSharpParser.cs

@ -2217,8 +2217,25 @@ namespace ICSharpCode.NRefactory.CSharp
if (location != null) if (location != null)
result.AddChild (new CSharpTokenNode (Convert (location[1]), 1), ObjectCreateExpression.Roles.RPar); result.AddChild (new CSharpTokenNode (Convert (location[1]), 1), ObjectCreateExpression.Roles.RPar);
// TODO: Collection initializer ? return result;
}
public override object Visit (NewAnonymousType newAnonymousType)
{
var result = new AnonymousTypeCreateExpression ();
foreach (var par in newAnonymousType.Parameters) {
var location = LocationsBag.GetLocations (par);
if (location == null) {
result.AddChild ((Expression)par.Expr.Accept (this), AnonymousTypeCreateExpression.Roles.Expression);
} else {
var namedArgument = new NamedArgumentExpression ();
namedArgument.AddChild (new Identifier (par.Name, Convert (par.Location)), AnonymousTypeCreateExpression.Roles.Identifier);
namedArgument.AddChild (new CSharpTokenNode (Convert (location[0]), 1), AnonymousTypeCreateExpression.Roles.Assign);
namedArgument.AddChild ((Expression)par.Expr.Accept (this), AnonymousTypeCreateExpression.Roles.Expression);
result.AddChild (namedArgument, AnonymousTypeCreateExpression.Roles.Expression);
}
}
return result; return result;
} }
@ -2542,47 +2559,98 @@ namespace ICSharpCode.NRefactory.CSharp
#endregion #endregion
#region LINQ expressions #region LINQ expressions
/* public override object Visit (Mono.CSharp.Linq.Query queryExpression) public override object Visit (Mono.CSharp.Linq.QueryExpression queryExpression)
{ {
var result = new QueryFromClause (); var result = new QueryExpression ();
var location = LocationsBag.GetLocations (queryExpression);
if (location != null) var currentClause = queryExpression.next;
result.AddChild (new CSharpTokenNode (Convert (location[0]), "from".Length), QueryFromClause.FromKeywordRole); var queryStarts = new Stack<QueryClause> ();
// TODO: select identifier
if (location != null) while (currentClause != null) {
result.AddChild (new CSharpTokenNode (Convert (location[1]), "in".Length), QueryFromClause.InKeywordRole); Console.WriteLine (currentClause);
var query = queryExpression.Expr as Mono.CSharp.Linq.AQueryClause; QueryClause clause = (QueryClause)currentClause.Accept (this);
// if (query != null && query.Expr != null) if (clause is QueryFromClause) {
// result.AddChild ((AstNode)query.Expr.Accept (this), QueryFromClause.Roles.Expression); queryStarts.Push (clause);
} else if (clause is QueryContinuationClause) {
var lastStart = queryStarts.Pop ();
var precedingQuery = new QueryExpression ();
List<AstNode> children = new List<AstNode> ();
AstNode node = lastStart;
while (node != null) {
children.Add (node);
node = node.NextSibling;
}
result.LastChild = lastStart.PrevSibling;
if (lastStart.PrevSibling != null) {
lastStart.PrevSibling.NextSibling = null;
lastStart.PrevSibling = null;
} else {
// lastStart == FirstChild
result.FirstChild = null;
}
children.ForEach (c => c.Parent = precedingQuery);
precedingQuery.FirstChild = children.First ();
precedingQuery.LastChild = children.Last ();
((QueryContinuationClause)clause).PrecedingQuery = precedingQuery;
queryStarts.Push (clause);
}
result.AddChild (clause, QueryExpression.ClauseRole);
currentClause = currentClause.next;
}
return result; return result;
} */ }
public override object Visit (Mono.CSharp.Linq.SelectMany selectMany) public override object Visit (Mono.CSharp.Linq.QueryStartClause queryStart)
{ {
var result = new QueryFromClause (); if (queryStart.Expr == null) {
// TODO: var intoClause = new QueryContinuationClause ();
// Mono.CSharp.Linq.Cast cast = selectMany.Expr as Mono.CSharp.Linq.Cast; intoClause.AddChild (new CSharpTokenNode (Convert (queryStart.Location), "into".Length), QueryContinuationClause.IntoKeywordRole);
var location = LocationsBag.GetLocations (selectMany); intoClause.AddChild (new Identifier (queryStart.IntoVariable.Name, Convert(queryStart.IntoVariable.Location)), QueryContinuationClause.Roles.Identifier);
if (location != null) return intoClause;
result.AddChild (new CSharpTokenNode (Convert (location[0]), "from".Length), QueryFromClause.FromKeywordRole); }
// result.AddChild ((AstNode)cast.TypeExpr.Accept (this), QueryFromClause.Roles.ReturnType); var fromClause = new QueryFromClause ();
// if (cast != null) var location = LocationsBag.GetLocations (queryStart);
// result.AddChild (new Identifier (selectMany.SelectIdentifier.Value, Convert (selectMany.SelectIdentifier.Location)), QueryFromClause.Roles.Identifier); fromClause.AddChild (new CSharpTokenNode (Convert (queryStart.Location), "from".Length), QueryFromClause.FromKeywordRole);
// result.AddChild (new CSharpTokenNode (Convert (location[1]), "in".Length), QueryFromClause.InKeywordRole);
// result.AddChild ((AstNode)(cast != null ? cast.Expr : selectMany.Expr).Accept (this), QueryFromClause.Roles.Expression); if (queryStart.IdentifierType != null)
fromClause.AddChild (ConvertToType (queryStart.IdentifierType), QueryFromClause.Roles.Type);
fromClause.AddChild (new Identifier (queryStart.IntoVariable.Name, Convert(queryStart.IntoVariable.Location)), QueryFromClause.Roles.Identifier);
return result; if (location != null)
fromClause.AddChild (new CSharpTokenNode (Convert (location[0]), "in".Length), QueryFromClause.InKeywordRole);
fromClause.AddChild ((Expression)queryStart.Expr.Accept (this), QueryFromClause.Roles.Expression);
return fromClause;
}
public override object Visit (Mono.CSharp.Linq.SelectMany queryStart)
{
var fromClause = new QueryFromClause ();
var location = LocationsBag.GetLocations (queryStart);
fromClause.AddChild (new CSharpTokenNode (Convert (queryStart.Location), "from".Length), QueryFromClause.FromKeywordRole);
if (queryStart.IdentifierType != null)
fromClause.AddChild (ConvertToType (queryStart.IdentifierType), QueryFromClause.Roles.Type);
fromClause.AddChild (new Identifier (queryStart.IntoVariable.Name, Convert(queryStart.IntoVariable.Location)), QueryFromClause.Roles.Identifier);
if (location != null)
fromClause.AddChild (new CSharpTokenNode (Convert (location[0]), "in".Length), QueryFromClause.InKeywordRole);
fromClause.AddChild ((Expression)queryStart.Expr.Accept (this), QueryFromClause.Roles.Expression);
return fromClause;
} }
public override object Visit (Mono.CSharp.Linq.Select sel) public override object Visit (Mono.CSharp.Linq.Select sel)
{ {
var result = new QuerySelectClause (); var result = new QuerySelectClause ();
var location = LocationsBag.GetLocations (sel); result.AddChild (new CSharpTokenNode (Convert (sel.Location), "select".Length), QueryWhereClause.Roles.Keyword);
result.AddChild (new CSharpTokenNode (Convert (location[0]), "select".Length), QueryWhereClause.Roles.Keyword);
result.AddChild ((Expression)sel.Expr.Accept (this), QueryWhereClause.Roles.Expression); result.AddChild ((Expression)sel.Expr.Accept (this), QueryWhereClause.Roles.Expression);
return result; return result;
} }
@ -2591,12 +2659,11 @@ namespace ICSharpCode.NRefactory.CSharp
{ {
var result = new QueryGroupClause (); var result = new QueryGroupClause ();
var location = LocationsBag.GetLocations (groupBy); var location = LocationsBag.GetLocations (groupBy);
result.AddChild (new CSharpTokenNode (Convert (groupBy.Location), "group".Length), QueryGroupClause.GroupKeywordRole);
result.AddChild ((Expression)groupBy.ElementSelector.Accept (this), QueryGroupClause.KeyRole);
if (location != null) if (location != null)
result.AddChild (new CSharpTokenNode (Convert (location[0]), "group".Length), QueryGroupClause.GroupKeywordRole); result.AddChild (new CSharpTokenNode (Convert (location[0]), "by".Length), QueryGroupClause.ByKeywordRole);
// result.AddChild ((AstNode)groupBy.ElementSelector.Accept (this), QueryGroupClause.GroupByExpressionRole); result.AddChild ((Expression)groupBy.Expr.Accept (this), QueryGroupClause.ProjectionRole);
// if (location != null)
// result.AddChild (new CSharpTokenNode (Convert (location[1]), "by".Length), QueryGroupClause.ByKeywordRole);
// result.AddChild ((AstNode)groupBy.Expr.Accept (this), QueryGroupClause.ProjectionExpressionRole);
return result; return result;
} }
@ -2605,17 +2672,11 @@ namespace ICSharpCode.NRefactory.CSharp
var result = new QueryLetClause (); var result = new QueryLetClause ();
var location = LocationsBag.GetLocations (l); var location = LocationsBag.GetLocations (l);
result.AddChild (new CSharpTokenNode (Convert (l.Location), "let".Length), QueryLetClause.Roles.Keyword);
result.AddChild (new Identifier (l.IntoVariable.Name, Convert (l.IntoVariable.Location)), Identifier.Roles.Identifier);
if (location != null) if (location != null)
result.AddChild (new CSharpTokenNode (Convert (location[0]), "let".Length), QueryWhereClause.Roles.Keyword); result.AddChild (new CSharpTokenNode (Convert (location[0]), 1), QueryLetClause.Roles.Assign);
result.AddChild ((Expression)l.Expr.Accept (this), QueryLetClause.Roles.Expression);
NewAnonymousType aType = l.Expr as NewAnonymousType;
AnonymousTypeParameter param = ((AnonymousTypeParameter)aType.Parameters[1]);
result.AddChild (new Identifier (param.Name, Convert (param.Location)), Identifier.Roles.Identifier);
if (location != null)
result.AddChild (new CSharpTokenNode (Convert (location[1]), 1), QueryWhereClause.Roles.Assign);
result.AddChild ((Expression)param.Expr.Accept (this), QueryWhereClause.Roles.Condition);
return result; return result;
} }
@ -2632,98 +2693,117 @@ namespace ICSharpCode.NRefactory.CSharp
public override object Visit (Mono.CSharp.Linq.Join join) public override object Visit (Mono.CSharp.Linq.Join join)
{ {
var result = new QueryJoinClause (); var result = new QueryJoinClause ();
/* var location = LocationsBag.GetLocations (join); var location = LocationsBag.GetLocations (join);
if (location != null) result.AddChild (new CSharpTokenNode (Convert (join.Location), "join".Length), QueryJoinClause.JoinKeywordRole);
result.AddChild (new CSharpTokenNode (Convert (location[0]), "join".Length), QueryJoinClause.JoinKeywordRole);
result.AddChild (new Identifier (join.JoinVariable.Name, Convert (join.JoinVariable.Location)), Identifier.Roles.Identifier); result.AddChild (new Identifier (join.JoinVariable.Name, Convert (join.JoinVariable.Location)), Identifier.Roles.Identifier);
if (location != null) if (location != null)
result.AddChild (new CSharpTokenNode (Convert (location[1]), "in".Length), QueryJoinClause.InKeywordRole); result.AddChild (new CSharpTokenNode (Convert (location[0]), "in".Length), QueryJoinClause.InKeywordRole);
result.AddChild ((AstNode)join.Expr.Accept (this), QueryJoinClause.Roles.Expression); result.AddChild ((Expression)join.Expr.Accept (this), QueryJoinClause.Roles.Expression);
if (location != null) if (location != null)
result.AddChild (new CSharpTokenNode (Convert (location[2]), "on".Length), QueryJoinClause.OnKeywordRole); result.AddChild (new CSharpTokenNode (Convert (location[1]), "on".Length), QueryJoinClause.OnKeywordRole);
// TODO: on expression // TODO: on expression
if (location != null) if (location != null)
result.AddChild (new CSharpTokenNode (Convert (location[3]), "equals".Length), QueryJoinClause.EqualsKeywordRole); result.AddChild (new CSharpTokenNode (Convert (location[2]), "equals".Length), QueryJoinClause.EqualsKeywordRole);
// TODO: equals expression // TODO: equals expression
*/
return result; return result;
} }
public override object Visit (Mono.CSharp.Linq.GroupJoin groupJoin) public override object Visit (Mono.CSharp.Linq.GroupJoin join)
{ {
var result = new QueryJoinClause (); var result = new QueryJoinClause ();
/* var location = LocationsBag.GetLocations (groupJoin); var location = LocationsBag.GetLocations (join);
if (location != null) result.AddChild (new CSharpTokenNode (Convert (join.Location), "join".Length), QueryJoinClause.JoinKeywordRole);
result.AddChild (new CSharpTokenNode (Convert (location[0]), "join".Length), QueryJoinClause.JoinKeywordRole);
result.AddChild (new Identifier (groupJoin.JoinVariable.Name, Convert (groupJoin.JoinVariable.Location)), Identifier.Roles.Identifier); result.AddChild (new Identifier (join.JoinVariable.Name, Convert (join.JoinVariable.Location)), Identifier.Roles.Identifier);
if (location != null) if (location != null)
result.AddChild (new CSharpTokenNode (Convert (location[1]), "in".Length), QueryJoinClause.InKeywordRole); result.AddChild (new CSharpTokenNode (Convert (location[0]), "in".Length), QueryJoinClause.InKeywordRole);
result.AddChild ((AstNode)groupJoin.Expr.Accept (this), QueryJoinClause.Roles.Expression); result.AddChild ((Expression)join.Expr.Accept (this), QueryJoinClause.Roles.Expression);
if (location != null) if (location != null)
result.AddChild (new CSharpTokenNode (Convert (location[2]), "on".Length), QueryJoinClause.OnKeywordRole); result.AddChild (new CSharpTokenNode (Convert (location[1]), "on".Length), QueryJoinClause.OnKeywordRole);
// TODO: on expression // TODO: on expression
if (location != null) if (location != null)
result.AddChild (new CSharpTokenNode (Convert (location[3]), "equals".Length), QueryJoinClause.EqualsKeywordRole); result.AddChild (new CSharpTokenNode (Convert (location[2]), "equals".Length), QueryJoinClause.EqualsKeywordRole);
// TODO: equals expression // TODO: equals expression
if (location != null) if (location != null)
result.AddChild (new CSharpTokenNode (Convert (location[4]), "into".Length), QueryJoinClause.IntoKeywordRole); result.AddChild (new CSharpTokenNode (Convert (location[3]), "into".Length), QueryJoinClause.IntoKeywordRole);
result.AddChild (new Identifier (groupJoin.JoinVariable.Name, Convert (groupJoin.JoinVariable.Location)), Identifier.Roles.Identifier);*/ result.AddChild (new Identifier (join.JoinVariable.Name, Convert (join.JoinVariable.Location)), Identifier.Roles.Identifier);
return result; return result;
} }
public override object Visit (Mono.CSharp.Linq.OrderByAscending orderByAscending) public override object Visit (Mono.CSharp.Linq.OrderByAscending orderByAscending)
{ {
var result = new QueryOrderClause (); var result = new QueryOrderClause ();
/* result.OrderAscending = true;
result.AddChild ((AstNode)orderByAscending.Expr.Accept (this), QueryWhereClause.Roles.Expression); var ordering = new QueryOrdering ();
ordering.AddChild ((Expression)orderByAscending.Expr.Accept (this), QueryWhereClause.Roles.Expression);
var location = LocationsBag.GetLocations (orderByAscending); var location = LocationsBag.GetLocations (orderByAscending);
if (location != null) if (location != null) {
result.AddChild (new CSharpTokenNode (Convert (location[0]), "ascending".Length), QueryWhereClause.Roles.Keyword);*/ ordering.Direction = QueryOrderingDirection.Ascending;
ordering.AddChild (new CSharpTokenNode (Convert (location[0]), "ascending".Length), QueryWhereClause.Roles.Keyword);
}
result.AddChild (ordering, QueryOrderClause.OrderingRole);
return result; return result;
} }
public override object Visit (Mono.CSharp.Linq.OrderByDescending orderByDescending) public override object Visit (Mono.CSharp.Linq.OrderByDescending orderByDescending)
{ {
var result = new QueryOrderClause (); var result = new QueryOrderClause ();
/* result.OrderAscending = false;
result.AddChild ((AstNode)orderByDescending.Expr.Accept (this), QueryWhereClause.Roles.Expression); var ordering = new QueryOrdering ();
ordering.AddChild ((Expression)orderByDescending.Expr.Accept (this), QueryWhereClause.Roles.Expression);
var location = LocationsBag.GetLocations (orderByDescending); var location = LocationsBag.GetLocations (orderByDescending);
if (location != null) if (location != null) {
result.AddChild (new CSharpTokenNode (Convert (location[0]), "descending".Length), QueryWhereClause.Roles.Keyword);*/ ordering.Direction = QueryOrderingDirection.Descending;
ordering.AddChild (new CSharpTokenNode (Convert (location[0]), "ascending".Length), QueryWhereClause.Roles.Keyword);
}
result.AddChild (ordering, QueryOrderClause.OrderingRole);
return result; return result;
} }
public override object Visit (Mono.CSharp.Linq.ThenByAscending thenByAscending) public override object Visit (Mono.CSharp.Linq.ThenByAscending thenByAscending)
{ {
var result = new QueryOrderClause (); var result = new QueryOrderClause ();
/* result.OrderAscending = true;
result.AddChild ((AstNode)thenByAscending.Expr.Accept (this), QueryWhereClause.Roles.Expression); var ordering = new QueryOrdering ();
ordering.AddChild ((Expression)thenByAscending.Expr.Accept (this), QueryWhereClause.Roles.Expression);
var location = LocationsBag.GetLocations (thenByAscending); var location = LocationsBag.GetLocations (thenByAscending);
if (location != null) if (location != null) {
result.AddChild (new CSharpTokenNode (Convert (location[0]), "ascending".Length), QueryWhereClause.Roles.Keyword);*/ ordering.Direction = QueryOrderingDirection.Ascending;
ordering.AddChild (new CSharpTokenNode (Convert (location[0]), "ascending".Length), QueryWhereClause.Roles.Keyword);
}
result.AddChild (ordering, QueryOrderClause.OrderingRole);
return result; return result;
} }
public override object Visit (Mono.CSharp.Linq.ThenByDescending thenByDescending) public override object Visit (Mono.CSharp.Linq.ThenByDescending thenByDescending)
{ {
var result = new QueryOrderClause (); var result = new QueryOrderClause ();
/* result.OrderAscending = false;
result.AddChild ((AstNode)thenByDescending.Expr.Accept (this), QueryWhereClause.Roles.Expression); var ordering = new QueryOrdering ();
ordering.AddChild ((Expression)thenByDescending.Expr.Accept (this), QueryWhereClause.Roles.Expression);
var location = LocationsBag.GetLocations (thenByDescending); var location = LocationsBag.GetLocations (thenByDescending);
if (location != null) if (location != null) {
result.AddChild (new CSharpTokenNode (Convert (location[0]), "descending".Length), QueryWhereClause.Roles.Keyword);*/ ordering.Direction = QueryOrderingDirection.Descending;
ordering.AddChild (new CSharpTokenNode (Convert (location[0]), "ascending".Length), QueryWhereClause.Roles.Keyword);
}
result.AddChild (ordering, QueryOrderClause.OrderingRole);
return result; return result;
} }
#endregion #endregion

142
ICSharpCode.NRefactory/CSharp/Parser/mcs/cs-parser.cs

@ -3674,7 +3674,7 @@ case 879:
case_879(); case_879();
break; break;
case 885: case 885:
#line 5704 "cs-parser.jay" #line 5705 "cs-parser.jay"
{ {
current_block = new Linq.QueryBlock (current_block, lexer.Location); current_block = new Linq.QueryBlock (current_block, lexer.Location);
} }
@ -3683,7 +3683,7 @@ case 886:
case_886(); case_886();
break; break;
case 887: case 887:
#line 5722 "cs-parser.jay" #line 5724 "cs-parser.jay"
{ {
current_block = new Linq.QueryBlock (current_block, lexer.Location); current_block = new Linq.QueryBlock (current_block, lexer.Location);
} }
@ -3716,13 +3716,13 @@ case 896:
case_896(); case_896();
break; break;
case 898: case 898:
#line 5864 "cs-parser.jay" #line 5868 "cs-parser.jay"
{ {
yyVal = yyVals[0+yyTop]; yyVal = yyVals[0+yyTop];
} }
break; break;
case 899: case 899:
#line 5871 "cs-parser.jay" #line 5875 "cs-parser.jay"
{ {
current_block = new Linq.QueryBlock (current_block, lexer.Location); current_block = new Linq.QueryBlock (current_block, lexer.Location);
} }
@ -3743,40 +3743,28 @@ case 906:
case_906(); case_906();
break; break;
case 907: case 907:
#line 5917 "cs-parser.jay" #line 5921 "cs-parser.jay"
{ {
yyVal = new Linq.OrderByAscending ((Linq.QueryBlock) current_block, (Expression)yyVals[0+yyTop]); yyVal = new Linq.OrderByAscending ((Linq.QueryBlock) current_block, (Expression)yyVals[0+yyTop]);
} }
break; break;
case 908: case 908:
#line 5921 "cs-parser.jay" case_908();
{
yyVal = new Linq.OrderByAscending ((Linq.QueryBlock) current_block, (Expression)yyVals[-1+yyTop]);
}
break; break;
case 909: case 909:
#line 5925 "cs-parser.jay" case_909();
{
yyVal = new Linq.OrderByDescending ((Linq.QueryBlock) current_block, (Expression)yyVals[-1+yyTop]);
}
break; break;
case 910: case 910:
#line 5932 "cs-parser.jay" #line 5938 "cs-parser.jay"
{ {
yyVal = new Linq.ThenByAscending ((Linq.QueryBlock) current_block, (Expression)yyVals[0+yyTop]); yyVal = new Linq.ThenByAscending ((Linq.QueryBlock) current_block, (Expression)yyVals[0+yyTop]);
} }
break; break;
case 911: case 911:
#line 5936 "cs-parser.jay" case_911();
{
yyVal = new Linq.ThenByAscending ((Linq.QueryBlock) current_block, (Expression)yyVals[-1+yyTop]);
}
break; break;
case 912: case 912:
#line 5940 "cs-parser.jay" case_912();
{
yyVal = new Linq.ThenByDescending ((Linq.QueryBlock) current_block, (Expression)yyVals[-1+yyTop]);
}
break; break;
case 914: case 914:
case_914(); case_914();
@ -3791,13 +3779,13 @@ case 919:
case_919(); case_919();
break; break;
case 927: case 927:
#line 6054 "cs-parser.jay" #line 6062 "cs-parser.jay"
{ {
module.DocumentationBuilder.ParsedName = (MemberName) yyVals[0+yyTop]; module.DocumentationBuilder.ParsedName = (MemberName) yyVals[0+yyTop];
} }
break; break;
case 928: case 928:
#line 6061 "cs-parser.jay" #line 6069 "cs-parser.jay"
{ {
module.DocumentationBuilder.ParsedParameters = (List<DocumentationParameter>)yyVals[0+yyTop]; module.DocumentationBuilder.ParsedParameters = (List<DocumentationParameter>)yyVals[0+yyTop];
} }
@ -3809,13 +3797,13 @@ case 930:
case_930(); case_930();
break; break;
case 931: case 931:
#line 6078 "cs-parser.jay" #line 6086 "cs-parser.jay"
{ {
yyVal = new MemberName ((MemberName) yyVals[-2+yyTop], new MemberName (MemberCache.IndexerNameAlias)); yyVal = new MemberName ((MemberName) yyVals[-2+yyTop], new MemberName (MemberCache.IndexerNameAlias));
} }
break; break;
case 932: case 932:
#line 6082 "cs-parser.jay" #line 6090 "cs-parser.jay"
{ {
valid_param_mod = ParameterModifierType.Ref | ParameterModifierType.Out; valid_param_mod = ParameterModifierType.Ref | ParameterModifierType.Out;
} }
@ -3833,25 +3821,25 @@ case 936:
case_936(); case_936();
break; break;
case 938: case 938:
#line 6118 "cs-parser.jay" #line 6126 "cs-parser.jay"
{ {
yyVal = new MemberName (((MemberName) yyVals[-2+yyTop]), (MemberName) yyVals[0+yyTop]); yyVal = new MemberName (((MemberName) yyVals[-2+yyTop]), (MemberName) yyVals[0+yyTop]);
} }
break; break;
case 940: case 940:
#line 6126 "cs-parser.jay" #line 6134 "cs-parser.jay"
{ {
valid_param_mod = ParameterModifierType.Ref | ParameterModifierType.Out; valid_param_mod = ParameterModifierType.Ref | ParameterModifierType.Out;
} }
break; break;
case 941: case 941:
#line 6130 "cs-parser.jay" #line 6138 "cs-parser.jay"
{ {
yyVal = yyVals[-1+yyTop]; yyVal = yyVals[-1+yyTop];
} }
break; break;
case 942: case 942:
#line 6137 "cs-parser.jay" #line 6145 "cs-parser.jay"
{ {
yyVal = new List<DocumentationParameter> (0); yyVal = new List<DocumentationParameter> (0);
} }
@ -8127,25 +8115,27 @@ void case_875()
#line 5670 "cs-parser.jay" #line 5670 "cs-parser.jay"
{ {
yyVal = new Linq.GroupBy ((Linq.QueryBlock)current_block, (Expression)yyVals[-3+yyTop], linq_clause_blocks.Pop (), (Expression)yyVals[0+yyTop], GetLocation (yyVals[-5+yyTop])); yyVal = new Linq.GroupBy ((Linq.QueryBlock)current_block, (Expression)yyVals[-3+yyTop], linq_clause_blocks.Pop (), (Expression)yyVals[0+yyTop], GetLocation (yyVals[-5+yyTop]));
lbag.AddLocation (yyVal, GetLocation (yyVals[-1+yyTop]));
current_block.SetEndLocation (lexer.Location); current_block.SetEndLocation (lexer.Location);
current_block = current_block.Parent; current_block = current_block.Parent;
} }
void case_879() void case_879()
#line 5686 "cs-parser.jay" #line 5687 "cs-parser.jay"
{ {
((Linq.AQueryClause)yyVals[-1+yyTop]).Tail.Next = (Linq.AQueryClause)yyVals[0+yyTop]; ((Linq.AQueryClause)yyVals[-1+yyTop]).Tail.Next = (Linq.AQueryClause)yyVals[0+yyTop];
yyVal = yyVals[-1+yyTop]; yyVal = yyVals[-1+yyTop];
} }
void case_886() void case_886()
#line 5706 "cs-parser.jay" #line 5707 "cs-parser.jay"
{ {
var lt = (Tokenizer.LocatedToken) yyVals[-3+yyTop]; var lt = (Tokenizer.LocatedToken) yyVals[-3+yyTop];
var sn = new Linq.RangeVariable (lt.Value, lt.Location); var sn = new Linq.RangeVariable (lt.Value, lt.Location);
yyVal = new Linq.Let ((Linq.QueryBlock) current_block, sn, (Expression)yyVals[0+yyTop], GetLocation (yyVals[-4+yyTop])); yyVal = new Linq.Let ((Linq.QueryBlock) current_block, sn, (Expression)yyVals[0+yyTop], GetLocation (yyVals[-4+yyTop]));
lbag.AddLocation (yyVal, GetLocation (yyVals[-2+yyTop]));
current_block.SetEndLocation (lexer.Location); current_block.SetEndLocation (lexer.Location);
current_block = current_block.Parent; current_block = current_block.Parent;
@ -8153,7 +8143,7 @@ void case_886()
} }
void case_888() void case_888()
#line 5724 "cs-parser.jay" #line 5726 "cs-parser.jay"
{ {
yyVal = new Linq.Where ((Linq.QueryBlock)current_block, (Expression)yyVals[0+yyTop], GetLocation (yyVals[-2+yyTop])); yyVal = new Linq.Where ((Linq.QueryBlock)current_block, (Expression)yyVals[0+yyTop], GetLocation (yyVals[-2+yyTop]));
@ -8162,7 +8152,7 @@ void case_888()
} }
void case_889() void case_889()
#line 5734 "cs-parser.jay" #line 5736 "cs-parser.jay"
{ {
if (linq_clause_blocks == null) if (linq_clause_blocks == null)
linq_clause_blocks = new Stack<Linq.QueryBlock> (); linq_clause_blocks = new Stack<Linq.QueryBlock> ();
@ -8172,7 +8162,7 @@ void case_889()
} }
void case_890() void case_890()
#line 5742 "cs-parser.jay" #line 5744 "cs-parser.jay"
{ {
current_block.SetEndLocation (lexer.Location); current_block.SetEndLocation (lexer.Location);
current_block = current_block.Parent; current_block = current_block.Parent;
@ -8182,7 +8172,7 @@ void case_890()
} }
void case_891() void case_891()
#line 5750 "cs-parser.jay" #line 5752 "cs-parser.jay"
{ {
current_block.AddStatement (new ContextualReturn ((Expression) yyVals[-1+yyTop])); current_block.AddStatement (new ContextualReturn ((Expression) yyVals[-1+yyTop]));
current_block.SetEndLocation (lexer.Location); current_block.SetEndLocation (lexer.Location);
@ -8192,7 +8182,7 @@ void case_891()
} }
void case_892() void case_892()
#line 5758 "cs-parser.jay" #line 5760 "cs-parser.jay"
{ {
current_block.AddStatement (new ContextualReturn ((Expression) yyVals[-1+yyTop])); current_block.AddStatement (new ContextualReturn ((Expression) yyVals[-1+yyTop]));
current_block.SetEndLocation (lexer.Location); current_block.SetEndLocation (lexer.Location);
@ -8207,6 +8197,7 @@ void case_892()
if (yyVals[0+yyTop] == null) { if (yyVals[0+yyTop] == null) {
into = sn; into = sn;
yyVal = new Linq.Join (block, sn, (Expression)yyVals[-7+yyTop], outer_selector, (Linq.QueryBlock) current_block, GetLocation (yyVals[-11+yyTop])); yyVal = new Linq.Join (block, sn, (Expression)yyVals[-7+yyTop], outer_selector, (Linq.QueryBlock) current_block, GetLocation (yyVals[-11+yyTop]));
lbag.AddLocation (yyVal, GetLocation (yyVals[-9+yyTop]), GetLocation (yyVals[-6+yyTop]), GetLocation (yyVals[-3+yyTop]));
} else { } else {
/**/ /**/
/* Set equals right side parent to beginning of linq query, it is not accessible therefore cannot cause name collisions*/ /* Set equals right side parent to beginning of linq query, it is not accessible therefore cannot cause name collisions*/
@ -8223,6 +8214,7 @@ void case_892()
into = new Linq.RangeVariable (lt.Value, lt.Location); into = new Linq.RangeVariable (lt.Value, lt.Location);
yyVal = new Linq.GroupJoin (block, sn, (Expression)yyVals[-7+yyTop], outer_selector, (Linq.QueryBlock) current_block, into, GetLocation (yyVals[-11+yyTop])); yyVal = new Linq.GroupJoin (block, sn, (Expression)yyVals[-7+yyTop], outer_selector, (Linq.QueryBlock) current_block, into, GetLocation (yyVals[-11+yyTop]));
lbag.AddLocation (yyVal, GetLocation (yyVals[-9+yyTop]), GetLocation (yyVals[-6+yyTop]), GetLocation (yyVals[-3+yyTop]), GetLocation (yyVals[0+yyTop]));
} }
current_block = block.Parent; current_block = block.Parent;
@ -8230,7 +8222,7 @@ void case_892()
} }
void case_893() void case_893()
#line 5794 "cs-parser.jay" #line 5798 "cs-parser.jay"
{ {
if (linq_clause_blocks == null) if (linq_clause_blocks == null)
linq_clause_blocks = new Stack<Linq.QueryBlock> (); linq_clause_blocks = new Stack<Linq.QueryBlock> ();
@ -8240,7 +8232,7 @@ void case_893()
} }
void case_894() void case_894()
#line 5802 "cs-parser.jay" #line 5806 "cs-parser.jay"
{ {
current_block.SetEndLocation (lexer.Location); current_block.SetEndLocation (lexer.Location);
current_block = current_block.Parent; current_block = current_block.Parent;
@ -8250,7 +8242,7 @@ void case_894()
} }
void case_895() void case_895()
#line 5810 "cs-parser.jay" #line 5814 "cs-parser.jay"
{ {
current_block.AddStatement (new ContextualReturn ((Expression) yyVals[-1+yyTop])); current_block.AddStatement (new ContextualReturn ((Expression) yyVals[-1+yyTop]));
current_block.SetEndLocation (lexer.Location); current_block.SetEndLocation (lexer.Location);
@ -8260,7 +8252,7 @@ void case_895()
} }
void case_896() void case_896()
#line 5818 "cs-parser.jay" #line 5822 "cs-parser.jay"
{ {
current_block.AddStatement (new ContextualReturn ((Expression) yyVals[-1+yyTop])); current_block.AddStatement (new ContextualReturn ((Expression) yyVals[-1+yyTop]));
current_block.SetEndLocation (lexer.Location); current_block.SetEndLocation (lexer.Location);
@ -8302,7 +8294,7 @@ void case_896()
} }
void case_900() void case_900()
#line 5873 "cs-parser.jay" #line 5877 "cs-parser.jay"
{ {
current_block.SetEndLocation (lexer.Location); current_block.SetEndLocation (lexer.Location);
current_block = current_block.Parent; current_block = current_block.Parent;
@ -8311,7 +8303,7 @@ void case_900()
} }
void case_902() void case_902()
#line 5884 "cs-parser.jay" #line 5888 "cs-parser.jay"
{ {
current_block.SetEndLocation (lexer.Location); current_block.SetEndLocation (lexer.Location);
current_block = current_block.Parent; current_block = current_block.Parent;
@ -8320,14 +8312,14 @@ void case_902()
} }
void case_903() void case_903()
#line 5891 "cs-parser.jay" #line 5895 "cs-parser.jay"
{ {
((Linq.AQueryClause)yyVals[-3+yyTop]).Next = (Linq.AQueryClause)yyVals[0+yyTop]; ((Linq.AQueryClause)yyVals[-3+yyTop]).Next = (Linq.AQueryClause)yyVals[0+yyTop];
yyVal = yyVals[-3+yyTop]; yyVal = yyVals[-3+yyTop];
} }
void case_905() void case_905()
#line 5900 "cs-parser.jay" #line 5904 "cs-parser.jay"
{ {
current_block.SetEndLocation (lexer.Location); current_block.SetEndLocation (lexer.Location);
current_block = current_block.Parent; current_block = current_block.Parent;
@ -8336,14 +8328,42 @@ void case_905()
} }
void case_906() void case_906()
#line 5907 "cs-parser.jay" #line 5911 "cs-parser.jay"
{ {
((Linq.AQueryClause)yyVals[-3+yyTop]).Tail.Next = (Linq.AQueryClause)yyVals[0+yyTop]; ((Linq.AQueryClause)yyVals[-3+yyTop]).Tail.Next = (Linq.AQueryClause)yyVals[0+yyTop];
yyVal = yyVals[-3+yyTop]; yyVal = yyVals[-3+yyTop];
} }
void case_908()
#line 5923 "cs-parser.jay"
{
yyVal = new Linq.OrderByAscending ((Linq.QueryBlock) current_block, (Expression)yyVals[-1+yyTop]);
lbag.AddLocation (yyVal, GetLocation (yyVals[0+yyTop]));
}
void case_909()
#line 5928 "cs-parser.jay"
{
yyVal = new Linq.OrderByDescending ((Linq.QueryBlock) current_block, (Expression)yyVals[-1+yyTop]);
lbag.AddLocation (yyVal, GetLocation (yyVals[0+yyTop]));
}
void case_911()
#line 5940 "cs-parser.jay"
{
yyVal = new Linq.ThenByAscending ((Linq.QueryBlock) current_block, (Expression)yyVals[-1+yyTop]);
lbag.AddLocation (yyVal, GetLocation (yyVals[0+yyTop]));
}
void case_912()
#line 5945 "cs-parser.jay"
{
yyVal = new Linq.ThenByDescending ((Linq.QueryBlock) current_block, (Expression)yyVals[-1+yyTop]);
lbag.AddLocation (yyVal, GetLocation (yyVals[0+yyTop]));
}
void case_914() void case_914()
#line 5947 "cs-parser.jay" #line 5955 "cs-parser.jay"
{ {
/* query continuation block is not linked with query block but with block*/ /* query continuation block is not linked with query block but with block*/
/* before. This means each query can use same range variable names for*/ /* before. This means each query can use same range variable names for*/
@ -8361,7 +8381,7 @@ void case_914()
} }
void case_915() void case_915()
#line 5963 "cs-parser.jay" #line 5971 "cs-parser.jay"
{ {
var current_block = linq_clause_blocks.Pop (); var current_block = linq_clause_blocks.Pop ();
var lt = (Tokenizer.LocatedToken) yyVals[-2+yyTop]; var lt = (Tokenizer.LocatedToken) yyVals[-2+yyTop];
@ -8372,7 +8392,7 @@ void case_915()
} }
void case_918() void case_918()
#line 5990 "cs-parser.jay" #line 5998 "cs-parser.jay"
{ {
current_container = new Class (current_namespace, current_class, new MemberName ("<InteractiveExpressionClass>"), Modifiers.PUBLIC, null); current_container = new Class (current_namespace, current_class, new MemberName ("<InteractiveExpressionClass>"), Modifiers.PUBLIC, null);
current_class = current_container; current_class = current_container;
@ -8404,7 +8424,7 @@ void case_918()
} }
void case_919() void case_919()
#line 6020 "cs-parser.jay" #line 6028 "cs-parser.jay"
{ {
--lexer.parsing_block; --lexer.parsing_block;
Method method = (Method) oob_stack.Pop (); Method method = (Method) oob_stack.Pop ();
@ -8416,7 +8436,7 @@ void case_919()
} }
void case_929() void case_929()
#line 6063 "cs-parser.jay" #line 6071 "cs-parser.jay"
{ {
module.DocumentationBuilder.ParsedBuiltinType = (TypeExpression)yyVals[-1+yyTop]; module.DocumentationBuilder.ParsedBuiltinType = (TypeExpression)yyVals[-1+yyTop];
module.DocumentationBuilder.ParsedParameters = (List<DocumentationParameter>)yyVals[0+yyTop]; module.DocumentationBuilder.ParsedParameters = (List<DocumentationParameter>)yyVals[0+yyTop];
@ -8424,7 +8444,7 @@ void case_929()
} }
void case_930() void case_930()
#line 6069 "cs-parser.jay" #line 6077 "cs-parser.jay"
{ {
module.DocumentationBuilder.ParsedBuiltinType = (TypeExpression)yyVals[-3+yyTop]; module.DocumentationBuilder.ParsedBuiltinType = (TypeExpression)yyVals[-3+yyTop];
module.DocumentationBuilder.ParsedParameters = (List<DocumentationParameter>)yyVals[0+yyTop]; module.DocumentationBuilder.ParsedParameters = (List<DocumentationParameter>)yyVals[0+yyTop];
@ -8433,14 +8453,14 @@ void case_930()
} }
void case_933() void case_933()
#line 6084 "cs-parser.jay" #line 6092 "cs-parser.jay"
{ {
module.DocumentationBuilder.ParsedParameters = (List<DocumentationParameter>)yyVals[-1+yyTop]; module.DocumentationBuilder.ParsedParameters = (List<DocumentationParameter>)yyVals[-1+yyTop];
yyVal = new MemberName ((MemberName) yyVals[-6+yyTop], new MemberName (MemberCache.IndexerNameAlias)); yyVal = new MemberName ((MemberName) yyVals[-6+yyTop], new MemberName (MemberCache.IndexerNameAlias));
} }
void case_934() void case_934()
#line 6089 "cs-parser.jay" #line 6097 "cs-parser.jay"
{ {
var p = (List<DocumentationParameter>)yyVals[0+yyTop] ?? new List<DocumentationParameter> (1); var p = (List<DocumentationParameter>)yyVals[0+yyTop] ?? new List<DocumentationParameter> (1);
p.Add (new DocumentationParameter ((FullNamedExpression) yyVals[-1+yyTop])); p.Add (new DocumentationParameter ((FullNamedExpression) yyVals[-1+yyTop]));
@ -8450,7 +8470,7 @@ void case_934()
} }
void case_935() void case_935()
#line 6097 "cs-parser.jay" #line 6105 "cs-parser.jay"
{ {
var p = (List<DocumentationParameter>)yyVals[0+yyTop] ?? new List<DocumentationParameter> (1); var p = (List<DocumentationParameter>)yyVals[0+yyTop] ?? new List<DocumentationParameter> (1);
p.Add (new DocumentationParameter ((FullNamedExpression) yyVals[-1+yyTop])); p.Add (new DocumentationParameter ((FullNamedExpression) yyVals[-1+yyTop]));
@ -8460,7 +8480,7 @@ void case_935()
} }
void case_936() void case_936()
#line 6105 "cs-parser.jay" #line 6113 "cs-parser.jay"
{ {
var p = (List<DocumentationParameter>)yyVals[0+yyTop] ?? new List<DocumentationParameter> (1); var p = (List<DocumentationParameter>)yyVals[0+yyTop] ?? new List<DocumentationParameter> (1);
module.DocumentationBuilder.ParsedParameters = p; module.DocumentationBuilder.ParsedParameters = p;
@ -8469,7 +8489,7 @@ void case_936()
} }
void case_944() void case_944()
#line 6143 "cs-parser.jay" #line 6151 "cs-parser.jay"
{ {
var parameters = new List<DocumentationParameter> (); var parameters = new List<DocumentationParameter> ();
parameters.Add ((DocumentationParameter) yyVals[0+yyTop]); parameters.Add ((DocumentationParameter) yyVals[0+yyTop]);
@ -8477,7 +8497,7 @@ void case_944()
} }
void case_945() void case_945()
#line 6149 "cs-parser.jay" #line 6157 "cs-parser.jay"
{ {
var parameters = yyVals[-2+yyTop] as List<DocumentationParameter>; var parameters = yyVals[-2+yyTop] as List<DocumentationParameter>;
parameters.Add ((DocumentationParameter) yyVals[0+yyTop]); parameters.Add ((DocumentationParameter) yyVals[0+yyTop]);
@ -8485,7 +8505,7 @@ void case_945()
} }
void case_946() void case_946()
#line 6158 "cs-parser.jay" #line 6166 "cs-parser.jay"
{ {
if (yyVals[-1+yyTop] != null) if (yyVals[-1+yyTop] != null)
yyVal = new DocumentationParameter ((Parameter.Modifier) yyVals[-1+yyTop], (FullNamedExpression) yyVals[0+yyTop]); yyVal = new DocumentationParameter ((Parameter.Modifier) yyVals[-1+yyTop], (FullNamedExpression) yyVals[0+yyTop]);
@ -11811,7 +11831,7 @@ void case_946()
-1, -1, 359, -1, -1, 359,
}; };
#line 6167 "cs-parser.jay" #line 6175 "cs-parser.jay"
// <summary> // <summary>
// A class used to hold info about an operator declarator // A class used to hold info about an operator declarator

10
ICSharpCode.NRefactory/CSharp/Parser/mcs/cs-parser.jay

@ -5669,6 +5669,7 @@ select_or_group_clause
BY expression BY expression
{ {
$$ = new Linq.GroupBy ((Linq.QueryBlock)current_block, (Expression)$3, linq_clause_blocks.Pop (), (Expression)$6, GetLocation ($1)); $$ = new Linq.GroupBy ((Linq.QueryBlock)current_block, (Expression)$3, linq_clause_blocks.Pop (), (Expression)$6, GetLocation ($1));
lbag.AddLocation ($$, GetLocation ($5));
current_block.SetEndLocation (lexer.Location); current_block.SetEndLocation (lexer.Location);
current_block = current_block.Parent; current_block = current_block.Parent;
@ -5707,7 +5708,8 @@ let_clause
var lt = (Tokenizer.LocatedToken) $2; var lt = (Tokenizer.LocatedToken) $2;
var sn = new Linq.RangeVariable (lt.Value, lt.Location); var sn = new Linq.RangeVariable (lt.Value, lt.Location);
$$ = new Linq.Let ((Linq.QueryBlock) current_block, sn, (Expression)$5, GetLocation ($1)); $$ = new Linq.Let ((Linq.QueryBlock) current_block, sn, (Expression)$5, GetLocation ($1));
lbag.AddLocation ($$, GetLocation ($3));
current_block.SetEndLocation (lexer.Location); current_block.SetEndLocation (lexer.Location);
current_block = current_block.Parent; current_block = current_block.Parent;
@ -5769,6 +5771,7 @@ join_clause
if ($12 == null) { if ($12 == null) {
into = sn; into = sn;
$$ = new Linq.Join (block, sn, (Expression)$5, outer_selector, (Linq.QueryBlock) current_block, GetLocation ($1)); $$ = new Linq.Join (block, sn, (Expression)$5, outer_selector, (Linq.QueryBlock) current_block, GetLocation ($1));
lbag.AddLocation ($$, GetLocation ($3), GetLocation ($6), GetLocation ($9));
} else { } else {
// //
// Set equals right side parent to beginning of linq query, it is not accessible therefore cannot cause name collisions // Set equals right side parent to beginning of linq query, it is not accessible therefore cannot cause name collisions
@ -5785,6 +5788,7 @@ join_clause
into = new Linq.RangeVariable (lt.Value, lt.Location); into = new Linq.RangeVariable (lt.Value, lt.Location);
$$ = new Linq.GroupJoin (block, sn, (Expression)$5, outer_selector, (Linq.QueryBlock) current_block, into, GetLocation ($1)); $$ = new Linq.GroupJoin (block, sn, (Expression)$5, outer_selector, (Linq.QueryBlock) current_block, into, GetLocation ($1));
lbag.AddLocation ($$, GetLocation ($3), GetLocation ($6), GetLocation ($9), GetLocation ($12));
} }
current_block = block.Parent; current_block = block.Parent;
@ -5918,10 +5922,12 @@ order_by
| expression ASCENDING | expression ASCENDING
{ {
$$ = new Linq.OrderByAscending ((Linq.QueryBlock) current_block, (Expression)$1); $$ = new Linq.OrderByAscending ((Linq.QueryBlock) current_block, (Expression)$1);
lbag.AddLocation ($$, GetLocation ($2));
} }
| expression DESCENDING | expression DESCENDING
{ {
$$ = new Linq.OrderByDescending ((Linq.QueryBlock) current_block, (Expression)$1); $$ = new Linq.OrderByDescending ((Linq.QueryBlock) current_block, (Expression)$1);
lbag.AddLocation ($$, GetLocation ($2));
} }
; ;
@ -5933,10 +5939,12 @@ then_by
| expression ASCENDING | expression ASCENDING
{ {
$$ = new Linq.ThenByAscending ((Linq.QueryBlock) current_block, (Expression)$1); $$ = new Linq.ThenByAscending ((Linq.QueryBlock) current_block, (Expression)$1);
lbag.AddLocation ($$, GetLocation ($2));
} }
| expression DESCENDING | expression DESCENDING
{ {
$$ = new Linq.ThenByDescending ((Linq.QueryBlock) current_block, (Expression)$1); $$ = new Linq.ThenByDescending ((Linq.QueryBlock) current_block, (Expression)$1);
lbag.AddLocation ($$, GetLocation ($2));
} }
; ;

7
ICSharpCode.NRefactory/CSharp/Parser/mcs/expression.cs

@ -9670,7 +9670,7 @@ namespace Mono.CSharp
public override object Accept (StructuralVisitor visitor) public override object Accept (StructuralVisitor visitor)
{ {
return visitor.Visit (this); return visitor.Visit (this);
} }
} }
public class NewAnonymousType : New public class NewAnonymousType : New
@ -9783,6 +9783,11 @@ namespace Mono.CSharp
RequestedType = new GenericTypeExpr (anonymous_type.Definition, new TypeArguments (t_args), loc); RequestedType = new GenericTypeExpr (anonymous_type.Definition, new TypeArguments (t_args), loc);
return base.DoResolve (ec); return base.DoResolve (ec);
} }
public override object Accept (StructuralVisitor visitor)
{
return visitor.Visit (this);
}
} }
public class AnonymousTypeParameter : ShimExpression public class AnonymousTypeParameter : ShimExpression

27
ICSharpCode.NRefactory/CSharp/Parser/mcs/linq.cs

@ -273,7 +273,13 @@ namespace Mono.CSharp.Linq
} }
protected RangeVariable identifier; protected RangeVariable identifier;
public RangeVariable IntoVariable {
get {
return identifier;
}
}
protected ARangeVariableQueryClause (QueryBlock block, RangeVariable identifier, Expression expr, Location loc) protected ARangeVariableQueryClause (QueryBlock block, RangeVariable identifier, Expression expr, Location loc)
: base (block, expr, loc) : base (block, expr, loc)
{ {
@ -434,6 +440,11 @@ namespace Mono.CSharp.Linq
protected override string MethodName { protected override string MethodName {
get { throw new NotSupportedException (); } get { throw new NotSupportedException (); }
} }
public override object Accept (StructuralVisitor visitor)
{
return visitor.Visit (this);
}
} }
@ -500,7 +511,19 @@ namespace Mono.CSharp.Linq
public RangeVariable JoinVariable { public RangeVariable JoinVariable {
get { return this.GetIntoVariable (); } get { return this.GetIntoVariable (); }
} }
public QueryBlock InnerSelector {
get {
return inner_selector;
}
}
public QueryBlock OuterSelector {
get {
return outer_selector;
}
}
public Join (QueryBlock block, RangeVariable lt, Expression inner, QueryBlock outerSelector, QueryBlock innerSelector, Location loc) public Join (QueryBlock block, RangeVariable lt, Expression inner, QueryBlock outerSelector, QueryBlock innerSelector, Location loc)
: base (block, lt, inner, loc) : base (block, lt, inner, loc)
{ {

10
ICSharpCode.NRefactory/CSharp/Parser/mcs/visit.cs

@ -446,6 +446,11 @@ namespace Mono.CSharp
return null; return null;
} }
public virtual object Visit (NewAnonymousType newAnonymousType)
{
return null;
}
public virtual object Visit (NewInitialize newInitializeExpression) public virtual object Visit (NewInitialize newInitializeExpression)
{ {
return null; return null;
@ -546,6 +551,11 @@ namespace Mono.CSharp
return null; return null;
} }
public virtual object Visit (Linq.QueryStartClause queryExpression)
{
return null;
}
public virtual object Visit (Linq.SelectMany selectMany) public virtual object Visit (Linq.SelectMany selectMany)
{ {
return null; return null;

1
ICSharpCode.NRefactory/ICSharpCode.NRefactory.csproj

@ -351,6 +351,7 @@
<Compile Include="CSharp\Ast\TypeMembers\FixedVariableInitializer.cs" /> <Compile Include="CSharp\Ast\TypeMembers\FixedVariableInitializer.cs" />
<Compile Include="CSharp\Ast\GeneralScope\ExternAliasDeclaration.cs" /> <Compile Include="CSharp\Ast\GeneralScope\ExternAliasDeclaration.cs" />
<Compile Include="CSharp\Formatter\CSharpFormattingOptions.cs" /> <Compile Include="CSharp\Formatter\CSharpFormattingOptions.cs" />
<Compile Include="CSharp\Ast\Expressions\AnonymousTypeCreateExpression.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Folder Include="CSharp\" /> <Folder Include="CSharp\" />

Loading…
Cancel
Save