Why doesn't eclipse-python have a magic refactor?

Eclipse can use compiled bytecode to enable the magic refactor function β€” rename methods, track the class hierarchy up and down, and track through method calls.

What are the technical barriers that make it difficult to work with languages ​​like Python and Javascript?

+4
source share
2 answers

therefore, it turns out that tracing static information, such as methods and class hierarchies, is entirely possible in python. This is done by the eclipse PyDev plugin. The PyLint plugin tries to do static analysis even on things like dynamic variables, assuming nothing happens at run time, and does a pretty good job.

+1
source

Due to dynamic binding. Python is a dynamic language in such a way that you can do almost everything with your variables. You can even access globals-dict and introduce new variables consisting of runtime values.

Thus, the IDE cannot be sure which variables exist when. See this example:

#silly.py import sys if len(sys.argv) > 1: thisNowExists = True #1 try: if thisNowExists: print("this existed before") except NameError: print("this _now_ exists") thisNowExists = True 

No person or IDE can know if thisNowExists defined in position #1 , so if you want to rename the stupidly named thisNowExists below this point, it is undefined if we need to rename the appearance before #1 too.

You will need to conduct an extended control flow analysis to understand well that thisNowExists is defined below with a try / catch statement, but due to the dynamic loading of the script ( thisNowExists = 1; import silly ) and sorting it might even exist before import sys with no arguments.

Naming your variables in different ways, and finding / replacing is your best bet;)

+6
source

Source: https://habr.com/ru/post/1339704/


All Articles