Remove node_is_object, not used anymore

This commit is contained in:
Dave Halter
2019-08-22 23:13:34 +02:00
parent faf6752ff8
commit 6d5e9f4b0f
2 changed files with 18 additions and 22 deletions

View File

@@ -293,7 +293,6 @@ def _create(inference_state, access_handle, parent_context, *args):
module_context.create_context(
tree_node,
node_is_value=True,
node_is_object=True
)._value
# TODO private access!
})

View File

@@ -22,26 +22,11 @@ class AbstractContext(object):
def get_root_context(self):
return self._value.get_root_context()
def create_context(self, node, node_is_value=False, node_is_object=False):
def create_context(self, node, node_is_value=False):
from jedi.inference.value import ClassValue, FunctionValue, \
AnonymousInstance, BoundMethod
def parent_scope(node):
while True:
node = node.parent
if parser_utils.is_scope(node):
return node
elif node.type in ('argument', 'testlist_comp'):
if node.children[1].type in ('comp_for', 'sync_comp_for'):
return node.children[1]
elif node.type == 'dictorsetmaker':
for n in node.children[1:4]:
# In dictionaries it can be pretty much anything.
if n.type in ('comp_for', 'sync_comp_for'):
return n
def from_scope_node(scope_node, is_nested=True, node_is_object=False):
def from_scope_node(scope_node, is_nested=True):
if scope_node == base_node:
return self
@@ -59,9 +44,6 @@ class AbstractContext(object):
instance=instance,
function=func
)
if is_nested and not node_is_object:
return func.get_function_execution()
return func.as_context()
elif scope_node.type == 'classdef':
return ClassValue(self.inference_state, parent_context, scope_node).as_context()
@@ -76,6 +58,21 @@ class AbstractContext(object):
if node_is_value and parser_utils.is_scope(node):
scope_node = node
else:
def parent_scope(node):
while True:
node = node.parent
if parser_utils.is_scope(node):
return node
elif node.type in ('argument', 'testlist_comp'):
if node.children[1].type in ('comp_for', 'sync_comp_for'):
return node.children[1]
elif node.type == 'dictorsetmaker':
for n in node.children[1:4]:
# In dictionaries it can be pretty much anything.
if n.type in ('comp_for', 'sync_comp_for'):
return n
scope_node = parent_scope(node)
if scope_node.type in ('funcdef', 'classdef'):
colon = scope_node.children[scope_node.children.index(':')]
@@ -83,7 +80,7 @@ class AbstractContext(object):
parent = node.parent
if not (parent.type == 'param' and parent.name == node):
scope_node = parent_scope(scope_node)
return from_scope_node(scope_node, is_nested=True, node_is_object=node_is_object)
return from_scope_node(scope_node, is_nested=True)
def goto(self, name_or_str, position):
from jedi.inference import finder