Skip to content

Commit 77b4de3

Browse files
authored
feat: more accurate and specific binding scopes (#598)
* Moved and renamed Template grammar for consistency * Mark structural directive's asterisk prefix as punctuation * Add actual attribute name to scope * Updated snapshot * Formatting
1 parent f781be1 commit 77b4de3

File tree

3 files changed

+48
-42
lines changed

3 files changed

+48
-42
lines changed

syntaxes/src/build.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88

99
import * as fs from 'fs';
1010

11-
import {GrammarDefinition, JsonObject} from './types';
12-
import {template} from './template/grammar';
13-
import {InlineTemplate} from './inline-template';
1411
import {InlineStyles} from './inline-styles';
12+
import {InlineTemplate} from './inline-template';
13+
import {Template} from './template';
14+
import {GrammarDefinition, JsonObject} from './types';
1515

1616
// Recursively transforms a TypeScript grammar definition into an object which can be processed by
1717
// JSON.stringify to generate a valid TextMate JSON grammar definition
@@ -42,6 +42,6 @@ function build(grammar: GrammarDefinition, filename: string): void {
4242
});
4343
}
4444

45-
build(template, 'template');
45+
build(Template, 'template');
4646
build(InlineTemplate, 'inline-template');
4747
build(InlineStyles, 'inline-styles');

syntaxes/src/template/grammar.ts renamed to syntaxes/src/template.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88

9-
import {GrammarDefinition} from '../types';
9+
import {GrammarDefinition} from './types';
1010

11-
export const template: GrammarDefinition = {
11+
export const Template: GrammarDefinition = {
1212
scopeName: 'template.ng',
1313
injectionSelector: 'L:text.html -comment',
1414
patterns: [
@@ -130,10 +130,11 @@ export const template: GrammarDefinition = {
130130
bindingKey: {
131131
patterns: [
132132
{
133-
match: /([\[\(]{1,2})(?:\s*)(@?[-_a-zA-Z0-9.$]*)(?:\s*)([\]\)]{1,2})/,
133+
match: /([\[\(]{1,2}|\*)(?:\s*)(@?[-_a-zA-Z0-9.$]*)(?:\s*)([\]\)]{1,2})?/,
134134
captures: {
135135
1: {name: 'punctuation.definition.ng-binding-name.begin.html'},
136136
2: {
137+
name: 'entity.other.ng-binding-name.$2.html',
137138
patterns: [
138139
{
139140
match: /\./,

0 commit comments

Comments
 (0)