Browse Source

* Src/Visitors/LookupTableVisitor.cs: Added IsQueryContinuation flag

to local lookup variables. This helps resolving the type of "from
  ... where ... into VAR" constructs.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/3.0@3927 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Mike Krüger 16 years ago
parent
commit
5705bb78c5
  1. 35
      src/Libraries/NRefactory/Project/Src/Visitors/LookupTableVisitor.cs

35
src/Libraries/NRefactory/Project/Src/Visitors/LookupTableVisitor.cs

@ -22,8 +22,9 @@ namespace ICSharpCode.NRefactory.Visitors @@ -22,8 +22,9 @@ namespace ICSharpCode.NRefactory.Visitors
public readonly bool IsLoopVariable;
public readonly Expression Initializer;
public readonly LambdaExpression ParentLambdaExpression;
public readonly bool IsQueryContinuation;
public LocalLookupVariable(string name, TypeReference typeRef, Location startPos, Location endPos, bool isConst, bool isLoopVariable, Expression initializer, LambdaExpression parentLambdaExpression)
public LocalLookupVariable(string name, TypeReference typeRef, Location startPos, Location endPos, bool isConst, bool isLoopVariable, Expression initializer, LambdaExpression parentLambdaExpression, bool isQueryContinuation)
{
this.Name = name;
this.TypeRef = typeRef;
@ -33,7 +34,9 @@ namespace ICSharpCode.NRefactory.Visitors @@ -33,7 +34,9 @@ namespace ICSharpCode.NRefactory.Visitors
this.IsLoopVariable = isLoopVariable;
this.Initializer = initializer;
this.ParentLambdaExpression = parentLambdaExpression;
this.IsQueryContinuation = isQueryContinuation;
}
}
public sealed class LookupTableVisitor : AbstractAstVisitor
@ -69,7 +72,8 @@ namespace ICSharpCode.NRefactory.Visitors @@ -69,7 +72,8 @@ namespace ICSharpCode.NRefactory.Visitors
public void AddVariable(TypeReference typeRef, string name,
Location startPos, Location endPos, bool isConst,
bool isLoopVariable, Expression initializer,
LambdaExpression parentLambdaExpression)
LambdaExpression parentLambdaExpression,
bool isQueryContinuation)
{
if (name == null || name.Length == 0) {
return;
@ -80,7 +84,7 @@ namespace ICSharpCode.NRefactory.Visitors @@ -80,7 +84,7 @@ namespace ICSharpCode.NRefactory.Visitors
} else {
list = (List<LocalLookupVariable>)variables[name];
}
list.Add(new LocalLookupVariable(name, typeRef, startPos, endPos, isConst, isLoopVariable, initializer, parentLambdaExpression));
list.Add(new LocalLookupVariable(name, typeRef, startPos, endPos, isConst, isLoopVariable, initializer, parentLambdaExpression, isQueryContinuation));
}
public override object VisitWithStatement(WithStatement withStatement, object data)
@ -115,7 +119,7 @@ namespace ICSharpCode.NRefactory.Visitors @@ -115,7 +119,7 @@ namespace ICSharpCode.NRefactory.Visitors
localVariableDeclaration.StartLocation,
CurrentEndLocation,
(localVariableDeclaration.Modifier & Modifiers.Const) == Modifiers.Const,
false, varDecl.Initializer, null);
false, varDecl.Initializer, null, false);
}
return base.VisitLocalVariableDeclaration(localVariableDeclaration, data);
}
@ -125,7 +129,7 @@ namespace ICSharpCode.NRefactory.Visitors @@ -125,7 +129,7 @@ namespace ICSharpCode.NRefactory.Visitors
foreach (ParameterDeclarationExpression p in anonymousMethodExpression.Parameters) {
AddVariable(p.TypeReference, p.ParameterName,
anonymousMethodExpression.StartLocation, anonymousMethodExpression.EndLocation,
false, false, null, null);
false, false, null, null, false);
}
return base.VisitAnonymousMethodExpression(anonymousMethodExpression, data);
}
@ -135,7 +139,7 @@ namespace ICSharpCode.NRefactory.Visitors @@ -135,7 +139,7 @@ namespace ICSharpCode.NRefactory.Visitors
foreach (ParameterDeclarationExpression p in lambdaExpression.Parameters) {
AddVariable(p.TypeReference, p.ParameterName,
lambdaExpression.StartLocation, lambdaExpression.ExtendedEndLocation,
false, false, null, lambdaExpression);
false, false, null, lambdaExpression, false);
}
return base.VisitLambdaExpression(lambdaExpression, data);
}
@ -155,9 +159,10 @@ namespace ICSharpCode.NRefactory.Visitors @@ -155,9 +159,10 @@ namespace ICSharpCode.NRefactory.Visitors
public override object VisitQueryExpressionFromClause(QueryExpressionFromClause fromClause, object data)
{
QueryExpression parent = fromClause.Parent as QueryExpression;
AddVariable(fromClause.Type, fromClause.Identifier,
fromClause.StartLocation, CurrentEndLocation,
false, true, fromClause.InExpression, null);
false, true, fromClause.InExpression, null, parent != null && parent.IsQueryContinuation);
return base.VisitQueryExpressionFromClause(fromClause, data);
}
@ -166,15 +171,15 @@ namespace ICSharpCode.NRefactory.Visitors @@ -166,15 +171,15 @@ namespace ICSharpCode.NRefactory.Visitors
if (string.IsNullOrEmpty(joinClause.IntoIdentifier)) {
AddVariable(joinClause.Type, joinClause.Identifier,
joinClause.StartLocation, CurrentEndLocation,
false, true, joinClause.InExpression, null);
false, true, joinClause.InExpression, null, false);
} else {
AddVariable(joinClause.Type, joinClause.Identifier,
joinClause.StartLocation, joinClause.EndLocation,
false, true, joinClause.InExpression, null);
false, true, joinClause.InExpression, null, false);
AddVariable(joinClause.Type, joinClause.IntoIdentifier,
joinClause.StartLocation, CurrentEndLocation,
false, false, joinClause.InExpression, null);
false, false, joinClause.InExpression, null, false);
}
return base.VisitQueryExpressionJoinClause(joinClause, data);
}
@ -183,7 +188,7 @@ namespace ICSharpCode.NRefactory.Visitors @@ -183,7 +188,7 @@ namespace ICSharpCode.NRefactory.Visitors
{
AddVariable(null, letClause.Identifier,
letClause.StartLocation, CurrentEndLocation,
false, false, letClause.Expression, null);
false, false, letClause.Expression, null, false);
return base.VisitQueryExpressionLetClause(letClause, data);
}
@ -199,7 +204,8 @@ namespace ICSharpCode.NRefactory.Visitors @@ -199,7 +204,8 @@ namespace ICSharpCode.NRefactory.Visitors
forNextStatement.EndLocation,
false, false,
forNextStatement.Start,
null);
null,
false);
base.VisitForNextStatement(forNextStatement, data);
@ -264,7 +270,8 @@ namespace ICSharpCode.NRefactory.Visitors @@ -264,7 +270,8 @@ namespace ICSharpCode.NRefactory.Visitors
foreachStatement.EndLocation,
false, true,
foreachStatement.Expression,
null);
null,
false);
if (foreachStatement.Expression != null) {
foreachStatement.Expression.AcceptVisitor(this, data);
@ -291,7 +298,7 @@ namespace ICSharpCode.NRefactory.Visitors @@ -291,7 +298,7 @@ namespace ICSharpCode.NRefactory.Visitors
catchClause.VariableName,
catchClause.StatementBlock.StartLocation,
catchClause.StatementBlock.EndLocation,
false, false, null, null);
false, false, null, null, false);
}
catchClause.StatementBlock.AcceptVisitor(this, data);
}

Loading…
Cancel
Save