1878 """ and redo history?""")) |
1878 """ and redo history?""")) |
1879 if res: |
1879 if res: |
1880 self.__project.history.clear() |
1880 self.__project.history.clear() |
1881 |
1881 |
1882 ##################################################### |
1882 ##################################################### |
1883 ## Find actions |
1883 ## Find actions including mouse click handler |
1884 ##################################################### |
1884 ##################################################### |
1885 |
1885 |
1886 def __queryReferences(self): |
1886 def __queryReferences(self): |
1887 """ |
1887 """ |
1888 Private slot to handle the Find References action. |
1888 Private slot to handle the Find References action. |
1891 |
1891 |
1892 if aw is None: |
1892 if aw is None: |
1893 return |
1893 return |
1894 |
1894 |
1895 title = self.tr("Find Occurrences") |
1895 title = self.tr("Find Occurrences") |
1896 if not aw.hasSelectedText(): |
|
1897 # no selection available |
|
1898 E5MessageBox.warning( |
|
1899 self.__ui, title, |
|
1900 self.tr("Highlight the class, method, function or variable" |
|
1901 " to search for and try again.")) |
|
1902 return |
|
1903 |
1896 |
1904 if not self.confirmAllBuffersSaved(): |
1897 if not self.confirmAllBuffersSaved(): |
1905 return |
1898 return |
1906 |
1899 |
1907 filename = aw.getFileName() |
1900 filename = aw.getFileName() |
1908 line, index, line1, index1 = aw.getSelection() |
1901 line, index = aw.getCursorPosition() |
1909 offset = self.__getOffset(aw, line, index) |
1902 offset = self.__getOffset(aw, line, index) |
1910 |
1903 |
1911 import rope.contrib.findit |
1904 import rope.contrib.findit |
1912 from ProgressHandle import ProgressHandle |
1905 from ProgressHandle import ProgressHandle |
1913 resource = rope.base.libutils.path_to_resource( |
1906 resource = rope.base.libutils.path_to_resource( |
1944 |
1937 |
1945 if aw is None: |
1938 if aw is None: |
1946 return |
1939 return |
1947 |
1940 |
1948 title = self.tr("Find &Definition") |
1941 title = self.tr("Find &Definition") |
1949 if not aw.hasSelectedText(): |
|
1950 # no selection available |
|
1951 E5MessageBox.warning( |
|
1952 self.__ui, title, |
|
1953 self.tr("Highlight the class, method, function or" |
|
1954 " variable reference to search definition for and" |
|
1955 " try again.")) |
|
1956 return |
|
1957 |
1942 |
1958 if not self.confirmAllBuffersSaved(): |
1943 if not self.confirmAllBuffersSaved(): |
1959 return |
1944 return |
1960 |
1945 |
1961 filename = aw.getFileName() |
1946 filename = aw.getFileName() |
1962 line, index, line1, index1 = aw.getSelection() |
1947 line, index = aw.getCursorPosition() |
1963 offset = self.__getOffset(aw, line, index) |
1948 offset = self.__getOffset(aw, line, index) |
1964 |
1949 |
1965 import rope.contrib.findit |
1950 import rope.contrib.findit |
1966 resource = rope.base.libutils.path_to_resource( |
1951 resource = rope.base.libutils.path_to_resource( |
1967 self.__project, filename) |
1952 self.__project, filename) |
1980 else: |
1965 else: |
1981 E5MessageBox.warning( |
1966 E5MessageBox.warning( |
1982 self.__ui, title, |
1967 self.__ui, title, |
1983 self.tr("No matching definition found.")) |
1968 self.tr("No matching definition found.")) |
1984 |
1969 |
|
1970 def gotoDefinition(self): |
|
1971 """ |
|
1972 Public slot to find the definition for the word at the cursor position |
|
1973 and go to it. |
|
1974 |
|
1975 Note: This is executed upon a mouse click sequence. |
|
1976 """ |
|
1977 aw = e5App().getObject("ViewManager").activeWindow() |
|
1978 |
|
1979 if aw is None: |
|
1980 return |
|
1981 |
|
1982 filename = aw.getFileName() |
|
1983 line, index = aw.getCursorPosition() |
|
1984 offset = self.__getOffset(aw, line, index) |
|
1985 |
|
1986 import rope.contrib.findit |
|
1987 resource = rope.base.libutils.path_to_resource( |
|
1988 self.__project, filename) |
|
1989 try: |
|
1990 location = rope.contrib.findit.find_definition( |
|
1991 self.__project, aw.text(), offset, resource) |
|
1992 except Exception: |
|
1993 # simply ignore them |
|
1994 return |
|
1995 |
|
1996 if location is not None: |
|
1997 e5App().getObject("ViewManager").openSourceFile( |
|
1998 location.resource.real_path, location.lineno, next=True) |
|
1999 |
1985 def __queryImplementations(self): |
2000 def __queryImplementations(self): |
1986 """ |
2001 """ |
1987 Private slot to handle the Find Implementations action. |
2002 Private slot to handle the Find Implementations action. |
1988 """ |
2003 """ |
1989 aw = e5App().getObject("ViewManager").activeWindow() |
2004 aw = e5App().getObject("ViewManager").activeWindow() |
1990 |
2005 |
1991 if aw is None: |
2006 if aw is None: |
1992 return |
2007 return |
1993 |
2008 |
1994 title = self.tr("Find Implementations") |
2009 title = self.tr("Find Implementations") |
1995 if not aw.hasSelectedText(): |
|
1996 # no selection available |
|
1997 E5MessageBox.warning( |
|
1998 self.__ui, title, |
|
1999 self.tr("Highlight the method to search for" |
|
2000 " and try again.")) |
|
2001 return |
|
2002 |
2010 |
2003 if not self.confirmAllBuffersSaved(): |
2011 if not self.confirmAllBuffersSaved(): |
2004 return |
2012 return |
2005 |
2013 |
2006 filename = aw.getFileName() |
2014 filename = aw.getFileName() |
2007 line, index, line1, index1 = aw.getSelection() |
2015 line, index = aw.getCursorPosition() |
2008 offset = self.__getOffset(aw, line, index) |
2016 offset = self.__getOffset(aw, line, index) |
2009 |
2017 |
2010 import rope.contrib.findit |
2018 import rope.contrib.findit |
2011 from ProgressHandle import ProgressHandle |
2019 from ProgressHandle import ProgressHandle |
2012 resource = rope.base.libutils.path_to_resource( |
2020 resource = rope.base.libutils.path_to_resource( |