RefactoringRope/Refactoring.py

changeset 133
6fb6ac582a39
parent 129
23ee57a96ea3
child 144
bfc6a3b38330
equal deleted inserted replaced
132:5384651b27c7 133:6fb6ac582a39
1965 else: 1965 else:
1966 E5MessageBox.warning( 1966 E5MessageBox.warning(
1967 self.__ui, title, 1967 self.__ui, title,
1968 self.tr("No matching definition found.")) 1968 self.tr("No matching definition found."))
1969 1969
1970 def gotoDefinition(self): 1970 def gotoDefinition(self, editor):
1971 """ 1971 """
1972 Public slot to find the definition for the word at the cursor position 1972 Public slot to find the definition for the word at the cursor position
1973 and go to it. 1973 and go to it.
1974 1974
1975 Note: This is executed upon a mouse click sequence. 1975 Note: This is executed upon a mouse click sequence.
1976 """ 1976
1977 aw = e5App().getObject("ViewManager").activeWindow() 1977 @param editor reference to the calling editor (Editor)
1978 1978 """
1979 if aw is None: 1979 filename = editor.getFileName()
1980 return 1980 line, index = editor.getCursorPosition()
1981 1981 offset = self.__getOffset(editor, line, index)
1982 filename = aw.getFileName()
1983 line, index = aw.getCursorPosition()
1984 offset = self.__getOffset(aw, line, index)
1985 1982
1986 import rope.contrib.findit 1983 import rope.contrib.findit
1987 resource = rope.base.libutils.path_to_resource( 1984 resource = rope.base.libutils.path_to_resource(
1988 self.__project, filename) 1985 self.__project, filename)
1989 try: 1986 try:
1990 location = rope.contrib.findit.find_definition( 1987 location = rope.contrib.findit.find_definition(
1991 self.__project, aw.text(), offset, resource) 1988 self.__project, editor.text(), offset, resource)
1992 except Exception: 1989 except Exception:
1993 # simply ignore them 1990 # simply ignore them
1994 return 1991 return
1995 1992
1996 if location is not None: 1993 if location is not None:
1997 e5App().getObject("ViewManager").openSourceFile( 1994 e5App().getObject("ViewManager").openSourceFile(
1998 location.resource.real_path, location.lineno, next=True) 1995 location.resource.real_path, location.lineno, next=True)
1996 else:
1997 e5App().getObject("UserInterface").statusBar().showMessage(
1998 self.tr('No definition found'), 5000)
1999 1999
2000 def __queryImplementations(self): 2000 def __queryImplementations(self):
2001 """ 2001 """
2002 Private slot to handle the Find Implementations action. 2002 Private slot to handle the Find Implementations action.
2003 """ 2003 """

eric ide

mercurial