()
| 242 | } |
| 243 | |
| 244 | private _parseExpansionCase(): html.ExpansionCase | null { |
| 245 | const value = this._advance<ExpansionCaseValueToken>(); |
| 246 | |
| 247 | // read { |
| 248 | if (this._peek.type !== TokenType.EXPANSION_CASE_EXP_START) { |
| 249 | this.errors.push( |
| 250 | TreeError.create(null, this._peek.sourceSpan, `Invalid ICU message. Missing '{'.`), |
| 251 | ); |
| 252 | return null; |
| 253 | } |
| 254 | |
| 255 | // read until } |
| 256 | const start = this._advance<ExpansionCaseExpressionStartToken>(); |
| 257 | |
| 258 | const exp = this._collectExpansionExpTokens(start); |
| 259 | if (!exp) return null; |
| 260 | |
| 261 | const end = this._advance<ExpansionCaseExpressionEndToken>(); |
| 262 | exp.push({type: TokenType.EOF, parts: [], sourceSpan: end.sourceSpan}); |
| 263 | |
| 264 | // parse everything in between { and } |
| 265 | const expansionCaseParser = new _TreeBuilder(exp, this.tagDefinitionResolver); |
| 266 | expansionCaseParser.build(); |
| 267 | if (expansionCaseParser.errors.length > 0) { |
| 268 | this.errors = this.errors.concat(expansionCaseParser.errors); |
| 269 | return null; |
| 270 | } |
| 271 | |
| 272 | const sourceSpan = new ParseSourceSpan( |
| 273 | value.sourceSpan.start, |
| 274 | end.sourceSpan.end, |
| 275 | value.sourceSpan.fullStart, |
| 276 | ); |
| 277 | const expSourceSpan = new ParseSourceSpan( |
| 278 | start.sourceSpan.start, |
| 279 | end.sourceSpan.end, |
| 280 | start.sourceSpan.fullStart, |
| 281 | ); |
| 282 | return new html.ExpansionCase( |
| 283 | value.parts[0], |
| 284 | expansionCaseParser.rootNodes, |
| 285 | sourceSpan, |
| 286 | value.sourceSpan, |
| 287 | expSourceSpan, |
| 288 | ); |
| 289 | } |
| 290 | |
| 291 | private _collectExpansionExpTokens(start: Token): Token[] | null { |
| 292 | const exp: Token[] = []; |
no test coverage detected