-
Notifications
You must be signed in to change notification settings - Fork 0
Parsing Python function arguments and type hints
Raffi Khatchadourian edited this page Nov 7, 2022
·
3 revisions
Removed from https://github.com/ponder-lab/Hybridize-Functions-Refactoring/commit/7704cdb19331ed0634382b4e346c210543ad899c.
import org.python.pydev.parser.jython.ast.argumentsType;
import org.python.pydev.parser.jython.ast.exprType;
private static Set<FunctionDef> process(PythonNode pythonNode) throws ExecutionException {
ParsedItem entry = pythonNode.entry;
ASTEntryWithChildren ast = entry.getAstThis();
SimpleNode simpleNode = ast.node;
if (simpleNode instanceof FunctionDef) {
FunctionDef function = (FunctionDef) simpleNode;
argumentsType args = function.args;
exprType[] annotation = args.annotation;
if (annotation != null)
for (exprType annot : annotation)
if (annot != null)
System.out.println(annot);
exprType[] args2 = args.args;
if (args2 != null)
for (exprType argType : args2)
System.out.println(argType);
}