mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-08 23:04:48 +08:00
Cleaned up create_context for methods
Some improvements made a lot of things clearer about function/method contexts, therefore the code is now clearer.
This commit is contained in:
@@ -433,18 +433,15 @@ class Evaluator(object):
|
|||||||
parent_context = from_scope_node(parent_scope)
|
parent_context = from_scope_node(parent_scope)
|
||||||
|
|
||||||
if is_funcdef:
|
if is_funcdef:
|
||||||
parent_was_class = parent_context.is_class()
|
|
||||||
if parent_was_class:
|
|
||||||
parent_context = AnonymousInstance(
|
|
||||||
self, parent_context.parent_context, parent_context)
|
|
||||||
|
|
||||||
func = FunctionContext.from_context(parent_context, scope_node)
|
func = FunctionContext.from_context(parent_context, scope_node)
|
||||||
|
if parent_context.is_class():
|
||||||
if parent_was_class:
|
instance = AnonymousInstance(
|
||||||
|
self, parent_context.parent_context, parent_context)
|
||||||
func = BoundMethod(
|
func = BoundMethod(
|
||||||
instance=parent_context,
|
instance=instance,
|
||||||
function=func
|
function=func
|
||||||
)
|
)
|
||||||
|
|
||||||
if is_nested and not node_is_object:
|
if is_nested and not node_is_object:
|
||||||
return func.get_function_execution()
|
return func.get_function_execution()
|
||||||
return func
|
return func
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ from jedi.evaluate.arguments import AnonymousArguments
|
|||||||
from jedi.evaluate.filters import ParserTreeFilter, FunctionExecutionFilter
|
from jedi.evaluate.filters import ParserTreeFilter, FunctionExecutionFilter
|
||||||
from jedi.evaluate.names import ContextName, AbstractNameDefinition, ParamName
|
from jedi.evaluate.names import ContextName, AbstractNameDefinition, ParamName
|
||||||
from jedi.evaluate.base_context import ContextualizedNode, NO_CONTEXTS, \
|
from jedi.evaluate.base_context import ContextualizedNode, NO_CONTEXTS, \
|
||||||
ContextSet, TreeContext, ContextWrapper, LazyContextWrapper
|
ContextSet, TreeContext, ContextWrapper
|
||||||
from jedi.evaluate.lazy_context import LazyKnownContexts, LazyKnownContext, \
|
from jedi.evaluate.lazy_context import LazyKnownContexts, LazyKnownContext, \
|
||||||
LazyTreeContext
|
LazyTreeContext
|
||||||
from jedi.evaluate.context import iterable
|
from jedi.evaluate.context import iterable
|
||||||
|
|||||||
Reference in New Issue
Block a user