(self)
| 141 | return [self.generate_file()] |
| 142 | |
| 143 | def generate_file(self) -> GeneratedFile: |
| 144 | lines: List[str] = [] |
| 145 | lines.append(self.get_license_header("//")) |
| 146 | lines.append("") |
| 147 | lines.append("import Foundation") |
| 148 | lines.append("import Fory") |
| 149 | lines.append("") |
| 150 | |
| 151 | namespace_components = self.get_namespace_components() |
| 152 | indent_level = 0 |
| 153 | for component in namespace_components: |
| 154 | lines.append(f"{self.indent_str * indent_level}public enum {component} {{") |
| 155 | indent_level += 1 |
| 156 | if namespace_components: |
| 157 | lines.append("") |
| 158 | |
| 159 | for enum in self.schema.enums: |
| 160 | if self.is_imported_type(enum): |
| 161 | continue |
| 162 | lines.extend(self.generate_enum(enum, indent=indent_level)) |
| 163 | lines.append("") |
| 164 | |
| 165 | for union in self.schema.unions: |
| 166 | if self.is_imported_type(union): |
| 167 | continue |
| 168 | lines.extend(self.generate_union(union, indent=indent_level)) |
| 169 | lines.append("") |
| 170 | |
| 171 | for message in self.schema.messages: |
| 172 | if self.is_imported_type(message): |
| 173 | continue |
| 174 | lines.extend(self.generate_message(message, indent=indent_level)) |
| 175 | lines.append("") |
| 176 | |
| 177 | lines.extend(self.generate_module_type(indent=indent_level)) |
| 178 | lines.append("") |
| 179 | |
| 180 | if namespace_components: |
| 181 | for i in range(len(namespace_components) - 1, -1, -1): |
| 182 | lines.append(f"{self.indent_str * i}}}") |
| 183 | lines.append("") |
| 184 | |
| 185 | content = "\n".join(lines).rstrip() + "\n" |
| 186 | return GeneratedFile(path=self.output_file_path(), content=content) |
| 187 | |
| 188 | def output_file_path(self) -> str: |
| 189 | file_name = self.module_file_name() |
no test coverage detected