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