def _add_imports_to_env(self, raw_api):
for namespace, desc in raw_api:<EOL><INDENT>for item in desc:<EOL><INDENT>if isinstance(item, AstImport):<EOL><INDENT>if namespace.name == item.target:<EOL><INDENT>raise InvalidSpec('<STR_LIT>',<EOL>item.lineno, item.path)<EOL><DEDENT>if item.target not in self.api.namespaces:<EOL><INDENT>raise InvalidSpec(<EOL>'<STR_LIT>' %<EOL>quote(item.target),<EOL>item.lineno, item.path)<EOL><DEDENT>env = self._get_or_create_env(namespace.name)<EOL>imported_env = self._get_or_create_env(item.target)<EOL>if namespace.name in imported_env:<EOL><INDENT>raise InvalidSpec(<EOL>'<STR_LIT>'<EOL>'<STR_LIT>' %<EOL>(quote(namespace.name), quote(item.target)),<EOL>item.lineno, item.path)<EOL><DEDENT>env[item.target] = imported_env<EOL><DEDENT><DEDENT><DEDENT>
Scans raw parser output for import declarations. Checks if the imports
are valid, and then creates a reference to the namespace in the
environment.

Args:
    raw_api (Tuple[Namespace, List[stone.stone.parser._Element]]):
        Namespace paired with raw parser output.