public static void FindExpression(PythonAst ast, SourceLocation position, FindExpressionOptions options, out Node expression, out Node statement, out ScopeStatement scope) { expression = null; statement = null; scope = null; if (ast == null) { return; } var finder = new ExpressionFinder(ast, options); var index = ast.LocationToIndex(position); finder.Get(index, index, out expression, out statement, out scope); var col = position.Column; while (CanBackUp(ast, expression, statement, scope, col)) { col -= 1; index -= 1; finder.Get(index, index, out expression, out statement, out scope); } expression = expression ?? (statement as ExpressionStatement)?.Expression; }
public static Expression FindExpression(this PythonAst ast, SourceLocation location, FindExpressionOptions options) => new ExpressionFinder(ast, options).GetExpression(location) as Expression;
public static Expression FindExpression(this PythonAst ast, int index, FindExpressionOptions options) => new ExpressionFinder(ast, options).GetExpression(index) as Expression;