I want to create a python script that, given a name of a JAVA function, searches it in a library and copies it to another file. Is there any way to look up JAVA functions (providing the name) without doing the search string-a-string?
I want to create a python script that, given a name of a JAVA function, searches it in a library and copies it to another file. Is there any way to look up JAVA functions (providing the name) without doing the search string-a-string?
String the string "wont cut it" - you'll have to create a minimalist parser - possibly even make a regular expression - that reads the file, find method declarations, start and end lines (for this , just count the balance of "{" and "}" - and cut out that portion of the text.
I would read the whole file and do a mixed loop: while taking a whole line (looking forward in the text to the next "{") to find class and method declarations, and a character-by-character loop, keeping status information to count how many keys ("{") were opened and how many were closed.
Within a class, on any line with zero open keys where you have a "(" and do not have a "=" sign you are in the declaration of a method - then you can use the split method even to have the method name.Depending on what else you need to do, you can try this approach by "java parsers" in Python - a quick search on Pypi returned this one: link - see his documentation and if he already does what you need.