def _enter_identifier_terminate_node(self, id_term_node, is_on_lambda_body, is_on_lambda_str, is_declarative=None, is_function=None, is_declarative_parameter=None, is_lambda_argument=None): node_type = NodeType(id_term_node['type']) if node_type is NodeType.CURLYNAME: self._enter_curlyname_node( id_term_node, is_on_lambda_body=is_on_lambda_body, is_on_lambda_str=is_on_lambda_str, is_declarative=is_declarative, is_function=is_function, is_declarative_parameter=is_declarative_parameter, ) return is_autoload = '#' in id_term_node['value'] is_variadic = id_term_node['value'] == '...' _set_identifier_attribute( id_term_node, is_lambda_argument=is_lambda_argument, is_on_lambda_body=is_on_lambda_body, is_on_lambda_str=is_on_lambda_str, is_declarative=is_declarative, is_autoload=is_autoload, is_function=is_function, is_declarative_parameter=is_declarative_parameter, is_variadic=is_variadic, )
def _pre_mark_member_node(self, member_node, is_on_lambda_body, is_on_lambda_str): member_node_type = NodeType(member_node['type']) if member_node_type in IdentifierTerminateNodeTypes or \ member_node_type in AnalyzableSubScriptChildNodeTypes: _set_identifier_attribute( member_node, is_member=True, is_on_lambda_str=is_on_lambda_str, is_on_lambda_body=is_on_lambda_body, )
def _enter_curlyname_node(self, curlyname_node, is_on_lambda_body, is_on_lambda_str, is_declarative=None, is_function=None, is_declarative_parameter=None): # Curlyname node can have a dynamic name. For example: # let s:var = 'VAR' # let my_{s:var} = 0 _set_identifier_attribute( curlyname_node, is_dynamic=True, is_declarative=is_declarative, is_function=is_function, is_declarative_parameter=is_declarative_parameter, is_on_lambda_str=is_on_lambda_str, is_on_lambda_body=is_on_lambda_body, )
def _enter_accessor_node(self, accessor_node, is_on_lambda_body, is_on_lambda_str, is_declarative=None, is_function=None, is_declarative_parameter=None): accessor_node_type = NodeType(accessor_node['type']) if accessor_node_type is NodeType.DOT: _set_identifier_attribute( accessor_node['right'], is_declarative=is_declarative, is_dynamic=False, is_function=is_function, is_declarative_parameter=is_declarative_parameter, is_on_lambda_str=is_on_lambda_str, is_on_lambda_body=is_on_lambda_body, ) return if accessor_node_type is NodeType.SUBSCRIPT: subscript_right_type = NodeType(accessor_node['right']['type']) # We can do static analysis NodeType.SUBSCRIPT such as: # let object['name'] = 0 # # but we cannot do it in other cases such as: # let object[var] = 0 is_dynamic = subscript_right_type not in AnalyzableSubScriptChildNodeTypes if not is_dynamic: _set_identifier_attribute( accessor_node['right'], is_declarative=is_declarative, is_dynamic=False, is_function=is_function, is_declarative_parameter=is_declarative_parameter, is_on_lambda_str=is_on_lambda_str, is_on_lambda_body=is_on_lambda_body, ) return if accessor_node_type is NodeType.SLICE: for elem_node in accessor_node['rlist']: if type(elem_node) is list: # In VimLParser spec, an empty array means null. # list[1:] => {rlist: [node, []]} continue elem_node_type = NodeType(elem_node['type']) # We can do static analysis NodeType.SLICE such as: # let object[0:1] = 0 # # but we cannot do it in other cases such as: # let object[0:var] = 0 is_dynamic = elem_node_type not in AnalyzableSubScriptChildNodeTypes # In the following case, 0 is a declarative but var is not declarative. # It is more like a reference. # let object[0:var] = 0 is_declarative = elem_node_type in AnalyzableSubScriptChildNodeTypes _set_identifier_attribute( elem_node, is_declarative=is_declarative, is_dynamic=is_dynamic, is_function=is_function, is_declarative_parameter=is_declarative_parameter, is_on_lambda_str=is_on_lambda_str, is_on_lambda_body=is_on_lambda_body, ) return raise Exception()