mirror of
https://github.com/microsoft/monaco-editor.git
synced 2025-12-22 10:25:42 +01:00
Merge branch 'main' into feature/json_docsym
This commit is contained in:
commit
c38f07a36e
67 changed files with 2575 additions and 1068 deletions
|
|
@ -303,6 +303,17 @@ testTokenization('elixir', [
|
|||
]
|
||||
}
|
||||
],
|
||||
// Sigils (multi-letter uppercase)
|
||||
[
|
||||
{
|
||||
line: '~DX/foo/',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'sigil.delimiter.elixir' },
|
||||
{ startIndex: 4, type: 'sigil.elixir' },
|
||||
{ startIndex: 7, type: 'sigil.delimiter.elixir' }
|
||||
]
|
||||
}
|
||||
],
|
||||
// Sigils (no interpolation)
|
||||
[
|
||||
{
|
||||
|
|
@ -314,6 +325,17 @@ testTokenization('elixir', [
|
|||
]
|
||||
}
|
||||
],
|
||||
// Sigils (multi-letter uppercase no interpolation)
|
||||
[
|
||||
{
|
||||
line: '~WW/foo#{1}/',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'sigil.delimiter.elixir' },
|
||||
{ startIndex: 4, type: 'sigil.elixir' },
|
||||
{ startIndex: 11, type: 'sigil.delimiter.elixir' }
|
||||
]
|
||||
}
|
||||
],
|
||||
// Sigils (modifiers)
|
||||
[
|
||||
{
|
||||
|
|
@ -325,6 +347,17 @@ testTokenization('elixir', [
|
|||
]
|
||||
}
|
||||
],
|
||||
// Sigils (multi-letter uppercase with modifiers)
|
||||
[
|
||||
{
|
||||
line: '~DX/custom/az09',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'sigil.delimiter.elixir' },
|
||||
{ startIndex: 4, type: 'sigil.elixir' },
|
||||
{ startIndex: 10, type: 'sigil.delimiter.elixir' }
|
||||
]
|
||||
}
|
||||
],
|
||||
// Module attributes
|
||||
[
|
||||
{
|
||||
|
|
|
|||
|
|
@ -333,7 +333,8 @@ export const language = <languages.IMonarchLanguage>{
|
|||
|
||||
// See https://elixir-lang.org/getting-started/sigils.html
|
||||
// Sigils allow for typing values using their textual representation.
|
||||
// All sigils start with ~ followed by a letter indicating sigil type
|
||||
// All sigils start with ~ followed by a letter or
|
||||
// multi-letter uppercase starting at Elixir v1.15.0, indicating sigil type
|
||||
// and then a delimiter pair enclosing the textual representation.
|
||||
// Optional modifiers are allowed after the closing delimiter.
|
||||
// For instance a regular expressions can be written as:
|
||||
|
|
@ -353,16 +354,16 @@ export const language = <languages.IMonarchLanguage>{
|
|||
|
||||
sigils: [
|
||||
[/~[a-z]@sigilStartDelimiter/, { token: '@rematch', next: '@sigil.interpol' }],
|
||||
[/~[A-Z]@sigilStartDelimiter/, { token: '@rematch', next: '@sigil.noInterpol' }]
|
||||
[/~([A-Z]+)@sigilStartDelimiter/, { token: '@rematch', next: '@sigil.noInterpol' }]
|
||||
],
|
||||
|
||||
sigil: [
|
||||
[/~([a-zA-Z])\{/, { token: '@rematch', switchTo: '@sigilStart.$S2.$1.{.}' }],
|
||||
[/~([a-zA-Z])\[/, { token: '@rematch', switchTo: '@sigilStart.$S2.$1.[.]' }],
|
||||
[/~([a-zA-Z])\(/, { token: '@rematch', switchTo: '@sigilStart.$S2.$1.(.)' }],
|
||||
[/~([a-zA-Z])\</, { token: '@rematch', switchTo: '@sigilStart.$S2.$1.<.>' }],
|
||||
[/~([a-z]|[A-Z]+)\{/, { token: '@rematch', switchTo: '@sigilStart.$S2.$1.{.}' }],
|
||||
[/~([a-z]|[A-Z]+)\[/, { token: '@rematch', switchTo: '@sigilStart.$S2.$1.[.]' }],
|
||||
[/~([a-z]|[A-Z]+)\(/, { token: '@rematch', switchTo: '@sigilStart.$S2.$1.(.)' }],
|
||||
[/~([a-z]|[A-Z]+)\</, { token: '@rematch', switchTo: '@sigilStart.$S2.$1.<.>' }],
|
||||
[
|
||||
/~([a-zA-Z])(@sigilSymmetricDelimiter)/,
|
||||
/~([a-z]|[A-Z]+)(@sigilSymmetricDelimiter)/,
|
||||
{ token: '@rematch', switchTo: '@sigilStart.$S2.$1.$2.$2' }
|
||||
]
|
||||
],
|
||||
|
|
@ -475,7 +476,7 @@ export const language = <languages.IMonarchLanguage>{
|
|||
// Fallback to the generic sigil by default
|
||||
'sigilStart.interpol': [
|
||||
[
|
||||
/~([a-zA-Z])@sigilStartDelimiter/,
|
||||
/~([a-z]|[A-Z]+)@sigilStartDelimiter/,
|
||||
{
|
||||
token: 'sigil.delimiter',
|
||||
switchTo: '@sigilContinue.$S2.$S3.$S4.$S5'
|
||||
|
|
@ -498,7 +499,7 @@ export const language = <languages.IMonarchLanguage>{
|
|||
|
||||
'sigilStart.noInterpol': [
|
||||
[
|
||||
/~([a-zA-Z])@sigilStartDelimiter/,
|
||||
/~([a-z]|[A-Z]+)@sigilStartDelimiter/,
|
||||
{
|
||||
token: 'sigil.delimiter',
|
||||
switchTo: '@sigilContinue.$S2.$S3.$S4.$S5'
|
||||
|
|
|
|||
|
|
@ -39,6 +39,65 @@ testTokenization('javascript', [
|
|||
}
|
||||
],
|
||||
|
||||
// identifiers
|
||||
[
|
||||
{
|
||||
line: 'foo;',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'identifier.js' },
|
||||
{ startIndex: 3, type: 'delimiter.js' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[
|
||||
{
|
||||
line: 'foo() { return 1; }',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'identifier.js' },
|
||||
{ startIndex: 3, type: 'delimiter.parenthesis.js' },
|
||||
{ startIndex: 5, type: '' },
|
||||
{ startIndex: 6, type: 'delimiter.bracket.js' },
|
||||
{ startIndex: 7, type: '' },
|
||||
{ startIndex: 8, type: 'keyword.js' },
|
||||
{ startIndex: 14, type: '' },
|
||||
{ startIndex: 15, type: 'number.js' },
|
||||
{ startIndex: 16, type: 'delimiter.js' },
|
||||
{ startIndex: 17, type: '' },
|
||||
{ startIndex: 18, type: 'delimiter.bracket.js' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[
|
||||
{
|
||||
line: '#foo;',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'identifier.js' },
|
||||
{ startIndex: 4, type: 'delimiter.js' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[
|
||||
{
|
||||
line: '#foo() { return 1; }',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'identifier.js' },
|
||||
{ startIndex: 4, type: 'delimiter.parenthesis.js' },
|
||||
{ startIndex: 6, type: '' },
|
||||
{ startIndex: 7, type: 'delimiter.bracket.js' },
|
||||
{ startIndex: 8, type: '' },
|
||||
{ startIndex: 9, type: 'keyword.js' },
|
||||
{ startIndex: 15, type: '' },
|
||||
{ startIndex: 16, type: 'number.js' },
|
||||
{ startIndex: 17, type: 'delimiter.js' },
|
||||
{ startIndex: 18, type: '' },
|
||||
{ startIndex: 19, type: 'delimiter.bracket.js' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
// Comments - single line
|
||||
[
|
||||
{
|
||||
|
|
|
|||
|
|
@ -43,6 +43,7 @@ export const language = <languages.IMonarchLanguage>{
|
|||
'null',
|
||||
'return',
|
||||
'set',
|
||||
'static',
|
||||
'super',
|
||||
'switch',
|
||||
'symbol',
|
||||
|
|
|
|||
24
src/basic-languages/mdx/mdx.contribution.ts
Normal file
24
src/basic-languages/mdx/mdx.contribution.ts
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { registerLanguage } from '../_.contribution';
|
||||
|
||||
declare var AMD: any;
|
||||
declare var require: any;
|
||||
|
||||
registerLanguage({
|
||||
id: 'mdx',
|
||||
extensions: ['.mdx'],
|
||||
aliases: ['MDX', 'mdx'],
|
||||
loader: () => {
|
||||
if (AMD) {
|
||||
return new Promise((resolve, reject) => {
|
||||
require(['vs/basic-languages/mdx/mdx'], resolve, reject);
|
||||
});
|
||||
} else {
|
||||
return import('./mdx');
|
||||
}
|
||||
}
|
||||
});
|
||||
171
src/basic-languages/mdx/mdx.test.ts
Normal file
171
src/basic-languages/mdx/mdx.test.ts
Normal file
|
|
@ -0,0 +1,171 @@
|
|||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { testTokenization } from '../test/testRunner';
|
||||
|
||||
testTokenization(
|
||||
['mdx', 'yaml'],
|
||||
[
|
||||
// headers
|
||||
[
|
||||
{
|
||||
line: '# header 1',
|
||||
tokens: [{ startIndex: 0, type: 'keyword.mdx' }]
|
||||
},
|
||||
{
|
||||
line: '## header 2',
|
||||
tokens: [{ startIndex: 0, type: 'keyword.mdx' }]
|
||||
},
|
||||
{
|
||||
line: '### header 3',
|
||||
tokens: [{ startIndex: 0, type: 'keyword.mdx' }]
|
||||
},
|
||||
{
|
||||
line: '#### header 4',
|
||||
tokens: [{ startIndex: 0, type: 'keyword.mdx' }]
|
||||
},
|
||||
{
|
||||
line: '##### header 5',
|
||||
tokens: [{ startIndex: 0, type: 'keyword.mdx' }]
|
||||
},
|
||||
{
|
||||
line: '###### header 6',
|
||||
tokens: [{ startIndex: 0, type: 'keyword.mdx' }]
|
||||
}
|
||||
],
|
||||
|
||||
// Lists
|
||||
[
|
||||
{
|
||||
line: '- apple',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.mdx' },
|
||||
{ startIndex: 1, type: 'white.mdx' },
|
||||
{ startIndex: 2, type: '' }
|
||||
]
|
||||
},
|
||||
{
|
||||
line: '* pear',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.mdx' },
|
||||
{ startIndex: 1, type: 'white.mdx' },
|
||||
{ startIndex: 2, type: '' }
|
||||
]
|
||||
},
|
||||
{
|
||||
line: '+ pineapple',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.mdx' },
|
||||
{ startIndex: 1, type: 'white.mdx' },
|
||||
{ startIndex: 2, type: '' }
|
||||
]
|
||||
},
|
||||
{
|
||||
line: '1. orange',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.mdx' },
|
||||
{ startIndex: 2, type: 'white.mdx' },
|
||||
{ startIndex: 3, type: '' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
// Frontmatter
|
||||
[
|
||||
{
|
||||
line: '---',
|
||||
tokens: [{ startIndex: 0, type: 'meta.content.mdx' }]
|
||||
},
|
||||
{
|
||||
line: 'frontmatter: yaml',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'type.yaml' },
|
||||
{ startIndex: 11, type: 'operators.yaml' },
|
||||
{ startIndex: 12, type: 'white.yaml' },
|
||||
{ startIndex: 13, type: 'string.yaml' }
|
||||
]
|
||||
},
|
||||
{
|
||||
line: '---',
|
||||
tokens: [{ startIndex: 0, type: 'meta.content.mdx' }]
|
||||
}
|
||||
],
|
||||
|
||||
// links
|
||||
[
|
||||
{
|
||||
line: '[MDX](https://mdxjs.com)',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: '' },
|
||||
{ startIndex: 1, type: 'type.identifier.mdx' },
|
||||
{ startIndex: 4, type: '' },
|
||||
{ startIndex: 6, type: 'string.link.mdx' },
|
||||
{ startIndex: 23, type: '' }
|
||||
]
|
||||
},
|
||||
{
|
||||
line: '[monaco][monaco]',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: '' },
|
||||
{ startIndex: 1, type: 'type.identifier.mdx' },
|
||||
{ startIndex: 7, type: '' },
|
||||
{ startIndex: 9, type: 'type.identifier.mdx' },
|
||||
{ startIndex: 15, type: '' }
|
||||
]
|
||||
},
|
||||
{
|
||||
line: '[monaco][]',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: '' },
|
||||
{ startIndex: 1, type: 'type.identifier.mdx' },
|
||||
{ startIndex: 9, type: '' }
|
||||
]
|
||||
},
|
||||
{
|
||||
line: '[monaco]',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: '' },
|
||||
{ startIndex: 1, type: 'type.identifier.mdx' },
|
||||
{ startIndex: 7, type: '' }
|
||||
]
|
||||
},
|
||||
{
|
||||
line: '[monaco]: https://github.com/microsoft/monaco-editor',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: '' },
|
||||
{ startIndex: 1, type: 'type.identifier.mdx' },
|
||||
{ startIndex: 7, type: '' },
|
||||
{ startIndex: 10, type: 'string.link.mdx' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
// JSX
|
||||
[
|
||||
{
|
||||
line: '<div>**child**</div>',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'type.identifier.mdx' },
|
||||
// This is incorrect. MDX children that start on the same line are JSX, not markdown
|
||||
{ startIndex: 5, type: 'strong.mdx' },
|
||||
{ startIndex: 14, type: 'type.identifier.mdx' }
|
||||
]
|
||||
},
|
||||
{
|
||||
line: '{console.log("This is JavaScript")}',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'delimiter.bracket.mdx' },
|
||||
{ startIndex: 1, type: 'identifier.js' },
|
||||
{ startIndex: 8, type: 'delimiter.js' },
|
||||
{ startIndex: 9, type: 'identifier.js' },
|
||||
{ startIndex: 12, type: 'delimiter.parenthesis.js' },
|
||||
{ startIndex: 13, type: 'string.js' },
|
||||
{ startIndex: 33, type: 'delimiter.parenthesis.js' },
|
||||
{ startIndex: 34, type: 'delimiter.bracket.mdx' }
|
||||
]
|
||||
}
|
||||
]
|
||||
]
|
||||
);
|
||||
163
src/basic-languages/mdx/mdx.ts
Normal file
163
src/basic-languages/mdx/mdx.ts
Normal file
|
|
@ -0,0 +1,163 @@
|
|||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { languages } from '../../fillers/monaco-editor-core';
|
||||
|
||||
export const conf: languages.LanguageConfiguration = {
|
||||
comments: {
|
||||
blockComment: ['{/*', '*/}']
|
||||
},
|
||||
brackets: [['{', '}']],
|
||||
autoClosingPairs: [
|
||||
{ open: '"', close: '"' },
|
||||
{ open: "'", close: "'" },
|
||||
{ open: '“', close: '”' },
|
||||
{ open: '‘', close: '’' },
|
||||
{ open: '`', close: '`' },
|
||||
{ open: '{', close: '}' },
|
||||
{ open: '(', close: ')' },
|
||||
{ open: '_', close: '_' },
|
||||
{ open: '**', close: '**' },
|
||||
{ open: '<', close: '>' }
|
||||
],
|
||||
onEnterRules: [
|
||||
{
|
||||
beforeText: /^\s*- .+/,
|
||||
action: { indentAction: languages.IndentAction.None, appendText: '- ' }
|
||||
},
|
||||
{
|
||||
beforeText: /^\s*\+ .+/,
|
||||
action: { indentAction: languages.IndentAction.None, appendText: '+ ' }
|
||||
},
|
||||
{
|
||||
beforeText: /^\s*\* .+/,
|
||||
action: { indentAction: languages.IndentAction.None, appendText: '* ' }
|
||||
},
|
||||
{
|
||||
beforeText: /^> /,
|
||||
action: { indentAction: languages.IndentAction.None, appendText: '> ' }
|
||||
},
|
||||
{
|
||||
beforeText: /<\w+/,
|
||||
action: { indentAction: languages.IndentAction.Indent }
|
||||
},
|
||||
{
|
||||
beforeText: /\s+>\s*$/,
|
||||
action: { indentAction: languages.IndentAction.Indent }
|
||||
},
|
||||
{
|
||||
beforeText: /<\/\w+>/,
|
||||
action: { indentAction: languages.IndentAction.Outdent }
|
||||
},
|
||||
...Array.from({ length: 100 }, (_, index) => ({
|
||||
beforeText: new RegExp(`^${index}\\. .+`),
|
||||
action: { indentAction: languages.IndentAction.None, appendText: `${index + 1}. ` }
|
||||
}))
|
||||
]
|
||||
};
|
||||
|
||||
export const language = <languages.IMonarchLanguage>{
|
||||
defaultToken: '',
|
||||
tokenPostfix: '.mdx',
|
||||
control: /[!#()*+.[\\\]_`{}\-]/,
|
||||
escapes: /\\@control/,
|
||||
|
||||
tokenizer: {
|
||||
root: [
|
||||
[/^---$/, { token: 'meta.content', next: '@frontmatter', nextEmbedded: 'yaml' }],
|
||||
[/^\s*import/, { token: 'keyword', next: '@import', nextEmbedded: 'js' }],
|
||||
[/^\s*export/, { token: 'keyword', next: '@export', nextEmbedded: 'js' }],
|
||||
[/<\w+/, { token: 'type.identifier', next: '@jsx' }],
|
||||
[/<\/?\w+>/, 'type.identifier'],
|
||||
[
|
||||
/^(\s*)(>*\s*)(#{1,6}\s)/,
|
||||
[{ token: 'white' }, { token: 'comment' }, { token: 'keyword', next: '@header' }]
|
||||
],
|
||||
[/^(\s*)(>*\s*)([*+-])(\s+)/, ['white', 'comment', 'keyword', 'white']],
|
||||
[/^(\s*)(>*\s*)(\d{1,9}\.)(\s+)/, ['white', 'comment', 'number', 'white']],
|
||||
[/^(\s*)(>*\s*)(\d{1,9}\.)(\s+)/, ['white', 'comment', 'number', 'white']],
|
||||
[/^(\s*)(>*\s*)(-{3,}|\*{3,}|_{3,})$/, ['white', 'comment', 'keyword']],
|
||||
[/`{3,}(\s.*)?$/, { token: 'string', next: '@codeblock_backtick' }],
|
||||
[/~{3,}(\s.*)?$/, { token: 'string', next: '@codeblock_tilde' }],
|
||||
[
|
||||
/`{3,}(\S+).*$/,
|
||||
{ token: 'string', next: '@codeblock_highlight_backtick', nextEmbedded: '$1' }
|
||||
],
|
||||
[
|
||||
/~{3,}(\S+).*$/,
|
||||
{ token: 'string', next: '@codeblock_highlight_tilde', nextEmbedded: '$1' }
|
||||
],
|
||||
[/^(\s*)(-{4,})$/, ['white', 'comment']],
|
||||
[/^(\s*)(>+)/, ['white', 'comment']],
|
||||
{ include: 'content' }
|
||||
],
|
||||
content: [
|
||||
[
|
||||
/(\[)(.+)(]\()(.+)(\s+".*")(\))/,
|
||||
['', 'string.link', '', 'type.identifier', 'string.link', '']
|
||||
],
|
||||
[/(\[)(.+)(]\()(.+)(\))/, ['', 'type.identifier', '', 'string.link', '']],
|
||||
[/(\[)(.+)(]\[)(.+)(])/, ['', 'type.identifier', '', 'type.identifier', '']],
|
||||
[/(\[)(.+)(]:\s+)(\S*)/, ['', 'type.identifier', '', 'string.link']],
|
||||
[/(\[)(.+)(])/, ['', 'type.identifier', '']],
|
||||
[/`.*`/, 'variable.source'],
|
||||
[/_/, { token: 'emphasis', next: '@emphasis_underscore' }],
|
||||
[/\*(?!\*)/, { token: 'emphasis', next: '@emphasis_asterisk' }],
|
||||
[/\*\*/, { token: 'strong', next: '@strong' }],
|
||||
[/{/, { token: 'delimiter.bracket', next: '@expression', nextEmbedded: 'js' }]
|
||||
],
|
||||
import: [[/'\s*(;|$)/, { token: 'string', next: '@pop', nextEmbedded: '@pop' }]],
|
||||
expression: [
|
||||
[/{/, { token: 'delimiter.bracket', next: '@expression' }],
|
||||
[/}/, { token: 'delimiter.bracket', next: '@pop', nextEmbedded: '@pop' }]
|
||||
],
|
||||
export: [[/^\s*$/, { token: 'delimiter.bracket', next: '@pop', nextEmbedded: '@pop' }]],
|
||||
jsx: [
|
||||
[/\s+/, ''],
|
||||
[/(\w+)(=)("(?:[^"\\]|\\.)*")/, ['attribute.name', 'operator', 'string']],
|
||||
[/(\w+)(=)('(?:[^'\\]|\\.)*')/, ['attribute.name', 'operator', 'string']],
|
||||
[/(\w+(?=\s|>|={|$))/, ['attribute.name']],
|
||||
[/={/, { token: 'delimiter.bracket', next: '@expression', nextEmbedded: 'js' }],
|
||||
[/>/, { token: 'type.identifier', next: '@pop' }]
|
||||
],
|
||||
header: [
|
||||
[/.$/, { token: 'keyword', next: '@pop' }],
|
||||
{ include: 'content' },
|
||||
[/./, { token: 'keyword' }]
|
||||
],
|
||||
strong: [
|
||||
[/\*\*/, { token: 'strong', next: '@pop' }],
|
||||
{ include: 'content' },
|
||||
[/./, { token: 'strong' }]
|
||||
],
|
||||
emphasis_underscore: [
|
||||
[/_/, { token: 'emphasis', next: '@pop' }],
|
||||
{ include: 'content' },
|
||||
[/./, { token: 'emphasis' }]
|
||||
],
|
||||
emphasis_asterisk: [
|
||||
[/\*(?!\*)/, { token: 'emphasis', next: '@pop' }],
|
||||
{ include: 'content' },
|
||||
[/./, { token: 'emphasis' }]
|
||||
],
|
||||
frontmatter: [[/^---$/, { token: 'meta.content', nextEmbedded: '@pop', next: '@pop' }]],
|
||||
codeblock_highlight_backtick: [
|
||||
[/\s*`{3,}\s*$/, { token: 'string', next: '@pop', nextEmbedded: '@pop' }],
|
||||
[/.*$/, 'variable.source']
|
||||
],
|
||||
codeblock_highlight_tilde: [
|
||||
[/\s*~{3,}\s*$/, { token: 'string', next: '@pop', nextEmbedded: '@pop' }],
|
||||
[/.*$/, 'variable.source']
|
||||
],
|
||||
codeblock_backtick: [
|
||||
[/\s*`{3,}\s*$/, { token: 'string', next: '@pop' }],
|
||||
[/.*$/, 'variable.source']
|
||||
],
|
||||
codeblock_tilde: [
|
||||
[/\s*~{3,}\s*$/, { token: 'string', next: '@pop' }],
|
||||
[/.*$/, 'variable.source']
|
||||
]
|
||||
}
|
||||
};
|
||||
|
|
@ -39,6 +39,7 @@ import './lua/lua.contribution';
|
|||
import './liquid/liquid.contribution';
|
||||
import './m3/m3.contribution';
|
||||
import './markdown/markdown.contribution';
|
||||
import './mdx/mdx.contribution';
|
||||
import './mips/mips.contribution';
|
||||
import './msdax/msdax.contribution';
|
||||
import './mysql/mysql.contribution';
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ declare var require: any;
|
|||
|
||||
registerLanguage({
|
||||
id: 'st',
|
||||
extensions: ['.st', '.iecst', '.iecplc', '.lc3lib'],
|
||||
extensions: ['.st', '.iecst', '.iecplc', '.lc3lib', '.TcPOU', '.TcDUT', '.TcGVL', '.TcIO'],
|
||||
aliases: ['StructuredText', 'scl', 'stl'],
|
||||
loader: () => {
|
||||
if (AMD) {
|
||||
|
|
|
|||
|
|
@ -172,7 +172,8 @@ export const language = <languages.IMonarchLanguage>{
|
|||
'vendor',
|
||||
'common_source',
|
||||
'from',
|
||||
'extends'
|
||||
'extends',
|
||||
'implements'
|
||||
],
|
||||
|
||||
constant: ['false', 'true', 'null'],
|
||||
|
|
|
|||
|
|
@ -734,6 +734,15 @@ testTokenization(
|
|||
tokens: [{ startIndex: 0, type: 'comment.twig' }]
|
||||
}
|
||||
],
|
||||
[
|
||||
{
|
||||
line: 'test {# Hello World! #}',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: '' },
|
||||
{ startIndex: 5, type: 'comment.twig' }
|
||||
]
|
||||
}
|
||||
],
|
||||
[
|
||||
{
|
||||
line: '{#Hello World!#}',
|
||||
|
|
@ -860,6 +869,19 @@ testTokenization(
|
|||
]
|
||||
}
|
||||
],
|
||||
[
|
||||
{
|
||||
line: 'test {{ foo }}',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: '' },
|
||||
{ startIndex: 5, type: 'delimiter.twig' },
|
||||
{ startIndex: 7, type: '' },
|
||||
{ startIndex: 8, type: 'variable.twig' },
|
||||
{ startIndex: 11, type: '' },
|
||||
{ startIndex: 12, type: 'delimiter.twig' }
|
||||
]
|
||||
}
|
||||
],
|
||||
[
|
||||
{
|
||||
line: '{{ foo(42) }}',
|
||||
|
|
@ -962,6 +984,17 @@ testTokenization(
|
|||
]
|
||||
}
|
||||
],
|
||||
[
|
||||
{
|
||||
line: 'test {% %}',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: '' },
|
||||
{ startIndex: 5, type: 'delimiter.twig' },
|
||||
{ startIndex: 7, type: '' },
|
||||
{ startIndex: 8, type: 'delimiter.twig' }
|
||||
]
|
||||
}
|
||||
],
|
||||
[
|
||||
{
|
||||
line: '{% for item in navigation %}',
|
||||
|
|
|
|||
|
|
@ -104,7 +104,7 @@ export const language = <languages.IMonarchLanguage>{
|
|||
[/(<)((?:[\w\-]+:)?[\w\-]+)/, ['delimiter.html', { token: 'tag.html', next: '@otherTag' }]],
|
||||
[/(<\/)((?:[\w\-]+:)?[\w\-]+)/, ['delimiter.html', { token: 'tag.html', next: '@otherTag' }]],
|
||||
[/</, 'delimiter.html'],
|
||||
[/[^<]+/] // text
|
||||
[/[^<{]+/] // text
|
||||
],
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -39,6 +39,65 @@ testTokenization('typescript', [
|
|||
}
|
||||
],
|
||||
|
||||
// identifiers
|
||||
[
|
||||
{
|
||||
line: 'foo;',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'identifier.ts' },
|
||||
{ startIndex: 3, type: 'delimiter.ts' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[
|
||||
{
|
||||
line: 'foo() { return 1; }',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'identifier.ts' },
|
||||
{ startIndex: 3, type: 'delimiter.parenthesis.ts' },
|
||||
{ startIndex: 5, type: '' },
|
||||
{ startIndex: 6, type: 'delimiter.bracket.ts' },
|
||||
{ startIndex: 7, type: '' },
|
||||
{ startIndex: 8, type: 'keyword.ts' },
|
||||
{ startIndex: 14, type: '' },
|
||||
{ startIndex: 15, type: 'number.ts' },
|
||||
{ startIndex: 16, type: 'delimiter.ts' },
|
||||
{ startIndex: 17, type: '' },
|
||||
{ startIndex: 18, type: 'delimiter.bracket.ts' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[
|
||||
{
|
||||
line: '#foo;',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'identifier.ts' },
|
||||
{ startIndex: 4, type: 'delimiter.ts' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[
|
||||
{
|
||||
line: '#foo() { return 1; }',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'identifier.ts' },
|
||||
{ startIndex: 4, type: 'delimiter.parenthesis.ts' },
|
||||
{ startIndex: 6, type: '' },
|
||||
{ startIndex: 7, type: 'delimiter.bracket.ts' },
|
||||
{ startIndex: 8, type: '' },
|
||||
{ startIndex: 9, type: 'keyword.ts' },
|
||||
{ startIndex: 15, type: '' },
|
||||
{ startIndex: 16, type: 'number.ts' },
|
||||
{ startIndex: 17, type: 'delimiter.ts' },
|
||||
{ startIndex: 18, type: '' },
|
||||
{ startIndex: 19, type: 'delimiter.bracket.ts' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
// Comments - single line
|
||||
[
|
||||
{
|
||||
|
|
|
|||
|
|
@ -227,7 +227,7 @@ export const language = {
|
|||
common: [
|
||||
// identifiers and keywords
|
||||
[
|
||||
/[a-z_$][\w$]*/,
|
||||
/#?[a-z_$][\w$]*/,
|
||||
{
|
||||
cases: {
|
||||
'@keywords': 'keyword',
|
||||
|
|
|
|||
|
|
@ -377,7 +377,7 @@ export const language = <languages.IMonarchLanguage>{
|
|||
predeclared_intrinsics,
|
||||
operators,
|
||||
|
||||
symbols: /[!%&*+\-\.\/:;<=>^|_~]+/,
|
||||
symbols: /[!%&*+\-\.\/:;<=>^|_~,]+/,
|
||||
|
||||
tokenizer: {
|
||||
root: [
|
||||
|
|
@ -402,8 +402,6 @@ export const language = <languages.IMonarchLanguage>{
|
|||
{ include: '@commentOrSpace' },
|
||||
{ include: '@numbers' },
|
||||
|
||||
[/;:\./, 'delimiter'],
|
||||
[/,/, 'delimiter'], // Hack: Should be in previous rule
|
||||
[/[{}()\[\]]/, '@brackets'],
|
||||
['@', 'annotation', '@attribute'],
|
||||
[
|
||||
|
|
|
|||
|
|
@ -890,7 +890,7 @@ export class OutlineAdapter extends Adapter implements languages.DocumentSymbolP
|
|||
range: this._textSpanToRange(model, item.spans[0]),
|
||||
selectionRange: this._textSpanToRange(model, item.spans[0]),
|
||||
tags: [],
|
||||
children: item.childItems?.map((child) => convert(child, result.name)),
|
||||
children: item.childItems?.map((child) => convert(child, item.text)),
|
||||
containerName: containerLabel
|
||||
};
|
||||
return result;
|
||||
|
|
|
|||
|
|
@ -40937,7 +40937,7 @@ ${lanes.join("\n")}
|
|||
trace(state.host, Diagnostics.Module_name_0_matched_pattern_1, moduleName, matchedPatternText);
|
||||
}
|
||||
const resolved = forEach(paths[matchedPatternText], (subst) => {
|
||||
const path = matchedStar ? subst.replace("*", matchedStar) : subst;
|
||||
const path = matchedStar ? subst.replace("*", matchedStar) : subst; // CodeQL [SM02383] This is a false positive, the code is from the TypeScript compiler
|
||||
const candidate = normalizePath(combinePaths(baseDirectory, path));
|
||||
if (state.traceEnabled) {
|
||||
trace(state.host, Diagnostics.Trying_substitution_0_candidate_module_location_Colon_1, subst, path);
|
||||
|
|
@ -44626,7 +44626,7 @@ ${lanes.join("\n")}
|
|||
for (const { ending, value } of candidates) {
|
||||
if (value.length >= prefix.length + suffix.length && startsWith(value, prefix) && endsWith(value, suffix) && validateEnding({ ending, value })) {
|
||||
const matchedStar = value.substring(prefix.length, value.length - suffix.length);
|
||||
return key.replace("*", matchedStar);
|
||||
return key.replace("*", matchedStar); // CodeQL [SM02383] This is a false positive, the code is from the TypeScript compiler
|
||||
}
|
||||
}
|
||||
} else if (some(candidates, (c) => c.ending !== 0 /* Minimal */ && pattern === c.value) || some(candidates, (c) => c.ending === 0 /* Minimal */ && pattern === c.value && validateEnding(c))) {
|
||||
|
|
|
|||
|
|
@ -3,15 +3,17 @@
|
|||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as edworker from 'monaco-editor-core/esm/vs/editor/editor.worker';
|
||||
import { ICreateData, create } from './tsWorker';
|
||||
import { initialize } from 'monaco-editor-core/esm/vs/editor/editor.worker';
|
||||
import * as ts from './lib/typescriptServices';
|
||||
import { ICreateData, TypeScriptWorker, create } from './tsWorker';
|
||||
import { worker } from '../../fillers/monaco-editor-core';
|
||||
import { libFileMap } from './lib/lib';
|
||||
|
||||
self.onmessage = () => {
|
||||
// ignore the first message
|
||||
edworker.initialize((ctx: worker.IWorkerContext, createData: ICreateData) => {
|
||||
initialize((ctx: worker.IWorkerContext, createData: ICreateData) => {
|
||||
return create(ctx, createData);
|
||||
});
|
||||
};
|
||||
|
||||
export { create } from './tsWorker';
|
||||
export { TypeScriptWorker, create, initialize, libFileMap, ts };
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue