Example #1
0
        def _add_builtin_variable(self, id_node, explicity, is_function):
            # type: (Dict[str, Any], ExplicityOfScopeVisibility, bool) -> None
            variable_name = remove_optional_scope_prefix(id_node['value'])

            self._register_variable(self.get_global_scope(),
                                    variable_name,
                                    id_node,
                                    explicity,
                                    is_function,
                                    is_builtin=True,
                                    is_explicit_lambda_argument=False)
Example #2
0
        def _add_variable(self, objective_scope, id_node, is_function,
                          explicity):
            # type: (Scope, Dict[str, Any], bool, ExplicityOfScopeVisibility) -> None
            variable_name = remove_optional_scope_prefix(id_node['value'])

            self._register_variable(objective_scope,
                                    variable_name,
                                    id_node,
                                    explicity,
                                    is_function,
                                    is_builtin=False,
                                    is_explicit_lambda_argument=False)
Example #3
0
        def _add_self_variable(self, objective_scope):  # type: (Scope) -> None
            variable_name = remove_optional_scope_prefix('l:self')
            virtual_node = _create_virtual_identifier_node(variable_name)

            self._register_variable(
                objective_scope,
                variable_name,
                virtual_node,
                explicity=ExplicityOfScopeVisibility.EXPLICIT,
                is_function=False,
                is_builtin=False,
                is_explicit_lambda_argument=False)
Example #4
0
        def _add_builtin_variable(self, id_node, explicity, is_function):
            # type: (Dict[str, Any], ExplicityOfScopeVisibility, bool) -> None
            variable_name = remove_optional_scope_prefix(id_node['value'])

            self._register_variable(
                self.get_global_scope(),
                variable_name,
                id_node,
                explicity,
                is_function,
                is_builtin=True,
                is_explicit_lambda_argument=False
            )
Example #5
0
        def _add_variable(self, objective_scope, id_node, is_function, explicity):
            # type: (Scope, Dict[str, Any], bool, ExplicityOfScopeVisibility) -> None
            variable_name = remove_optional_scope_prefix(id_node['value'])

            self._register_variable(
                objective_scope,
                variable_name,
                id_node,
                explicity,
                is_function,
                is_builtin=False,
                is_explicit_lambda_argument=False
            )
Example #6
0
        def _add_self_variable(self, objective_scope):  # type: (Scope) -> None
            variable_name = remove_optional_scope_prefix('l:self')
            virtual_node = _create_virtual_identifier_node(variable_name)

            self._register_variable(
                objective_scope,
                variable_name,
                virtual_node,
                explicity=ExplicityOfScopeVisibility.EXPLICIT,
                is_function=False,
                is_builtin=False,
                is_explicit_lambda_argument=False
            )
    def get_referenced_variable_declarations(self, ref_id_node):
        # type: (Dict[str, Any]) -> Union[List[VariableDeclaration], GlobalVariableDeclaration]

        scope = self._scope_linker.link_registry.get_context_scope_by_identifier(
            ref_id_node)
        var_name = remove_optional_scope_prefix(ref_id_node['value'])
        is_func_id = is_function_identifier(ref_id_node)

        while scope is not None:
            if is_func_id:
                functions_list = scope.functions
                if var_name in functions_list:
                    # The function is found in the symbol table for functions.
                    funcs = functions_list[var_name]

                    for func in funcs:
                        declaring_id_node = self._scope_linker.link_registry \
                            .get_declarative_identifier_by_variable(func)
                        declaring_id_node[REFERENCED_FLAG] = True

                    return funcs
                else:
                    # We can access the function via a variable function
                    # reference if the function not found from the symbol table
                    # for functions. So we should check the symbol table for
                    # variables to search the function reference.
                    pass

            variables_list = scope.variables
            if var_name in variables_list:
                # The variable or function reference found in the symbol table
                # for variables.
                variables = variables_list[var_name]

                for variable in variables:
                    declaring_id_node = self._scope_linker.link_registry \
                        .get_declarative_identifier_by_variable(variable)
                    declaring_id_node[REFERENCED_FLAG] = True

                return variables

            scope = scope.parent

        # If it is builtin, it will be used by Vim.
        if is_builtin_variable(ref_id_node):
            return GLOBAL_VARIABLE_DECLARATION

        return []
    def get_referenced_variable_declarations(self, ref_id_node):
        # type: (Dict[str, Any]) -> Union[List[VariableDeclaration], GlobalVariableDeclaration]

        scope = self._scope_linker.link_registry.get_context_scope_by_identifier(ref_id_node)
        var_name = remove_optional_scope_prefix(ref_id_node['value'])
        is_func_id = is_function_identifier(ref_id_node)

        while scope is not None:
            if is_func_id:
                functions_list = scope.functions
                if var_name in functions_list:
                    # The function is found in the symbol table for functions.
                    funcs = functions_list[var_name]

                    for func in funcs:
                        declaring_id_node = self._scope_linker.link_registry \
                            .get_declarative_identifier_by_variable(func)
                        declaring_id_node[REFERENCED_FLAG] = True

                    return funcs
                else:
                    # We can access the function via a variable function
                    # reference if the function not found from the symbol table
                    # for functions. So we should check the symbol table for
                    # variables to search the function reference.
                    pass

            variables_list = scope.variables
            if var_name in variables_list:
                # The variable or function reference found in the symbol table
                # for variables.
                variables = variables_list[var_name]

                for variable in variables:
                    declaring_id_node = self._scope_linker.link_registry \
                        .get_declarative_identifier_by_variable(variable)
                    declaring_id_node[REFERENCED_FLAG] = True

                return variables

            scope = scope.parent

        # If it is builtin, it will be used by Vim.
        if is_builtin_variable(ref_id_node):
            return GLOBAL_VARIABLE_DECLARATION

        return []