Пример #1
0
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