We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
All the previous question ask to extract method + its body as a text.
I want to know given a .java source, how can I extract method declarations which means:
as a python list.
PS: I don't need method's body.
Can the same be done for fields in class as well?
Is it possible with javalang?
The text was updated successfully, but these errors were encountered:
Yes, it's possible, but you'll have to do some work yourself to make the list the way you want it.
tree.filter(javalang.tree.MethodDeclaration)
name
modifiers
parameters
return_type
This is an example of very simple method:
MethodDeclaration(annotations=[], body=[ReturnStatement(expression=This(postfix_operators=[], prefix_operators=[], qualifier=None, selectors=[MemberReference(member=msg, postfix_operators=None, prefix_operators=None, qualifier=None, selectors=None)]), label=None)], documentation=None, modifiers={'public'}, name=getMessage, parameters=[], return_type=ReferenceType(arguments=None, dimensions=[], name=String, sub_type=None), throws=None, type_parameters=None)
Sorry, something went wrong.
how can I get the body from this ? I tried the following code, but nothing works:
for path, node in tree.filter(javalang.tree.MethodDeclaration): print(node['body'])
for path, node in tree.filter(javalang.tree.MethodDeclaration): print(node[1])
EDIT: I am able to access it using node.body
node.body
No branches or pull requests
All the previous question ask to extract method + its body as a text.
I want to know given a .java source, how can I extract method declarations which means:
as a python list.
PS: I don't need method's body.
Can the same be done for fields in class as well?
Is it possible with javalang?
The text was updated successfully, but these errors were encountered: