325 api = self.__apisManager.getAPIs(ApisNameProject) |
325 api = self.__apisManager.getAPIs(ApisNameProject) |
326 projectCompletionList = self.__getApiCompletions( |
326 projectCompletionList = self.__getApiCompletions( |
327 api, word, context, prefix, mod, editor) |
327 api, word, context, prefix, mod, editor) |
328 |
328 |
329 if self.__plugin.getPreferences("AutoCompletionSource") & AcsDocument: |
329 if self.__plugin.getPreferences("AutoCompletionSource") & AcsDocument: |
330 docCompletionsList = self.getCompletionsFromDocument( |
330 docCompletionsList = self.__getDocumentCompletions( |
331 editor, word, context, sep, prefix, mod) |
331 editor, word, context, sep, prefix, mod) |
332 |
332 |
333 completionsList = list( |
333 completionsList = list( |
334 set(apiCompletionsList) |
334 set(apiCompletionsList) |
335 .union(set(docCompletionsList)) |
335 .union(set(docCompletionsList)) |
425 continue |
425 continue |
426 if entry not in completionsList: |
426 if entry not in completionsList: |
427 completionsList.append(entry) |
427 completionsList.append(entry) |
428 return completionsList |
428 return completionsList |
429 |
429 |
430 def getCompletionsFromDocument(self, editor, word, context, sep, prefix, module): |
430 def __getDocumentCompletions(self, editor, word, context, sep, prefix, module): |
431 """ |
431 """ |
432 Public method to determine autocompletion proposals from the document. |
432 Private method to determine autocompletion proposals from the document. |
433 |
433 |
434 @param editor reference to the editor object (QScintilla.Editor) |
434 @param editor reference to the editor object (QScintilla.Editor) |
435 @param word string to be completed (string) |
435 @param word string to be completed (string) |
436 @param context flag indicating to autocomplete a context (boolean) |
436 @param context flag indicating to autocomplete a context (boolean) |
437 @param sep separator string (string) |
437 @param sep separator string (string) |
462 iconID = Editor.MethodID |
462 iconID = Editor.MethodID |
463 if hasattr(method, "modifier"): |
463 if hasattr(method, "modifier"): |
464 if (prefix == "cls" and \ |
464 if (prefix == "cls" and \ |
465 method.modifier == method.Class) or \ |
465 method.modifier == method.Class) or \ |
466 prefix == "self": |
466 prefix == "self": |
467 comps.append((method.name, iconID)) |
467 comps.append((method.name, cl.name, iconID)) |
468 else: |
468 else: |
469 # eric 5.1 cannot differentiate method types |
469 # eric 5.1 cannot differentiate method types |
470 comps.append((method.name, iconID)) |
470 comps.append((method.name, cl.name, iconID)) |
471 if prefix != "cls": |
471 if prefix != "cls": |
472 for attribute in cl.attributes.values(): |
472 for attribute in cl.attributes.values(): |
473 # determine icon type |
473 # determine icon type |
474 if attribute.isPrivate(): |
474 if attribute.isPrivate(): |
475 iconID = Editor.AttributePrivateID |
475 iconID = Editor.AttributePrivateID |
476 elif attribute.isProtected(): |
476 elif attribute.isProtected(): |
477 iconID = Editor.AttributeProtectedID |
477 iconID = Editor.AttributeProtectedID |
478 else: |
478 else: |
479 iconID = Editor.AttributePrivateID |
479 iconID = Editor.AttributePrivateID |
480 comps.append((attribute.name, iconID)) |
480 comps.append((attribute.name, cl.name, iconID)) |
481 for attribute in cl.globals.values(): |
481 for attribute in cl.globals.values(): |
482 # determine icon type |
482 # determine icon type |
483 if attribute.isPrivate(): |
483 if attribute.isPrivate(): |
484 iconID = Editor.AttributePrivateID |
484 iconID = Editor.AttributePrivateID |
485 elif attribute.isProtected(): |
485 elif attribute.isProtected(): |
486 iconID = Editor.AttributeProtectedID |
486 iconID = Editor.AttributeProtectedID |
487 else: |
487 else: |
488 iconID = Editor.AttributePrivateID |
488 iconID = Editor.AttributePrivateID |
489 comps.append((attribute.name, iconID)) |
489 comps.append((attribute.name, cl.name, iconID)) |
490 |
490 |
491 if word != prefix: |
491 if word != prefix: |
492 completionsList.extend( |
492 completionsList.extend( |
493 ["{0}?{1}".format(c[0], c[1]) |
493 ["{0} ({1})?{2}".format(c[0], c[1], c[2]) |
494 for c in comps if c[0].startswith(word)]) |
494 for c in comps if c[0].startswith(word)]) |
495 else: |
495 else: |
496 completionsList.extend( |
496 completionsList.extend( |
497 ["{0}?{1}".format(c[0], c[1]) |
497 ["{0} ({1})?{2}".format(c[0], c[1], c[2]) |
498 for c in comps]) |
498 for c in comps]) |
499 break |
499 break |
500 else: |
500 else: |
501 # possibly completing a named class attribute or method |
501 # possibly completing a named class attribute or method |
502 if prefix in module.classes: |
502 if prefix in module.classes: |
515 iconID = Editor.MethodPrivateID |
515 iconID = Editor.MethodPrivateID |
516 elif method.isProtected(): |
516 elif method.isProtected(): |
517 iconID = Editor.MethodProtectedID |
517 iconID = Editor.MethodProtectedID |
518 else: |
518 else: |
519 iconID = Editor.MethodID |
519 iconID = Editor.MethodID |
520 comps.append((method.name, iconID)) |
520 comps.append((method.name, cl.name, iconID)) |
521 for attribute in cl.globals.values(): |
521 for attribute in cl.globals.values(): |
522 # determine icon type |
522 # determine icon type |
523 if attribute.isPrivate(): |
523 if attribute.isPrivate(): |
524 iconID = Editor.AttributePrivateID |
524 iconID = Editor.AttributePrivateID |
525 elif attribute.isProtected(): |
525 elif attribute.isProtected(): |
526 iconID = Editor.AttributeProtectedID |
526 iconID = Editor.AttributeProtectedID |
527 else: |
527 else: |
528 iconID = Editor.AttributePrivateID |
528 iconID = Editor.AttributePrivateID |
529 comps.append((attribute.name, iconID)) |
529 comps.append((attribute.name, cl.name, iconID)) |
530 |
530 |
531 if word != prefix: |
531 if word != prefix: |
532 completionsList.extend( |
532 completionsList.extend( |
533 ["{0}?{1}".format(c[0], c[1]) |
533 ["{0} ({1})?{2}".format(c[0], c[1], c[2]) |
534 for c in comps if c[0].startswith(word)]) |
534 for c in comps if c[0].startswith(word)]) |
535 else: |
535 else: |
536 completionsList.extend( |
536 completionsList.extend( |
537 ["{0}?{1}".format(c[0], c[1]) |
537 ["{0} ({1})?{2}".format(c[0], c[1], c[2]) |
538 for c in comps]) |
538 for c in comps]) |
539 |
539 |
540 if not prefixFound: |
540 if not prefixFound: |
541 currentPos = editor.currentPosition() |
541 currentPos = editor.currentPosition() |
542 if context: |
542 if context: |
647 api = self.__apisManager.getAPIs(ApisNameProject) |
647 api = self.__apisManager.getAPIs(ApisNameProject) |
648 projectCalltips = self.__getApiCalltips( |
648 projectCalltips = self.__getApiCalltips( |
649 api, word, commas, prefix, mod, editor) |
649 api, word, commas, prefix, mod, editor) |
650 |
650 |
651 if self.__plugin.getPreferences("AutoCompletionSource") & AcsDocument: |
651 if self.__plugin.getPreferences("AutoCompletionSource") & AcsDocument: |
652 documentCalltips = self.__getCalltipsFromDocument( |
652 documentCalltips = self.__getDocumentCalltips( |
653 word, prefix, mod, editor) |
653 word, prefix, mod, editor) |
654 |
654 |
655 return sorted( |
655 return sorted( |
656 set(apiCalltips) |
656 set(apiCalltips) |
657 .union(set(projectCalltips)) |
657 .union(set(projectCalltips)) |
685 self.__lastFullContext, |
685 self.__lastFullContext, |
686 self.__plugin.getPreferences("CallTipsContextShown")) |
686 self.__plugin.getPreferences("CallTipsContextShown")) |
687 |
687 |
688 return calltips |
688 return calltips |
689 |
689 |
690 def __getCalltipsFromDocument(self, word, prefix, module, editor): |
690 def __getDocumentCalltips(self, word, prefix, module, editor): |
691 """ |
691 """ |
692 Private method to determine calltips from the document. |
692 Private method to determine calltips from the document. |
693 |
693 |
694 @param word function to get calltips for (string) |
694 @param word function to get calltips for (string) |
695 @param prefix prefix of the word to be completed (string) |
695 @param prefix prefix of the word to be completed (string) |