public override void VisitFunctionCallExpression(FunctionCallExpressionSyntaxNode node) { if (!(_insideFunction || _insideMethod)) { return; } var name = node.FunctionName.Text; if (_variableAssignments.Find(name) != null) { return; } Console.Write($"Function call: {name}..."); if (_context.FindFunction(name) || _methodAssignments.Find(name) != null) { Console.WriteLine("found."); } else if (_context.FindClass(name)) { Console.WriteLine("found class constructor."); } else { Console.WriteLine("NOT FOUND."); } base.VisitFunctionCallExpression(node); }
private bool IsDefined(SyntaxNode node) { Variable assignment; switch (node.Kind) { case TokenKind.IdentifierNameExpression: assignment = _variableAssignments.Find(node.Text); if (assignment != null || node.Text == "end") { return(true); } break; case TokenKind.FunctionCallExpression: var functionCall = (FunctionCallExpressionSyntaxNode)node; return ((IsDefined(functionCall.FunctionName) && IsDefined(functionCall.Nodes)) || (IsDefinedFunctionName(functionCall.FunctionName) && IsDefined(functionCall.Nodes))); case TokenKind.CellArrayElementAccessExpression: var cellArrayElementAccess = (CellArrayElementAccessExpressionSyntaxNode)node; return(IsDefined(cellArrayElementAccess.Expression) && IsDefined(cellArrayElementAccess.Nodes)); case TokenKind.List: var list = (SyntaxNodeOrTokenList)node; return(list.All(x => x.IsNode ? IsDefined(x.AsNode()) : IsDefinedToken(x.AsToken()))); case TokenKind.NumberLiteralExpression: return(true); case TokenKind.StringLiteralExpression: return(true); case TokenKind.BinaryOperationExpression: var binaryOperation = (BinaryOperationExpressionSyntaxNode)node; return(IsDefined(binaryOperation.Lhs) && IsDefined(binaryOperation.Rhs)); case TokenKind.UnaryPrefixOperationExpression: var unaryOperation = (UnaryPrefixOperationExpressionSyntaxNode)node; return(IsDefined(unaryOperation.Operand)); case TokenKind.ArrayLiteralExpression: var arrayLiteral = (ArrayLiteralExpressionSyntaxNode)node; return(arrayLiteral.Nodes == null || IsDefined(arrayLiteral.Nodes)); default: break; } return(false); }