|
| 1 | +/** |
| 2 | + * @license |
| 3 | + * Copyright Google Inc. All Rights Reserved. |
| 4 | + * |
| 5 | + * Use of this source code is governed by an MIT-style license that can be |
| 6 | + * found in the LICENSE file at https://angular.io/license |
| 7 | + */ |
| 8 | + |
| 9 | +import {GrammarDefinition} from './types'; |
| 10 | + |
| 11 | +export const LetDeclaration: GrammarDefinition = { |
| 12 | + scopeName: 'template.let.ng', |
| 13 | + injectionSelector: 'L:text.html -comment -expression.ng -meta.tag -source.css -source.js', |
| 14 | + patterns: [ |
| 15 | + {include: '#letDeclaration'}, |
| 16 | + ], |
| 17 | + repository: { |
| 18 | + letDeclaration: { |
| 19 | + // Equals group is optional so that we start highlighting as |
| 20 | + // soon as the user starts writing a valid name. |
| 21 | + begin: /(@let)\s+([_$[:alpha:]][_$[:alnum:]]*)\s*(=)?/, |
| 22 | + beginCaptures: { |
| 23 | + 1: {name: 'storage.type.ng'}, |
| 24 | + 2: {name: 'meta.definition.variable.ng'}, |
| 25 | + 3: {name: 'keyword.operator.assignment.ng'}, |
| 26 | + }, |
| 27 | + patterns: [{include: '#letInitializer'}], |
| 28 | + contentName: 'meta.definition.variable.ng', |
| 29 | + end: /(?<=;)/, |
| 30 | + }, |
| 31 | + |
| 32 | + letInitializer: { |
| 33 | + begin: /\s*/, |
| 34 | + beginCaptures: { |
| 35 | + 0: {name: 'keyword.operator.assignment.ng'}, |
| 36 | + }, |
| 37 | + contentName: 'meta.definition.variable.initializer.ng', |
| 38 | + patterns: [{include: 'expression.ng'}], |
| 39 | + end: /;/, |
| 40 | + endCaptures: { |
| 41 | + 0: {name: 'punctuation.terminator.statement.ng'}, |
| 42 | + }, |
| 43 | + }, |
| 44 | + }, |
| 45 | +}; |
0 commit comments