private Document IntroduceQueryLocalForSingleOccurrence( SemanticDocument document, ExpressionSyntax expression, NameSyntax newLocalName, LetClauseSyntax letClause, bool allOccurrences, CancellationToken cancellationToken) { var oldClause = expression.GetAncestors<SyntaxNode>().First(IsAnyQueryClause); var newClause = Rewrite( document, expression, newLocalName, document, oldClause, allOccurrences, cancellationToken); var oldQuery = (QueryBodySyntax)oldClause.Parent; var newQuery = GetNewQuery(oldQuery, oldClause, newClause, letClause); var newRoot = document.Root.ReplaceNode(oldQuery, newQuery); return document.Document.WithSyntaxRoot(newRoot); }
// // Summary: // Called when the visitor visits a LetClauseSyntax node. public virtual void VisitLetClause(LetClauseSyntax node);
public override void VisitLetClause(LetClauseSyntax node) { base.VisitLetClause(node); Add(node.Identifier); }
public override void VisitLetClause(LetClauseSyntax node) { node.Expression?.Accept(this); base.VisitLetClause(node); }
public override LuaSyntaxNode VisitLetClause(LetClauseSyntax node) { throw new InvalidOperationException(); }
public override void VisitLetClause(LetClauseSyntax node) { var saveCurrentScope = currentScope; currentScope = new DeclarationScope(currentScope); Visit(node.Expression); Debug.Assert(currentScope.Parent == saveCurrentScope); currentScope = saveCurrentScope; }
public override void VisitLetClause(LetClauseSyntax node) { Log(node, "Unsupported Syntax !"); }
/// <inheritdoc /> public override Expression VisitLetClause(LetClauseSyntax node) { throw Unexpected(node, nameof(VisitQueryExpression)); }
public override void VisitLetClause(LetClauseSyntax node) { this.Found |= node.Identifier.ValueText == this.name; base.VisitLetClause(node); }
/// <summary> /// /// </summary> /// <param name="node"></param> public override sealed void VisitLetClause(LetClauseSyntax node) { this.OnNodeVisited(node, this.type.IsInstanceOfType(node)); base.VisitLetClause(node); }
public override void VisitLetClause(LetClauseSyntax node) { var membersVisitor = new GetMembersVisitor(this); membersVisitor.Visit(node.Expression); _variables.Add(node.Identifier.ValueText, membersVisitor._properties); AddProperties(membersVisitor._properties); _fromVariables.Add(node.Identifier.ValueText, _linqIndex); _proceed = true; }
public override void VisitLetClause(LetClauseSyntax node) { FindSpellingMistakesForIdentifier(node.Identifier); base.VisitLetClause(node); }
public override void VisitLetClause(LetClauseSyntax node) { map.Add(node.Identifier.ValueText, node.Identifier); base.VisitLetClause(node); }
/// <summary> /// /// </summary> /// <param name="node"></param> public override sealed void VisitLetClause(LetClauseSyntax node) { this.OnNodeVisited(node); if (!this.traverseRootOnly) base.VisitLetClause(node); }
public override void VisitLetClause(LetClauseSyntax node) => base.VisitLetClause(node);
private void ReduceLet(LetClauseSyntax let, QueryTranslationState state, DiagnosticBag diagnostics) { // A query expression with a let clause // from x in e // let y = f // ... // is translated into // from * in ( e ) . Select ( x => new { x , y = f } ) // ... var x = state.rangeVariable; // We use a slightly different translation strategy. We produce // from * in ( e ) . Select ( x => new Pair<X,Y>(x, f) ) // Where X is the type of x, and Y is the type of the expression f. // Subsequently, x (or members of x, if it is a transparent identifier) // are accessed as TRID.Item1 (or members of that), and y is accessed // as TRID.Item2, where TRID is the compiler-generated identifier used // to represent the transparent identifier in the result. LambdaBodyFactory bodyFactory = (LambdaSymbol lambdaSymbol, ref Binder lambdaBodyBinder, DiagnosticBag d) => { var xExpression = new BoundParameter(let, lambdaSymbol.Parameters[0]) { WasCompilerGenerated = true }; var yExpression = lambdaBodyBinder.BindValue(let.Expression, d, BindValueKind.RValue); SourceLocation errorLocation = new SourceLocation(let.SyntaxTree, new TextSpan(let.Identifier.SpanStart, let.Expression.Span.End - let.Identifier.SpanStart)); if (!yExpression.HasAnyErrors && !yExpression.HasExpressionType()) { MessageID id = MessageID.IDS_NULL; if (yExpression.Kind == BoundKind.UnboundLambda) { id = ((UnboundLambda)yExpression).MessageID; } else if (yExpression.Kind == BoundKind.MethodGroup) { id = MessageID.IDS_MethodGroup; } else { Debug.Assert(yExpression.IsLiteralNull(), "How did we successfully bind an expression without a type?"); } Error(d, ErrorCode.ERR_QueryRangeVariableAssignedBadValue, errorLocation, id.Localize()); yExpression = new BoundBadExpression(yExpression.Syntax, LookupResultKind.Empty, ImmutableArray<Symbol>.Empty, ImmutableArray.Create<BoundNode>(yExpression), CreateErrorType()); } else if (!yExpression.HasAnyErrors && yExpression.Type.SpecialType == SpecialType.System_Void) { Error(d, ErrorCode.ERR_QueryRangeVariableAssignedBadValue, errorLocation, yExpression.Type); yExpression = new BoundBadExpression(yExpression.Syntax, LookupResultKind.Empty, ImmutableArray<Symbol>.Empty, ImmutableArray.Create<BoundNode>(yExpression), yExpression.Type); } var construction = MakePair(let, x.Name, xExpression, let.Identifier.ValueText, yExpression, state, d); return lambdaBodyBinder.CreateBlockFromExpression(let, lambdaBodyBinder.Locals, null, construction, d); }; var lambda = MakeQueryUnboundLambda(state.RangeVariableMap(), ImmutableArray.Create(x), let.Expression, bodyFactory); state.rangeVariable = state.TransparentRangeVariable(this); state.AddTransparentIdentifier(x.Name); var y = state.AddRangeVariable(this, let.Identifier, diagnostics); state.allRangeVariables[y].Add(let.Identifier.ValueText); var invocation = MakeQueryInvocation(let, state.fromExpression, "Select", lambda, diagnostics); state.fromExpression = MakeQueryClause(let, invocation, y, invocation); }
public TameLetClauseSyntax(LetClauseSyntax node) { Node = node; AddChildren(); }
public override void VisitLetClause(LetClauseSyntax node) { Console.WriteLine("Found a let clause " + node.Identifier.Text); base.VisitLetClause(node); }
public override void VisitLetClause(LetClauseSyntax queryLetClause) { base.VisitLetClause(queryLetClause); _indexData.HasLet = true; }
public override Evaluation VisitLetClause(LetClauseSyntax node) { node.Expression?.Accept <Evaluation>(this); return(base.VisitLetClause(node)); }
private static QueryBodySyntax GetNewQuery( QueryBodySyntax oldQuery, SyntaxNode oldClause, SyntaxNode newClause, LetClauseSyntax letClause) { var oldClauses = oldQuery.GetAllClauses(); var oldClauseIndex = oldClauses.IndexOf(oldClause); var newClauses = oldClauses.Take(oldClauseIndex) .Concat(letClause) .Concat(newClause) .Concat(oldClauses.Skip(oldClauseIndex + 1)).ToList(); return oldQuery.WithAllClauses(newClauses); }
public override SyntaxNode VisitLetClause(LetClauseSyntax node) { node = (LetClauseSyntax)base.VisitLetClause(node); Classes.Add(node); return(node); }
public override void VisitLetClause(LetClauseSyntax node) { throw new NotImplementedException(); }
private void ReduceLet(LetClauseSyntax let, QueryTranslationState state, DiagnosticBag diagnostics) { // A query expression with a let clause // from x in e // let y = f // ... // is translated into // from * in ( e ) . Select ( x => new { x , y = f } ) // ... var x = state.rangeVariable; // We use a slightly different translation strategy. We produce // from * in ( e ) . Select ( x => new Pair<X,Y>(x, f) ) // Where X is the type of x, and Y is the type of the expression f. // Subsequently, x (or members of x, if it is a transparent identifier) // are accessed as TRID.Item1 (or members of that), and y is accessed // as TRID.Item2, where TRID is the compiler-generated identifier used // to represent the transparent identifier in the result. LambdaBodyFactory bodyFactory = (LambdaSymbol lambdaSymbol, ref Binder lambdaBodyBinder, DiagnosticBag d) => { var xExpression = new BoundParameter(let, lambdaSymbol.Parameters[0]) { WasCompilerGenerated = true }; var yExpression = lambdaBodyBinder.BindValue(let.Expression, d, BindValueKind.RValue); SourceLocation errorLocation = new SourceLocation(let.SyntaxTree, new TextSpan(let.Identifier.SpanStart, let.Expression.Span.End - let.Identifier.SpanStart)); if (!yExpression.HasAnyErrors && !yExpression.HasExpressionType()) { MessageID id = MessageID.IDS_NULL; if (yExpression.Kind == BoundKind.UnboundLambda) { id = ((UnboundLambda)yExpression).MessageID; } else if (yExpression.Kind == BoundKind.MethodGroup) { id = MessageID.IDS_MethodGroup; } else { Debug.Assert(yExpression.IsLiteralNull(), "How did we successfully bind an expression without a type?"); } Error(d, ErrorCode.ERR_QueryRangeVariableAssignedBadValue, errorLocation, id.Localize()); yExpression = new BoundBadExpression(yExpression.Syntax, LookupResultKind.Empty, ImmutableArray <Symbol> .Empty, ImmutableArray.Create <BoundNode>(yExpression), CreateErrorType()); } else if (!yExpression.HasAnyErrors && yExpression.Type.SpecialType == SpecialType.System_Void) { Error(d, ErrorCode.ERR_QueryRangeVariableAssignedBadValue, errorLocation, yExpression.Type); yExpression = new BoundBadExpression(yExpression.Syntax, LookupResultKind.Empty, ImmutableArray <Symbol> .Empty, ImmutableArray.Create <BoundNode>(yExpression), yExpression.Type); } var construction = MakePair(let, x.Name, xExpression, let.Identifier.ValueText, yExpression, state, d); // The bound block represents a closure scope for transparent identifiers captured in the let clause. // Such closures shall be associated with the lambda body expression. return(lambdaBodyBinder.CreateBlockFromExpression(let.Expression, lambdaBodyBinder.Locals, null, construction, d)); }; var lambda = MakeQueryUnboundLambda(state.RangeVariableMap(), ImmutableArray.Create(x), let.Expression, bodyFactory); state.rangeVariable = state.TransparentRangeVariable(this); state.AddTransparentIdentifier(x.Name); var y = state.AddRangeVariable(this, let.Identifier, diagnostics); state.allRangeVariables[y].Add(let.Identifier.ValueText); var invocation = MakeQueryInvocation(let, state.fromExpression, "Select", lambda, diagnostics); state.fromExpression = MakeQueryClause(let, invocation, y, invocation); }
public override void VisitLetClause(LetClauseSyntax node) { return; }
private void ReduceLet(LetClauseSyntax let, QueryTranslationState state, DiagnosticBag diagnostics) { // A query expression with a let clause // from x in e // let y = f // ... // is translated into // from * in ( e ) . Select ( x => new { x , y = f } ) // ... var x = state.rangeVariable; // We use a slightly different translation strategy. We produce // from * in ( e ) . Select ( x => new Pair<X,Y>(x, f) ) // Where X is the type of x, and Y is the type of the expression f. // Subsequently, x (or members of x, if it is a transparent identifier) // are accessed as TRID.Item1 (or members of that), and y is accessed // as TRID.Item2, where TRID is the compiler-generated identifier used // to represent the transparent identifier in the result. LambdaBodyFactory bodyFactory = (LambdaSymbol lambdaSymbol, Binder lambdaBodyBinder, DiagnosticBag d) => { var xExpression = new BoundParameter(let, lambdaSymbol.Parameters[0]) { WasCompilerGenerated = true }; lambdaBodyBinder = lambdaBodyBinder.GetBinder(let.Expression); Debug.Assert(lambdaBodyBinder != null); var yExpression = lambdaBodyBinder.BindValue(let.Expression, d, BindValueKind.RValue); SourceLocation errorLocation = new SourceLocation(let.SyntaxTree, new TextSpan(let.Identifier.SpanStart, let.Expression.Span.End - let.Identifier.SpanStart)); if (!yExpression.HasAnyErrors && !yExpression.HasExpressionType()) { Error(d, ErrorCode.ERR_QueryRangeVariableAssignedBadValue, errorLocation, yExpression.Display); yExpression = new BoundBadExpression(yExpression.Syntax, LookupResultKind.Empty, ImmutableArray<Symbol>.Empty, ImmutableArray.Create<BoundNode>(yExpression), CreateErrorType()); } else if (!yExpression.HasAnyErrors && yExpression.Type.SpecialType == SpecialType.System_Void) { Error(d, ErrorCode.ERR_QueryRangeVariableAssignedBadValue, errorLocation, yExpression.Type); yExpression = new BoundBadExpression(yExpression.Syntax, LookupResultKind.Empty, ImmutableArray<Symbol>.Empty, ImmutableArray.Create<BoundNode>(yExpression), yExpression.Type); } var construction = MakePair(let, x.Name, xExpression, let.Identifier.ValueText, yExpression, state, d); // The bound block represents a closure scope for transparent identifiers captured in the let clause. // Such closures shall be associated with the lambda body expression. return lambdaBodyBinder.CreateBlockFromExpression(let.Expression, lambdaBodyBinder.GetDeclaredLocalsForScope(let.Expression), RefKind.None, construction, null, d); }; var lambda = MakeQueryUnboundLambda(state.RangeVariableMap(), ImmutableArray.Create(x), let.Expression, bodyFactory); state.rangeVariable = state.TransparentRangeVariable(this); state.AddTransparentIdentifier(x.Name); var y = state.AddRangeVariable(this, let.Identifier, diagnostics); state.allRangeVariables[y].Add(let.Identifier.ValueText); var invocation = MakeQueryInvocation(let, state.fromExpression, "Select", lambda, diagnostics); state.fromExpression = MakeQueryClause(let, invocation, y, invocation); }
public void VisitLetClause(LetClauseSyntax node) { if (node == null) throw new ArgumentNullException("node"); node.Validate(); if (!_writer.Configuration.LineBreaksAndWrapping.Other.PlaceLinqExpressionOnSingleLine) _writer.Break(true); _writer.WriteKeyword(PrinterKeyword.Let); _writer.WriteSpace(); _writer.WriteIdentifier(node.Identifier); _writer.WriteSpace(); _writer.WriteOperator(PrinterOperator.Equals); _writer.WriteSpace(); node.Expression.Accept(this); }
public override void VisitLetClause(LetClauseSyntax node) { throw new NotSupportedException(); }