public AnnotatedExpression AnnotateNameExpression(NameExpressionSyntax syntax) { var name = syntax.IdentifierToken.Text; if (string.IsNullOrEmpty(name)) { return(new AnnotatedLiteralExpression(0)); } _scope.TryLookup(name, out var symbol); if (symbol == null) { _diagnostics.ReportUndefinedName(syntax.IdentifierToken.Span, name); return(new AnnotatedLiteralExpression(0)); } return(new AnnotatedVariableExpression(symbol)); }
private BoundExpression BindNameExpression(NameExpressionSyntax syntax) { var name = syntax.IdentifierToken.Text; if (string.IsNullOrEmpty(name)) { //already reported, this is null because name was synthesized return(new BoundLiteralExpression(0)); } if (!_scope.TryLookup(name, out var variable)) { _diagnostics.ReportUndefinedName(syntax.IdentifierToken.Span, name); return(new BoundLiteralExpression(0)); } return(new BoundVariableExpression(variable)); }
private BoundExpression BindNameExpression(NameExpressionSyntax syntax) { var name = syntax.IdentifierToken.Text; if (string.IsNullOrEmpty(name)) { // this means the token was inserted by parser and we already reported an error return(new BoundLiteralExpression(0)); } if (!_scope.TryLookup(name, out VariableSymbol variable)) { _diagnostics.ReportUndefinedName(syntax.IdentifierToken.Span, name); return(new BoundLiteralExpression(0)); } return(new BoundVariableExpression(variable)); }
private BoundExpression BindNameExpression(NameExpressionSyntax syntax) { var name = syntax.IdentifierToken.Text; if (syntax.IdentifierToken.IsMissing) { // This means the token was inserted by the parser. We already // reported error so we can just return an error expression. return(new BoundErrorExpression()); } if (!_scope.TryLookupVariable(name, out var variable)) { _diagnostics.ReportUndefinedName(syntax.IdentifierToken.Span, name); return(new BoundErrorExpression()); } return(new BoundVariableExpression(variable)); }
private BoundExpression BindNameExpression(NameExpressionSyntax syntax) { var name = syntax.NameToken.Text; if (String.IsNullOrEmpty(name)) { // Specified syntax was inserted by the Parser as a result of a parse error. // Diagnostic has already been reported by the Parser. return(new BoundErrorExpression()); } if (!_scope.TryLookupVariable(name, out var variable)) { _diagnostics.ReportUndefinedName(syntax.NameToken.Span, name); return(new BoundErrorExpression()); } return(new BoundVariableExpression(variable)); }
private BoundExpression BindNameExpression(NameExpressionSyntax syntax) { var name = syntax.IdentifierToken.Text; if (syntax.IdentifierToken.IsMissing) { // If we get here we ended up on a // syntactic token, inserted by the parser // Error has been reported already so we just // return an error expression return(new BoundErrorExpression()); } if (!_scope.TryLookup(name, out var variable)) { Diagnostics.ReportUndefinedName(syntax.IdentifierToken.Span, name); return(new BoundErrorExpression()); } return(new BoundVariableExpression(variable)); }
internal static string Token(this NameExpressionSyntax expression) { Assert.NotNull(expression.IdentifierToken); return(expression.ToString()); }
internal CallExpressionSyntax(SyntaxTree syntaxTree, NameExpressionSyntax identifier, SyntaxToken openParenthesisToken, SeparatedSyntaxList <ExpressionSyntax> arguments, SyntaxToken closeParenthesisToken) : this(syntaxTree, (ExpressionSyntax)identifier, openParenthesisToken, arguments, closeParenthesisToken) { }
public BoundAssignementExpression(NameExpressionSyntax name, BoundExpression expression) { Name = name; Expression = expression; }
/// <summary> /// Tries to get a member from this imported class symbol. /// </summary> /// <param name="text">The name of the member.</param> /// <param name="ne">The name expression.</param> /// <param name="member">The resulting member, if one is found.</param> /// <returns>Whether we found a matching member or not.</returns> public bool TryLookupMember(string text, NameExpressionSyntax ne, out object member) { throw new NotImplementedException(); }
public virtual void VisitNameExpression(NameExpressionSyntax node) { DefaultVisit(node); }
private BoundExpression BindNameExpression(NameExpressionSyntax node) { if (node.Name.IsMissing) { // If this token was inserted by the parser, there is no point in // trying to resolve this guy. return(new BoundErrorExpression()); } var name = node.Name; var symbols = LookupColumnTableOrVariable(name).ToImmutableArray(); if (symbols.Length == 0) { var isInvocable = LookupSymbols <FunctionSymbol>(name).Any() || LookupSymbols <AggregateSymbol>(name).Any(); if (isInvocable) { Diagnostics.ReportInvocationRequiresParenthesis(name); } else { Diagnostics.ReportColumnTableOrVariableNotDeclared(name); } return(new BoundErrorExpression()); } if (symbols.Length > 1) { Diagnostics.ReportAmbiguousName(name, symbols); } var symbol = symbols.First(); switch (symbol.Kind) { case SymbolKind.TableColumnInstance: return(new BoundColumnExpression((ColumnInstanceSymbol)symbol)); case SymbolKind.Variable: return(new BoundVariableExpression((VariableSymbol)symbol)); case SymbolKind.TableInstance: { // If symbol refers to a table, we need to make sure that it's either not a derived table/CTE // or we are used in column access context (i.e. our parent is a a property access). // // For example, the following query is invalid // // SELECT D -- ERROR // FROM ( // SELECT * // FROM Employees e // ) AS D // // You cannot obtain a value for D itself. var tableInstance = symbol as TableInstanceSymbol; if (tableInstance != null) { // TODO: Fully support row access //var isColumnAccess = node.Parent is PropertyAccessExpressionSyntax; //var hasNoType = tableInstance.Table.Type.IsMissing(); //if (!isColumnAccess && hasNoType) // Diagnostics.ReportInvalidRowReference(name); var isColumnAccess = node.Parent is PropertyAccessExpressionSyntax; if (!isColumnAccess) { Diagnostics.ReportInvalidRowReference(name); return(new BoundErrorExpression()); } } return(new BoundTableExpression(tableInstance)); } default: throw ExceptionBuilder.UnexpectedValue(symbol.Kind); } }
public virtual TResult VisitNameExpression(NameExpressionSyntax node) { return(DefaultVisit(node)); }
public QualifyColumnCodeAction(NameExpressionSyntax node, TableColumnInstanceSymbol symbol) : base(node.SyntaxTree) { _node = node; _symbol = symbol; }
private void ClassifyNameExpression(NameExpressionSyntax node) { ClassifyExpression(node, node.Name); }