Add JavaScript coloring

pull/2748/head
Alex Dima 7 years ago
parent 4b1d2982ff
commit 3979a669f3

@ -17,6 +17,7 @@ Colorization and configuration supports for multiple languages for the Monaco Ed
* html * html
* ini * ini
* java * java
* javascript
* lua * lua
* markdown * markdown
* msdax * msdax

@ -34,6 +34,7 @@ bundleOne('html/html');
bundleOne('ini/ini'); bundleOne('ini/ini');
bundleOne('pug/pug'); bundleOne('pug/pug');
bundleOne('java/java'); bundleOne('java/java');
bundleOne('javascript/javascript');
bundleOne('less/less'); bundleOne('less/less');
bundleOne('lua/lua'); bundleOne('lua/lua');
bundleOne('markdown/markdown'); bundleOne('markdown/markdown');

@ -7,7 +7,7 @@
import { testTokenization } from '../test/testRunner'; import { testTokenization } from '../test/testRunner';
testTokenization(['html', 'css'], [ testTokenization(['html', 'css', 'javascript'], [
// Open Start Tag #1' // Open Start Tag #1'
[{ [{
@ -147,7 +147,13 @@ testTokenization(['html', 'css'], [
{ startIndex: 12, type: 'delimiter.html' }, { startIndex: 12, type: 'delimiter.html' },
{ startIndex: 13, type: 'attribute.value.html' }, { startIndex: 13, type: 'attribute.value.html' },
{ startIndex: 30, type: 'delimiter.html' }, { startIndex: 30, type: 'delimiter.html' },
{ startIndex: 31, type: '' }, { startIndex: 31, type: 'keyword.js' },
{ startIndex: 34, type: '' },
{ startIndex: 35, type: 'identifier.js' },
{ startIndex: 36, type: 'delimiter.js' },
{ startIndex: 37, type: '' },
{ startIndex: 38, type: 'number.js' },
{ startIndex: 40, type: 'delimiter.js' },
{ startIndex: 41, type: 'delimiter.html' }, { startIndex: 41, type: 'delimiter.html' },
{ startIndex: 43, type: 'tag.html' }, { startIndex: 43, type: 'tag.html' },
{ startIndex: 49, type: 'delimiter.html' } { startIndex: 49, type: 'delimiter.html' }
@ -169,7 +175,13 @@ testTokenization(['html', 'css'], [
}, { }, {
line: 'var i= 10;', line: 'var i= 10;',
tokens: [ tokens: [
{ startIndex: 0, type: '' }, { startIndex: 0, type: 'keyword.js' },
{ startIndex: 3, type: '' },
{ startIndex: 4, type: 'identifier.js' },
{ startIndex: 5, type: 'delimiter.js' },
{ startIndex: 6, type: '' },
{ startIndex: 7, type: 'number.js' },
{ startIndex: 9, type: 'delimiter.js' },
] ]
}, { }, {
line: '</script>', line: '</script>',
@ -191,7 +203,14 @@ testTokenization(['html', 'css'], [
{ startIndex: 12, type: 'delimiter.html' }, { startIndex: 12, type: 'delimiter.html' },
{ startIndex: 13, type: 'attribute.value.html' }, { startIndex: 13, type: 'attribute.value.html' },
{ startIndex: 30, type: 'delimiter.html' }, { startIndex: 30, type: 'delimiter.html' },
{ startIndex: 31, type: '' }, { startIndex: 31, type: 'keyword.js' },
{ startIndex: 34, type: '' },
{ startIndex: 35, type: 'identifier.js' },
{ startIndex: 36, type: 'delimiter.js' },
{ startIndex: 37, type: '' },
{ startIndex: 38, type: 'number.js' },
{ startIndex: 40, type: 'delimiter.js' },
] ]
}, { }, {
line: '</script>', line: '</script>',
@ -217,7 +236,13 @@ testTokenization(['html', 'css'], [
}, { }, {
line: 'var i= 10;</script>', line: 'var i= 10;</script>',
tokens: [ tokens: [
{ startIndex: 0, type: '' }, { startIndex: 0, type: 'keyword.js' },
{ startIndex: 3, type: '' },
{ startIndex: 4, type: 'identifier.js' },
{ startIndex: 5, type: 'delimiter.js' },
{ startIndex: 6, type: '' },
{ startIndex: 7, type: 'number.js' },
{ startIndex: 9, type: 'delimiter.js' },
{ startIndex: 10, type: 'delimiter.html' }, { startIndex: 10, type: 'delimiter.html' },
{ startIndex: 12, type: 'tag.html' }, { startIndex: 12, type: 'tag.html' },
{ startIndex: 18, type: 'delimiter.html' } { startIndex: 18, type: 'delimiter.html' }
@ -254,14 +279,14 @@ testTokenization(['html', 'css'], [
{ startIndex: 0, type: 'delimiter.html' }, { startIndex: 0, type: 'delimiter.html' },
{ startIndex: 1, type: 'tag.html' }, { startIndex: 1, type: 'tag.html' },
{ startIndex: 7, type: 'delimiter.html' }, { startIndex: 7, type: 'delimiter.html' },
{ startIndex: 8, type: '' }, { startIndex: 8, type: 'identifier.js' },
{ startIndex: 9, type: 'delimiter.html' }, { startIndex: 9, type: 'delimiter.html' },
{ startIndex: 11, type: 'tag.html' }, { startIndex: 11, type: 'tag.html' },
{ startIndex: 17, type: 'delimiter.html' }, { startIndex: 17, type: 'delimiter.html' },
// { startIndex:18, type: 'delimiter.html' }, // { startIndex:18, type: 'delimiter.html' },
{ startIndex: 19, type: 'tag.html' }, { startIndex: 19, type: 'tag.html' },
{ startIndex: 25, type: 'delimiter.html' }, { startIndex: 25, type: 'delimiter.html' },
{ startIndex: 26, type: '' }, { startIndex: 26, type: 'identifier.js' },
{ startIndex: 27, type: 'delimiter.html' }, { startIndex: 27, type: 'delimiter.html' },
{ startIndex: 29, type: 'tag.html' }, { startIndex: 29, type: 'tag.html' },
{ startIndex: 35, type: 'delimiter.html' } { startIndex: 35, type: 'delimiter.html' }
@ -292,7 +317,13 @@ testTokenization(['html', 'css'], [
{ startIndex: 0, type: 'delimiter.html' }, { startIndex: 0, type: 'delimiter.html' },
{ startIndex: 1, type: 'tag.html' }, { startIndex: 1, type: 'tag.html' },
{ startIndex: 7, type: 'delimiter.html' }, { startIndex: 7, type: 'delimiter.html' },
{ startIndex: 8, type: '' }, { startIndex: 8, type: 'keyword.js' },
{ startIndex: 11, type: '' },
{ startIndex: 12, type: 'identifier.js' },
{ startIndex: 13, type: 'delimiter.js' },
{ startIndex: 14, type: '' },
{ startIndex: 15, type: 'number.js' },
{ startIndex: 17, type: 'delimiter.js' },
{ startIndex: 18, type: 'delimiter.html' }, { startIndex: 18, type: 'delimiter.html' },
{ startIndex: 20, type: 'tag.html' }, { startIndex: 20, type: 'tag.html' },
{ startIndex: 26, type: 'delimiter.html' } { startIndex: 26, type: 'delimiter.html' }

@ -0,0 +1,20 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';
import { registerLanguage } from '../_.contribution';
// Allow for running under nodejs/requirejs in tests
const _monaco: typeof monaco = (typeof monaco === 'undefined' ? (<any>self).monaco : monaco);
registerLanguage({
id: 'javascript',
extensions: ['.js', '.es6', '.jsx'],
firstLine: '^#!.*\\bnode',
filenames: ['jakefile'],
aliases: ['JavaScript', 'javascript', 'js'],
mimetypes: ['text/javascript'],
loader: () => _monaco.Promise.wrap(import('./javascript'))
});

@ -0,0 +1,553 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';
import { testTokenization } from '../test/testRunner';
testTokenization('javascript', [
// Keywords
[{
line: 'var x = function() { };',
tokens: [
{ startIndex: 0, type: 'keyword.js' },
{ startIndex: 3, type: '' },
{ startIndex: 4, type: 'identifier.js' },
{ startIndex: 5, type: '' },
{ startIndex: 6, type: 'delimiter.js' },
{ startIndex: 7, type: '' },
{ startIndex: 8, type: 'keyword.js' },
{ startIndex: 16, type: 'delimiter.parenthesis.js' },
{ startIndex: 18, type: '' },
{ startIndex: 19, type: 'delimiter.bracket.js' },
{ startIndex: 20, type: '' },
{ startIndex: 21, type: 'delimiter.bracket.js' },
{ startIndex: 22, type: 'delimiter.js' }
]
}],
[{
line: ' var ',
tokens: [
{ startIndex: 0, type: '' },
{ startIndex: 4, type: 'keyword.js' },
{ startIndex: 7, type: '' }
]
}],
// Comments - single line
[{
line: '//',
tokens: [
{ startIndex: 0, type: 'comment.js' }
]
}],
[{
line: ' // a comment',
tokens: [
{ startIndex: 0, type: '' },
{ startIndex: 4, type: 'comment.js' }
]
}],
[{
line: '// a comment',
tokens: [
{ startIndex: 0, type: 'comment.js' }
]
}],
[{
line: '// a comment /*',
tokens: [
{ startIndex: 0, type: 'comment.js' }
]
}],
[{
line: '// a comment /**',
tokens: [
{ startIndex: 0, type: 'comment.js' }
]
}],
[{
line: '//sticky comment',
tokens: [
{ startIndex: 0, type: 'comment.js' }
]
}],
[{
line: 'var x = 1; // my comment // is a nice one',
tokens: [
{ startIndex: 0, type: 'keyword.js' },
{ startIndex: 3, type: '' },
{ startIndex: 4, type: 'identifier.js' },
{ startIndex: 5, type: '' },
{ startIndex: 6, type: 'delimiter.js' },
{ startIndex: 7, type: '' },
{ startIndex: 8, type: 'number.js' },
{ startIndex: 9, type: 'delimiter.js' },
{ startIndex: 10, type: '' },
{ startIndex: 11, type: 'comment.js' }
]
}],
// Comments - range comment, single line
[{
line: '/* a simple comment */',
tokens: [
{ startIndex: 0, type: 'comment.js' }
]
}],
[{
line: 'var x = /* a simple comment */ 1;',
tokens: [
{ startIndex: 0, type: 'keyword.js' },
{ startIndex: 3, type: '' },
{ startIndex: 4, type: 'identifier.js' },
{ startIndex: 5, type: '' },
{ startIndex: 6, type: 'delimiter.js' },
{ startIndex: 7, type: '' },
{ startIndex: 8, type: 'comment.js' },
{ startIndex: 30, type: '' },
{ startIndex: 31, type: 'number.js' },
{ startIndex: 32, type: 'delimiter.js' }
]
}],
[{
line: 'x = /**/;',
tokens: [
{ startIndex: 0, type: 'identifier.js' },
{ startIndex: 1, type: '' },
{ startIndex: 2, type: 'delimiter.js' },
{ startIndex: 3, type: '' },
{ startIndex: 4, type: 'comment.js' },
{ startIndex: 8, type: 'delimiter.js' }
]
}],
[{
line: 'x = /*/;',
tokens: [
{ startIndex: 0, type: 'identifier.js' },
{ startIndex: 1, type: '' },
{ startIndex: 2, type: 'delimiter.js' },
{ startIndex: 3, type: '' },
{ startIndex: 4, type: 'comment.js' }
]
}],
// Comments - range comment, multi lines
[{
line: '/* a multiline comment',
tokens: [
{ startIndex: 0, type: 'comment.js' }
]
}, {
line: 'can actually span',
tokens: [
{ startIndex: 0, type: 'comment.js' }
]
}, {
line: 'multiple lines */',
tokens: [
{ startIndex: 0, type: 'comment.js' }
]
}],
[{
line: 'var x = /* start a comment',
tokens: [
{ startIndex: 0, type: 'keyword.js' },
{ startIndex: 3, type: '' },
{ startIndex: 4, type: 'identifier.js' },
{ startIndex: 5, type: '' },
{ startIndex: 6, type: 'delimiter.js' },
{ startIndex: 7, type: '' },
{ startIndex: 8, type: 'comment.js' }
]
}, {
line: ' a ',
tokens: [
{ startIndex: 0, type: 'comment.js' }
]
}, {
line: 'and end it */ var a = 2;',
tokens: [
{ startIndex: 0, type: 'comment.js' },
{ startIndex: 13, type: '' },
{ startIndex: 14, type: 'keyword.js' },
{ startIndex: 17, type: '' },
{ startIndex: 18, type: 'identifier.js' },
{ startIndex: 19, type: '' },
{ startIndex: 20, type: 'delimiter.js' },
{ startIndex: 21, type: '' },
{ startIndex: 22, type: 'number.js' },
{ startIndex: 23, type: 'delimiter.js' }
]
}],
// Strings
[{
line: 'var a = \'a\';',
tokens: [
{ startIndex: 0, type: 'keyword.js' },
{ startIndex: 3, type: '' },
{ startIndex: 4, type: 'identifier.js' },
{ startIndex: 5, type: '' },
{ startIndex: 6, type: 'delimiter.js' },
{ startIndex: 7, type: '' },
{ startIndex: 8, type: 'string.js' },
{ startIndex: 11, type: 'delimiter.js' }
]
}],
[{
line: '"use strict";',
tokens: [
{ startIndex: 0, type: 'string.js' },
{ startIndex: 12, type: 'delimiter.js' }
]
}],
[{
line: 'b = a + " \'cool\' "',
tokens: [
{ startIndex: 0, type: 'identifier.js' },
{ startIndex: 1, type: '' },
{ startIndex: 2, type: 'delimiter.js' },
{ startIndex: 3, type: '' },
{ startIndex: 4, type: 'identifier.js' },
{ startIndex: 5, type: '' },
{ startIndex: 6, type: 'delimiter.js' },
{ startIndex: 7, type: '' },
{ startIndex: 8, type: 'string.js' }
]
}],
[{
line: '"escaping \\"quotes\\" is cool"',
tokens: [
{ startIndex: 0, type: 'string.js' },
{ startIndex: 10, type: 'string.escape.js' },
{ startIndex: 12, type: 'string.js' },
{ startIndex: 18, type: 'string.escape.js' },
{ startIndex: 20, type: 'string.js' },
]
}],
[{
line: '\'\'\'',
tokens: [
{ startIndex: 0, type: 'string.js' },
{ startIndex: 2, type: 'string.invalid.js' },
]
}],
[{
line: '\'\\\'\'',
tokens: [
{ startIndex: 0, type: 'string.js' },
{ startIndex: 1, type: 'string.escape.js' },
{ startIndex: 3, type: 'string.js' },
]
}],
[{
line: '\'be careful \\not to escape\'',
tokens: [
{ startIndex: 0, type: 'string.js' },
{ startIndex: 12, type: 'string.escape.js' },
{ startIndex: 14, type: 'string.js' },
]
}],
// Numbers
[{
line: '0',
tokens: [
{ startIndex: 0, type: 'number.js' }
]
}],
[{
line: ' 0',
tokens: [
{ startIndex: 0, type: '' },
{ startIndex: 1, type: 'number.js' }
]
}],
[{
line: ' 0 ',
tokens: [
{ startIndex: 0, type: '' },
{ startIndex: 1, type: 'number.js' },
{ startIndex: 2, type: '' }
]
}],
[{
line: '0 ',
tokens: [
{ startIndex: 0, type: 'number.js' },
{ startIndex: 1, type: '' }
]
}],
[{
line: '0+0',
tokens: [
{ startIndex: 0, type: 'number.js' },
{ startIndex: 1, type: 'delimiter.js' },
{ startIndex: 2, type: 'number.js' }
]
}],
[{
line: '100+10',
tokens: [
{ startIndex: 0, type: 'number.js' },
{ startIndex: 3, type: 'delimiter.js' },
{ startIndex: 4, type: 'number.js' }
]
}],
[{
line: '0 + 0',
tokens: [
{ startIndex: 0, type: 'number.js' },
{ startIndex: 1, type: '' },
{ startIndex: 2, type: 'delimiter.js' },
{ startIndex: 3, type: '' },
{ startIndex: 4, type: 'number.js' }
]
}],
[{
line: '0123',
tokens: [
{ startIndex: 0, type: 'number.octal.js' }
]
}],
[{
line: '01239',
tokens: [
{ startIndex: 0, type: 'number.octal.js' },
{ startIndex: 4, type: 'number.js' }
]
}],
[{
line: '0x',
tokens: [
{ startIndex: 0, type: 'number.js' },
{ startIndex: 1, type: 'identifier.js' }
]
}],
[{
line: '0x123',
tokens: [
{ startIndex: 0, type: 'number.hex.js' }
]
}],
// Regular Expressions
[{
line: '//',
tokens: [
{ startIndex: 0, type: 'comment.js' }
]
}],
[{
line: '/**/',
tokens: [
{ startIndex: 0, type: 'comment.js' }
]
}],
[{
line: '/***/',
tokens: [
{ startIndex: 0, type: 'comment.doc.js' }
]
}],
[{
line: '5 / 3;',
tokens: [
{ startIndex: 0, type: 'number.js' },
{ startIndex: 1, type: '' },
{ startIndex: 2, type: 'delimiter.js' },
{ startIndex: 3, type: '' },
{ startIndex: 4, type: 'number.js' },
{ startIndex: 5, type: 'delimiter.js' }
]
}],
// Advanced regular expressions
[{
line: '1 / 2; /* comment',
tokens: [
{ startIndex: 0, type: 'number.js' },
{ startIndex: 1, type: '' },
{ startIndex: 2, type: 'delimiter.js' },
{ startIndex: 3, type: '' },
{ startIndex: 4, type: 'number.js' },
{ startIndex: 5, type: 'delimiter.js' },
{ startIndex: 6, type: '' },
{ startIndex: 7, type: 'comment.js' }
]
}],
[{
line: '1 / 2 / x / b;',
tokens: [
{ startIndex: 0, type: 'number.js' },
{ startIndex: 1, type: '' },
{ startIndex: 2, type: 'delimiter.js' },
{ startIndex: 3, type: '' },
{ startIndex: 4, type: 'number.js' },
{ startIndex: 5, type: '' },
{ startIndex: 6, type: 'delimiter.js' },
{ startIndex: 7, type: '' },
{ startIndex: 8, type: 'identifier.js' },
{ startIndex: 9, type: '' },
{ startIndex: 10, type: 'delimiter.js' },
{ startIndex: 11, type: '' },
{ startIndex: 12, type: 'identifier.js' },
{ startIndex: 13, type: 'delimiter.js' }
]
}],
[{
line: 'a /ads/ b;',
tokens: [
{ startIndex: 0, type: 'identifier.js' },
{ startIndex: 1, type: '' },
{ startIndex: 2, type: 'delimiter.js' },
{ startIndex: 3, type: 'identifier.js' },
{ startIndex: 6, type: 'delimiter.js' },
{ startIndex: 7, type: '' },
{ startIndex: 8, type: 'identifier.js' },
{ startIndex: 9, type: 'delimiter.js' }
]
}],
[{
line: '1/(2/3)/2/3;',
tokens: [
{ startIndex: 0, type: 'number.js' },
{ startIndex: 1, type: 'delimiter.js' },
{ startIndex: 2, type: 'delimiter.parenthesis.js' },
{ startIndex: 3, type: 'number.js' },
{ startIndex: 4, type: 'delimiter.js' },
{ startIndex: 5, type: 'number.js' },
{ startIndex: 6, type: 'delimiter.parenthesis.js' },
{ startIndex: 7, type: 'delimiter.js' },
{ startIndex: 8, type: 'number.js' },
{ startIndex: 9, type: 'delimiter.js' },
{ startIndex: 10, type: 'number.js' },
{ startIndex: 11, type: 'delimiter.js' }
]
}],
[{
line: '{ key: 123 }',
tokens: [
{ startIndex: 0, type: 'delimiter.bracket.js' },
{ startIndex: 1, type: '' },
{ startIndex: 2, type: 'identifier.js' },
{ startIndex: 5, type: 'delimiter.js' },
{ startIndex: 6, type: '' },
{ startIndex: 7, type: 'number.js' },
{ startIndex: 10, type: '' },
{ startIndex: 11, type: 'delimiter.bracket.js' }
]
}],
[{
line: '[1,2,3]',
tokens: [
{ startIndex: 0, type: 'delimiter.square.js' },
{ startIndex: 1, type: 'number.js' },
{ startIndex: 2, type: 'delimiter.js' },
{ startIndex: 3, type: 'number.js' },
{ startIndex: 4, type: 'delimiter.js' },
{ startIndex: 5, type: 'number.js' },
{ startIndex: 6, type: 'delimiter.square.js' }
]
}],
[{
line: 'foo(123);',
tokens: [
{ startIndex: 0, type: 'identifier.js' },
{ startIndex: 3, type: 'delimiter.parenthesis.js' },
{ startIndex: 4, type: 'number.js' },
{ startIndex: 7, type: 'delimiter.parenthesis.js' },
{ startIndex: 8, type: 'delimiter.js' }
]
}],
[{
line: '{a:{b:[]}}',
tokens: [
{ startIndex: 0, type: 'delimiter.bracket.js' },
{ startIndex: 1, type: 'identifier.js' },
{ startIndex: 2, type: 'delimiter.js' },
{ startIndex: 3, type: 'delimiter.bracket.js' },
{ startIndex: 4, type: 'identifier.js' },
{ startIndex: 5, type: 'delimiter.js' },
{ startIndex: 6, type: 'delimiter.square.js' },
{ startIndex: 8, type: 'delimiter.bracket.js' }
]
}],
[{
line: 'x = "[{()}]"',
tokens: [
{ startIndex: 0, type: 'identifier.js' },
{ startIndex: 1, type: '' },
{ startIndex: 2, type: 'delimiter.js' },
{ startIndex: 3, type: '' },
{ startIndex: 4, type: 'string.js' }
]
}],
[{
line: '`${5 + \'x\' + 3}a${4}`',
tokens: [
{ startIndex: 0, type: 'string.js' },
{ startIndex: 1, type: 'delimiter.bracket.js' },
{ startIndex: 3, type: 'number.js' },
{ startIndex: 4, type: '' },
{ startIndex: 5, type: 'delimiter.js' },
{ startIndex: 6, type: '' },
{ startIndex: 7, type: 'string.js' },
{ startIndex: 10, type: '' },
{ startIndex: 11, type: 'delimiter.js' },
{ startIndex: 12, type: '' },
{ startIndex: 13, type: 'number.js' },
{ startIndex: 14, type: 'delimiter.bracket.js' },
{ startIndex: 15, type: 'string.js' },
{ startIndex: 16, type: 'delimiter.bracket.js' },
{ startIndex: 18, type: 'number.js' },
{ startIndex: 19, type: 'delimiter.bracket.js' },
{ startIndex: 20, type: 'string.js' },
]
}]
]);

@ -0,0 +1,41 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';
import { conf as tsConf, language as tsLanguage } from '../typescript/typescript';
import IRichLanguageConfiguration = monaco.languages.LanguageConfiguration;
import ILanguage = monaco.languages.IMonarchLanguage;
// Allow for running under nodejs/requirejs in tests
const _monaco: typeof monaco = (typeof monaco === 'undefined' ? (<any>self).monaco : monaco);
export const conf: IRichLanguageConfiguration = tsConf;
export const language = <ILanguage>{
// Set defaultToken to invalid to see what you do not tokenize yet
defaultToken: 'invalid',
tokenPostfix: '.js',
keywords: [
'break', 'case', 'catch', 'class', 'continue', 'const',
'constructor', 'debugger', 'default', 'delete', 'do', 'else',
'export', 'extends', 'false', 'finally', 'for', 'from', 'function',
'get', 'if', 'import', 'in', 'instanceof', 'let', 'new', 'null',
'return', 'set', 'super', 'switch', 'symbol', 'this', 'throw', 'true',
'try', 'typeof', 'undefined', 'var', 'void', 'while', 'with', 'yield',
'async', 'await', 'of'
],
typeKeywords: [],
operators: tsLanguage.operators,
symbols: tsLanguage.symbols,
escapes: tsLanguage.escapes,
digits: tsLanguage.digits,
octaldigits: tsLanguage.octaldigits,
binarydigits: tsLanguage.binarydigits,
hexdigits: tsLanguage.hexdigits,
tokenizer: tsLanguage.tokenizer,
};

@ -7,7 +7,7 @@
import { testTokenization } from '../test/testRunner'; import { testTokenization } from '../test/testRunner';
testTokenization(['less'], [ testTokenization(['less', 'javascript'], [
// Keywords // Keywords
[{ [{
@ -641,7 +641,10 @@ testTokenization(['less'], [
{ startIndex: 5, type: 'delimiter.less' }, { startIndex: 5, type: 'delimiter.less' },
{ startIndex: 6, type: '' }, { startIndex: 6, type: '' },
{ startIndex: 7, type: 'delimiter.backtick.less' }, { startIndex: 7, type: 'delimiter.backtick.less' },
{ startIndex: 8, type: '' }, { startIndex: 8, type: 'keyword.js' },
{ startIndex: 16, type: '' },
{ startIndex: 17, type: 'identifier.js' },
{ startIndex: 24, type: 'delimiter.parenthesis.js' },
{ startIndex: 26, type: 'delimiter.backtick.less' }, { startIndex: 26, type: 'delimiter.backtick.less' },
{ startIndex: 27, type: '' }, { startIndex: 27, type: '' },
{ startIndex: 28, type: 'comment.less' } { startIndex: 28, type: 'comment.less' }

@ -17,6 +17,7 @@ import './handlebars/handlebars.contribution';
import './html/html.contribution'; import './html/html.contribution';
import './ini/ini.contribution'; import './ini/ini.contribution';
import './java/java.contribution'; import './java/java.contribution';
import './javascript/javascript.contribution';
import './less/less.contribution'; import './less/less.contribution';
import './lua/lua.contribution'; import './lua/lua.contribution';
import './markdown/markdown.contribution'; import './markdown/markdown.contribution';

@ -7,7 +7,7 @@
import { testTokenization } from '../test/testRunner'; import { testTokenization } from '../test/testRunner';
testTokenization(['php', 'css'], [ testTokenization(['php', 'css', 'javascript'], [
// Bug 13596:[ErrorTelemetry] Stream did not advance while tokenizing. Mode id is php (stuck) // Bug 13596:[ErrorTelemetry] Stream did not advance while tokenizing. Mode id is php (stuck)
// We're testing the fact that tokenize does not throw // We're testing the fact that tokenize does not throw
[ [
@ -1863,7 +1863,13 @@ testTokenization(['php', 'css'], [
// { startIndex:5, type: 'delimiter.html' }, // { startIndex:5, type: 'delimiter.html' },
{ startIndex: 6, type: 'tag.html' }, { startIndex: 6, type: 'tag.html' },
{ startIndex: 12, type: 'delimiter.html' }, { startIndex: 12, type: 'delimiter.html' },
{ startIndex: 13, type: '' }, { startIndex: 13, type: 'keyword.js' },
{ startIndex: 16, type: '' },
{ startIndex: 17, type: 'identifier.js' },
{ startIndex: 18, type: 'delimiter.js' },
{ startIndex: 19, type: '' },
{ startIndex: 20, type: 'number.js' },
{ startIndex: 22, type: 'delimiter.js' },
{ startIndex: 23, type: 'delimiter.html' }, { startIndex: 23, type: 'delimiter.html' },
{ startIndex: 25, type: 'tag.html' }, { startIndex: 25, type: 'tag.html' },
{ startIndex: 31, type: 'delimiter.html' }, { startIndex: 31, type: 'delimiter.html' },
@ -1888,7 +1894,13 @@ testTokenization(['php', 'css'], [
// { startIndex:5, type: 'delimiter.html' }, // { startIndex:5, type: 'delimiter.html' },
{ startIndex: 6, type: 'tag.html' }, { startIndex: 6, type: 'tag.html' },
{ startIndex: 12, type: 'delimiter.html' }, { startIndex: 12, type: 'delimiter.html' },
{ startIndex: 13, type: '' }, { startIndex: 13, type: 'keyword.js' },
{ startIndex: 16, type: '' },
{ startIndex: 17, type: 'identifier.js' },
{ startIndex: 18, type: 'delimiter.js' },
{ startIndex: 19, type: '' },
{ startIndex: 20, type: 'number.js' },
{ startIndex: 22, type: 'delimiter.js' },
{ startIndex: 23, type: 'delimiter.html' }, { startIndex: 23, type: 'delimiter.html' },
{ startIndex: 25, type: 'tag.html' }, { startIndex: 25, type: 'tag.html' },
{ startIndex: 31, type: 'delimiter.html' }, { startIndex: 31, type: 'delimiter.html' },
@ -1900,7 +1912,13 @@ testTokenization(['php', 'css'], [
{ startIndex: 42, type: 'delimiter.html' }, { startIndex: 42, type: 'delimiter.html' },
{ startIndex: 43, type: 'tag.html' }, { startIndex: 43, type: 'tag.html' },
{ startIndex: 49, type: 'delimiter.html' }, { startIndex: 49, type: 'delimiter.html' },
{ startIndex: 50, type: '' }, { startIndex: 50, type: 'keyword.js' },
{ startIndex: 53, type: '' },
{ startIndex: 54, type: 'identifier.js' },
{ startIndex: 55, type: 'delimiter.js' },
{ startIndex: 56, type: '' },
{ startIndex: 57, type: 'number.js' },
{ startIndex: 59, type: 'delimiter.js' },
{ startIndex: 60, type: 'delimiter.html' }, { startIndex: 60, type: 'delimiter.html' },
{ startIndex: 62, type: 'tag.html' }, { startIndex: 62, type: 'tag.html' },
{ startIndex: 68, type: 'delimiter.html' } { startIndex: 68, type: 'delimiter.html' }
@ -1969,12 +1987,28 @@ testTokenization(['php', 'css'], [
{ startIndex: 73, type: 'delimiter.html' }, { startIndex: 73, type: 'delimiter.html' },
{ startIndex: 74, type: 'tag.html' }, { startIndex: 74, type: 'tag.html' },
{ startIndex: 80, type: 'delimiter.html' }, { startIndex: 80, type: 'delimiter.html' },
{ startIndex: 81, type: '' }, { startIndex: 81, type: 'keyword.js' },
{ startIndex: 84, type: '' },
{ startIndex: 85, type: 'identifier.js' },
{ startIndex: 86, type: '' },
{ startIndex: 87, type: 'delimiter.js' },
{ startIndex: 88, type: '' },
{ startIndex: 89, type: 'number.js' },
{ startIndex: 90, type: 'delimiter.js' },
{ startIndex: 91, type: 'comment.js' },
{ startIndex: 94, type: 'metatag.php' }, { startIndex: 94, type: 'metatag.php' },
{ startIndex: 97, type: 'string.php' }, { startIndex: 97, type: 'string.php' },
{ startIndex: 109, type: 'comment.php' }, { startIndex: 109, type: 'comment.php' },
{ startIndex: 122, type: 'metatag.php' }, { startIndex: 122, type: 'metatag.php' },
{ startIndex: 124, type: '' }, { startIndex: 124, type: '' },
{ startIndex: 127, type: 'keyword.js' },
{ startIndex: 130, type: '' },
{ startIndex: 131, type: 'identifier.js' },
{ startIndex: 132, type: '' },
{ startIndex: 133, type: 'delimiter.js' },
{ startIndex: 134, type: '' },
{ startIndex: 135, type: 'number.js' },
{ startIndex: 136, type: 'delimiter.js' },
{ startIndex: 137, type: 'delimiter.html' }, { startIndex: 137, type: 'delimiter.html' },
{ startIndex: 139, type: 'tag.html' }, { startIndex: 139, type: 'tag.html' },
{ startIndex: 145, type: 'delimiter.html' }, { startIndex: 145, type: 'delimiter.html' },
@ -2010,7 +2044,7 @@ testTokenization(['php', 'css'], [
{ startIndex: 0, type: 'delimiter.html' }, { startIndex: 0, type: 'delimiter.html' },
{ startIndex: 1, type: 'tag.html' }, { startIndex: 1, type: 'tag.html' },
{ startIndex: 7, type: 'delimiter.html' }, { startIndex: 7, type: 'delimiter.html' },
{ startIndex: 8, type: '' }, { startIndex: 8, type: 'comment.js' },
{ startIndex: 10, type: 'metatag.php' } { startIndex: 10, type: 'metatag.php' }
] ]
}], }],
@ -2021,13 +2055,13 @@ testTokenization(['php', 'css'], [
{ startIndex: 0, type: 'delimiter.html' }, { startIndex: 0, type: 'delimiter.html' },
{ startIndex: 1, type: 'tag.html' }, { startIndex: 1, type: 'tag.html' },
{ startIndex: 7, type: 'delimiter.html' }, { startIndex: 7, type: 'delimiter.html' },
{ startIndex: 8, type: '' }, { startIndex: 8, type: 'string.invalid.js' },
{ startIndex: 9, type: 'metatag.php' }, { startIndex: 9, type: 'metatag.php' },
{ startIndex: 14, type: 'number.php' }, { startIndex: 14, type: 'number.php' },
{ startIndex: 15, type: 'delimiter.php' }, { startIndex: 15, type: 'delimiter.php' },
{ startIndex: 16, type: 'number.php' }, { startIndex: 16, type: 'number.php' },
{ startIndex: 17, type: 'metatag.php' }, { startIndex: 17, type: 'metatag.php' },
{ startIndex: 19, type: '' } { startIndex: 19, type: 'string.invalid.js' }
] ]
}], }],

@ -527,7 +527,7 @@ testTokenization('typescript', [
[{ [{
line: '`${5 + \'x\' + (<any>)3}`', line: '`${5 + \'x\' + (<any>)3}a${4}`',
tokens: [ tokens: [
{ startIndex: 0, type: 'string.ts' }, { startIndex: 0, type: 'string.ts' },
{ startIndex: 1, type: 'delimiter.bracket.ts' }, { startIndex: 1, type: 'delimiter.bracket.ts' },
@ -547,6 +547,10 @@ testTokenization('typescript', [
{ startIndex: 20, type: 'number.ts' }, { startIndex: 20, type: 'number.ts' },
{ startIndex: 21, type: 'delimiter.bracket.ts' }, { startIndex: 21, type: 'delimiter.bracket.ts' },
{ startIndex: 22, type: 'string.ts' }, { startIndex: 22, type: 'string.ts' },
{ startIndex: 23, type: 'delimiter.bracket.ts' },
{ startIndex: 25, type: 'number.ts' },
{ startIndex: 26, type: 'delimiter.bracket.ts' },
{ startIndex: 27, type: 'string.ts' },
] ]
}] }]

@ -67,7 +67,7 @@ export const conf: IRichLanguageConfiguration = {
} }
}; };
export const language = <ILanguage>{ export const language = {
// Set defaultToken to invalid to see what you do not tokenize yet // Set defaultToken to invalid to see what you do not tokenize yet
defaultToken: 'invalid', defaultToken: 'invalid',
tokenPostfix: '.ts', tokenPostfix: '.ts',
@ -190,7 +190,7 @@ export const language = <ILanguage>{
string_backtick: [ string_backtick: [
[/\$\{/, { token: 'delimiter.bracket', next: '@bracketCounting' }], [/\$\{/, { token: 'delimiter.bracket', next: '@bracketCounting' }],
[/[^\\`]+/, 'string'], [/[^\\`$]+/, 'string'],
[/@escapes/, 'string.escape'], [/@escapes/, 'string.escape'],
[/\\./, 'string.escape.invalid'], [/\\./, 'string.escape.invalid'],
[/`/, 'string', '@pop'] [/`/, 'string', '@pop']

@ -38,6 +38,7 @@ define(['require'], function (require) {
'release/dev/html/html.test', 'release/dev/html/html.test',
'release/dev/pug/pug.test', 'release/dev/pug/pug.test',
'release/dev/java/java.test', 'release/dev/java/java.test',
'release/dev/javascript/javascript.test',
'release/dev/less/less.test', 'release/dev/less/less.test',
'release/dev/lua/lua.test', 'release/dev/lua/lua.test',
'release/dev/markdown/markdown.test', 'release/dev/markdown/markdown.test',

Loading…
Cancel
Save