예제 #1
0
파일: helpers.py 프로젝트: kavinvin/jedi
def evaluate_goto_definition(evaluator, context, leaf, prefer_stubs=False):
    if leaf.type == 'name':
        # In case of a name we can just use goto_definition which does all the
        # magic itself.
        if prefer_stubs:
            return evaluator.goto_stub_definitions(context, leaf)
        else:
            return evaluator.goto_definitions(context, leaf)

    parent = leaf.parent
    definitions = NO_CONTEXTS
    if parent.type == 'atom':
        definitions = context.eval_node(leaf.parent)
    elif parent.type == 'trailer':
        definitions = evaluate_call_of_leaf(context, leaf)
    elif isinstance(leaf, tree.Literal):
        return eval_atom(context, leaf)
    elif leaf.type in ('fstring_string', 'fstring_start', 'fstring_end'):
        return get_string_context_set(evaluator)
    if prefer_stubs:
        return definitions
    from jedi.evaluate.gradual.conversion import try_stubs_to_actual_context_set
    return try_stubs_to_actual_context_set(
        definitions,
        prefer_stub_to_compiled=True,
    )
예제 #2
0
def evaluate_goto_definition(evaluator, context, leaf):
    if leaf.type == 'name':
        # In case of a name we can just use goto_definition which does all the
        # magic itself.
        return evaluator.goto_definitions(context, leaf)

    parent = leaf.parent
    if parent.type == 'atom':
        return context.eval_node(leaf.parent)
    elif parent.type == 'trailer':
        return evaluate_call_of_leaf(context, leaf)
    elif isinstance(leaf, tree.Literal):
        return eval_atom(context, leaf)
    return []
예제 #3
0
def evaluate_goto_definition(evaluator, context, leaf):
    if leaf.type == 'name':
        # In case of a name we can just use goto_definition which does all the
        # magic itself.
        return evaluator.goto_definitions(context, leaf)

    parent = leaf.parent
    if parent.type == 'atom':
        return context.eval_node(leaf.parent)
    elif parent.type == 'trailer':
        return evaluate_call_of_leaf(context, leaf)
    elif isinstance(leaf, tree.Literal):
        return eval_atom(context, leaf)
    return []
예제 #4
0
def evaluate_goto_definition(evaluator, context, leaf):
    if leaf.type == 'name':
        # In case of a name we can just use goto_definition which does all the
        # magic itself.
        return evaluator.goto_definitions(context, leaf)

    parent = leaf.parent
    definitions = NO_CONTEXTS
    if parent.type == 'atom':
        definitions = context.eval_node(leaf.parent)
    elif parent.type == 'trailer':
        definitions = evaluate_call_of_leaf(context, leaf)
    elif isinstance(leaf, tree.Literal):
        return eval_atom(context, leaf)
    elif leaf.type in ('fstring_string', 'fstring_start', 'fstring_end'):
        return get_string_context_set(evaluator)
    return definitions