[Eric] Can't find definition using Rope
Ali Gholami Rudi
aliqrudi at gmail.com
Mon Apr 20 14:54:47 BST 2009
Hi,
OldGrantonian <oldgrantonian at googlemail.com> wrote:
> I had very brief experience of Eric a couple of years ago. I now want to use
> it again.
Part of the explanation is the same as the last time.
> I want to use Rope to find the definition of insertItem in the following
> line:
>
> main_widget.helpMenu.insertItem("Hello world",self.hi,0,666)
>
> I highlight "insertItem" and click Refactoring > Query > Find Definition
>
> I get the message: "No matching definition found"
Rope does not guess the definition location of a name because of name
similarity:
class C(object):
def c_method(self):
pass
def f(c)
c.c_method()
Here you might argue calling goto definition on the c_method occurrence
inside f() should find C.c_method(). But rope won't do that; the
c_method inside f might be unrelated to C.c_method(). Although for this
case adding a call like:
f(C())
solves this problem using rope static object analysis, that does not
always work. The main problem is, not all things can be inferred from
the code easily. But rope employs mechanisms that handle common cases
(simple object inference and static object analysis).
In your example, rope should first infer the object main_widget holds
and then its helpMenu attribute and finally its insertItem. When rope
cannot find the location of insertItem, it has failed to follow this
chain (maybe some dynamic or uncommon case).
By the way, if you merely want to find the location of methods and
classes based on their name, you can use the old but effective tags
mechanism.
Regards,
Ali
More information about the Eric
mailing list