def __call__(self, buffer, cursor, showCandidates): failure = (False, buffer, cursor) if not buffer or cursor == 0: return failure before = buffer[:cursor] after = buffer[cursor:] if re_command.match(before): return self.__findCompletion(buffer, cursor, before, self.__debugger.getCommandNames(), showCandidates, True) runtime = self.__debugger.getCurrentRuntime() match = re_property.match(before) if runtime and match and self.__argumentIsScript(buffer): command = match.group(1) expression = match.group(3) identifier = match.group(4) inScope = True base = "" parens = [] if expression and expression.strip()[-1] == '.': expression = expression.strip()[:-1] inScope = False while expression: match = re_whitespace_at_end.match(expression) if match: base = match.group(2) + base expression = expression[:match.start(2)] if not expression: break match = re_identifier_at_end.match(expression) if match: base = match.group(2) + base expression = expression[:match.start(2)] continue ch = expression[-1] if ch in (')', ']'): parens.append({ ')': '(', ']': '[' }[ch]) base = ch + base expression = expression[:-1] continue if ch in ('(', '['): if not parens or parens[-1] != ch: break parens.pop(-1) base = ch + base expression = expression[:-1] continue if expression[-1] == '.': base = '.' + base expression = expression[:-1] continue if len(expression) >= 3 and expression[-3:] in operators3: if not parens: break base = expression[-3:] + base expression = expression[:-3] continue if len(expression) >= 2 and expression[-2:] in operators2: if not parens: break base = expression[-2:] + base expression = expression[:-2] continue if len(expression) >= 1 and expression[-1:] in operators1: if not parens: break base = expression[-1:] + base expression = expression[:-1] continue return failure if not parens: if inScope: object = None else: try: result = runtime.eval(base, True, True) except KeyboardInterrupt: return failure if result and result.isObject(): object = result.getValue() else: return failure examiner = Examiner(runtime, object, 0xffff, 0, False, False, [], inScope) try: examiner.update() except KeyboardInterrupt: return failure if inScope: scope = examiner.getScope() else: scope = [object] propertyNames = [] for object in scope: while object: propertyNames.extend([name for name, value in examiner.getObjectProperties(object)]) object = object.getPrototype() return self.__findCompletion(buffer, cursor, identifier, propertyNames, showCandidates, False) return failure
def __call__(self, buffer, cursor, showCandidates): failure = (False, buffer, cursor) if not buffer or cursor == 0: return failure before = buffer[:cursor] after = buffer[cursor:] if re_command.match(before): return self.__findCompletion(buffer, cursor, before, self.__debugger.getCommandNames(), showCandidates, True) runtime = self.__debugger.getCurrentRuntime() match = re_property.match(before) if runtime and match and self.__argumentIsScript(buffer): command = match.group(1) expression = match.group(3) identifier = match.group(4) inScope = True base = "" parens = [] if expression and expression.strip()[-1] == '.': expression = expression.strip()[:-1] inScope = False while expression: match = re_whitespace_at_end.match(expression) if match: base = match.group(2) + base expression = expression[:match.start(2)] if not expression: break match = re_identifier_at_end.match(expression) if match: base = match.group(2) + base expression = expression[:match.start(2)] continue ch = expression[-1] if ch in (')', ']'): parens.append({')': '(', ']': '['}[ch]) base = ch + base expression = expression[:-1] continue if ch in ('(', '['): if not parens or parens[-1] != ch: break parens.pop(-1) base = ch + base expression = expression[:-1] continue if expression[-1] == '.': base = '.' + base expression = expression[:-1] continue if len(expression) >= 3 and expression[-3:] in operators3: if not parens: break base = expression[-3:] + base expression = expression[:-3] continue if len(expression) >= 2 and expression[-2:] in operators2: if not parens: break base = expression[-2:] + base expression = expression[:-2] continue if len(expression) >= 1 and expression[-1:] in operators1: if not parens: break base = expression[-1:] + base expression = expression[:-1] continue return failure if not parens: if inScope: object = None else: try: result = runtime.eval(base, True, True) except KeyboardInterrupt: return failure if result and result.isObject(): object = result.getValue() else: return failure examiner = Examiner(runtime, object, 0xffff, 0, False, False, [], inScope) try: examiner.update() except KeyboardInterrupt: return failure if inScope: scope = examiner.getScope() else: scope = [object] propertyNames = [] for object in scope: while object: propertyNames.extend([ name for name, value in examiner.getObjectProperties(object) ]) object = object.getPrototype() return self.__findCompletion(buffer, cursor, identifier, propertyNames, showCandidates, False) return failure