(ids: Id[])
| 155 | } |
| 156 | |
| 157 | function generateTypeScriptIds(ids: Id[]): TypeScriptFile { |
| 158 | const definition = new OutputWriter(); |
| 159 | const implementation = new OutputWriter(); |
| 160 | |
| 161 | definition.append('export class Ids {\n'); |
| 162 | implementation.append('module.exports.Ids = {\n'); |
| 163 | |
| 164 | definition.beginIndent(' '); |
| 165 | implementation.beginIndent(' '); |
| 166 | |
| 167 | let first = true; |
| 168 | for (const id of ids) { |
| 169 | if (!first) { |
| 170 | definition.append('\n'); |
| 171 | } |
| 172 | first = false; |
| 173 | |
| 174 | if (id.description) { |
| 175 | definition.append(GeneratedFileHeader.generateMultilineComment(id.description)); |
| 176 | } |
| 177 | definition.append(`static ${id.name}(): string;\n`); |
| 178 | |
| 179 | implementation.append(`${id.name}: () => '${escapeJSSingleQuotedString(id.identifier)}',\n`); |
| 180 | } |
| 181 | |
| 182 | definition.endIndent(); |
| 183 | implementation.endIndent(); |
| 184 | |
| 185 | implementation.append('}\n'); |
| 186 | definition.append('}\n'); |
| 187 | |
| 188 | return { |
| 189 | definition: definition.content(), |
| 190 | implementation: implementation.content(), |
| 191 | }; |
| 192 | } |
| 193 | |
| 194 | export function generateIds(moduleName: string, iosHeaderImportPath: string, fileContent: string): GenerateIds { |
| 195 | const ids = parseIds(moduleName, fileContent); |
no test coverage detected