309 projectType = self.__getProjectType(editor) |
309 projectType = self.__getProjectType(editor) |
310 |
310 |
311 line, col = editor.getCursorPosition() |
311 line, col = editor.getCursorPosition() |
312 self.__completingContext = context |
312 self.__completingContext = context |
313 sep = "" |
313 sep = "" |
314 if context: |
314 if language and context: |
315 wc = re.sub("\w", "", editor.wordCharacters()) |
315 wc = re.sub("\w", "", editor.wordCharacters()) |
316 pat = re.compile("\w{0}".format(re.escape(wc))) |
316 pat = re.compile("\w{0}".format(re.escape(wc))) |
317 text = editor.text(line) |
317 text = editor.text(line) |
318 |
318 |
319 beg = text[:col] |
319 beg = text[:col] |
359 if context: |
359 if context: |
360 beg = beg[:col + 1] |
360 beg = beg[:col + 1] |
361 else: |
361 else: |
362 beg = editor.text(line)[:col] |
362 beg = editor.text(line)[:col] |
363 col = len(beg) |
363 col = len(beg) |
364 wsep = editor.getLexer().autoCompletionWordSeparators() |
364 if language: |
365 if wsep: |
365 wseps = editor.getLexer().autoCompletionWordSeparators() |
366 wsep.append(" ") |
366 else: |
367 if col > 0 and beg[col - 1] in wsep: |
367 wseps = [] |
|
368 if wseps: |
|
369 wseps.append(" ") |
|
370 if col > 0 and beg[col - 1] in wseps: |
368 col -= 1 |
371 col -= 1 |
369 else: |
372 else: |
370 while col > 0 and beg[col - 1] not in wsep: |
373 while col > 0 and beg[col - 1] not in wseps: |
371 col -= 1 |
374 col -= 1 |
372 if col > 0 and beg[col - 1] != " ": |
375 if col > 0 and beg[col - 1] != " ": |
373 col -= 1 |
376 col -= 1 |
374 prefix = editor.getWordLeft(line, col) |
377 prefix = editor.getWordLeft(line, col) |
375 if editor.isPy2File() or editor.isPy3File(): |
378 if editor.isPy2File() or editor.isPy3File(): |
397 tokens = text.split() |
400 tokens = text.split() |
398 if len(tokens) >= 3 and tokens[2] == "import": |
401 if len(tokens) >= 3 and tokens[2] == "import": |
399 importCompletion = True |
402 importCompletion = True |
400 prefix = tokens[1] |
403 prefix = tokens[1] |
401 col = len(prefix) - 1 |
404 col = len(prefix) - 1 |
402 wsep = editor.getLexer().autoCompletionWordSeparators() |
405 wseps = editor.getLexer().autoCompletionWordSeparators() |
403 while col >= 0 and prefix[col] not in wsep: |
406 while col >= 0 and prefix[col] not in wseps: |
404 col -= 1 |
407 col -= 1 |
405 if col >= 0: |
408 if col >= 0: |
406 prefix = prefix[col + 1:] |
409 prefix = prefix[col + 1:] |
407 if word == tokens[2]: |
410 if word == tokens[2]: |
408 word = "" |
411 word = "" |
806 |
809 |
807 prefix = "" |
810 prefix = "" |
808 mod = None |
811 mod = None |
809 beg = editor.text(line)[:col] |
812 beg = editor.text(line)[:col] |
810 col = len(beg) |
813 col = len(beg) |
811 wsep = editor.getLexer().autoCompletionWordSeparators() |
814 if language: |
812 if wsep: |
815 wseps = editor.getLexer().autoCompletionWordSeparators() |
813 if col > 0 and beg[col - 1] in wsep: |
816 else: |
|
817 wseps = [] |
|
818 if wseps: |
|
819 if col > 0 and beg[col - 1] in wseps: |
814 col -= 1 |
820 col -= 1 |
815 else: |
821 else: |
816 while col > 0 and beg[col - 1] not in wsep + [" ", "\t"]: |
822 while col > 0 and beg[col - 1] not in wseps + [" ", "\t"]: |
817 col -= 1 |
823 col -= 1 |
818 if col >= 0: |
824 if col >= 0: |
819 col -= 1 |
825 col -= 1 |
820 prefix = editor.getWordLeft(line, col) |
826 prefix = editor.getWordLeft(line, col) |
821 if editor.isPy2File() or editor.isPy3File(): |
827 if editor.isPy2File() or editor.isPy3File(): |
900 @param editor reference to the editor object (QScintilla.Editor) |
906 @param editor reference to the editor object (QScintilla.Editor) |
901 @keyparam doHierarchy flag indicating a hierarchical search (boolean) |
907 @keyparam doHierarchy flag indicating a hierarchical search (boolean) |
902 @return list of calltips (list of string) |
908 @return list of calltips (list of string) |
903 """ |
909 """ |
904 calltips = [] |
910 calltips = [] |
905 if module: |
911 if module and bool(editor.getLexer()): |
906 if prefix: |
912 if prefix: |
907 # prefix can be 'self', 'cls' or a class name |
913 # prefix can be 'self', 'cls' or a class name |
908 sep = editor.getLexer().autoCompletionWordSeparators()[0] |
914 sep = editor.getLexer().autoCompletionWordSeparators()[0] |
909 if prefix in ["self", "cls"]: |
915 if prefix in ["self", "cls"]: |
910 line, col = editor.getCursorPosition() |
916 line, col = editor.getCursorPosition() |