diff -r b447f89da620 -r 67197c1f11eb AssistantEric/Assistant.py --- a/AssistantEric/Assistant.py Sun Oct 13 18:32:15 2013 +0200 +++ b/AssistantEric/Assistant.py Thu Oct 24 19:04:41 2013 +0200 @@ -155,7 +155,8 @@ in the current line. @param pos position to get character at (integer) - @param editor reference to the editor object to work with (QScintilla.Editor) + @param editor reference to the editor object to work with + (QScintilla.Editor) @return requested character or "", if there are no more (string) and the next position (i.e. pos - 1) """ @@ -260,7 +261,7 @@ depth = 0 while col > 0 and \ - not pat.match(text[col - 1]): + not pat.match(text[col - 1]): ch = text[col - 1] if ch == ')': depth = 1 @@ -344,16 +345,18 @@ word = "" if word or importCompletion: - completionsList = self.__getCompletions(word, context, prefix, language, - mod, editor, importCompletion, sep) + completionsList = self.__getCompletions( + word, context, prefix, language, mod, editor, + importCompletion, sep) if len(completionsList) == 0 and prefix: # searching with prefix didn't return anything, try without - completionsList = self.__getCompletions(word, context, "", language, - mod, editor, importCompletion, - sep) + completionsList = self.__getCompletions( + word, context, "", language, mod, editor, importCompletion, + sep) if len(completionsList) > 0: completionsList.sort() - editor.showUserList(EditorAutoCompletionListID, completionsList) + editor.showUserList(EditorAutoCompletionListID, + completionsList) def __getCompletions(self, word, context, prefix, language, module, editor, importCompletion, sep): @@ -384,8 +387,8 @@ projectCompletionList = self.__getApiCompletions( api, word, context, prefix, module, editor) - if self.__plugin.getPreferences("AutoCompletionSource") & AcsDocument and \ - not importCompletion: + if self.__plugin.getPreferences("AutoCompletionSource") & AcsDocument \ + and not importCompletion: docCompletionsList = self.__getDocumentCompletions( editor, word, context, sep, prefix, module) @@ -393,7 +396,7 @@ set(apiCompletionsList) .union(set(docCompletionsList)) .union(set(projectCompletionList)) - ) + ) return completionsList def __getApiCompletions(self, api, word, context, prefix, module, editor): @@ -419,14 +422,24 @@ for super in cl.super: if prefix == word: completions.extend( - api.getCompletions(context=super, - followHierarchy=self.__plugin.getPreferences( - "AutoCompletionFollowHierarchy"))) + api.getCompletions( + context=super, + followHierarchy= + self.__plugin.getPreferences( + "AutoCompletionFollowHierarchy" + ) + ) + ) else: completions.extend( - api.getCompletions(start=word, context=super, - followHierarchy=self.__plugin.getPreferences( - "AutoCompletionFollowHierarchy"))) + api.getCompletions( + start=word, context=super, + followHierarchy= + self.__plugin.getPreferences( + "AutoCompletionFollowHierarchy" + ) + ) + ) for completion in completions: if not completion["context"]: entry = completion["completion"] @@ -441,7 +454,8 @@ entry += "?{0}".format(completion["pictureId"]) else: cont = False - re = QRegExp(QRegExp.escape(entry) + "\?\d{,2}") + re = QRegExp( + QRegExp.escape(entry) + "\?\d{,2}") for comp in completionsList: if re.exactMatch(comp): cont = True @@ -462,7 +476,8 @@ completionsList.append(entry) else: if prefix: - completions = api.getCompletions(start=word, context=prefix) + completions = api.getCompletions( + start=word, context=prefix) if not prefix or not completions: # if no completions were returned try without prefix completions = api.getCompletions(start=word) @@ -491,8 +506,8 @@ completionsList.append(entry) return completionsList - def __getDocumentCompletions(self, editor, word, context, sep, prefix, module, - doHierarchy=False): + def __getDocumentCompletions(self, editor, word, context, sep, prefix, + module, doHierarchy=False): """ Private method to determine autocompletion proposals from the document. @@ -529,10 +544,11 @@ else: iconID = Editor.MethodID if hasattr(method, "modifier"): - if (prefix == "cls" and \ + if (prefix == "cls" and method.modifier == method.Class) or \ prefix == "self": - comps.append((method.name, cl.name, iconID)) + comps.append((method.name, cl.name, + iconID)) else: # eric 5.1 cannot differentiate method types comps.append((method.name, cl.name, iconID)) @@ -571,9 +587,10 @@ nword = sup else: nword = word - completionsList.extend(self.__getDocumentCompletions( - editor, nword, context, sep, sup, module, - doHierarchy=True)) + completionsList.extend( + self.__getDocumentCompletions( + editor, nword, context, sep, sup, + module, doHierarchy=True)) break else: @@ -625,9 +642,10 @@ nword = sup else: nword = word - completionsList.extend(self.__getDocumentCompletions( - editor, nword, context, sep, sup, module, - doHierarchy=True)) + completionsList.extend( + self.__getDocumentCompletions( + editor, nword, context, sep, sup, module, + doHierarchy=True)) if not prefixFound: currentPos = editor.currentPosition() @@ -638,8 +656,8 @@ sword = word.encode("utf-8") else: sword = word - res = editor.findFirstTarget(sword, False, - editor.autoCompletionCaseSensitivity(), + res = editor.findFirstTarget( + sword, False, editor.autoCompletionCaseSensitivity(), False, begline=0, begindex=0, ws_=True) while res: start, length = editor.getFoundTarget() @@ -654,7 +672,8 @@ completion += curWord[len(completion):] if completion and completion not in completionsList: completionsList.append( - "{0}?{1}".format(completion, self.__fromDocumentID)) + "{0}?{1}".format( + completion, self.__fromDocumentID)) res = editor.findNextTarget() @@ -687,7 +706,8 @@ @param editor reference to the editor (QScintilla.Editor) @param pos position in the text for the calltip (integer) - @param commas minimum number of commas contained in the calltip (integer) + @param commas minimum number of commas contained in the calltip + (integer) @return list of possible calltips (list of strings) """ language = editor.getLanguage() @@ -699,7 +719,7 @@ pat = re.compile("\w{0}".format(re.escape(wc))) text = editor.text(line) while col > 0 and \ - not pat.match(text[col - 1]): + not pat.match(text[col - 1]): col -= 1 word = editor.getWordLeft(line, col) @@ -757,7 +777,8 @@ @param api reference to the API object to be used (APIsManager.DbAPIs) @param word function to get calltips for (string) - @param commas minimum number of commas contained in the calltip (integer) + @param commas minimum number of commas contained in the calltip + (integer) @param prefix prefix of the word to be completed (string) @param module reference to the scanned module info (Module) @param editor reference to the editor object (QScintilla.Editor) @@ -770,19 +791,22 @@ if line >= cl.lineno and \ (cl.endlineno == -1 or line <= cl.endlineno): for super in cl.super: - calltips.extend(api.getCalltips(word, commas, super, None, - self.__plugin.getPreferences("CallTipsContextShown"), + calltips.extend(api.getCalltips( + word, commas, super, None, + self.__plugin.getPreferences( + "CallTipsContextShown"), followHierarchy=self.__plugin.getPreferences( "CallTipsFollowHierarchy"))) break else: - calltips = api.getCalltips(word, commas, self.__lastContext, - self.__lastFullContext, + calltips = api.getCalltips( + word, commas, self.__lastContext, self.__lastFullContext, self.__plugin.getPreferences("CallTipsContextShown")) return calltips - def __getDocumentCalltips(self, word, prefix, module, editor, doHierarchy=False): + def __getDocumentCalltips(self, word, prefix, module, editor, + doHierarchy=False): """ Private method to determine calltips from the document. @@ -807,15 +831,18 @@ method = cl.methods[word] if hasattr(method, "modifier"): if prefix == "self" or \ - (prefix == "cls" and \ - method.modifier == method.Class): - calltips.append("{0}{1}{2}({3})".format( - cl.name, - sep, - word, - ', '.join(method.parameters[1:]))) + (prefix == "cls" and + method.modifier == method.Class): + calltips.append( + "{0}{1}{2}({3})".format( + cl.name, + sep, + word, + ', '.join(method.parameters[1:] + ))) else: - # eric 5.1 cannot differentiate method types + # eric 5.1 cannot differentiate method + # types calltips.append("{0}{1}{2}({3})".format( cl.name, sep, @@ -824,7 +851,8 @@ for sup in cl.super: calltips.extend(self.__getDocumentCalltips( - word, sup, module, editor, doHierarchy=True)) + word, sup, module, editor, + doHierarchy=True)) break else: @@ -833,9 +861,10 @@ if word in cl.methods: method = cl.methods[word] if doHierarchy or \ - (hasattr(method, "modifier") and \ - method.modifier == method.Class): - # only eric 5.2 and newer can differentiate method types + (hasattr(method, "modifier") and + method.modifier == method.Class): + # only eric 5.2 and newer can differentiate + # method types calltips.append("{0}{1}{2}({3})".format( cl.name, sep,