Fragment tag more expressions

Revise make_function3 comment wrt args and kwargs
This commit is contained in:
rocky
2017-06-10 16:31:56 -04:00
parent bf45260588
commit daea3c348c
2 changed files with 12 additions and 5 deletions

View File

@@ -178,15 +178,22 @@ class FragmentsWalker(pysource.SourceWalker, object):
return
def n_binary_subscr(self, node):
def table_r_node(self, node):
"""General pattern where the last node should should
get the text span attributes of the entire tree"""
start = len(self.f.getvalue())
try:
self.default(node)
except GenericASTTraversalPruningException:
self.set_pos_info(node, start, len(self.f.getvalue()))
self.set_pos_info(node[-1], start, len(self.f.getvalue()))
final = len(self.f.getvalue())
self.set_pos_info(node, start, final)
self.set_pos_info(node[-1], start, final)
raise GenericASTTraversalPruningException
n_slice0 = n_slice1 = n_slice2 = n_slice3 = n_binary_subscr = table_r_node
n_augassign_1 = n_print_item = exec_stmt = print_to_item = del_stmt = table_r_node
n_classdefco1 = n_classdefco2 = except_cond1 = except_cond2 = table_r_node
def n_passtmt(self, node):
start = len(self.f.getvalue()) + len(self.indent)
self.set_pos_info(node, start, start+len("pass"))

View File

@@ -489,10 +489,10 @@ def make_function3(self, node, isLambda, nested=1, codeNode=None):
if isinstance(args_node.attr, tuple):
pos_args, kw_args, annotate_argc = args_node.attr
if self.version <= 3.3 and len(node) > 2 and node[lambda_index] != 'LOAD_LAMBDA':
# args are after kwargs ?
# args are after kwargs; kwargs are bundled as one node
defparams = node[1:args_node.attr[0]+1]
else:
# args are before kwargs ?
# args are before kwargs; kwags as bundled as one node
defparams = node[:args_node.attr[0]]
else:
if self.version < 3.6: