Ejemplo n.º 1
0
 def GotoDefinition(self):
     line = self.GetCurrentLine()
     pos = self.GetCurrentPos()
     text = self.GetTypeWord(pos)
     open_new_doc = False
     module_scope = Service.Service.GetActiveView().ModuleScope
     if module_scope is None:
         scope_found = None
     else:
         scope = module_scope.FindScope(line)
         scope_found = scope.FindDefinitionMember(text)
     if scope_found is None:
         wx.MessageBox(_("Cannot find definition") + "\"" + text + "\"",_("Goto Definition"),wx.OK|wx.ICON_EXCLAMATION,wx.GetApp().GetTopWindow())
     else:
         if scope_found.Parent is None:
             wx.GetApp().GotoView(scope_found.Module.Path,0)
         else:
             open_new_doc = (scope_found.Root != scope.Root)
             if not open_new_doc:
                 doc_view = wx.GetApp().GetDocumentManager().GetCurrentView()
                 startPos = doc_view.PositionFromLine(scope_found.Node.Line)
                 doc_view.GotoPos(startPos + scope_found.Node.Col)
             else:
                 if -1 == scope_found.Node.Line:
                     wx.MessageBox(_("Cannot go to definition") + "\"" + text + "\"",_("Goto Definition"),wx.OK|wx.ICON_EXCLAMATION,wx.GetApp().GetTopWindow())
                     return
                 wx.GetApp().GotoViewPos(scope_found.Root.Module.Path,scope_found.Node.Line,scope_found.Node.Col)
Ejemplo n.º 2
0
 def OnDwellStart(self, evt):
     mpoint = wx.GetMousePosition()
     brect = self.GetScreenRect()
     #avoid trigger tool many times
     if not brect.Contains(mpoint) or \
        not self.IsShown() or \
        not wx.GetApp().GetTopWindow().IsActive():
         return
     position = evt.Position
     if position >= 0 and self.IsCaretLocateInWord(position):
         line = self.LineFromPosition(position) + 1
         dwellword = self.GetTypeWord(position)
         doc_view = Service.Service.GetActiveView()
         if doc_view.GetLangLexer() == parserconfig.LANG_PYTHON_LEXER:
             module_scope = doc_view.ModuleScope
             if module_scope is None:
                 scope_found = None
             else:
                 scope = module_scope.FindScope(line)
                 scope_found = scope.FindDefinitionMember(dwellword)
             if scope_found is not None:
                 doc = scope_found.GetDoc()
                 if doc is not None:
                     self.CallTipShow(position, doc.decode('utf-8'))
         else:
             app_debugLogger.debug('active view is not python code view')
     
     CodeEditor.CodeCtrl.OnDwellStart(self,evt)
Ejemplo n.º 3
0
 def GetArgTip(self,pos):
     text = self.GetTypeWord(pos)
     line = self.LineFromPosition(pos)
     module_scope = wx.GetApp().GetDocumentManager().GetCurrentView().ModuleScope
     if module_scope is None:
         return
     scope = module_scope.FindScope(line+1)
     scope_found = scope.FindDefinitionMember(text)
     tip = ''
     if None != scope_found:
         if scope_found.Parent is not None and isinstance(scope_found.Node,nodeast.ImportNode):
             tip = scope_found.GetImportMemberArgTip(text)
         else:
             tip = scope_found.GetArgTip()
     if tip == '':
         return
     self.CallTipShow(pos,tip)