def _populate_type_attributes(self):
for namespace in self.api.namespaces.values():<EOL><INDENT>env = self._get_or_create_env(namespace.name)<EOL>for annotation in namespace.annotations:<EOL><INDENT>if isinstance(annotation, CustomAnnotation):<EOL><INDENT>loc = annotation._ast_node.lineno, annotation._ast_node.path<EOL>if annotation.annotation_type_ns:<EOL><INDENT>if annotation.annotation_type_ns not in env:<EOL><INDENT>raise InvalidSpec(<EOL>'<STR_LIT>' %<EOL>quote(annotation.annotation_type_ns), *loc)<EOL><DEDENT>annotation_type_env = env[annotation.annotation_type_ns]<EOL>if not isinstance(annotation_type_env, Environment):<EOL><INDENT>raise InvalidSpec(<EOL>'<STR_LIT>' %<EOL>quote(annotation.annotation_type_ns), *loc)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>annotation_type_env = env<EOL><DEDENT>if annotation.annotation_type_name not in annotation_type_env:<EOL><INDENT>raise InvalidSpec(<EOL>'<STR_LIT>' %<EOL>quote(annotation.annotation_type_name), *loc)<EOL><DEDENT>annotation_type = annotation_type_env[annotation.annotation_type_name]<EOL>if not isinstance(annotation_type, AnnotationType):<EOL><INDENT>raise InvalidSpec(<EOL>'<STR_LIT>' % quote(annotation.annotation_type_name),<EOL>*loc<EOL>)<EOL><DEDENT>annotation.set_attributes(annotation_type)<EOL><DEDENT><DEDENT>for alias in namespace.aliases:<EOL><INDENT>data_type = self._resolve_type(env, alias._ast_node.type_ref)<EOL>alias.set_attributes(alias._ast_node.doc, data_type)<EOL>annotations = [self._resolve_annotation_type(env, annotation)<EOL>for annotation in alias._ast_node.annotations]<EOL>alias.set_annotations(annotations)<EOL><DEDENT>for data_type in namespace.data_types:<EOL><INDENT>if not data_type._is_forward_ref:<EOL><INDENT>continue<EOL><DEDENT>self._resolution_in_progress.add(data_type)<EOL>if isinstance(data_type, Struct):<EOL><INDENT>self._populate_struct_type_attributes(env, data_type)<EOL><DEDENT>elif isinstance(data_type, Union):<EOL><INDENT>self._populate_union_type_attributes(env, data_type)<EOL><DEDENT>else:<EOL><INDENT>raise AssertionError('<STR_LIT>' %<EOL>type(data_type))<EOL><DEDENT>self._resolution_in_progress.remove(data_type)<EOL><DEDENT><DEDENT>assert len(self._resolution_in_progress) == <NUM_LIT:0><EOL>
Converts each struct, union, and route from a forward reference to a
full definition.