(start: CharacterCursor)
| 300 | } |
| 301 | |
| 302 | private _consumeBlockStart(start: CharacterCursor) { |
| 303 | this._requireCharCode(chars.$AT); |
| 304 | this._beginToken(TokenType.BLOCK_OPEN_START, start); |
| 305 | const startToken = this._endToken([this._getBlockName()]); |
| 306 | |
| 307 | if (this._cursor.peek() === chars.$LPAREN) { |
| 308 | // Advance past the opening paren. |
| 309 | this._cursor.advance(); |
| 310 | // Capture the parameters. |
| 311 | this._consumeBlockParameters(); |
| 312 | // Allow spaces before the closing paren. |
| 313 | this._attemptCharCodeUntilFn(isNotWhitespace); |
| 314 | |
| 315 | if (this._attemptCharCode(chars.$RPAREN)) { |
| 316 | // Allow spaces after the paren. |
| 317 | this._attemptCharCodeUntilFn(isNotWhitespace); |
| 318 | } else { |
| 319 | startToken.type = TokenType.INCOMPLETE_BLOCK_OPEN; |
| 320 | return; |
| 321 | } |
| 322 | } |
| 323 | |
| 324 | if (startToken.parts[0] === 'default never' && this._attemptCharCode(chars.$SEMICOLON)) { |
| 325 | this._beginToken(TokenType.BLOCK_OPEN_END); |
| 326 | this._endToken([]); |
| 327 | this._beginToken(TokenType.BLOCK_CLOSE); |
| 328 | this._endToken([]); |
| 329 | return; |
| 330 | } |
| 331 | |
| 332 | if (this._attemptCharCode(chars.$LBRACE)) { |
| 333 | this._beginToken(TokenType.BLOCK_OPEN_END); |
| 334 | this._endToken([]); |
| 335 | } else if ( |
| 336 | this._isBlockStart() && |
| 337 | (startToken.parts[0] === 'case' || startToken.parts[0] === 'default') |
| 338 | ) { |
| 339 | // We only allow @case statements to be consecutive without a block in between. |
| 340 | this._beginToken(TokenType.BLOCK_OPEN_END); |
| 341 | this._endToken([]); |
| 342 | this._beginToken(TokenType.BLOCK_CLOSE); |
| 343 | this._endToken([]); |
| 344 | } else { |
| 345 | startToken.type = TokenType.INCOMPLETE_BLOCK_OPEN; |
| 346 | } |
| 347 | } |
| 348 | |
| 349 | private _consumeBlockEnd(start: CharacterCursor) { |
| 350 | this._beginToken(TokenType.BLOCK_CLOSE, start); |
no test coverage detected