183 |
183 |
184 ################################# |
184 ################################# |
185 ## auto-completion methods below |
185 ## auto-completion methods below |
186 ################################# |
186 ################################# |
187 |
187 |
188 def __completionListSelected(self, id, txt): |
188 def __completionListSelected(self, userListId, txt): |
189 """ |
189 """ |
190 Private slot to handle the selection from the completion list. |
190 Private slot to handle the selection from the completion list. |
191 |
191 |
192 @param id the ID of the user list (should be 1) (integer) |
192 @param userListId the ID of the user list (should be 1) (integer) |
193 @param txt the selected text (string) |
193 @param txt the selected text (string) |
194 """ |
194 """ |
195 from QScintilla.Editor import EditorAutoCompletionListID |
195 from QScintilla.Editor import EditorAutoCompletionListID |
196 |
196 |
197 editor = self.sender() |
197 editor = self.sender() |
198 if id == EditorAutoCompletionListID: |
198 if userListId == EditorAutoCompletionListID: |
199 lst = txt.split() |
199 lst = txt.split() |
200 if len(lst) > 1: |
200 if len(lst) > 1: |
201 txt = lst[0] |
201 txt = lst[0] |
202 self.__lastFullContext = lst[1][1:].split(")")[0] |
202 self.__lastFullContext = lst[1][1:].split(")")[0] |
203 else: |
203 else: |
217 elif wLeft: |
217 elif wLeft: |
218 txt = txt[len(wLeft):] |
218 txt = txt[len(wLeft):] |
219 editor.insert(txt) |
219 editor.insert(txt) |
220 editor.setCursorPosition(line, col + len(txt)) |
220 editor.setCursorPosition(line, col + len(txt)) |
221 |
221 |
222 def __recordSelectedContext(self, id, txt): |
222 def __recordSelectedContext(self, userListId, txt): |
223 """ |
223 """ |
224 Private slot to handle the selection from the completion list to |
224 Private slot to handle the selection from the completion list to |
225 record the selected completion context. |
225 record the selected completion context. |
226 |
226 |
227 @param id the ID of the user list (should be 1) (integer) |
227 @param userListId the ID of the user list (should be 1) (integer) |
228 @param txt the selected text (string) |
228 @param txt the selected text (string) |
229 """ |
229 """ |
230 from QScintilla.Editor import EditorAutoCompletionListID |
230 from QScintilla.Editor import EditorAutoCompletionListID |
231 |
231 |
232 if id == EditorAutoCompletionListID: |
232 if userListId == EditorAutoCompletionListID: |
233 lst = txt.split() |
233 lst = txt.split() |
234 if len(lst) > 1: |
234 if len(lst) > 1: |
235 self.__lastFullContext = lst[1][1:].split(")")[0] |
235 self.__lastFullContext = lst[1][1:].split(")")[0] |
236 else: |
236 else: |
237 self.__lastFullContext = None |
237 self.__lastFullContext = None |
488 line, col = editor.getCursorPosition() |
488 line, col = editor.getCursorPosition() |
489 for cl in module.classes.values(): |
489 for cl in module.classes.values(): |
490 if line >= cl.lineno and \ |
490 if line >= cl.lineno and \ |
491 (cl.endlineno == -1 or line <= cl.endlineno): |
491 (cl.endlineno == -1 or line <= cl.endlineno): |
492 completions = [] |
492 completions = [] |
493 for super in cl.super: |
493 for superClass in cl.super: |
494 if prefix == word: |
494 if prefix == word: |
495 completions.extend( |
495 completions.extend( |
496 api.getCompletions( |
496 api.getCompletions( |
497 context=super, |
497 context=superClass, |
498 followHierarchy=self.__plugin |
498 followHierarchy=self.__plugin |
499 .getPreferences( |
499 .getPreferences( |
500 "AutoCompletionFollowHierarchy" |
500 "AutoCompletionFollowHierarchy" |
501 ) |
501 ) |
502 ) |
502 ) |
503 ) |
503 ) |
504 else: |
504 else: |
505 completions.extend( |
505 completions.extend( |
506 api.getCompletions( |
506 api.getCompletions( |
507 start=word, context=super, |
507 start=word, context=superClass, |
508 followHierarchy=self.__plugin |
508 followHierarchy=self.__plugin |
509 .getPreferences( |
509 .getPreferences( |
510 "AutoCompletionFollowHierarchy" |
510 "AutoCompletionFollowHierarchy" |
511 ) |
511 ) |
512 ) |
512 ) |
878 if prefix and module and prefix == "self": |
878 if prefix and module and prefix == "self": |
879 line, col = editor.getCursorPosition() |
879 line, col = editor.getCursorPosition() |
880 for cl in module.classes.values(): |
880 for cl in module.classes.values(): |
881 if line >= cl.lineno and \ |
881 if line >= cl.lineno and \ |
882 (cl.endlineno == -1 or line <= cl.endlineno): |
882 (cl.endlineno == -1 or line <= cl.endlineno): |
883 for super in cl.super: |
883 for superClass in cl.super: |
884 calltips.extend(api.getCalltips( |
884 calltips.extend(api.getCalltips( |
885 word, commas, super, None, |
885 word, commas, superClass, None, |
886 self.__plugin.getPreferences( |
886 self.__plugin.getPreferences( |
887 "CallTipsContextShown"), |
887 "CallTipsContextShown"), |
888 followHierarchy=self.__plugin.getPreferences( |
888 followHierarchy=self.__plugin.getPreferences( |
889 "CallTipsFollowHierarchy"))) |
889 "CallTipsFollowHierarchy"))) |
890 break |
890 break |