diff --git a/scripts/build.sh b/scripts/build.sh index cfc16526a5..1b1c38687d 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -22,9 +22,6 @@ cp server/package.json server/yarn.lock server/README.md dist/server node syntaxes/out/build.js mkdir dist/syntaxes cp syntaxes/out/*.json dist/syntaxes -# TODO: Remove the next two lines once all syntaxes have been refactored to TypeScript -cp syntaxes/*.json dist/syntaxes -rm dist/syntaxes/tsconfig.json pushd dist yarn install --production --ignore-scripts diff --git a/syntaxes/inline-styles.json b/syntaxes/inline-styles.json deleted file mode 100644 index 3e5fb77436..0000000000 --- a/syntaxes/inline-styles.json +++ /dev/null @@ -1,95 +0,0 @@ -{ - "scopeName": "inline-styles.ng", - "injectionSelector": "L:source.ts#meta.decorator.ts -comment", - "patterns": [ - { - "include": "#inline-styles" - } - ], - "repository": { - "inline-styles": { - "begin": "(styles)\\s*(:)", - "beginCaptures": { - "1": { - "name": "meta.object-literal.key.ts" - }, - "2": { - "name": "meta.object-literal.key.ts punctuation.separator.key-value.ts" - } - }, - "end": "(?=,|})", - "patterns": [ - { - "include": "#ts-paren-expression" - }, - { - "include": "#ts-bracket-expression" - } - ] - }, - - "ts-paren-expression": { - "begin": "\\G\\s*(\\()", - "beginCaptures": { - "1": { - "name": "meta.brace.round.ts" - } - }, - "end": "\\)", - "endCaptures": { - "0": { - "name": "meta.brace.round.ts" - } - }, - "patterns": [ - { - "include": "$self" - }, - { - "include": "#ts-bracket-expression" - } - ] - }, - - "ts-bracket-expression": { - "begin": "\\G\\s*(\\[)", - "beginCaptures": { - "1": { - "name": "meta.array.literal.ts meta.brace.square.ts" - } - }, - "end": "\\]", - "endCaptures": { - "0": { - "name": "meta.array.literal.ts meta.brace.square.ts" - } - }, - "patterns": [ - { - "include": "#style" - } - ] - }, - - "style": { - "begin": "\\s*([`|'|\"])", - "beginCaptures": { - "1": { - "name": "string" - } - }, - "end": "\\1", - "endCaptures": { - "0": { - "name": "string" - } - }, - "contentName": "source.css", - "patterns": [ - { - "include": "source.css" - } - ] - } - } -} diff --git a/syntaxes/inline-template.json b/syntaxes/inline-template.json deleted file mode 100644 index 8853bb663b..0000000000 --- a/syntaxes/inline-template.json +++ /dev/null @@ -1,78 +0,0 @@ -{ - "scopeName": "inline-template.ng", - "injectionSelector": "L:meta.decorator.ts -comment", - "patterns": [ - { - "include": "#inline-template" - } - ], - "repository": { - "inline-template": { - "begin": "(template)\\s*(:)", - "beginCaptures": { - "1": { - "name": "meta.object-literal.key.ts" - }, - "2": { - "name": "meta.object-literal.key.ts punctuation.separator.key-value.ts" - } - }, - "end": "(?=,|})", - "patterns": [ - { - "include": "#ts-paren-expression" - }, - { - "include": "#ng-template" - } - ] - }, - - "ts-paren-expression": { - "begin": "\\G\\s*(\\()", - "beginCaptures": { - "1": { - "name": "meta.brace.round.ts" - } - }, - "end": "\\)", - "endCaptures": { - "0": { - "name": "meta.brace.round.ts" - } - }, - "patterns": [ - { - "include": "#ts-paren-expression" - }, - { - "include": "#ng-template" - } - ] - }, - - "ng-template": { - "begin": "\\G\\s*([`|'|\"])", - "beginCaptures": { - "1": { - "name": "string" - } - }, - "end": "\\1", - "endCaptures": { - "0": { - "name": "string" - } - }, - "contentName": "text.html", - "patterns": [ - { - "include": "text.html.derivative" - }, - { - "include": "template.ng" - } - ] - } - } -} diff --git a/syntaxes/src/build.ts b/syntaxes/src/build.ts index 296fa75af7..af3a24fd56 100644 --- a/syntaxes/src/build.ts +++ b/syntaxes/src/build.ts @@ -10,6 +10,8 @@ import * as fs from 'fs'; import {GrammarDefinition, JsonObject} from './types'; import {template} from './template/grammar'; +import {InlineTemplate} from './inline-template'; +import {InlineStyles} from './inline-styles'; // Recursively transforms a TypeScript grammar definition into an object which can be processed by // JSON.stringify to generate a valid TextMate JSON grammar definition @@ -41,3 +43,5 @@ function build(grammar: GrammarDefinition, filename: string): void { } build(template, 'template'); +build(InlineTemplate, 'inline-template'); +build(InlineStyles, 'inline-styles'); diff --git a/syntaxes/src/inline-styles.ts b/syntaxes/src/inline-styles.ts new file mode 100644 index 0000000000..5d28d27005 --- /dev/null +++ b/syntaxes/src/inline-styles.ts @@ -0,0 +1,51 @@ +/** + * @license + * Copyright Google Inc. All Rights Reserved. + * + * Use of this source code is governed by an MIT-style license that can be + * found in the LICENSE file at https://angular.io/license + */ + +import {GrammarDefinition} from './types'; + +export const InlineStyles: GrammarDefinition = { + scopeName: 'inline-styles.ng', + injectionSelector: 'L:source.ts#meta.decorator.ts -comment', + patterns: [{include: '#inlineStyles'}], + repository: { + inlineStyles: { + begin: /(styles)\s*(:)/, + beginCaptures: { + 1: {name: 'meta.object-literal.key.ts'}, + 2: {name: 'meta.object-literal.key.ts punctuation.separator.key-value.ts'} + }, + end: /(?=,|})/, + patterns: [{include: '#tsParenExpression'}, {include: '#tsBracketExpression'}] + }, + + tsParenExpression: { + begin: /\G\s*(\()/, + beginCaptures: {1: {name: 'meta.brace.round.ts'}}, + end: /\)/, + endCaptures: {0: {name: 'meta.brace.round.ts'}}, + patterns: [{include: '$self'}, {include: '#tsBracketExpression'}] + }, + + 'tsBracketExpression': { + begin: /\G\s*(\[)/, + beginCaptures: {1: {name: 'meta.array.literal.ts meta.brace.square.ts'}}, + end: /\]/, + endCaptures: {0: {name: 'meta.array.literal.ts meta.brace.square.ts'}}, + patterns: [{include: '#style'}] + }, + + style: { + begin: /\s*([`|'|"])/, + beginCaptures: {1: {name: 'string'}}, + end: /\1/, + endCaptures: {0: {name: 'string'}}, + contentName: 'source.css', + patterns: [{include: 'source.css'}] + } + } +} diff --git a/syntaxes/src/inline-template.ts b/syntaxes/src/inline-template.ts new file mode 100644 index 0000000000..9d6149fcab --- /dev/null +++ b/syntaxes/src/inline-template.ts @@ -0,0 +1,43 @@ +/** + * @license + * Copyright Google Inc. All Rights Reserved. + * + * Use of this source code is governed by an MIT-style license that can be + * found in the LICENSE file at https://angular.io/license + */ + +import {GrammarDefinition} from './types'; + +export const InlineTemplate: GrammarDefinition = { + scopeName: 'inline-template.ng', + injectionSelector: 'L:meta.decorator.ts -comment', + patterns: [{include: '#inlineTemplate'}], + repository: { + inlineTemplate: { + begin: /(template)\s*(:)/, + beginCaptures: { + 1: {name: 'meta.object-literal.key.ts'}, + 2: {name: 'meta.object-literal.key.ts punctuation.separator.key-value.ts'} + }, + end: /(?=,|})/, + patterns: [{include: '#tsParenExpression'}, {include: '#ngTemplate'}] + }, + + tsParenExpression: { + begin: /\G\s*(\()/, + beginCaptures: {1: {name: 'meta.brace.round.ts'}}, + end: /\)/, + endCaptures: {0: {name: 'meta.brace.round.ts'}}, + patterns: [{include: '#tsParenExpression'}, {include: '#ngTemplate'}] + }, + + ngTemplate: { + begin: /\G\s*([`|'|"])/, + beginCaptures: {1: {name: 'string'}}, + end: /\1/, + endCaptures: {0: {name: 'string'}}, + contentName: 'text.html', + patterns: [{include: 'text.html.derivative'}, {include: 'template.ng'}] + } + } +} diff --git a/syntaxes/test/cases.json b/syntaxes/test/cases.json index b4b6a96b9b..fda2126abc 100644 --- a/syntaxes/test/cases.json +++ b/syntaxes/test/cases.json @@ -3,7 +3,7 @@ "name": "inline template", "scopeName": "inline-template.ng", "grammarFiles": [ - "syntaxes/inline-template.json", + "syntaxes/out/inline-template.json", "syntaxes/out/template.json" ], "testFile": "syntaxes/test/data/inline-template.ts" @@ -11,7 +11,7 @@ { "name": "inline styles", "scopeName": "inline-styles.ng", - "grammarFiles": ["syntaxes/inline-styles.json"], + "grammarFiles": ["syntaxes/out/inline-styles.json"], "testFile": "syntaxes/test/data/inline-styles.ts" }, {