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)
def LodBuiltInData(self,interpreter): if interpreter.IsV2(): builtin_data_path = os.path.join(self.__builtin_data_location,"2") else: builtin_data_path = os.path.join(self.__builtin_data_location,"3") app_debugLogger.debug('builtin data path:%s',builtin_data_path) if not os.path.exists(builtin_data_path): return self.LoadIntellisenceDirData(builtin_data_path)
def parse_project(self, doc): assert (doc != None) project = doc.GetModel() interpreter_path = project.Interpreter.Path interpreter = interpretermanager.InterpreterManager( ).GetInterpreterByPath(interpreter_path) if interpreter is None: return project_location = os.path.dirname(doc.GetFilename()) path_list = [project_location] metadata_path = os.path.join(project_location, ".metadata") intellisence_data_path = os.path.join(metadata_path, str(interpreter.Id)) self.last_update_time = self.get_last_update(intellisence_data_path) if not os.path.exists(intellisence_data_path): parserutils.MakeDirs(intellisence_data_path) #hidden intellisence data path on windows and linux if sysutilslib.isWindows(): import win32api import win32con win32api.SetFileAttributes(metadata_path, win32con.FILE_ATTRIBUTE_HIDDEN) update_file_count = 0 for filepath in project.filePaths: if self._stop: break file_dir = os.path.dirname(filepath) is_package_dir = fileparser.is_package_dir(file_dir) if is_package_dir or parserutils.PathsContainPath( path_list, file_dir): ext = strutils.GetFileExt(filepath) if ext in ['py', 'pyw']: mk_time = os.path.getmtime(filepath) relative_module_name, is_package = parserutils.get_relative_name( filepath, path_list) if mk_time > self.last_update_time or not os.path.exists( os.path.join(intellisence_data_path, relative_module_name + ".$members")): app_debugLogger.debug('update file %s ,relative module name is %s',\ filepath,parserutils.get_relative_name(filepath,path_list)[0]) fileparser.dump(filepath, relative_module_name, intellisence_data_path, is_package) update_file_count += 1 else: app_debugLogger.debug('%s is not valid parse dir', file_dir) app_debugLogger.debug('total update %d files', update_file_count) if update_file_count > 0: self.update_last_time(intellisence_data_path)
def GetBuiltinModuleMembers(self): app_debugLogger.debug('get builtin module name is:%s',self.GetBuiltinModule().Name) return self.GetModuleMembers(self.GetBuiltinModule().Name,"")
def LoadBuiltinModule(self,interpreter): app_debugLogger.debug('current interpreter builtin module name is:%s',interpreter.BuiltinModuleName) builtin_module_loader = self._manager.GetModule(interpreter.BuiltinModuleName) data = builtin_module_loader.LoadMembers() self._builtin_module = BuiltinModule.BuiltinModule(builtin_module_loader.Name) self._builtin_module.load(data)