diff --git a/src/bat.ts b/src/bat.ts index 5961b001..953aab2c 100644 --- a/src/bat.ts +++ b/src/bat.ts @@ -8,7 +8,7 @@ import IRichLanguageConfiguration = monaco.languages.LanguageConfiguration; import ILanguage = monaco.languages.IMonarchLanguage; -export var conf: IRichLanguageConfiguration = { +export const conf: IRichLanguageConfiguration = { comments: { lineComment: 'REM' }, @@ -30,7 +30,7 @@ export var conf: IRichLanguageConfiguration = { ] }; -export var language = { +export const language = { defaultToken: '', ignoreCase: true, tokenPostfix: '.bat', diff --git a/src/coffee.ts b/src/coffee.ts index 30eb2925..7dc780cc 100644 --- a/src/coffee.ts +++ b/src/coffee.ts @@ -8,7 +8,7 @@ import IRichLanguageConfiguration = monaco.languages.LanguageConfiguration; import ILanguage = monaco.languages.IMonarchLanguage; -export var conf: IRichLanguageConfiguration = { +export const conf: IRichLanguageConfiguration = { wordPattern: /(-?\d*\.\d\w*)|([^\`\~\!\@\#%\^\&\*\(\)\=\$\-\+\[\{\]\}\\\|\;\:\'\"\,\.\<\>\/\?\s]+)/g, comments: { blockComment: ['###', '###'], @@ -35,7 +35,7 @@ export var conf: IRichLanguageConfiguration = { ] }; -export var language = { +export const language = { defaultToken: '', ignoreCase: true, tokenPostfix: '.coffee', diff --git a/src/cpp.ts b/src/cpp.ts index 8de851c6..9d4b2baf 100644 --- a/src/cpp.ts +++ b/src/cpp.ts @@ -8,7 +8,7 @@ import IRichLanguageConfiguration = monaco.languages.LanguageConfiguration; import ILanguage = monaco.languages.IMonarchLanguage; -export var conf: IRichLanguageConfiguration = { +export const conf: IRichLanguageConfiguration = { comments: { lineComment: '//', blockComment: ['/*', '*/'], @@ -34,7 +34,7 @@ export var conf: IRichLanguageConfiguration = { ] }; -export var language = { +export const language = { defaultToken: '', tokenPostfix: '.cpp', diff --git a/src/csharp.ts b/src/csharp.ts index 404d8feb..d07e5f5c 100644 --- a/src/csharp.ts +++ b/src/csharp.ts @@ -8,7 +8,7 @@ import IRichLanguageConfiguration = monaco.languages.LanguageConfiguration; import ILanguage = monaco.languages.IMonarchLanguage; -export var conf: IRichLanguageConfiguration = { +export const conf: IRichLanguageConfiguration = { wordPattern: /(-?\d*\.\d\w*)|([^\`\~\!\#\$\%\^\&\*\(\)\-\=\+\[\{\]\}\\\|\;\:\'\"\,\.\<\>\/\?\s]+)/g, comments: { lineComment: '//', @@ -36,7 +36,7 @@ export var conf: IRichLanguageConfiguration = { ] }; -export var language = { +export const language = { defaultToken: '', tokenPostfix: '.cs', diff --git a/src/css.ts b/src/css.ts index f3365636..f6b6c0ae 100644 --- a/src/css.ts +++ b/src/css.ts @@ -8,7 +8,7 @@ import LanguageConfiguration = monaco.languages.LanguageConfiguration; import IMonarchLanguage = monaco.languages.IMonarchLanguage; -export var conf: LanguageConfiguration = { +export const conf: LanguageConfiguration = { wordPattern: /(#?-?\d*\.\d\w*%?)|((::|[@#.!:])?[\w-?]+%?)|::|[@#.!:]/g, comments: { @@ -38,13 +38,7 @@ export var conf: LanguageConfiguration = { ] }; -const TOKEN_SELECTOR = 'tag'; -const TOKEN_SELECTOR_TAG = 'tag'; -const TOKEN_PROPERTY = 'attribute.name'; -const TOKEN_VALUE = 'attribute.value'; -const TOKEN_AT_KEYWORD = 'keyword'; - -export var language = { +export const language = { defaultToken: '', tokenPostfix: '.css', @@ -67,13 +61,13 @@ export var language = { { include: '@comments' }, { include: '@import' }, { include: '@strings' }, - ['[@](keyframes|-webkit-keyframes|-moz-keyframes|-o-keyframes)', { token: TOKEN_AT_KEYWORD, next: '@keyframedeclaration' }], - ['[@](page|content|font-face|-moz-document)', { token: TOKEN_AT_KEYWORD }], - ['[@](charset|namespace)', { token: TOKEN_AT_KEYWORD, next: '@declarationbody' }], + ['[@](keyframes|-webkit-keyframes|-moz-keyframes|-o-keyframes)', { token: 'keyword', next: '@keyframedeclaration' }], + ['[@](page|content|font-face|-moz-document)', { token: 'keyword' }], + ['[@](charset|namespace)', { token: 'keyword', next: '@declarationbody' }], ['(url-prefix)(\\()', ['attribute.value', { token: 'delimiter.parenthesis', next: '@urldeclaration' }]], ['(url)(\\()', ['attribute.value', { token: 'delimiter.parenthesis', next: '@urldeclaration' }]], { include: '@selectorname' }, - ['[\\*]', TOKEN_SELECTOR_TAG], // selector symbols + ['[\\*]', 'tag'], // selector symbols ['[>\\+,]', 'delimiter'], // selector operators ['\\[', { token: 'delimiter.bracket', next: '@selectorattribute' }], ['{', { token: 'delimiter.bracket', next: '@selectorbody' }] @@ -81,12 +75,12 @@ export var language = { selectorbody: [ { include: '@comments' }, - ['[*_]?@identifier@ws:(?=(\\s|\\d|[^{;}]*[;}]))', TOKEN_PROPERTY, '@rulevalue'], // rule definition: to distinguish from a nested selector check for whitespace, number or a semicolon + ['[*_]?@identifier@ws:(?=(\\s|\\d|[^{;}]*[;}]))', 'attribute.name', '@rulevalue'], // rule definition: to distinguish from a nested selector check for whitespace, number or a semicolon ['}', { token: 'delimiter.bracket', next: '@pop' }] ], selectorname: [ - ['(\\.|#(?=[^{])|%|(@identifier)|:)+', TOKEN_SELECTOR], // selector (.foo, div, ...) + ['(\\.|#(?=[^{])|%|(@identifier)|:)+', 'tag'], // selector (.foo, div, ...) ], selectorattribute: [ @@ -115,11 +109,11 @@ export var language = { ], warndebug: [ - ['[@](warn|debug)', { token: TOKEN_AT_KEYWORD, next: '@declarationbody' }] + ['[@](warn|debug)', { token: 'keyword', next: '@declarationbody' }] ], import: [ - ['[@](import)', { token: TOKEN_AT_KEYWORD, next: '@declarationbody' }] + ['[@](import)', { token: 'keyword', next: '@declarationbody' }] ], urldeclaration: [ @@ -151,7 +145,7 @@ export var language = { ], name: [ - ['@identifier', TOKEN_VALUE] + ['@identifier', 'attribute.value'] ], numbers: [ @@ -179,7 +173,7 @@ export var language = { ], functionarguments: [ - ['\\$@identifier@ws:', TOKEN_PROPERTY], + ['\\$@identifier@ws:', 'attribute.name'], ['[,]', 'delimiter'], { include: '@term' }, ['\\)', { token: 'attribute.value', next: '@pop' }], diff --git a/src/dockerfile.ts b/src/dockerfile.ts index c94a77c7..b8ef3af7 100644 --- a/src/dockerfile.ts +++ b/src/dockerfile.ts @@ -8,7 +8,7 @@ import IRichLanguageConfiguration = monaco.languages.LanguageConfiguration; import ILanguage = monaco.languages.IMonarchLanguage; -export var conf: IRichLanguageConfiguration = { +export const conf: IRichLanguageConfiguration = { brackets: [ ['{', '}'], ['[', ']'], @@ -30,7 +30,7 @@ export var conf: IRichLanguageConfiguration = { ] }; -export var language = { +export const language = { defaultToken: '', tokenPostfix: '.dockerfile', diff --git a/src/fsharp.ts b/src/fsharp.ts index 2114c4d3..281385b0 100644 --- a/src/fsharp.ts +++ b/src/fsharp.ts @@ -8,7 +8,7 @@ import IRichLanguageConfiguration = monaco.languages.LanguageConfiguration; import ILanguage = monaco.languages.IMonarchLanguage; -export var conf: IRichLanguageConfiguration = { +export const conf: IRichLanguageConfiguration = { comments: { lineComment: '//', blockComment: ['(*', '*)'], @@ -33,7 +33,7 @@ export var conf: IRichLanguageConfiguration = { ] }; -export var language = { +export const language = { defaultToken: '', tokenPostfix: '.fs', diff --git a/src/go.ts b/src/go.ts index 50385a36..aaac31ce 100644 --- a/src/go.ts +++ b/src/go.ts @@ -8,7 +8,7 @@ import IRichLanguageConfiguration = monaco.languages.LanguageConfiguration; import ILanguage = monaco.languages.IMonarchLanguage; -export var conf: IRichLanguageConfiguration = { +export const conf: IRichLanguageConfiguration = { comments: { lineComment: '//', blockComment: ['/*', '*/'], @@ -36,7 +36,7 @@ export var conf: IRichLanguageConfiguration = { ] }; -export var language = { +export const language = { defaultToken: '', tokenPostfix: '.go', diff --git a/src/handlebars.ts b/src/handlebars.ts index f0b4a80c..18fdcce9 100644 --- a/src/handlebars.ts +++ b/src/handlebars.ts @@ -9,11 +9,11 @@ import IRichLanguageConfiguration = monaco.languages.LanguageConfiguration; import ILanguage = monaco.languages.IMonarchLanguage; // Allow for running under nodejs/requirejs in tests -var _monaco: typeof monaco = (typeof monaco === 'undefined' ? (self).monaco : monaco); +const _monaco: typeof monaco = (typeof monaco === 'undefined' ? (self).monaco : monaco); const EMPTY_ELEMENTS: string[] = ['area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input', 'keygen', 'link', 'menuitem', 'meta', 'param', 'source', 'track', 'wbr']; -export var conf: IRichLanguageConfiguration = { +export const conf: IRichLanguageConfiguration = { wordPattern: /(-?\d*\.\d\w*)|([^\`\~\!\@\$\^\&\*\(\)\=\+\[\{\]\}\\\|\;\:\'\"\,\.\<\>\/\s]+)/g, comments: { @@ -55,17 +55,7 @@ export var conf: IRichLanguageConfiguration = { ], } -export const htmlTokenTypes = { - DELIM_START: 'delimiter.html', - DELIM_END: 'delimiter.html', - DELIM_COMMENT: 'comment.html', - COMMENT: 'comment.content.html', - getTag: (name: string) => { - return 'tag.html'; - } -}; - -export var language = { +export const language = { defaultToken: '', tokenPostfix: '', // ignoreCase: true, @@ -76,13 +66,13 @@ export var language = { [/\{\{/, { token: '@rematch', switchTo: '@handlebarsInSimpleState.root' }], [/)/, [htmlTokenTypes.DELIM_START, 'tag.html', htmlTokenTypes.DELIM_END]], - [/(<)(script)/, [htmlTokenTypes.DELIM_START, { token: 'tag.html', next: '@script' }]], - [/(<)(style)/, [htmlTokenTypes.DELIM_START, { token: 'tag.html', next: '@style' }]], - [/(<)([:\w]+)/, [htmlTokenTypes.DELIM_START, { token: 'tag.html', next: '@otherTag' }]], - [/(<\/)(\w+)/, [htmlTokenTypes.DELIM_START, { token: 'tag.html', next: '@otherTag' }]], - [/)/, ['delimiter.html', 'tag.html', 'delimiter.html']], + [/(<)(script)/, ['delimiter.html', { token: 'tag.html', next: '@script' }]], + [/(<)(style)/, ['delimiter.html', { token: 'tag.html', next: '@style' }]], + [/(<)([:\w]+)/, ['delimiter.html', { token: 'tag.html', next: '@otherTag' }]], + [/(<\/)(\w+)/, ['delimiter.html', { token: 'tag.html', next: '@otherTag' }]], + [/{ otherTag: [ [/\{\{/, { token: '@rematch', switchTo: '@handlebarsInSimpleState.otherTag' }], - [/\/?>/, htmlTokenTypes.DELIM_END, '@pop'], + [/\/?>/, 'delimiter.html', '@pop'], [/"([^"]*)"/, 'attribute.value'], [/'([^']*)'/, 'attribute.value'], [/[\w\-]+/, 'attribute.name'], @@ -119,9 +109,9 @@ export var language = { [/'([^']*)'/, 'attribute.value'], [/[\w\-]+/, 'attribute.name'], [/=/, 'delimiter'], - [/>/, { token: htmlTokenTypes.DELIM_END, next: '@scriptEmbedded.text/javascript', nextEmbedded: 'text/javascript' }], + [/>/, { token: 'delimiter.html', next: '@scriptEmbedded.text/javascript', nextEmbedded: 'text/javascript' }], [/[ \t\r\n]+/], // whitespace - [/(<\/)(script\s*)(>)/, [htmlTokenTypes.DELIM_START, 'tag.html', { token: htmlTokenTypes.DELIM_END, next: '@pop' }]] + [/(<\/)(script\s*)(>)/, ['delimiter.html', 'tag.html', { token: 'delimiter.html', next: '@pop' }]] ], // After ', tokens: [ - { startIndex: 0, type: HTML_DELIM_START }, - { startIndex: 1, type: getTag('script') }, + { startIndex: 0, type: 'delimiter.html' }, + { startIndex: 1, type: 'tag.html' }, { startIndex: 7, type: '' }, - { startIndex: 8, type: HTML_ATTRIB_NAME }, - { startIndex: 12, type: DELIM_ASSIGN }, - { startIndex: 13, type: HTML_ATTRIB_VALUE }, - { startIndex: 41, type: HTML_DELIM_END }, - { startIndex: 42, type: HTML_DELIM_START }, - { startIndex: 43, type: getTag('h1') }, - { startIndex: 45, type: HTML_DELIM_END }, - { startIndex: 46, type: handlebarsTokenTypes.EMBED }, + { startIndex: 8, type: 'attribute.name' }, + { startIndex: 12, type: 'delimiter' }, + { startIndex: 13, type: 'attribute.value' }, + { startIndex: 41, type: 'delimiter.html' }, + { startIndex: 42, type: 'delimiter.html' }, + { startIndex: 43, type: 'tag.html' }, + { startIndex: 45, type: 'delimiter.html' }, + { startIndex: 46, type: 'delimiter.handlebars' }, { startIndex: 48, type: '' }, - { startIndex: 49, type: handlebarsTokenTypes.VARIABLE }, + { startIndex: 49, type: 'variable.parameter.handlebars' }, { startIndex: 54, type: '' }, - { startIndex: 55, type: handlebarsTokenTypes.EMBED }, - { startIndex: 57, type: HTML_DELIM_START }, - { startIndex: 59, type: getTag('h1') }, - { startIndex: 61, type: HTML_DELIM_END }, - { startIndex: 62, type: HTML_DELIM_START }, - { startIndex: 64, type: getTag('script') }, - { startIndex: 70, type: HTML_DELIM_END } + { startIndex: 55, type: 'delimiter.handlebars' }, + { startIndex: 57, type: 'delimiter.html' }, + { startIndex: 59, type: 'tag.html' }, + { startIndex: 61, type: 'delimiter.html' }, + { startIndex: 62, type: 'delimiter.html' }, + { startIndex: 64, type: 'tag.html' }, + { startIndex: 70, type: 'delimiter.html' } ] }], @@ -203,35 +186,35 @@ testTokenization(['handlebars', 'css'], [ [{ line: '', tokens: [ - { startIndex: 0, type: HTML_DELIM_START }, - { startIndex: 2, type: getTag('script') }, - { startIndex: 8, type: HTML_DELIM_END } + { startIndex: 0, type: 'delimiter.html' }, + { startIndex: 2, type: 'tag.html' }, + { startIndex: 8, type: 'delimiter.html' } ] }], @@ -239,18 +222,18 @@ testTokenization(['handlebars', 'css'], [ [{ line: '{{foo}}{{bar}}', tokens: [ - { startIndex: 0, type: handlebarsTokenTypes.EMBED }, - { startIndex: 2, type: handlebarsTokenTypes.VARIABLE }, - { startIndex: 5, type: handlebarsTokenTypes.EMBED }, - { startIndex: 7, type: HTML_DELIM_START }, - { startIndex: 8, type: getTag('script') }, - { startIndex: 14, type: HTML_DELIM_END }, - // { startIndex:15, type: HTML_DELIM_START }, - { startIndex: 17, type: getTag('script') }, - { startIndex: 23, type: HTML_DELIM_END }, - { startIndex: 24, type: handlebarsTokenTypes.EMBED }, - { startIndex: 26, type: handlebarsTokenTypes.VARIABLE }, - { startIndex: 29, type: handlebarsTokenTypes.EMBED } + { startIndex: 0, type: 'delimiter.handlebars' }, + { startIndex: 2, type: 'variable.parameter.handlebars' }, + { startIndex: 5, type: 'delimiter.handlebars' }, + { startIndex: 7, type: 'delimiter.html' }, + { startIndex: 8, type: 'tag.html' }, + { startIndex: 14, type: 'delimiter.html' }, + // { startIndex:15, type: 'delimiter.html' }, + { startIndex: 17, type: 'tag.html' }, + { startIndex: 23, type: 'delimiter.html' }, + { startIndex: 24, type: 'delimiter.handlebars' }, + { startIndex: 26, type: 'variable.parameter.handlebars' }, + { startIndex: 29, type: 'delimiter.handlebars' } ] }], @@ -258,9 +241,9 @@ testTokenization(['handlebars', 'css'], [ [{ line: '{{else}}', tokens: [ - { startIndex: 0, type: handlebarsTokenTypes.EMBED }, - { startIndex: 2, type: handlebarsTokenTypes.KEYWORD }, - { startIndex: 6, type: handlebarsTokenTypes.EMBED } + { startIndex: 0, type: 'delimiter.handlebars' }, + { startIndex: 2, type: 'keyword.helper.handlebars' }, + { startIndex: 6, type: 'delimiter.handlebars' } ] }], @@ -268,9 +251,9 @@ testTokenization(['handlebars', 'css'], [ [{ line: '{{elseFoo}}', tokens: [ - { startIndex: 0, type: handlebarsTokenTypes.EMBED }, - { startIndex: 2, type: handlebarsTokenTypes.VARIABLE }, - { startIndex: 9, type: handlebarsTokenTypes.EMBED } + { startIndex: 0, type: 'delimiter.handlebars' }, + { startIndex: 2, type: 'variable.parameter.handlebars' }, + { startIndex: 9, type: 'delimiter.handlebars' } ] }], @@ -278,13 +261,13 @@ testTokenization(['handlebars', 'css'], [ [{ line: '', tokens: [ - { startIndex: 0, type: HTML_DELIM_START }, - { startIndex: 1, type: getTag('a') }, + { startIndex: 0, type: 'delimiter.html' }, + { startIndex: 1, type: 'tag.html' }, { startIndex: 2, type: '' }, - { startIndex: 3, type: HTML_ATTRIB_NAME }, - { startIndex: 7, type: DELIM_ASSIGN }, - { startIndex: 8, type: HTML_ATTRIB_VALUE }, - { startIndex: 30, type: HTML_DELIM_END } + { startIndex: 3, type: 'attribute.name' }, + { startIndex: 7, type: 'delimiter' }, + { startIndex: 8, type: 'attribute.value' }, + { startIndex: 30, type: 'delimiter.html' } ] }] ]); diff --git a/test/html.test.ts b/test/html.test.ts index aab1566c..d3c2d335 100644 --- a/test/html.test.ts +++ b/test/html.test.ts @@ -6,22 +6,6 @@ 'use strict'; import { testTokenization } from './testRunner'; -import { htmlTokenTypes } from '../src/html'; - -const DELIM_START = htmlTokenTypes.DELIM_START + '.html'; -const DELIM_END = htmlTokenTypes.DELIM_END + '.html'; -const ATTRIB_NAME = 'attribute.name.html'; -const DELIM_ASSIGN = 'delimiter.html'; -const ATTRIB_VALUE = 'attribute.value.html'; - -function getTag(name: string): string { - return htmlTokenTypes.getTag(name) + '.html'; -} - -const DELIM_COMMENT = 'comment.html'; -const COMMENT = 'comment.content.html'; -const DELIM_DOCTYPE = 'metatag.html'; -const DOCTYPE = 'metatag.content.html'; testTokenization(['html', 'css'], [ @@ -29,8 +13,8 @@ testTokenization(['html', 'css'], [ [{ line: '', tokens: [ - { startIndex: 0, type: DELIM_START }, + { startIndex: 0, type: 'delimiter.html' }, { startIndex: 1, type: '' } ] }], @@ -66,8 +50,8 @@ testTokenization(['html', 'css'], [ line: 'i ', tokens: [ - { startIndex: 0, type: DELIM_START }, - { startIndex: 1, type: getTag('abc') }, - { startIndex: 4, type: DELIM_END } + { startIndex: 0, type: 'delimiter.html' }, + { startIndex: 1, type: 'tag.html' }, + { startIndex: 4, type: 'delimiter.html' } ] }], @@ -103,10 +87,10 @@ testTokenization(['html', 'css'], [ [{ line: '', tokens: [ - { startIndex: 0, type: DELIM_START }, - { startIndex: 1, type: getTag('abc') }, + { startIndex: 0, type: 'delimiter.html' }, + { startIndex: 1, type: 'tag.html' }, { startIndex: 4, type: '' }, - { startIndex: 5, type: DELIM_END } + { startIndex: 5, type: 'delimiter.html' } ] }], @@ -114,9 +98,9 @@ testTokenization(['html', 'css'], [ [{ line: '', tokens: [ - { startIndex: 0, type: DELIM_START }, - { startIndex: 1, type: getTag('foo-bar') }, - { startIndex: 8, type: DELIM_END } + { startIndex: 0, type: 'delimiter.html' }, + { startIndex: 1, type: 'tag.html' }, + { startIndex: 8, type: 'delimiter.html' } ] }], @@ -124,9 +108,9 @@ testTokenization(['html', 'css'], [ [{ line: '', tokens: [ - { startIndex: 0, type: DELIM_START }, - { startIndex: 2, type: getTag('abc') }, - { startIndex: 5, type: DELIM_END } + { startIndex: 0, type: 'delimiter.html' }, + { startIndex: 2, type: 'tag.html' }, + { startIndex: 5, type: 'delimiter.html' } ] }], @@ -134,10 +118,10 @@ testTokenization(['html', 'css'], [ [{ line: '', tokens: [ - { startIndex: 0, type: DELIM_START }, - { startIndex: 2, type: getTag('abc') }, + { startIndex: 0, type: 'delimiter.html' }, + { startIndex: 2, type: 'tag.html' }, { startIndex: 5, type: '' }, - { startIndex: 7, type: DELIM_END } + { startIndex: 7, type: 'delimiter.html' } ] }], @@ -145,10 +129,10 @@ testTokenization(['html', 'css'], [ [{ line: '', tokens: [ - { startIndex: 0, type: DELIM_START }, - { startIndex: 1, type: getTag('abc') }, + { startIndex: 0, type: 'delimiter.html' }, + { startIndex: 1, type: 'tag.html' }, { startIndex: 4, type: '' }, - { startIndex: 5, type: DELIM_END } + { startIndex: 5, type: 'delimiter.html' } ] }], @@ -156,17 +140,17 @@ testTokenization(['html', 'css'], [ [{ line: '', tokens: [ - { startIndex: 0, type: DELIM_START }, - { startIndex: 1, type: getTag('script') }, + { startIndex: 0, type: 'delimiter.html' }, + { startIndex: 1, type: 'tag.html' }, { startIndex: 7, type: '' }, - { startIndex: 8, type: ATTRIB_NAME }, - { startIndex: 12, type: DELIM_ASSIGN }, - { startIndex: 13, type: ATTRIB_VALUE }, - { startIndex: 30, type: DELIM_END }, + { startIndex: 8, type: 'attribute.name.html' }, + { startIndex: 12, type: 'delimiter.html' }, + { startIndex: 13, type: 'attribute.value.html' }, + { startIndex: 30, type: 'delimiter.html' }, { startIndex: 31, type: '' }, - { startIndex: 41, type: DELIM_START }, - { startIndex: 43, type: getTag('script') }, - { startIndex: 49, type: DELIM_END } + { startIndex: 41, type: 'delimiter.html' }, + { startIndex: 43, type: 'tag.html' }, + { startIndex: 49, type: 'delimiter.html' } ] }], @@ -174,13 +158,13 @@ testTokenization(['html', 'css'], [ [{ line: '', tokens: [ - { startIndex: 0, type: DELIM_START }, - { startIndex: 2, type: getTag('script') }, - { startIndex: 8, type: DELIM_END } + { startIndex: 0, type: 'delimiter.html' }, + { startIndex: 2, type: 'tag.html' }, + { startIndex: 8, type: 'delimiter.html' } ] }], @@ -200,21 +184,21 @@ testTokenization(['html', 'css'], [ [{ line: '', tokens: [ - { startIndex: 0, type: DELIM_START }, - { startIndex: 2, type: getTag('script') }, - { startIndex: 8, type: DELIM_END } + { startIndex: 0, type: 'delimiter.html' }, + { startIndex: 2, type: 'tag.html' }, + { startIndex: 8, type: 'delimiter.html' } ] }], @@ -222,21 +206,21 @@ testTokenization(['html', 'css'], [ [{ line: '', tokens: [ { startIndex: 0, type: '' }, - { startIndex: 10, type: DELIM_START }, - { startIndex: 12, type: getTag('script') }, - { startIndex: 18, type: DELIM_END } + { startIndex: 10, type: 'delimiter.html' }, + { startIndex: 12, type: 'tag.html' }, + { startIndex: 18, type: 'delimiter.html' } ] }], @@ -244,22 +228,22 @@ testTokenization(['html', 'css'], [ [{ line: '', tokens: [ { startIndex: 0, type: '' }, - { startIndex: 2, type: DELIM_START }, - { startIndex: 4, type: getTag('script') }, - { startIndex: 10, type: DELIM_END } + { startIndex: 2, type: 'delimiter.html' }, + { startIndex: 4, type: 'tag.html' }, + { startIndex: 10, type: 'delimiter.html' } ] }], @@ -267,20 +251,20 @@ testTokenization(['html', 'css'], [ [{ line: '', tokens: [ - { startIndex: 0, type: DELIM_START }, - { startIndex: 1, type: getTag('script') }, - { startIndex: 7, type: DELIM_END }, + { startIndex: 0, type: 'delimiter.html' }, + { startIndex: 1, type: 'tag.html' }, + { startIndex: 7, type: 'delimiter.html' }, { startIndex: 8, type: '' }, - { startIndex: 9, type: DELIM_START }, - { startIndex: 11, type: getTag('script') }, - { startIndex: 17, type: DELIM_END }, - // { startIndex:18, type: DELIM_START }, - { startIndex: 19, type: getTag('script') }, - { startIndex: 25, type: DELIM_END }, + { startIndex: 9, type: 'delimiter.html' }, + { startIndex: 11, type: 'tag.html' }, + { startIndex: 17, type: 'delimiter.html' }, + // { startIndex:18, type: 'delimiter.html' }, + { startIndex: 19, type: 'tag.html' }, + { startIndex: 25, type: 'delimiter.html' }, { startIndex: 26, type: '' }, - { startIndex: 27, type: DELIM_START }, - { startIndex: 29, type: getTag('script') }, - { startIndex: 35, type: DELIM_END } + { startIndex: 27, type: 'delimiter.html' }, + { startIndex: 29, type: 'tag.html' }, + { startIndex: 35, type: 'delimiter.html' } ] }], @@ -288,16 +272,16 @@ testTokenization(['html', 'css'], [ [{ line: '', tokens: [ - { startIndex: 0, type: DELIM_START }, - { startIndex: 1, type: getTag('script') }, + { startIndex: 0, type: 'delimiter.html' }, + { startIndex: 1, type: 'tag.html' }, { startIndex: 7, type: '' }, - { startIndex: 8, type: ATTRIB_NAME }, - { startIndex: 12, type: DELIM_ASSIGN }, - { startIndex: 13, type: ATTRIB_VALUE }, - { startIndex: 30, type: DELIM_END }, - // { startIndex:31, type: DELIM_START }, - { startIndex: 33, type: getTag('script') }, - { startIndex: 39, type: DELIM_END } + { startIndex: 8, type: 'attribute.name.html' }, + { startIndex: 12, type: 'delimiter.html' }, + { startIndex: 13, type: 'attribute.value.html' }, + { startIndex: 30, type: 'delimiter.html' }, + // { startIndex:31, type: 'delimiter.html' }, + { startIndex: 33, type: 'tag.html' }, + { startIndex: 39, type: 'delimiter.html' } ] }], @@ -305,13 +289,13 @@ testTokenization(['html', 'css'], [ [{ line: '', tokens: [ - { startIndex: 0, type: DELIM_START }, - { startIndex: 1, type: getTag('script') }, - { startIndex: 7, type: DELIM_END }, + { startIndex: 0, type: 'delimiter.html' }, + { startIndex: 1, type: 'tag.html' }, + { startIndex: 7, type: 'delimiter.html' }, { startIndex: 8, type: '' }, - { startIndex: 18, type: DELIM_START }, - { startIndex: 20, type: getTag('script') }, - { startIndex: 26, type: DELIM_END } + { startIndex: 18, type: 'delimiter.html' }, + { startIndex: 20, type: 'tag.html' }, + { startIndex: 26, type: 'delimiter.html' } ] }], @@ -319,20 +303,20 @@ testTokenization(['html', 'css'], [ [{ line: '', tokens: [ - { startIndex: 0, type: DELIM_START }, - { startIndex: 1, type: getTag('script') }, + { startIndex: 0, type: 'delimiter.html' }, + { startIndex: 1, type: 'tag.html' }, { startIndex: 7, type: '' }, - { startIndex: 8, type: ATTRIB_NAME }, - { startIndex: 12, type: DELIM_ASSIGN }, - { startIndex: 13, type: ATTRIB_VALUE }, + { startIndex: 8, type: 'attribute.name.html' }, + { startIndex: 12, type: 'delimiter.html' }, + { startIndex: 13, type: 'attribute.value.html' }, { startIndex: 30, type: '' }, - { startIndex: 31, type: ATTRIB_NAME }, - { startIndex: 34, type: DELIM_ASSIGN }, - { startIndex: 35, type: ATTRIB_VALUE }, - { startIndex: 44, type: DELIM_END }, - // { startIndex:45, type: DELIM_START }, - { startIndex: 47, type: getTag('script') }, - { startIndex: 53, type: DELIM_END } + { startIndex: 31, type: 'attribute.name.html' }, + { startIndex: 34, type: 'delimiter.html' }, + { startIndex: 35, type: 'attribute.value.html' }, + { startIndex: 44, type: 'delimiter.html' }, + // { startIndex:45, type: 'delimiter.html' }, + { startIndex: 47, type: 'tag.html' }, + { startIndex: 53, type: 'delimiter.html' } ] }], @@ -340,13 +324,13 @@ testTokenization(['html', 'css'], [ [{ line: '', tokens: [ - { startIndex: 0, type: DELIM_START }, - { startIndex: 1, type: getTag('abc') }, + { startIndex: 0, type: 'delimiter.html' }, + { startIndex: 1, type: 'tag.html' }, { startIndex: 4, type: '' }, - { startIndex: 5, type: ATTRIB_NAME }, - { startIndex: 8, type: DELIM_ASSIGN }, - { startIndex: 9, type: ATTRIB_VALUE }, - { startIndex: 14, type: DELIM_END } + { startIndex: 5, type: 'attribute.name.html' }, + { startIndex: 8, type: 'delimiter.html' }, + { startIndex: 9, type: 'attribute.value.html' }, + { startIndex: 14, type: 'delimiter.html' } ] }], @@ -354,13 +338,13 @@ testTokenization(['html', 'css'], [ [{ line: '', tokens: [ - { startIndex: 0, type: DELIM_START }, - { startIndex: 1, type: getTag('abc') }, + { startIndex: 0, type: 'delimiter.html' }, + { startIndex: 1, type: 'tag.html' }, { startIndex: 4, type: '' }, - { startIndex: 5, type: ATTRIB_NAME }, - { startIndex: 8, type: DELIM_ASSIGN }, - { startIndex: 9, type: ATTRIB_VALUE }, - { startIndex: 14, type: DELIM_END } + { startIndex: 5, type: 'attribute.name.html' }, + { startIndex: 8, type: 'delimiter.html' }, + { startIndex: 9, type: 'attribute.value.html' }, + { startIndex: 14, type: 'delimiter.html' } ] }], @@ -368,13 +352,13 @@ testTokenization(['html', 'css'], [ [{ line: '', tokens: [ - { startIndex: 0, type: DELIM_START }, - { startIndex: 1, type: getTag('abc') }, + { startIndex: 0, type: 'delimiter.html' }, + { startIndex: 1, type: 'tag.html' }, { startIndex: 4, type: '' }, - { startIndex: 5, type: ATTRIB_NAME }, - { startIndex: 8, type: DELIM_ASSIGN }, - { startIndex: 9, type: ATTRIB_VALUE }, - { startIndex: 11, type: DELIM_END } + { startIndex: 5, type: 'attribute.name.html' }, + { startIndex: 8, type: 'delimiter.html' }, + { startIndex: 9, type: 'attribute.value.html' }, + { startIndex: 11, type: 'delimiter.html' } ] }], @@ -382,17 +366,17 @@ testTokenization(['html', 'css'], [ [{ line: '', tokens: [ - { startIndex: 0, type: DELIM_START }, - { startIndex: 1, type: getTag('abc') }, + { startIndex: 0, type: 'delimiter.html' }, + { startIndex: 1, type: 'tag.html' }, { startIndex: 4, type: '' }, - { startIndex: 5, type: ATTRIB_NAME }, - { startIndex: 8, type: DELIM_ASSIGN }, - { startIndex: 9, type: ATTRIB_VALUE }, + { startIndex: 5, type: 'attribute.name.html' }, + { startIndex: 8, type: 'delimiter.html' }, + { startIndex: 9, type: 'attribute.value.html' }, { startIndex: 14, type: '' }, - { startIndex: 15, type: ATTRIB_NAME }, - { startIndex: 18, type: DELIM_ASSIGN }, - { startIndex: 19, type: ATTRIB_VALUE }, - { startIndex: 24, type: DELIM_END } + { startIndex: 15, type: 'attribute.name.html' }, + { startIndex: 18, type: 'delimiter.html' }, + { startIndex: 19, type: 'attribute.value.html' }, + { startIndex: 24, type: 'delimiter.html' } ] }], @@ -400,17 +384,17 @@ testTokenization(['html', 'css'], [ [{ line: '', tokens: [ - { startIndex: 0, type: DELIM_START }, - { startIndex: 1, type: getTag('abc') }, + { startIndex: 0, type: 'delimiter.html' }, + { startIndex: 1, type: 'tag.html' }, { startIndex: 4, type: '' }, - { startIndex: 5, type: ATTRIB_NAME }, - { startIndex: 8, type: DELIM_ASSIGN }, - { startIndex: 9, type: ATTRIB_NAME }, // slightly incorrect + { startIndex: 5, type: 'attribute.name.html' }, + { startIndex: 8, type: 'delimiter.html' }, + { startIndex: 9, type: 'attribute.name.html' }, // slightly incorrect { startIndex: 12, type: '' }, - { startIndex: 13, type: ATTRIB_NAME }, - { startIndex: 16, type: DELIM_ASSIGN }, - { startIndex: 17, type: ATTRIB_NAME }, // slightly incorrect - { startIndex: 24, type: DELIM_END } + { startIndex: 13, type: 'attribute.name.html' }, + { startIndex: 16, type: 'delimiter.html' }, + { startIndex: 17, type: 'attribute.name.html' }, // slightly incorrect + { startIndex: 24, type: 'delimiter.html' } ] }], @@ -418,14 +402,14 @@ testTokenization(['html', 'css'], [ [{ line: '', tokens: [ - { startIndex: 0, type: DELIM_START }, - { startIndex: 1, type: getTag('abc') }, + { startIndex: 0, type: 'delimiter.html' }, + { startIndex: 1, type: 'tag.html' }, { startIndex: 4, type: '' }, - { startIndex: 5, type: ATTRIB_NAME }, - { startIndex: 8, type: DELIM_ASSIGN }, + { startIndex: 5, type: 'attribute.name.html' }, + { startIndex: 8, type: 'delimiter.html' }, { startIndex: 9, type: '' }, - { startIndex: 11, type: ATTRIB_VALUE }, - { startIndex: 16, type: DELIM_END } + { startIndex: 11, type: 'attribute.value.html' }, + { startIndex: 16, type: 'delimiter.html' } ] }], @@ -433,15 +417,15 @@ testTokenization(['html', 'css'], [ [{ line: '', tokens: [ - { startIndex: 0, type: DELIM_START }, - { startIndex: 1, type: getTag('abc') }, + { startIndex: 0, type: 'delimiter.html' }, + { startIndex: 1, type: 'tag.html' }, { startIndex: 4, type: '' }, - { startIndex: 5, type: ATTRIB_NAME }, + { startIndex: 5, type: 'attribute.name.html' }, { startIndex: 8, type: '' }, - { startIndex: 9, type: DELIM_ASSIGN }, + { startIndex: 9, type: 'delimiter.html' }, { startIndex: 10, type: '' }, - { startIndex: 11, type: ATTRIB_VALUE }, - { startIndex: 16, type: DELIM_END } + { startIndex: 11, type: 'attribute.value.html' }, + { startIndex: 16, type: 'delimiter.html' } ] }], @@ -449,11 +433,11 @@ testTokenization(['html', 'css'], [ [{ line: '', tokens: [ - { startIndex: 0, type: DELIM_START }, - { startIndex: 1, type: getTag('abc') }, + { startIndex: 0, type: 'delimiter.html' }, + { startIndex: 1, type: 'tag.html' }, { startIndex: 4, type: '' }, - { startIndex: 5, type: ATTRIB_NAME }, - { startIndex: 8, type: DELIM_END } + { startIndex: 5, type: 'attribute.name.html' }, + { startIndex: 8, type: 'delimiter.html' } ] }], @@ -461,13 +445,13 @@ testTokenization(['html', 'css'], [ [{ line: '', tokens: [ - { startIndex: 0, type: DELIM_START }, - { startIndex: 1, type: getTag('abc') }, + { startIndex: 0, type: 'delimiter.html' }, + { startIndex: 1, type: 'tag.html' }, { startIndex: 4, type: '' }, - { startIndex: 5, type: ATTRIB_NAME }, + { startIndex: 5, type: 'attribute.name.html' }, { startIndex: 8, type: '' }, - { startIndex: 9, type: ATTRIB_NAME }, - { startIndex: 12, type: DELIM_END } + { startIndex: 9, type: 'attribute.name.html' }, + { startIndex: 12, type: 'delimiter.html' } ] }], @@ -475,14 +459,14 @@ testTokenization(['html', 'css'], [ [{ line: '', tokens: [ - { startIndex: 0, type: DELIM_START }, - { startIndex: 1, type: getTag('abc') }, + { startIndex: 0, type: 'delimiter.html' }, + { startIndex: 1, type: 'tag.html' }, { startIndex: 4, type: '' }, - { startIndex: 5, type: ATTRIB_NAME }, + { startIndex: 5, type: 'attribute.name.html' }, { startIndex: 8, type: '' }, - { startIndex: 11, type: DELIM_ASSIGN }, - { startIndex: 12, type: ATTRIB_VALUE }, - { startIndex: 17, type: DELIM_END } + { startIndex: 11, type: 'delimiter.html' }, + { startIndex: 12, type: 'attribute.value.html' }, + { startIndex: 17, type: 'delimiter.html' } ] }], @@ -490,25 +474,25 @@ testTokenization(['html', 'css'], [ [{ line: '', tokens: [ - { startIndex: 0, type: DELIM_START }, - { startIndex: 1, type: getTag('abc') }, + { startIndex: 0, type: 'delimiter.html' }, + { startIndex: 1, type: 'tag.html' }, { startIndex: 4, type: '' }, - { startIndex: 6, type: ATTRIB_NAME }, + { startIndex: 6, type: 'attribute.name.html' }, { startIndex: 13, type: '' }, - { startIndex: 15, type: ATTRIB_NAME }, + { startIndex: 15, type: 'attribute.name.html' }, { startIndex: 20, type: '' }, - { startIndex: 21, type: DELIM_ASSIGN }, - { startIndex: 22, type: ATTRIB_VALUE }, + { startIndex: 21, type: 'delimiter.html' }, + { startIndex: 22, type: 'attribute.value.html' }, { startIndex: 27, type: '' }, - { startIndex: 29, type: ATTRIB_NAME }, + { startIndex: 29, type: 'attribute.name.html' }, { startIndex: 34, type: '' }, - { startIndex: 35, type: DELIM_ASSIGN }, - { startIndex: 36, type: ATTRIB_VALUE }, + { startIndex: 35, type: 'delimiter.html' }, + { startIndex: 36, type: 'attribute.value.html' }, { startIndex: 50, type: '' }, - { startIndex: 52, type: ATTRIB_NAME }, - { startIndex: 56, type: DELIM_ASSIGN }, - { startIndex: 57, type: ATTRIB_VALUE }, - { startIndex: 72, type: DELIM_END } + { startIndex: 52, type: 'attribute.name.html' }, + { startIndex: 56, type: 'delimiter.html' }, + { startIndex: 57, type: 'attribute.value.html' }, + { startIndex: 72, type: 'delimiter.html' } ] }], @@ -516,13 +500,13 @@ testTokenization(['html', 'css'], [ [{ line: '', tokens: [ - { startIndex: 0, type: DOCTYPE }, - { startIndex: 11, type: DELIM_DOCTYPE } + { startIndex: 0, type: 'metatag.content.html' }, + { startIndex: 11, type: 'metatag.html' } ] }], @@ -605,13 +589,13 @@ testTokenization(['html', 'css'], [ [{ line: 'asd', tokens: [ - { startIndex: 0, type: DELIM_START }, - { startIndex: 1, type: getTag('asdf:bar') }, - { startIndex: 9, type: DELIM_END }, + { startIndex: 0, type: 'delimiter.html' }, + { startIndex: 1, type: 'tag.html' }, + { startIndex: 9, type: 'delimiter.html' }, { startIndex: 10, type: '' }, - { startIndex: 13, type: DELIM_START }, - { startIndex: 15, type: getTag('asdf:bar') }, - { startIndex: 23, type: DELIM_END } + { startIndex: 13, type: 'delimiter.html' }, + { startIndex: 15, type: 'tag.html' }, + { startIndex: 23, type: 'delimiter.html' } ] }] ]); diff --git a/test/php.test.ts b/test/php.test.ts index 2ca76a61..72323f2e 100644 --- a/test/php.test.ts +++ b/test/php.test.ts @@ -6,7 +6,6 @@ 'use strict'; import { testTokenization } from './testRunner'; -import { htmlTokenTypes } from '../src/php'; testTokenization(['php', 'css'], [ // Bug 13596:[ErrorTelemetry] Stream did not advance while tokenizing. Mode id is php (stuck) @@ -1809,9 +1808,9 @@ testTokenization(['php', 'css'], [ { startIndex: 6, type: 'delimiter.php' }, { startIndex: 7, type: 'number.php' }, { startIndex: 8, type: 'metatag.php' }, - { startIndex: 10, type: htmlTokenTypes.DELIM_START }, - { startIndex: 11, type: htmlTokenTypes.getTag('br') }, - { startIndex: 13, type: htmlTokenTypes.DELIM_END }, + { startIndex: 10, type: 'delimiter.html' }, + { startIndex: 11, type: 'tag.html' }, + { startIndex: 13, type: 'delimiter.html' }, { startIndex: 15, type: 'metatag.php' }, { startIndex: 18, type: 'number.php' }, { startIndex: 19, type: 'metatag.php' } @@ -1827,9 +1826,9 @@ testTokenization(['php', 'css'], [ { startIndex: 6, type: 'delimiter.php' }, { startIndex: 7, type: 'number.php' }, { startIndex: 8, type: 'metatag.php' }, - { startIndex: 10, type: htmlTokenTypes.DELIM_START }, - { startIndex: 11, type: htmlTokenTypes.getTag('abc') }, - { startIndex: 14, type: htmlTokenTypes.DELIM_END }, + { startIndex: 10, type: 'delimiter.html' }, + { startIndex: 11, type: 'tag.html' }, + { startIndex: 14, type: 'delimiter.html' }, { startIndex: 15, type: 'metatag.php' }, { startIndex: 18, type: 'number.php' }, { startIndex: 19, type: 'metatag.php' } @@ -1840,17 +1839,17 @@ testTokenization(['php', 'css'], [ [{ line: '', tokens: [ - { startIndex: 0, type: htmlTokenTypes.DELIM_START }, - { startIndex: 1, type: htmlTokenTypes.getTag('abc') }, - { startIndex: 4, type: htmlTokenTypes.DELIM_END }, + { startIndex: 0, type: 'delimiter.html' }, + { startIndex: 1, type: 'tag.html' }, + { startIndex: 4, type: 'delimiter.html' }, { startIndex: 5, type: 'metatag.php' }, { startIndex: 10, type: 'number.php' }, { startIndex: 11, type: 'delimiter.php' }, { startIndex: 12, type: 'number.php' }, { startIndex: 13, type: 'metatag.php' }, - { startIndex: 15, type: htmlTokenTypes.DELIM_START }, - { startIndex: 16, type: htmlTokenTypes.getTag('abc') }, - { startIndex: 19, type: htmlTokenTypes.DELIM_END } + { startIndex: 15, type: 'delimiter.html' }, + { startIndex: 16, type: 'tag.html' }, + { startIndex: 19, type: 'delimiter.html' } ] }], @@ -1858,24 +1857,24 @@ testTokenization(['php', 'css'], [ [{ line: '', tokens: [ - { startIndex: 0, type: htmlTokenTypes.DELIM_START }, - { startIndex: 1, type: htmlTokenTypes.getTag('abc') }, - { startIndex: 4, type: htmlTokenTypes.DELIM_END }, - // { startIndex:5, type: htmlTokenTypes.DELIM_START }, - { startIndex: 6, type: htmlTokenTypes.getTag('script') }, - { startIndex: 12, type: htmlTokenTypes.DELIM_END }, + { startIndex: 0, type: 'delimiter.html' }, + { startIndex: 1, type: 'tag.html' }, + { startIndex: 4, type: 'delimiter.html' }, + // { startIndex:5, type: 'delimiter.html' }, + { startIndex: 6, type: 'tag.html' }, + { startIndex: 12, type: 'delimiter.html' }, { startIndex: 13, type: '' }, - { startIndex: 23, type: htmlTokenTypes.DELIM_START }, - { startIndex: 25, type: htmlTokenTypes.getTag('script') }, - { startIndex: 31, type: htmlTokenTypes.DELIM_END }, + { startIndex: 23, type: 'delimiter.html' }, + { startIndex: 25, type: 'tag.html' }, + { startIndex: 31, type: 'delimiter.html' }, { startIndex: 32, type: 'metatag.php' }, { startIndex: 37, type: 'number.php' }, { startIndex: 38, type: 'delimiter.php' }, { startIndex: 39, type: 'number.php' }, { startIndex: 40, type: 'metatag.php' }, - { startIndex: 42, type: htmlTokenTypes.DELIM_START }, - { startIndex: 43, type: htmlTokenTypes.getTag('abc') }, - { startIndex: 46, type: htmlTokenTypes.DELIM_END } + { startIndex: 42, type: 'delimiter.html' }, + { startIndex: 43, type: 'tag.html' }, + { startIndex: 46, type: 'delimiter.html' } ] }], @@ -1883,28 +1882,28 @@ testTokenization(['php', 'css'], [ [{ line: '', tokens: [ - { startIndex: 0, type: htmlTokenTypes.DELIM_START }, - { startIndex: 1, type: htmlTokenTypes.getTag('abc') }, - { startIndex: 4, type: htmlTokenTypes.DELIM_END }, - // { startIndex:5, type: htmlTokenTypes.DELIM_START }, - { startIndex: 6, type: htmlTokenTypes.getTag('script') }, - { startIndex: 12, type: htmlTokenTypes.DELIM_END }, + { startIndex: 0, type: 'delimiter.html' }, + { startIndex: 1, type: 'tag.html' }, + { startIndex: 4, type: 'delimiter.html' }, + // { startIndex:5, type: 'delimiter.html' }, + { startIndex: 6, type: 'tag.html' }, + { startIndex: 12, type: 'delimiter.html' }, { startIndex: 13, type: '' }, - { startIndex: 23, type: htmlTokenTypes.DELIM_START }, - { startIndex: 25, type: htmlTokenTypes.getTag('script') }, - { startIndex: 31, type: htmlTokenTypes.DELIM_END }, + { startIndex: 23, type: 'delimiter.html' }, + { startIndex: 25, type: 'tag.html' }, + { startIndex: 31, type: 'delimiter.html' }, { startIndex: 32, type: 'metatag.php' }, { startIndex: 37, type: 'number.php' }, { startIndex: 38, type: 'delimiter.php' }, { startIndex: 39, type: 'number.php' }, { startIndex: 40, type: 'metatag.php' }, - { startIndex: 42, type: htmlTokenTypes.DELIM_START }, - { startIndex: 43, type: htmlTokenTypes.getTag('script') }, - { startIndex: 49, type: htmlTokenTypes.DELIM_END }, + { startIndex: 42, type: 'delimiter.html' }, + { startIndex: 43, type: 'tag.html' }, + { startIndex: 49, type: 'delimiter.html' }, { startIndex: 50, type: '' }, - { startIndex: 60, type: htmlTokenTypes.DELIM_START }, - { startIndex: 62, type: htmlTokenTypes.getTag('script') }, - { startIndex: 68, type: htmlTokenTypes.DELIM_END } + { startIndex: 60, type: 'delimiter.html' }, + { startIndex: 62, type: 'tag.html' }, + { startIndex: 68, type: 'delimiter.html' } ] }], @@ -1912,16 +1911,16 @@ testTokenization(['php', 'css'], [ [{ line: '', tokens: [ - { startIndex: 0, type: htmlTokenTypes.DELIM_START }, - { startIndex: 1, type: htmlTokenTypes.getTag('html') }, - { startIndex: 5, type: htmlTokenTypes.DELIM_END } + { startIndex: 0, type: 'delimiter.html' }, + { startIndex: 1, type: 'tag.html' }, + { startIndex: 5, type: 'delimiter.html' } ] }, { line: '', tokens: [ - { startIndex: 0, type: htmlTokenTypes.DELIM_START }, - { startIndex: 1, type: htmlTokenTypes.getTag('style') }, - { startIndex: 6, type: htmlTokenTypes.DELIM_END }, + { startIndex: 0, type: 'delimiter.html' }, + { startIndex: 1, type: 'tag.html' }, + { startIndex: 6, type: 'delimiter.html' }, { startIndex: 7, type: 'metatag.php' }, { startIndex: 10, type: 'string.php' }, { startIndex: 15, type: 'metatag.php' }, @@ -1932,9 +1931,9 @@ testTokenization(['php', 'css'], [ { startIndex: 29, type: 'delimiter.css' }, { startIndex: 30, type: '' }, { startIndex: 31, type: 'delimiter.bracket.css' }, - { startIndex: 32, type: htmlTokenTypes.DELIM_START }, - { startIndex: 34, type: htmlTokenTypes.getTag('style') }, - { startIndex: 39, type: htmlTokenTypes.DELIM_END } + { startIndex: 32, type: 'delimiter.html' }, + { startIndex: 34, type: 'tag.html' }, + { startIndex: 39, type: 'delimiter.html' } ] }], @@ -1942,12 +1941,12 @@ testTokenization(['php', 'css'], [ [{ line: '*/?> */var y = 4;', tokens: [ - { startIndex: 0, type: htmlTokenTypes.DELIM_START }, - { startIndex: 1, type: htmlTokenTypes.getTag('html') }, - { startIndex: 5, type: htmlTokenTypes.DELIM_END }, - // { startIndex:6, type: htmlTokenTypes.DELIM_START }, - { startIndex: 7, type: htmlTokenTypes.getTag('style') }, - { startIndex: 12, type: htmlTokenTypes.DELIM_END }, + { startIndex: 0, type: 'delimiter.html' }, + { startIndex: 1, type: 'tag.html' }, + { startIndex: 5, type: 'delimiter.html' }, + // { startIndex:6, type: 'delimiter.html' }, + { startIndex: 7, type: 'tag.html' }, + { startIndex: 12, type: 'delimiter.html' }, { startIndex: 13, type: 'metatag.php' }, { startIndex: 16, type: 'string.php' }, { startIndex: 21, type: 'metatag.php' }, @@ -1959,29 +1958,29 @@ testTokenization(['php', 'css'], [ { startIndex: 36, type: 'delimiter.css' }, { startIndex: 37, type: '' }, { startIndex: 38, type: 'delimiter.bracket.css' }, - { startIndex: 39, type: htmlTokenTypes.DELIM_START }, - { startIndex: 41, type: htmlTokenTypes.getTag('style') }, - { startIndex: 46, type: htmlTokenTypes.DELIM_END }, - { startIndex: 47, type: htmlTokenTypes.DELIM_COMMENT }, + { startIndex: 39, type: 'delimiter.html' }, + { startIndex: 41, type: 'tag.html' }, + { startIndex: 46, type: 'delimiter.html' }, + { startIndex: 47, type: 'comment.html' }, { startIndex: 51, type: 'metatag.php' }, { startIndex: 54, type: 'string.php' }, { startIndex: 68, type: 'metatag.php' }, - { startIndex: 70, type: htmlTokenTypes.DELIM_COMMENT }, - { startIndex: 73, type: htmlTokenTypes.DELIM_START }, - { startIndex: 74, type: htmlTokenTypes.getTag('script') }, - { startIndex: 80, type: htmlTokenTypes.DELIM_END }, + { startIndex: 70, type: 'comment.html' }, + { startIndex: 73, type: 'delimiter.html' }, + { startIndex: 74, type: 'tag.html' }, + { startIndex: 80, type: 'delimiter.html' }, { startIndex: 81, type: '' }, { startIndex: 94, type: 'metatag.php' }, { startIndex: 97, type: 'string.php' }, { startIndex: 109, type: 'comment.php' }, { startIndex: 122, type: 'metatag.php' }, { startIndex: 124, type: '' }, - { startIndex: 137, type: htmlTokenTypes.DELIM_START }, - { startIndex: 139, type: htmlTokenTypes.getTag('script') }, - { startIndex: 145, type: htmlTokenTypes.DELIM_END }, - // { startIndex:146, type: htmlTokenTypes.DELIM_START }, - { startIndex: 148, type: htmlTokenTypes.getTag('html') }, - { startIndex: 152, type: htmlTokenTypes.DELIM_END }, + { startIndex: 137, type: 'delimiter.html' }, + { startIndex: 139, type: 'tag.html' }, + { startIndex: 145, type: 'delimiter.html' }, + // { startIndex:146, type: 'delimiter.html' }, + { startIndex: 148, type: 'tag.html' }, + { startIndex: 152, type: 'delimiter.html' }, { startIndex: 153, type: 'metatag.php' }, { startIndex: 155, type: '' }, { startIndex: 156, type: 'variable.php' }, @@ -1998,9 +1997,9 @@ testTokenization(['php', 'css'], [ [{ line: '//""', tokens: [ - { startIndex: 0, type: htmlTokenTypes.DELIM_START }, - { startIndex: 1, type: htmlTokenTypes.getTag('script') }, - { startIndex: 7, type: htmlTokenTypes.DELIM_END }, + { startIndex: 0, type: 'delimiter.html' }, + { startIndex: 1, type: 'tag.html' }, + { startIndex: 7, type: 'delimiter.html' }, { startIndex: 8, type: '' }, { startIndex: 9, type: 'metatag.php' }, { startIndex: 14, type: 'number.php' }, diff --git a/test/razor.test.ts b/test/razor.test.ts index 09005100..fc534798 100644 --- a/test/razor.test.ts +++ b/test/razor.test.ts @@ -6,9 +6,6 @@ 'use strict'; import { testTokenization } from './testRunner'; -import { htmlTokenTypes } from '../src/php'; - -const EMBED_CS = 'metatag.cs'; testTokenization('razor', [ @@ -16,22 +13,22 @@ testTokenization('razor', [ [{ line: '@{ var x; x }', tokens: [ - { startIndex: 0, type: EMBED_CS }, + { startIndex: 0, type: 'metatag.cs' }, { startIndex: 2, type: '' }, { startIndex: 3, type: 'keyword.cs' }, { startIndex: 6, type: '' }, { startIndex: 7, type: 'identifier.cs' }, { startIndex: 8, type: 'delimiter.cs' }, { startIndex: 9, type: '' }, - { startIndex: 10, type: htmlTokenTypes.DELIM_START }, - { startIndex: 11, type: htmlTokenTypes.getTag('b') }, - { startIndex: 12, type: htmlTokenTypes.DELIM_END }, + { startIndex: 10, type: 'delimiter.html' }, + { startIndex: 11, type: 'tag.html' }, + { startIndex: 12, type: 'delimiter.html' }, { startIndex: 13, type: 'identifier.cs' }, - { startIndex: 14, type: htmlTokenTypes.DELIM_START }, - { startIndex: 16, type: htmlTokenTypes.getTag('b') }, - { startIndex: 17, type: htmlTokenTypes.DELIM_END }, + { startIndex: 14, type: 'delimiter.html' }, + { startIndex: 16, type: 'tag.html' }, + { startIndex: 17, type: 'delimiter.html' }, { startIndex: 18, type: '' }, - { startIndex: 19, type: EMBED_CS } + { startIndex: 19, type: 'metatag.cs' } ] }], @@ -39,7 +36,7 @@ testTokenization('razor', [ [{ line: '@{ var x; @* comment *@ x= 0; }', tokens: [ - { startIndex: 0, type: EMBED_CS }, + { startIndex: 0, type: 'metatag.cs' }, { startIndex: 2, type: '' }, { startIndex: 3, type: 'keyword.cs' }, { startIndex: 6, type: '' }, @@ -54,7 +51,7 @@ testTokenization('razor', [ { startIndex: 27, type: 'number.cs' }, { startIndex: 28, type: 'delimiter.cs' }, { startIndex: 29, type: '' }, - { startIndex: 30, type: EMBED_CS } + { startIndex: 30, type: 'metatag.cs' } ] }], @@ -62,7 +59,7 @@ testTokenization('razor', [ [{ line: '@{ var total = 0; }', tokens: [ - { startIndex: 0, type: EMBED_CS }, + { startIndex: 0, type: 'metatag.cs' }, { startIndex: 2, type: '' }, { startIndex: 3, type: 'keyword.cs' }, { startIndex: 6, type: '' }, @@ -73,19 +70,19 @@ testTokenization('razor', [ { startIndex: 15, type: 'number.cs' }, { startIndex: 16, type: 'delimiter.cs' }, { startIndex: 17, type: '' }, - { startIndex: 18, type: EMBED_CS } + { startIndex: 18, type: 'metatag.cs' } ] }], // [{ // line: '@if(true){ var total = 0; }', // tokens: [ - // { startIndex: 0, type: EMBED_CS }, + // { startIndex: 0, type: 'metatag.cs' }, // { startIndex: 1, type: 'keyword.cs' }, // { startIndex: 3, type: 'punctuation.parenthesis.cs' }, // { startIndex: 4, type: 'keyword.cs' }, // { startIndex: 8, type: 'punctuation.parenthesis.cs' }, - // { startIndex: 9, type: EMBED_CS }, + // { startIndex: 9, type: 'metatag.cs' }, // { startIndex: 10, type: '' }, // { startIndex: 11, type: 'keyword.cs' }, // { startIndex: 14, type: '' }, @@ -96,7 +93,7 @@ testTokenization('razor', [ // { startIndex: 23, type: 'number.cs' }, // { startIndex: 24, type: 'delimiter.cs' }, // { startIndex: 25, type: '' }, - // { startIndex: 26, type: EMBED_CS } + // { startIndex: 26, type: 'metatag.cs' } // ]}], // Expressions - csharp expressions in html @@ -104,11 +101,11 @@ testTokenization('razor', [ line: 'test@xyz
', tokens: [ { startIndex: 0, type: '' }, - { startIndex: 4, type: EMBED_CS }, + { startIndex: 4, type: 'metatag.cs' }, { startIndex: 5, type: 'identifier.cs' }, - { startIndex: 8, type: htmlTokenTypes.DELIM_START }, - { startIndex: 9, type: htmlTokenTypes.getTag('br') }, - { startIndex: 11, type: htmlTokenTypes.DELIM_END } + { startIndex: 8, type: 'delimiter.html' }, + { startIndex: 9, type: 'tag.html' }, + { startIndex: 11, type: 'delimiter.html' } ] }], @@ -116,7 +113,7 @@ testTokenization('razor', [ line: 'test@xyz', tokens: [ { startIndex: 0, type: '' }, - { startIndex: 4, type: EMBED_CS }, + { startIndex: 4, type: 'metatag.cs' }, { startIndex: 5, type: 'identifier.cs' } ] }], @@ -125,7 +122,7 @@ testTokenization('razor', [ line: 'test @ xyz', tokens: [ { startIndex: 0, type: '' }, - { startIndex: 5, type: EMBED_CS }, + { startIndex: 5, type: 'metatag.cs' }, { startIndex: 6, type: 'identifier.cs' } ] }], @@ -134,9 +131,9 @@ testTokenization('razor', [ line: 'test @(foo) xyz', tokens: [ { startIndex: 0, type: '' }, - { startIndex: 5, type: EMBED_CS }, + { startIndex: 5, type: 'metatag.cs' }, { startIndex: 7, type: 'identifier.cs' }, - { startIndex: 10, type: EMBED_CS }, + { startIndex: 10, type: 'metatag.cs' }, { startIndex: 11, type: '' } ] }], @@ -145,12 +142,12 @@ testTokenization('razor', [ line: 'test @(foo(\")\")) xyz', tokens: [ { startIndex: 0, type: '' }, - { startIndex: 5, type: EMBED_CS }, + { startIndex: 5, type: 'metatag.cs' }, { startIndex: 7, type: 'identifier.cs' }, { startIndex: 10, type: 'delimiter.parenthesis.cs' }, { startIndex: 11, type: 'string.cs' }, { startIndex: 14, type: 'delimiter.parenthesis.cs' }, - { startIndex: 15, type: EMBED_CS }, + { startIndex: 15, type: 'metatag.cs' }, { startIndex: 16, type: '' } ] }], diff --git a/test/testRunner.ts b/test/testRunner.ts index ec07beec..35a860ca 100644 --- a/test/testRunner.ts +++ b/test/testRunner.ts @@ -7,7 +7,7 @@ import {loadLanguage} from '../src/monaco.contribution'; import * as assert from 'assert'; // Allow for running under nodejs/requirejs in tests -var _monaco: typeof monaco = (typeof monaco === 'undefined' ? (self).monaco : monaco); +const _monaco: typeof monaco = (typeof monaco === 'undefined' ? (self).monaco : monaco); export interface IRelaxedToken { startIndex: number;