mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-08 14:54:47 +08:00
simple debugging improvement - make it more readable by giving it an indent
This commit is contained in:
@@ -27,8 +27,20 @@ ignored_modules = ['jedi.evaluate.builtin', 'jedi.parser']
|
||||
|
||||
|
||||
def reset_time():
|
||||
global start_time
|
||||
global start_time, debug_indent
|
||||
start_time = time.time()
|
||||
debug_indent = -1
|
||||
|
||||
|
||||
def increase_indent(func):
|
||||
"""Decorator for makin """
|
||||
def wrapper(*args, **kwargs):
|
||||
global debug_indent
|
||||
debug_indent += 1
|
||||
result = func(*args, **kwargs)
|
||||
debug_indent -= 1
|
||||
return result
|
||||
return wrapper
|
||||
|
||||
|
||||
def dbg(*args):
|
||||
@@ -37,18 +49,21 @@ def dbg(*args):
|
||||
frm = inspect.stack()[1]
|
||||
mod = inspect.getmodule(frm[0])
|
||||
if not (mod.__name__ in ignored_modules):
|
||||
debug_function(NOTICE, 'dbg: ' + ', '.join(u(a) for a in args))
|
||||
i = ' ' * debug_indent
|
||||
debug_function(NOTICE, i + 'dbg: ' + ', '.join(u(a) for a in args))
|
||||
|
||||
|
||||
def warning(*args):
|
||||
if debug_function and enable_warning:
|
||||
debug_function(WARNING, 'warning: ' + ', '.join(u(a) for a in args))
|
||||
i = ' ' * debug_indent
|
||||
debug_function(WARNING, i + 'warning: ' + ', '.join(u(a) for a in args))
|
||||
|
||||
|
||||
def speed(name):
|
||||
if debug_function and enable_speed:
|
||||
now = time.time()
|
||||
debug_function(SPEED, 'speed: ' + '%s %s' % (name, now - start_time))
|
||||
i = ' ' * debug_indent
|
||||
debug_function(SPEED, i + 'speed: ' + '%s %s' % (name, now - start_time))
|
||||
|
||||
|
||||
def print_to_stdout(level, str_out):
|
||||
|
||||
@@ -193,6 +193,7 @@ class Evaluator(object):
|
||||
|
||||
@memoize_default(default=(), evaluator_is_first_arg=True)
|
||||
@recursion.recursion_decorator
|
||||
@debug.increase_indent
|
||||
def eval_statement(self, stmt, seek_name=None):
|
||||
"""
|
||||
The starting point of the completion. A statement always owns a call
|
||||
@@ -377,6 +378,7 @@ class Evaluator(object):
|
||||
result = imports.strip_imports(self, types)
|
||||
return self.follow_path(path, set(result), scope, position=position)
|
||||
|
||||
@debug.increase_indent
|
||||
def execute(self, obj, params=(), evaluate_generator=False):
|
||||
if obj.isinstance(er.Function):
|
||||
obj = obj.get_decorated_func()
|
||||
|
||||
Reference in New Issue
Block a user