From cc724df7825a0e052896f12ace78cf89ce5b04c0 Mon Sep 17 00:00:00 2001 From: Erik Lieben Date: Fri, 29 Dec 2017 11:59:48 +0100 Subject: [PATCH] feat(syntax-highlight): highlight from-view / to-view, resolves #61 (#62) * feat(syntax-highlight): highlight from-view / to-view, resolves #61 --- syntaxes/html.json | 14 +- test/syntax.html/databinding.test.ts | 572 ++++++++++++++++----------- 2 files changed, 349 insertions(+), 237 deletions(-) diff --git a/syntaxes/html.json b/syntaxes/html.json index 1bd9fdd7..b5a88b95 100644 --- a/syntaxes/html.json +++ b/syntaxes/html.json @@ -240,7 +240,7 @@ ] }, "tag-aurelia-attribute-with-databinding-attribute": { - "match": "(? { - - it(`must tokenize (some).bind="foo" attribute with scope "databinding.attribute.html.au"`, () => { - - // arrange - let scope = 'databinding.attribute.html.au'; - - // act - let lineToken = tokenizeLine('
'); - - // assert - let token = getTokenOnCharRange(lineToken, 10, 14); - assert.isOk(hasScope(token.scopes, scope)); - - }); - - it(`must tokenize (some).one-way="foo" attribute with scope "databinding.attribute.html.au"`, () => { - - // arrange - let scope = 'databinding.attribute.html.au'; - - // act - let lineToken = tokenizeLine('
'); - - // assert - let token = getTokenOnCharRange(lineToken, 10, 17); - assert.isOk(hasScope(token.scopes, scope)); - - }); - - it(`must tokenize (some).two-way="foo" attribute with scope "databinding.attribute.html.au"`, () => { - - // arrange - let scope = 'databinding.attribute.html.au'; - - // act - let lineToken = tokenizeLine('
'); - - // assert - let token = getTokenOnCharRange(lineToken, 10, 17); - assert.isOk(hasScope(token.scopes, scope)); - - }); - - it(`must tokenize (some).one-time="foo" attribute with scope "databinding.attribute.html.au"`, () => { - - // arrange - let scope = 'databinding.attribute.html.au'; - - // act - let lineToken = tokenizeLine('
'); - - // assert - let token = getTokenOnCharRange(lineToken, 10, 18); - assert.isOk(hasScope(token.scopes, scope)); - - }); - - it(`must not tokenize a="x.(bind)" attribute with scope "databinding.attribute.html.au"`, () => { - - // arrange - let scope = 'databinding.attribute.html.au'; - - // act - let lineToken = tokenizeLine('
'); - - // assert - let token = getTokenOnCharRange(lineToken, 8, 14); - assert.isOk(!hasScope(token.scopes, scope)); - - }); - - it(`must not tokenize a="x; x.(bind)" attribute with scope "databinding.attribute.html.au"`, () => { - - // arrange - let scope = 'databinding.attribute.html.au'; - - // act - let lineToken = tokenizeLine('
'); - - // assert - let token = getTokenOnCharRange(lineToken, 8, 17); - assert.isOk(!hasScope(token.scopes, scope)); - - }); - - it(`must not tokenize a="x.(bind)='x'; x" attribute with scope "databinding.attribute.html.au"`, () => { - - // arrange - let scope = 'databinding.attribute.html.au'; - - // act - let lineToken = tokenizeLine('
'); - - // assert - let token = getTokenOnCharRange(lineToken, 8, 21); - assert.isOk(!hasScope(token.scopes, scope)); - - }); - - it(`must not tokenize a="x.(one-way)" attribute with scope "databinding.attribute.html.au"`, () => { - - // arrange - let scope = 'databinding.attribute.html.au'; - - // act - let lineToken = tokenizeLine('
'); - - // assert - let token = getTokenOnCharRange(lineToken, 8, 17); - assert.isOk(!hasScope(token.scopes, scope)); - - }); - - it(`must not tokenize a="x; x.(one-way)" attribute with scope "databinding.attribute.html.au"`, () => { - - // arrange - let scope = 'databinding.attribute.html.au'; - - // act - let lineToken = tokenizeLine('
'); - - // assert - let token = getTokenOnCharRange(lineToken, 8, 20); - assert.isOk(!hasScope(token.scopes, scope)); - - }); - - it(`must not tokenize a="x.(one-way)='x'; x" attribute with scope "databinding.attribute.html.au"`, () => { - - // arrange - let scope = 'databinding.attribute.html.au'; - - // act - let lineToken = tokenizeLine('
'); - - // assert - let token = getTokenOnCharRange(lineToken, 8, 24); - assert.isOk(!hasScope(token.scopes, scope)); - - }); - - it(`must not tokenize a="x.(two-way)" attribute with scope "databinding.attribute.html.au"`, () => { - - // arrange - let scope = 'databinding.attribute.html.au'; - - // act - let lineToken = tokenizeLine('
'); - - // assert - let token = getTokenOnCharRange(lineToken, 8, 17); - assert.isOk(!hasScope(token.scopes, scope)); - - }); - - it(`must not tokenize a="x; x.(two-way)" attribute with scope "databinding.attribute.html.au"`, () => { - - // arrange - let scope = 'databinding.attribute.html.au'; - - // act - let lineToken = tokenizeLine('
'); - - // assert - let token = getTokenOnCharRange(lineToken, 8, 20); - assert.isOk(!hasScope(token.scopes, scope)); - - }); - - it(`must not tokenize a="x.(two-way)='x; x" attribute with scope "databinding.attribute.html.au"`, () => { - - // arrange - let scope = 'databinding.attribute.html.au'; - - // act - let lineToken = tokenizeLine('
'); - - // assert - let token = getTokenOnCharRange(lineToken, 8, 24); - assert.isOk(!hasScope(token.scopes, scope)); - - }); - - it(`must not tokenize a="x.(one-time)" attribute with scope "databinding.attribute.html.au"`, () => { - - // arrange - let scope = 'databinding.attribute.html.au'; - - // act - let lineToken = tokenizeLine('
'); - - // assert - let token = getTokenOnCharRange(lineToken, 8, 18); - assert.isOk(!hasScope(token.scopes, scope)); - - }); - - it(`must not tokenize a="x; x.(one-time)" attribute with scope "databinding.attribute.html.au"`, () => { - - // arrange - let scope = 'databinding.attribute.html.au'; - - // act - let lineToken = tokenizeLine('
'); - - // assert - let token = getTokenOnCharRange(lineToken, 8, 21); - assert.isOk(!hasScope(token.scopes, scope)); - - }); - - it(`must not tokenize a="x.(one-time)='\'x\; x" attribute with scope "databinding.attribute.html.au"`, () => { - - // arrange - let scope = 'databinding.attribute.html.au'; - - // act - let lineToken = tokenizeLine('
'); - - // assert - let token = getTokenOnCharRange(lineToken, 8, 25); - assert.isOk(!hasScope(token.scopes, scope)); - - }); - -}); +import { assert } from 'chai'; +import { getTokenOnCharRange, hasScope, tokenizeLine } from './test.utils'; + +describe('The Aurelia HTML syntax databinding attributes', () => { + + it(`must tokenize (some).bind="foo" attribute with scope "databinding.attribute.html.au"`, () => { + + // arrange + let scope = 'databinding.attribute.html.au'; + + // act + let lineToken = tokenizeLine('
'); + + // assert + let token = getTokenOnCharRange(lineToken, 10, 14); + assert.isOk(hasScope(token.scopes, scope)); + + }); + + it(`must tokenize (some).one-way="foo" attribute with scope "databinding.attribute.html.au"`, () => { + + // arrange + let scope = 'databinding.attribute.html.au'; + + // act + let lineToken = tokenizeLine('
'); + + // assert + let token = getTokenOnCharRange(lineToken, 10, 17); + assert.isOk(hasScope(token.scopes, scope)); + + }); + + it(`must tokenize (some).two-way="foo" attribute with scope "databinding.attribute.html.au"`, () => { + + // arrange + let scope = 'databinding.attribute.html.au'; + + // act + let lineToken = tokenizeLine('
'); + + // assert + let token = getTokenOnCharRange(lineToken, 10, 17); + assert.isOk(hasScope(token.scopes, scope)); + + }); + + it(`must tokenize (some).one-time="foo" attribute with scope "databinding.attribute.html.au"`, () => { + + // arrange + let scope = 'databinding.attribute.html.au'; + + // act + let lineToken = tokenizeLine('
'); + + // assert + let token = getTokenOnCharRange(lineToken, 10, 18); + assert.isOk(hasScope(token.scopes, scope)); + + }); + + it(`must tokenize (some).from-view="foo" attribute with scope "databinding.attribute.html.au"`, () => { + + // arrange + let scope = 'databinding.attribute.html.au'; + + // act + let lineToken = tokenizeLine('
'); + + // assert + let token = getTokenOnCharRange(lineToken, 10, 19); + assert.isOk(hasScope(token.scopes, scope)); + + }); + + it(`must tokenize (some).to-view="foo" attribute with scope "databinding.attribute.html.au"`, () => { + + // arrange + let scope = 'databinding.attribute.html.au'; + + // act + let lineToken = tokenizeLine('
'); + + // assert + let token = getTokenOnCharRange(lineToken, 10, 17); + assert.isOk(hasScope(token.scopes, scope)); + + }); + + it(`must not tokenize a="x.(bind)" attribute with scope "databinding.attribute.html.au"`, () => { + + // arrange + let scope = 'databinding.attribute.html.au'; + + // act + let lineToken = tokenizeLine('
'); + + // assert + let token = getTokenOnCharRange(lineToken, 8, 14); + assert.isOk(!hasScope(token.scopes, scope)); + + }); + + it(`must not tokenize a="x; x.(bind)" attribute with scope "databinding.attribute.html.au"`, () => { + + // arrange + let scope = 'databinding.attribute.html.au'; + + // act + let lineToken = tokenizeLine('
'); + + // assert + let token = getTokenOnCharRange(lineToken, 8, 17); + assert.isOk(!hasScope(token.scopes, scope)); + + }); + + it(`must not tokenize a="x.(bind)='x'; x" attribute with scope "databinding.attribute.html.au"`, () => { + + // arrange + let scope = 'databinding.attribute.html.au'; + + // act + let lineToken = tokenizeLine('
'); + + // assert + let token = getTokenOnCharRange(lineToken, 8, 21); + assert.isOk(!hasScope(token.scopes, scope)); + + }); + + it(`must not tokenize a="x.(one-way)" attribute with scope "databinding.attribute.html.au"`, () => { + + // arrange + let scope = 'databinding.attribute.html.au'; + + // act + let lineToken = tokenizeLine('
'); + + // assert + let token = getTokenOnCharRange(lineToken, 8, 17); + assert.isOk(!hasScope(token.scopes, scope)); + + }); + + it(`must not tokenize a="x; x.(one-way)" attribute with scope "databinding.attribute.html.au"`, () => { + + // arrange + let scope = 'databinding.attribute.html.au'; + + // act + let lineToken = tokenizeLine('
'); + + // assert + let token = getTokenOnCharRange(lineToken, 8, 20); + assert.isOk(!hasScope(token.scopes, scope)); + + }); + + it(`must not tokenize a="x.(one-way)='x'; x" attribute with scope "databinding.attribute.html.au"`, () => { + + // arrange + let scope = 'databinding.attribute.html.au'; + + // act + let lineToken = tokenizeLine('
'); + + // assert + let token = getTokenOnCharRange(lineToken, 8, 24); + assert.isOk(!hasScope(token.scopes, scope)); + + }); + + it(`must not tokenize a="x.(two-way)" attribute with scope "databinding.attribute.html.au"`, () => { + + // arrange + let scope = 'databinding.attribute.html.au'; + + // act + let lineToken = tokenizeLine('
'); + + // assert + let token = getTokenOnCharRange(lineToken, 8, 17); + assert.isOk(!hasScope(token.scopes, scope)); + + }); + + it(`must not tokenize a="x; x.(two-way)" attribute with scope "databinding.attribute.html.au"`, () => { + + // arrange + let scope = 'databinding.attribute.html.au'; + + // act + let lineToken = tokenizeLine('
'); + + // assert + let token = getTokenOnCharRange(lineToken, 8, 20); + assert.isOk(!hasScope(token.scopes, scope)); + + }); + + it(`must not tokenize a="x.(two-way)='x; x" attribute with scope "databinding.attribute.html.au"`, () => { + + // arrange + let scope = 'databinding.attribute.html.au'; + + // act + let lineToken = tokenizeLine('
'); + + // assert + let token = getTokenOnCharRange(lineToken, 8, 24); + assert.isOk(!hasScope(token.scopes, scope)); + + }); + + it(`must not tokenize a="x.(one-time)" attribute with scope "databinding.attribute.html.au"`, () => { + + // arrange + let scope = 'databinding.attribute.html.au'; + + // act + let lineToken = tokenizeLine('
'); + + // assert + let token = getTokenOnCharRange(lineToken, 8, 18); + assert.isOk(!hasScope(token.scopes, scope)); + + }); + + it(`must not tokenize a="x; x.(one-time)" attribute with scope "databinding.attribute.html.au"`, () => { + + // arrange + let scope = 'databinding.attribute.html.au'; + + // act + let lineToken = tokenizeLine('
'); + + // assert + let token = getTokenOnCharRange(lineToken, 8, 21); + assert.isOk(!hasScope(token.scopes, scope)); + + }); + + it(`must not tokenize a="x.(one-time)='\'x\; x" attribute with scope "databinding.attribute.html.au"`, () => { + + // arrange + let scope = 'databinding.attribute.html.au'; + + // act + let lineToken = tokenizeLine('
'); + + // assert + let token = getTokenOnCharRange(lineToken, 8, 25); + assert.isOk(!hasScope(token.scopes, scope)); + + }); + + it(`must not tokenize a="x.(from-view)" attribute with scope "databinding.attribute.html.au"`, () => { + + // arrange + let scope = 'databinding.attribute.html.au'; + + // act + let lineToken = tokenizeLine('
'); + + // assert + let token = getTokenOnCharRange(lineToken, 8, 19); + assert.isOk(!hasScope(token.scopes, scope)); + + }); + + it(`must not tokenize a="x; x.(from-view)" attribute with scope "databinding.attribute.html.au"`, () => { + + // arrange + let scope = 'databinding.attribute.html.au'; + + // act + let lineToken = tokenizeLine('
'); + + // assert + let token = getTokenOnCharRange(lineToken, 8, 22); + assert.isOk(!hasScope(token.scopes, scope)); + + }); + + it(`must not tokenize a="x.(from-view)='\'x\; x" attribute with scope "databinding.attribute.html.au"`, () => { + + // arrange + let scope = 'databinding.attribute.html.au'; + + // act + let lineToken = tokenizeLine('
'); + + // assert + let token = getTokenOnCharRange(lineToken, 8, 26); + assert.isOk(!hasScope(token.scopes, scope)); + + }); + + it(`must not tokenize a="x.(to-view)" attribute with scope "databinding.attribute.html.au"`, () => { + + // arrange + let scope = 'databinding.attribute.html.au'; + + // act + let lineToken = tokenizeLine('
'); + + // assert + let token = getTokenOnCharRange(lineToken, 8, 17); + assert.isOk(!hasScope(token.scopes, scope)); + + }); + + it(`must not tokenize a="x; x.(to-view)" attribute with scope "databinding.attribute.html.au"`, () => { + + // arrange + let scope = 'databinding.attribute.html.au'; + + // act + let lineToken = tokenizeLine('
'); + + // assert + let token = getTokenOnCharRange(lineToken, 8, 20); + assert.isOk(!hasScope(token.scopes, scope)); + + }); + + it(`must not tokenize a="x.(to-view)='\'x\; x" attribute with scope "databinding.attribute.html.au"`, () => { + + // arrange + let scope = 'databinding.attribute.html.au'; + + // act + let lineToken = tokenizeLine('
'); + + // assert + let token = getTokenOnCharRange(lineToken, 8, 24); + assert.isOk(!hasScope(token.scopes, scope)); + + }); + +});