mirror of
https://github.com/microsoft/monaco-editor.git
synced 2025-12-22 09:20:10 +01:00
Merge branch 'main' into export-typescript-worker-members
This commit is contained in:
commit
c4e3037ed0
413 changed files with 189822 additions and 357969 deletions
|
|
@ -73,7 +73,7 @@ export function registerLanguage(def: ILang): void {
|
|||
return mod.language;
|
||||
}
|
||||
});
|
||||
languages.onLanguage(languageId, async () => {
|
||||
languages.onLanguageEncountered(languageId, async () => {
|
||||
const mod = await lazyLanguageLoader.load();
|
||||
languages.setLanguageConfiguration(languageId, mod.conf);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -197,6 +197,9 @@ export const language = <languages.IMonarchLanguage>{
|
|||
'__m256',
|
||||
'__m256d',
|
||||
'__m256i',
|
||||
'__m512',
|
||||
'__m512d',
|
||||
'__m512i',
|
||||
'__m64',
|
||||
'__multiple_inheritance',
|
||||
'__newslot',
|
||||
|
|
@ -272,7 +275,7 @@ export const language = <languages.IMonarchLanguage>{
|
|||
|
||||
// we include these common regular expressions
|
||||
symbols: /[=><!~?:&|+\-*\/\^%]+/,
|
||||
escapes: /\\(?:[abfnrtv\\"']|x[0-9A-Fa-f]{1,4}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})/,
|
||||
escapes: /\\(?:[0abfnrtv\\"']|x[0-9A-Fa-f]{1,4}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})/,
|
||||
integersuffix: /([uU](ll|LL|l|L)|(ll|LL|l|L)?[uU]?)/,
|
||||
floatsuffix: /[fFlL]?/,
|
||||
encoding: /u|u8|U|L/,
|
||||
|
|
|
|||
|
|
@ -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',
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ declare var require: any;
|
|||
|
||||
registerLanguage({
|
||||
id: 'kotlin',
|
||||
extensions: ['.kt'],
|
||||
extensions: ['.kt', '.kts'],
|
||||
aliases: ['Kotlin', 'kotlin'],
|
||||
mimetypes: ['text/x-kotlin-source', 'text/x-kotlin'],
|
||||
loader: () => {
|
||||
|
|
|
|||
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';
|
||||
|
|
@ -79,5 +80,6 @@ import './tcl/tcl.contribution';
|
|||
import './twig/twig.contribution';
|
||||
import './typescript/typescript.contribution';
|
||||
import './vb/vb.contribution';
|
||||
import './wgsl/wgsl.contribution';
|
||||
import './xml/xml.contribution';
|
||||
import './yaml/yaml.contribution';
|
||||
|
|
|
|||
|
|
@ -862,6 +862,7 @@ export const language = <languages.IMonarchLanguage>{
|
|||
[/"/, { token: 'string.double', next: '@stringDouble' }]
|
||||
],
|
||||
string: [
|
||||
[/\\'/, 'string'],
|
||||
[/[^']+/, 'string'],
|
||||
[/''/, 'string'],
|
||||
[/'/, { token: 'string', next: '@pop' }]
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ declare var require: any;
|
|||
|
||||
registerLanguage({
|
||||
id: 'perl',
|
||||
extensions: ['.pl'],
|
||||
extensions: ['.pl', '.pm'],
|
||||
aliases: ['Perl', 'pl'],
|
||||
loader: () => {
|
||||
if (AMD) {
|
||||
|
|
|
|||
|
|
@ -627,11 +627,15 @@ export const language = <languages.IMonarchLanguage>{
|
|||
'range_intersect_agg',
|
||||
'range_merge',
|
||||
'rank',
|
||||
'regexp_count',
|
||||
'regexp_instr',
|
||||
'regexp_like',
|
||||
'regexp_match',
|
||||
'regexp_matches',
|
||||
'regexp_replace',
|
||||
'regexp_split_to_array',
|
||||
'regexp_split_to_table',
|
||||
'regexp_substr',
|
||||
'regr_avgx',
|
||||
'regr_avgy',
|
||||
'regr_count',
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ declare var require: any;
|
|||
|
||||
registerLanguage({
|
||||
id: 'typescript',
|
||||
extensions: ['.ts', '.tsx'],
|
||||
extensions: ['.ts', '.tsx', '.cts', '.mts'],
|
||||
aliases: ['TypeScript', 'ts', 'typescript'],
|
||||
mimetypes: ['text/typescript'],
|
||||
loader: (): Promise<any> => {
|
||||
|
|
|
|||
|
|
@ -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
|
||||
[
|
||||
{
|
||||
|
|
|
|||
|
|
@ -137,6 +137,7 @@ export const language = {
|
|||
'require',
|
||||
'global',
|
||||
'return',
|
||||
'satisfies',
|
||||
'set',
|
||||
'static',
|
||||
'string',
|
||||
|
|
@ -226,7 +227,7 @@ export const language = {
|
|||
common: [
|
||||
// identifiers and keywords
|
||||
[
|
||||
/[a-z_$][\w$]*/,
|
||||
/#?[a-z_$][\w$]*/,
|
||||
{
|
||||
cases: {
|
||||
'@keywords': 'keyword',
|
||||
|
|
|
|||
24
src/basic-languages/wgsl/wgsl.contribution.ts
Normal file
24
src/basic-languages/wgsl/wgsl.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: 'wgsl',
|
||||
extensions: ['.wgsl'],
|
||||
aliases: ['WebGPU Shading Language', 'WGSL', 'wgsl'],
|
||||
loader: () => {
|
||||
if (AMD) {
|
||||
return new Promise((resolve, reject) => {
|
||||
require(['vs/basic-languages/wgsl/wgsl'], resolve, reject);
|
||||
});
|
||||
} else {
|
||||
return import('./wgsl');
|
||||
}
|
||||
}
|
||||
});
|
||||
3915
src/basic-languages/wgsl/wgsl.test.ts
Normal file
3915
src/basic-languages/wgsl/wgsl.test.ts
Normal file
File diff suppressed because it is too large
Load diff
485
src/basic-languages/wgsl/wgsl.ts
Normal file
485
src/basic-languages/wgsl/wgsl.ts
Normal file
|
|
@ -0,0 +1,485 @@
|
|||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation, Google LLC. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import type { languages } from '../../fillers/monaco-editor-core';
|
||||
|
||||
export const conf: languages.LanguageConfiguration = {
|
||||
comments: {
|
||||
lineComment: '//',
|
||||
blockComment: ['/*', '*/']
|
||||
},
|
||||
brackets: [
|
||||
['{', '}'],
|
||||
['[', ']'],
|
||||
['(', ')']
|
||||
],
|
||||
autoClosingPairs: [
|
||||
{ open: '[', close: ']' },
|
||||
{ open: '{', close: '}' },
|
||||
{ open: '(', close: ')' }
|
||||
],
|
||||
surroundingPairs: [
|
||||
{ open: '{', close: '}' },
|
||||
{ open: '[', close: ']' },
|
||||
{ open: '(', close: ')' }
|
||||
]
|
||||
};
|
||||
|
||||
// Returns a list of empty strings, from a possibly multi-line string,
|
||||
// stripping blanks and line endings. Emulates Perls 'qw' function.
|
||||
function qw(str: string): string[] {
|
||||
let result: string[] = [];
|
||||
const words = str.split(/\t+|\r+|\n+| +/);
|
||||
for (let i = 0; i < words.length; ++i) {
|
||||
if (words[i].length > 0) {
|
||||
result.push(words[i]);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
const atoms = qw('true false');
|
||||
|
||||
const keywords = qw(`
|
||||
alias
|
||||
break
|
||||
case
|
||||
const
|
||||
const_assert
|
||||
continue
|
||||
continuing
|
||||
default
|
||||
diagnostic
|
||||
discard
|
||||
else
|
||||
enable
|
||||
fn
|
||||
for
|
||||
if
|
||||
let
|
||||
loop
|
||||
override
|
||||
requires
|
||||
return
|
||||
struct
|
||||
switch
|
||||
var
|
||||
while
|
||||
`);
|
||||
|
||||
const reserved = qw(`
|
||||
NULL
|
||||
Self
|
||||
abstract
|
||||
active
|
||||
alignas
|
||||
alignof
|
||||
as
|
||||
asm
|
||||
asm_fragment
|
||||
async
|
||||
attribute
|
||||
auto
|
||||
await
|
||||
become
|
||||
binding_array
|
||||
cast
|
||||
catch
|
||||
class
|
||||
co_await
|
||||
co_return
|
||||
co_yield
|
||||
coherent
|
||||
column_major
|
||||
common
|
||||
compile
|
||||
compile_fragment
|
||||
concept
|
||||
const_cast
|
||||
consteval
|
||||
constexpr
|
||||
constinit
|
||||
crate
|
||||
debugger
|
||||
decltype
|
||||
delete
|
||||
demote
|
||||
demote_to_helper
|
||||
do
|
||||
dynamic_cast
|
||||
enum
|
||||
explicit
|
||||
export
|
||||
extends
|
||||
extern
|
||||
external
|
||||
fallthrough
|
||||
filter
|
||||
final
|
||||
finally
|
||||
friend
|
||||
from
|
||||
fxgroup
|
||||
get
|
||||
goto
|
||||
groupshared
|
||||
highp
|
||||
impl
|
||||
implements
|
||||
import
|
||||
inline
|
||||
instanceof
|
||||
interface
|
||||
layout
|
||||
lowp
|
||||
macro
|
||||
macro_rules
|
||||
match
|
||||
mediump
|
||||
meta
|
||||
mod
|
||||
module
|
||||
move
|
||||
mut
|
||||
mutable
|
||||
namespace
|
||||
new
|
||||
nil
|
||||
noexcept
|
||||
noinline
|
||||
nointerpolation
|
||||
noperspective
|
||||
null
|
||||
nullptr
|
||||
of
|
||||
operator
|
||||
package
|
||||
packoffset
|
||||
partition
|
||||
pass
|
||||
patch
|
||||
pixelfragment
|
||||
precise
|
||||
precision
|
||||
premerge
|
||||
priv
|
||||
protected
|
||||
pub
|
||||
public
|
||||
readonly
|
||||
ref
|
||||
regardless
|
||||
register
|
||||
reinterpret_cast
|
||||
require
|
||||
resource
|
||||
restrict
|
||||
self
|
||||
set
|
||||
shared
|
||||
sizeof
|
||||
smooth
|
||||
snorm
|
||||
static
|
||||
static_assert
|
||||
static_cast
|
||||
std
|
||||
subroutine
|
||||
super
|
||||
target
|
||||
template
|
||||
this
|
||||
thread_local
|
||||
throw
|
||||
trait
|
||||
try
|
||||
type
|
||||
typedef
|
||||
typeid
|
||||
typename
|
||||
typeof
|
||||
union
|
||||
unless
|
||||
unorm
|
||||
unsafe
|
||||
unsized
|
||||
use
|
||||
using
|
||||
varying
|
||||
virtual
|
||||
volatile
|
||||
wgsl
|
||||
where
|
||||
with
|
||||
writeonly
|
||||
yield
|
||||
`);
|
||||
|
||||
const predeclared_enums = qw(`
|
||||
read write read_write
|
||||
function private workgroup uniform storage
|
||||
perspective linear flat
|
||||
center centroid sample
|
||||
vertex_index instance_index position front_facing frag_depth
|
||||
local_invocation_id local_invocation_index
|
||||
global_invocation_id workgroup_id num_workgroups
|
||||
sample_index sample_mask
|
||||
rgba8unorm
|
||||
rgba8snorm
|
||||
rgba8uint
|
||||
rgba8sint
|
||||
rgba16uint
|
||||
rgba16sint
|
||||
rgba16float
|
||||
r32uint
|
||||
r32sint
|
||||
r32float
|
||||
rg32uint
|
||||
rg32sint
|
||||
rg32float
|
||||
rgba32uint
|
||||
rgba32sint
|
||||
rgba32float
|
||||
bgra8unorm
|
||||
`);
|
||||
|
||||
const predeclared_types = qw(`
|
||||
bool
|
||||
f16
|
||||
f32
|
||||
i32
|
||||
sampler sampler_comparison
|
||||
texture_depth_2d
|
||||
texture_depth_2d_array
|
||||
texture_depth_cube
|
||||
texture_depth_cube_array
|
||||
texture_depth_multisampled_2d
|
||||
texture_external
|
||||
texture_external
|
||||
u32
|
||||
`);
|
||||
|
||||
const predeclared_type_generators = qw(`
|
||||
array
|
||||
atomic
|
||||
mat2x2
|
||||
mat2x3
|
||||
mat2x4
|
||||
mat3x2
|
||||
mat3x3
|
||||
mat3x4
|
||||
mat4x2
|
||||
mat4x3
|
||||
mat4x4
|
||||
ptr
|
||||
texture_1d
|
||||
texture_2d
|
||||
texture_2d_array
|
||||
texture_3d
|
||||
texture_cube
|
||||
texture_cube_array
|
||||
texture_multisampled_2d
|
||||
texture_storage_1d
|
||||
texture_storage_2d
|
||||
texture_storage_2d_array
|
||||
texture_storage_3d
|
||||
vec2
|
||||
vec3
|
||||
vec4
|
||||
`);
|
||||
|
||||
const predeclared_type_aliases = qw(`
|
||||
vec2i vec3i vec4i
|
||||
vec2u vec3u vec4u
|
||||
vec2f vec3f vec4f
|
||||
vec2h vec3h vec4h
|
||||
mat2x2f mat2x3f mat2x4f
|
||||
mat3x2f mat3x3f mat3x4f
|
||||
mat4x2f mat4x3f mat4x4f
|
||||
mat2x2h mat2x3h mat2x4h
|
||||
mat3x2h mat3x3h mat3x4h
|
||||
mat4x2h mat4x3h mat4x4h
|
||||
`);
|
||||
|
||||
const predeclared_intrinsics = qw(`
|
||||
bitcast all any select arrayLength abs acos acosh asin asinh atan atanh atan2
|
||||
ceil clamp cos cosh countLeadingZeros countOneBits countTrailingZeros cross
|
||||
degrees determinant distance dot exp exp2 extractBits faceForward firstLeadingBit
|
||||
firstTrailingBit floor fma fract frexp inverseBits inverseSqrt ldexp length
|
||||
log log2 max min mix modf normalize pow quantizeToF16 radians reflect refract
|
||||
reverseBits round saturate sign sin sinh smoothstep sqrt step tan tanh transpose
|
||||
trunc dpdx dpdxCoarse dpdxFine dpdy dpdyCoarse dpdyFine fwidth fwidthCoarse fwidthFine
|
||||
textureDimensions textureGather textureGatherCompare textureLoad textureNumLayers
|
||||
textureNumLevels textureNumSamples textureSample textureSampleBias textureSampleCompare
|
||||
textureSampleCompareLevel textureSampleGrad textureSampleLevel textureSampleBaseClampToEdge
|
||||
textureStore atomicLoad atomicStore atomicAdd atomicSub atomicMax atomicMin
|
||||
atomicAnd atomicOr atomicXor atomicExchange atomicCompareExchangeWeak pack4x8snorm
|
||||
pack4x8unorm pack2x16snorm pack2x16unorm pack2x16float unpack4x8snorm unpack4x8unorm
|
||||
unpack2x16snorm unpack2x16unorm unpack2x16float storageBarrier workgroupBarrier
|
||||
workgroupUniformLoad
|
||||
`);
|
||||
|
||||
// https://gpuweb.github.io/gpuweb/wgsl/#syntactic-token
|
||||
// But skip bracket-like things, comma, colon, semicolon, underscore, at.
|
||||
const operators = qw(`
|
||||
&
|
||||
&&
|
||||
->
|
||||
/
|
||||
=
|
||||
==
|
||||
!=
|
||||
>
|
||||
>=
|
||||
<
|
||||
<=
|
||||
%
|
||||
-
|
||||
--
|
||||
+
|
||||
++
|
||||
|
|
||||
||
|
||||
*
|
||||
<<
|
||||
>>
|
||||
+=
|
||||
-=
|
||||
*=
|
||||
/=
|
||||
%=
|
||||
&=
|
||||
|=
|
||||
^=
|
||||
>>=
|
||||
<<=
|
||||
`);
|
||||
|
||||
const directive_re = /enable|requires|diagnostic/;
|
||||
|
||||
const ident_re = /[_\p{XID_Start}]\p{XID_Continue}*/u;
|
||||
|
||||
const predefined_token = 'variable.predefined';
|
||||
|
||||
export const language = <languages.IMonarchLanguage>{
|
||||
tokenPostfix: '.wgsl',
|
||||
defaultToken: 'invalid',
|
||||
unicode: true,
|
||||
|
||||
atoms,
|
||||
keywords,
|
||||
reserved,
|
||||
predeclared_enums,
|
||||
predeclared_types,
|
||||
predeclared_type_generators,
|
||||
predeclared_type_aliases,
|
||||
predeclared_intrinsics,
|
||||
operators,
|
||||
|
||||
symbols: /[!%&*+\-\.\/:;<=>^|_~,]+/,
|
||||
|
||||
tokenizer: {
|
||||
root: [
|
||||
[directive_re, 'keyword', '@directive'],
|
||||
[
|
||||
// Identifier-like things, but also include '_'
|
||||
ident_re,
|
||||
{
|
||||
cases: {
|
||||
'@atoms': predefined_token,
|
||||
'@keywords': 'keyword',
|
||||
'@reserved': 'invalid',
|
||||
'@predeclared_enums': predefined_token,
|
||||
'@predeclared_types': predefined_token,
|
||||
'@predeclared_type_generators': predefined_token,
|
||||
'@predeclared_type_aliases': predefined_token,
|
||||
'@predeclared_intrinsics': predefined_token,
|
||||
'@default': 'identifier'
|
||||
}
|
||||
}
|
||||
],
|
||||
{ include: '@commentOrSpace' },
|
||||
{ include: '@numbers' },
|
||||
|
||||
[/[{}()\[\]]/, '@brackets'],
|
||||
['@', 'annotation', '@attribute'],
|
||||
[
|
||||
/@symbols/,
|
||||
{
|
||||
cases: {
|
||||
'@operators': 'operator',
|
||||
'@default': 'delimiter'
|
||||
}
|
||||
}
|
||||
],
|
||||
[/./, 'invalid']
|
||||
],
|
||||
|
||||
commentOrSpace: [
|
||||
[/\s+/, 'white'],
|
||||
[/\/\*/, 'comment', '@blockComment'],
|
||||
[/\/\/.*$/, 'comment']
|
||||
],
|
||||
|
||||
blockComment: [
|
||||
// Soak up uninteresting text: anything except * or /
|
||||
[/[^\/*]+/, 'comment'],
|
||||
// Recognize the start of a nested block comment.
|
||||
[/\/\*/, 'comment', '@push'],
|
||||
// Recognize the end of a nested block comment.
|
||||
[/\*\//, 'comment', '@pop'],
|
||||
// Recognize insignificant * and /
|
||||
[/[\/*]/, 'comment']
|
||||
],
|
||||
|
||||
attribute: [
|
||||
// For things like '@fragment' both '@' and 'fragment'
|
||||
// are marked as annotations. This should work even if
|
||||
// there are spaces or comments between the two tokens.
|
||||
{ include: '@commentOrSpace' },
|
||||
[/\w+/, 'annotation', '@pop']
|
||||
],
|
||||
|
||||
directive: [
|
||||
// For things like 'enable f16;', 'enable' maps to 'meta'
|
||||
// and 'f16' maps to 'meta.tag'.
|
||||
{ include: '@commentOrSpace' },
|
||||
[/[()]/, '@brackets'],
|
||||
[/,/, 'delimiter'],
|
||||
[ident_re, 'meta.content'],
|
||||
[/;/, 'delimiter', '@pop']
|
||||
],
|
||||
|
||||
numbers: [
|
||||
// Decimal float literals
|
||||
// https://www.w3.org/TR/WGSL/#syntax-decimal_float_literal
|
||||
// 0, with type-specifying suffix.
|
||||
[/0[fh]/, 'number.float'],
|
||||
// Other decimal integer, with type-specifying suffix.
|
||||
[/[1-9][0-9]*[fh]/, 'number.float'],
|
||||
// Has decimal point, at least one digit after decimal.
|
||||
[/[0-9]*\.[0-9]+([eE][+-]?[0-9]+)?[fh]?/, 'number.float'],
|
||||
// Has decimal point, at least one digit before decimal.
|
||||
[/[0-9]+\.[0-9]*([eE][+-]?[0-9]+)?[fh]?/, 'number.float'],
|
||||
// Has at least one digit, and has an exponent.
|
||||
[/[0-9]+[eE][+-]?[0-9]+[fh]?/, 'number.float'],
|
||||
|
||||
// Hex float literals
|
||||
// https://www.w3.org/TR/WGSL/#syntax-hex_float_literal
|
||||
[/0[xX][0-9a-fA-F]*\.[0-9a-fA-F]+(?:[pP][+-]?[0-9]+[fh]?)?/, 'number.hex'],
|
||||
[/0[xX][0-9a-fA-F]+\.[0-9a-fA-F]*(?:[pP][+-]?[0-9]+[fh]?)?/, 'number.hex'],
|
||||
[/0[xX][0-9a-fA-F]+[pP][+-]?[0-9]+[fh]?/, 'number.hex'],
|
||||
|
||||
// Hexadecimal integer literals
|
||||
// https://www.w3.org/TR/WGSL/#syntax-hex_int_literal
|
||||
[/0[xX][0-9a-fA-F]+[iu]?/, 'number.hex'],
|
||||
|
||||
// Decimal integer literals
|
||||
// https://www.w3.org/TR/WGSL/#syntax-decimal_int_literal
|
||||
// We need two rules here because 01 is not valid.
|
||||
[/[1-9][0-9]*[iu]?/, 'number'],
|
||||
[/0[iu]?/, 'number'] // Must match last
|
||||
]
|
||||
}
|
||||
};
|
||||
|
|
@ -12,10 +12,13 @@ registerLanguage({
|
|||
id: 'xml',
|
||||
extensions: [
|
||||
'.xml',
|
||||
'.xsd',
|
||||
'.dtd',
|
||||
'.ascx',
|
||||
'.csproj',
|
||||
'.config',
|
||||
'.props',
|
||||
'.targets',
|
||||
'.wxi',
|
||||
'.wxl',
|
||||
'.wxs',
|
||||
|
|
@ -23,6 +26,7 @@ registerLanguage({
|
|||
'.svg',
|
||||
'.svgz',
|
||||
'.opf',
|
||||
'.xslt',
|
||||
'.xsl'
|
||||
],
|
||||
firstLine: '(\\<\\?xml.*)|(\\<svg)|(\\<\\!doctype\\s+svg)',
|
||||
|
|
|
|||
|
|
@ -458,6 +458,7 @@ testTokenization('yaml', [
|
|||
{ startIndex: 4, type: 'operators.yaml' },
|
||||
{ startIndex: 5, type: 'white.yaml' },
|
||||
{ startIndex: 6, type: 'string.yaml' },
|
||||
{ startIndex: 28, type: 'white.yaml' },
|
||||
{ startIndex: 29, type: 'comment.yaml' }
|
||||
]
|
||||
}
|
||||
|
|
@ -470,8 +471,200 @@ testTokenization('yaml', [
|
|||
{ startIndex: 6, type: 'operators.yaml' },
|
||||
{ startIndex: 7, type: 'white.yaml' },
|
||||
{ startIndex: 8, type: 'string.yaml' },
|
||||
{ startIndex: 9, type: 'white.yaml' },
|
||||
{ startIndex: 10, type: 'comment.yaml' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
// ': ' in double-quoted Value
|
||||
[
|
||||
{
|
||||
line: 'key: "va: lue"',
|
||||
tokens: [
|
||||
{
|
||||
startIndex: 0,
|
||||
type: 'type.yaml'
|
||||
},
|
||||
{
|
||||
startIndex: 3,
|
||||
type: 'operators.yaml'
|
||||
},
|
||||
{
|
||||
startIndex: 4,
|
||||
type: 'white.yaml'
|
||||
},
|
||||
{
|
||||
startIndex: 5,
|
||||
type: 'string.yaml'
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
// ': ' in single-quoted Value
|
||||
[
|
||||
{
|
||||
line: "key: 'va: lue'",
|
||||
tokens: [
|
||||
{
|
||||
startIndex: 0,
|
||||
type: 'type.yaml'
|
||||
},
|
||||
{
|
||||
startIndex: 3,
|
||||
type: 'operators.yaml'
|
||||
},
|
||||
{
|
||||
startIndex: 4,
|
||||
type: 'white.yaml'
|
||||
},
|
||||
{
|
||||
startIndex: 5,
|
||||
type: 'string.yaml'
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
// '#' in single-quoted Value
|
||||
[
|
||||
{
|
||||
line: "key: 'va#lue'",
|
||||
tokens: [
|
||||
{
|
||||
startIndex: 0,
|
||||
type: 'type.yaml'
|
||||
},
|
||||
{
|
||||
startIndex: 3,
|
||||
type: 'operators.yaml'
|
||||
},
|
||||
{
|
||||
startIndex: 4,
|
||||
type: 'white.yaml'
|
||||
},
|
||||
{
|
||||
startIndex: 5,
|
||||
type: 'string.yaml'
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
// '#' in double-quoted Value
|
||||
[
|
||||
{
|
||||
line: 'key: "va#lue"',
|
||||
tokens: [
|
||||
{
|
||||
startIndex: 0,
|
||||
type: 'type.yaml'
|
||||
},
|
||||
{
|
||||
startIndex: 3,
|
||||
type: 'operators.yaml'
|
||||
},
|
||||
{
|
||||
startIndex: 4,
|
||||
type: 'white.yaml'
|
||||
},
|
||||
{
|
||||
startIndex: 5,
|
||||
type: 'string.yaml'
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
// '#' in Value
|
||||
[
|
||||
{
|
||||
line: 'key: va#lue',
|
||||
tokens: [
|
||||
{
|
||||
startIndex: 0,
|
||||
type: 'type.yaml'
|
||||
},
|
||||
{
|
||||
startIndex: 3,
|
||||
type: 'operators.yaml'
|
||||
},
|
||||
{
|
||||
startIndex: 4,
|
||||
type: 'white.yaml'
|
||||
},
|
||||
{
|
||||
startIndex: 5,
|
||||
type: 'string.yaml'
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
// Comment following Value
|
||||
[
|
||||
{
|
||||
line: 'key: value #comment',
|
||||
tokens: [
|
||||
{
|
||||
startIndex: 0,
|
||||
type: 'type.yaml'
|
||||
},
|
||||
{
|
||||
startIndex: 3,
|
||||
type: 'operators.yaml'
|
||||
},
|
||||
{
|
||||
startIndex: 4,
|
||||
type: 'white.yaml'
|
||||
},
|
||||
{
|
||||
startIndex: 5,
|
||||
type: 'string.yaml'
|
||||
},
|
||||
{
|
||||
startIndex: 10,
|
||||
type: 'white.yaml'
|
||||
},
|
||||
{
|
||||
startIndex: 11,
|
||||
type: 'comment.yaml'
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
// ': ' in Comment following Value
|
||||
[
|
||||
{
|
||||
line: 'key: value #comment: also comment',
|
||||
tokens: [
|
||||
{
|
||||
startIndex: 0,
|
||||
type: 'type.yaml'
|
||||
},
|
||||
{
|
||||
startIndex: 3,
|
||||
type: 'operators.yaml'
|
||||
},
|
||||
{
|
||||
startIndex: 4,
|
||||
type: 'white.yaml'
|
||||
},
|
||||
{
|
||||
startIndex: 5,
|
||||
type: 'string.yaml'
|
||||
},
|
||||
{
|
||||
startIndex: 10,
|
||||
type: 'white.yaml'
|
||||
},
|
||||
{
|
||||
startIndex: 11,
|
||||
type: 'comment.yaml'
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
]);
|
||||
|
|
|
|||
|
|
@ -86,13 +86,13 @@ export const language = <languages.IMonarchLanguage>{
|
|||
[/@numberDate(?![ \t]*\S+)/, 'number.date'],
|
||||
|
||||
// Key:Value pair
|
||||
[/(".*?"|'.*?'|.*?)([ \t]*)(:)( |$)/, ['type', 'white', 'operators', 'white']],
|
||||
[/(".*?"|'.*?'|[^#'"]*?)([ \t]*)(:)( |$)/, ['type', 'white', 'operators', 'white']],
|
||||
|
||||
{ include: '@flowScalars' },
|
||||
|
||||
// String nodes
|
||||
[
|
||||
/[^#]+/,
|
||||
/.+?(?=(\s+#|$))/,
|
||||
{
|
||||
cases: {
|
||||
'@keywords': 'keyword',
|
||||
|
|
|
|||
|
|
@ -803,6 +803,8 @@ export class DocumentFormattingEditProvider<T extends ILanguageWorkerWithFormat>
|
|||
export class DocumentRangeFormattingEditProvider<T extends ILanguageWorkerWithFormat>
|
||||
implements languages.DocumentRangeFormattingEditProvider
|
||||
{
|
||||
readonly canFormatMultipleRanges = false;
|
||||
|
||||
constructor(private _worker: WorkerAccessor<T>) {}
|
||||
|
||||
public provideDocumentRangeFormattingEdits(
|
||||
|
|
|
|||
|
|
@ -474,7 +474,7 @@ export class SuggestAdapter extends Adapter implements languages.CompletionItemP
|
|||
}
|
||||
|
||||
const tags: languages.CompletionItemTag[] = [];
|
||||
if (entry.kindModifiers?.indexOf('deprecated') !== -1) {
|
||||
if (entry.kindModifiers !== undefined && entry.kindModifiers.indexOf('deprecated') !== -1) {
|
||||
tags.push(languages.CompletionItemTag.Deprecated);
|
||||
}
|
||||
|
||||
|
|
@ -715,7 +715,10 @@ export class QuickInfoAdapter extends Adapter implements languages.HoverProvider
|
|||
|
||||
// --- occurrences ------
|
||||
|
||||
export class OccurrencesAdapter extends Adapter implements languages.DocumentHighlightProvider {
|
||||
export class DocumentHighlightAdapter
|
||||
extends Adapter
|
||||
implements languages.DocumentHighlightProvider
|
||||
{
|
||||
public async provideDocumentHighlights(
|
||||
model: editor.ITextModel,
|
||||
position: Position,
|
||||
|
|
@ -729,19 +732,24 @@ export class OccurrencesAdapter extends Adapter implements languages.DocumentHig
|
|||
return;
|
||||
}
|
||||
|
||||
const entries = await worker.getOccurrencesAtPosition(resource.toString(), offset);
|
||||
const entries = await worker.getDocumentHighlights(resource.toString(), offset, [
|
||||
resource.toString()
|
||||
]);
|
||||
|
||||
if (!entries || model.isDisposed()) {
|
||||
return;
|
||||
}
|
||||
|
||||
return entries.map((entry) => {
|
||||
return <languages.DocumentHighlight>{
|
||||
range: this._textSpanToRange(model, entry.textSpan),
|
||||
kind: entry.isWriteAccess
|
||||
? languages.DocumentHighlightKind.Write
|
||||
: languages.DocumentHighlightKind.Text
|
||||
};
|
||||
return entries.flatMap((entry) => {
|
||||
return entry.highlightSpans.map((highlightSpans) => {
|
||||
return <languages.DocumentHighlight>{
|
||||
range: this._textSpanToRange(model, highlightSpans.textSpan),
|
||||
kind:
|
||||
highlightSpans.kind === 'writtenReference'
|
||||
? languages.DocumentHighlightKind.Write
|
||||
: languages.DocumentHighlightKind.Text
|
||||
};
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -865,39 +873,31 @@ export class OutlineAdapter extends Adapter implements languages.DocumentSymbolP
|
|||
return;
|
||||
}
|
||||
|
||||
const items = await worker.getNavigationBarItems(resource.toString());
|
||||
const root = await worker.getNavigationTree(resource.toString());
|
||||
|
||||
if (!items || model.isDisposed()) {
|
||||
if (!root || model.isDisposed()) {
|
||||
return;
|
||||
}
|
||||
|
||||
const convert = (
|
||||
bucket: languages.DocumentSymbol[],
|
||||
item: ts.NavigationBarItem,
|
||||
item: ts.NavigationTree,
|
||||
containerLabel?: string
|
||||
): void => {
|
||||
let result: languages.DocumentSymbol = {
|
||||
): languages.DocumentSymbol => {
|
||||
const result: languages.DocumentSymbol = {
|
||||
name: item.text,
|
||||
detail: '',
|
||||
kind: <languages.SymbolKind>(outlineTypeTable[item.kind] || languages.SymbolKind.Variable),
|
||||
range: this._textSpanToRange(model, item.spans[0]),
|
||||
selectionRange: this._textSpanToRange(model, item.spans[0]),
|
||||
tags: []
|
||||
tags: [],
|
||||
children: item.childItems?.map((child) => convert(child, item.text)),
|
||||
containerName: containerLabel
|
||||
};
|
||||
|
||||
if (containerLabel) result.containerName = containerLabel;
|
||||
|
||||
if (item.childItems && item.childItems.length > 0) {
|
||||
for (let child of item.childItems) {
|
||||
convert(bucket, child, result.name);
|
||||
}
|
||||
}
|
||||
|
||||
bucket.push(result);
|
||||
return result;
|
||||
};
|
||||
|
||||
let result: languages.DocumentSymbol[] = [];
|
||||
items.forEach((item) => convert(result, item));
|
||||
// Exclude the root node, as it alwas spans the entire document.
|
||||
const result = root.childItems ? root.childItems.map((item) => convert(item)) : [];
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
@ -989,6 +989,8 @@ export class FormatAdapter
|
|||
extends FormatHelper
|
||||
implements languages.DocumentRangeFormattingEditProvider
|
||||
{
|
||||
readonly canFormatMultipleRanges = false;
|
||||
|
||||
public async provideDocumentRangeFormattingEdits(
|
||||
model: editor.ITextModel,
|
||||
range: Range,
|
||||
|
|
|
|||
|
|
@ -10,6 +10,8 @@
|
|||
/** Contains all the lib files */
|
||||
export const libFileSet: Record<string, boolean> = {}
|
||||
libFileSet['lib.d.ts'] = true;
|
||||
libFileSet['lib.decorators.d.ts'] = true;
|
||||
libFileSet['lib.decorators.legacy.d.ts'] = true;
|
||||
libFileSet['lib.dom.d.ts'] = true;
|
||||
libFileSet['lib.dom.iterable.d.ts'] = true;
|
||||
libFileSet['lib.es2015.collection.d.ts'] = true;
|
||||
|
|
@ -42,13 +44,16 @@ libFileSet['lib.es2018.regexp.d.ts'] = true;
|
|||
libFileSet['lib.es2019.array.d.ts'] = true;
|
||||
libFileSet['lib.es2019.d.ts'] = true;
|
||||
libFileSet['lib.es2019.full.d.ts'] = true;
|
||||
libFileSet['lib.es2019.intl.d.ts'] = true;
|
||||
libFileSet['lib.es2019.object.d.ts'] = true;
|
||||
libFileSet['lib.es2019.string.d.ts'] = true;
|
||||
libFileSet['lib.es2019.symbol.d.ts'] = true;
|
||||
libFileSet['lib.es2020.bigint.d.ts'] = true;
|
||||
libFileSet['lib.es2020.d.ts'] = true;
|
||||
libFileSet['lib.es2020.date.d.ts'] = true;
|
||||
libFileSet['lib.es2020.full.d.ts'] = true;
|
||||
libFileSet['lib.es2020.intl.d.ts'] = true;
|
||||
libFileSet['lib.es2020.number.d.ts'] = true;
|
||||
libFileSet['lib.es2020.promise.d.ts'] = true;
|
||||
libFileSet['lib.es2020.sharedmemory.d.ts'] = true;
|
||||
libFileSet['lib.es2020.string.d.ts'] = true;
|
||||
|
|
@ -59,14 +64,23 @@ libFileSet['lib.es2021.intl.d.ts'] = true;
|
|||
libFileSet['lib.es2021.promise.d.ts'] = true;
|
||||
libFileSet['lib.es2021.string.d.ts'] = true;
|
||||
libFileSet['lib.es2021.weakref.d.ts'] = true;
|
||||
libFileSet['lib.es2022.array.d.ts'] = true;
|
||||
libFileSet['lib.es2022.d.ts'] = true;
|
||||
libFileSet['lib.es2022.error.d.ts'] = true;
|
||||
libFileSet['lib.es2022.full.d.ts'] = true;
|
||||
libFileSet['lib.es2022.intl.d.ts'] = true;
|
||||
libFileSet['lib.es2022.object.d.ts'] = true;
|
||||
libFileSet['lib.es2022.regexp.d.ts'] = true;
|
||||
libFileSet['lib.es2022.sharedmemory.d.ts'] = true;
|
||||
libFileSet['lib.es2022.string.d.ts'] = true;
|
||||
libFileSet['lib.es2023.array.d.ts'] = true;
|
||||
libFileSet['lib.es2023.d.ts'] = true;
|
||||
libFileSet['lib.es2023.full.d.ts'] = true;
|
||||
libFileSet['lib.es5.d.ts'] = true;
|
||||
libFileSet['lib.es6.d.ts'] = true;
|
||||
libFileSet['lib.esnext.d.ts'] = true;
|
||||
libFileSet['lib.esnext.full.d.ts'] = true;
|
||||
libFileSet['lib.esnext.intl.d.ts'] = true;
|
||||
libFileSet['lib.esnext.promise.d.ts'] = true;
|
||||
libFileSet['lib.esnext.string.d.ts'] = true;
|
||||
libFileSet['lib.esnext.weakref.d.ts'] = true;
|
||||
libFileSet['lib.scripthost.d.ts'] = true;
|
||||
libFileSet['lib.webworker.d.ts'] = true;
|
||||
libFileSet['lib.webworker.importscripts.d.ts'] = true;
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
4089
src/language/typescript/lib/typescriptServices.d.ts
vendored
4089
src/language/typescript/lib/typescriptServices.d.ts
vendored
File diff suppressed because it is too large
Load diff
File diff suppressed because one or more lines are too long
|
|
@ -2,4 +2,4 @@
|
|||
// **NOTE**: Do not edit directly! This file is generated using `npm run import-typescript`
|
||||
//
|
||||
|
||||
export const typescriptVersion = "4.5.5";
|
||||
export const typescriptVersion = "5.0.2";
|
||||
|
|
|
|||
|
|
@ -226,6 +226,73 @@ interface OutputFile {
|
|||
text: string;
|
||||
}
|
||||
|
||||
export interface ModeConfiguration {
|
||||
/**
|
||||
* Defines whether the built-in completionItemProvider is enabled.
|
||||
*/
|
||||
readonly completionItems?: boolean;
|
||||
|
||||
/**
|
||||
* Defines whether the built-in hoverProvider is enabled.
|
||||
*/
|
||||
readonly hovers?: boolean;
|
||||
|
||||
/**
|
||||
* Defines whether the built-in documentSymbolProvider is enabled.
|
||||
*/
|
||||
readonly documentSymbols?: boolean;
|
||||
|
||||
/**
|
||||
* Defines whether the built-in definitions provider is enabled.
|
||||
*/
|
||||
readonly definitions?: boolean;
|
||||
|
||||
/**
|
||||
* Defines whether the built-in references provider is enabled.
|
||||
*/
|
||||
readonly references?: boolean;
|
||||
|
||||
/**
|
||||
* Defines whether the built-in references provider is enabled.
|
||||
*/
|
||||
readonly documentHighlights?: boolean;
|
||||
|
||||
/**
|
||||
* Defines whether the built-in rename provider is enabled.
|
||||
*/
|
||||
readonly rename?: boolean;
|
||||
|
||||
/**
|
||||
* Defines whether the built-in diagnostic provider is enabled.
|
||||
*/
|
||||
readonly diagnostics?: boolean;
|
||||
|
||||
/**
|
||||
* Defines whether the built-in document formatting range edit provider is enabled.
|
||||
*/
|
||||
readonly documentRangeFormattingEdits?: boolean;
|
||||
|
||||
/**
|
||||
* Defines whether the built-in signature help provider is enabled.
|
||||
*/
|
||||
readonly signatureHelp?: boolean;
|
||||
|
||||
/**
|
||||
* Defines whether the built-in onType formatting edit provider is enabled.
|
||||
*/
|
||||
readonly onTypeFormattingEdits?: boolean;
|
||||
|
||||
/**
|
||||
* Defines whether the built-in code actions provider is enabled.
|
||||
*/
|
||||
readonly codeActions?: boolean;
|
||||
|
||||
/**
|
||||
* Defines whether the built-in inlay hints provider is enabled.
|
||||
*/
|
||||
readonly inlayHints?: boolean;
|
||||
}
|
||||
|
||||
export interface LanguageServiceDefaults {
|
||||
/**
|
||||
* Event fired when compiler options or diagnostics options are changed.
|
||||
|
|
@ -241,6 +308,9 @@ export interface LanguageServiceDefaults {
|
|||
|
||||
readonly inlayHintsOptions: InlayHintsOptions;
|
||||
|
||||
readonly modeConfiguration: ModeConfiguration;
|
||||
setModeConfiguration(modeConfiguration: ModeConfiguration): void;
|
||||
|
||||
/**
|
||||
* Get the current extra libs registered with the language service.
|
||||
*/
|
||||
|
|
@ -370,13 +440,10 @@ export interface TypeScriptWorker {
|
|||
*/
|
||||
getQuickInfoAtPosition(fileName: string, position: number): Promise<any | undefined>;
|
||||
|
||||
/**
|
||||
* Get other ranges which are related to the item at the given position in the file (often used for highlighting).
|
||||
* @returns `Promise<ReadonlyArray<typescript.ReferenceEntry> | undefined>`
|
||||
*/
|
||||
getOccurrencesAtPosition(
|
||||
getDocumentHighlights(
|
||||
fileName: string,
|
||||
position: number
|
||||
position: number,
|
||||
filesToSearch: string[]
|
||||
): Promise<ReadonlyArray<any> | undefined>;
|
||||
|
||||
/**
|
||||
|
|
@ -396,9 +463,9 @@ export interface TypeScriptWorker {
|
|||
|
||||
/**
|
||||
* Get outline entries for the item at the given position in the file.
|
||||
* @returns `Promise<typescript.NavigationBarItem[]>`
|
||||
* @returns `Promise<typescript.NavigationTree | undefined>`
|
||||
*/
|
||||
getNavigationBarItems(fileName: string): Promise<any[]>;
|
||||
getNavigationTree(fileName: string): Promise<any | undefined>;
|
||||
|
||||
/**
|
||||
* Get changes which should be applied to format the given file.
|
||||
|
|
@ -491,12 +558,14 @@ class LanguageServiceDefaultsImpl implements LanguageServiceDefaults {
|
|||
private _workerOptions!: WorkerOptions;
|
||||
private _onDidExtraLibsChangeTimeout: number;
|
||||
private _inlayHintsOptions!: InlayHintsOptions;
|
||||
private _modeConfiguration!: ModeConfiguration;
|
||||
|
||||
constructor(
|
||||
compilerOptions: CompilerOptions,
|
||||
diagnosticsOptions: DiagnosticsOptions,
|
||||
workerOptions: WorkerOptions,
|
||||
inlayHintsOptions: InlayHintsOptions
|
||||
inlayHintsOptions: InlayHintsOptions,
|
||||
modeConfiguration: ModeConfiguration
|
||||
) {
|
||||
this._extraLibs = Object.create(null);
|
||||
this._removedExtraLibs = Object.create(null);
|
||||
|
|
@ -505,6 +574,7 @@ class LanguageServiceDefaultsImpl implements LanguageServiceDefaults {
|
|||
this.setDiagnosticsOptions(diagnosticsOptions);
|
||||
this.setWorkerOptions(workerOptions);
|
||||
this.setInlayHintsOptions(inlayHintsOptions);
|
||||
this.setModeConfiguration(modeConfiguration);
|
||||
this._onDidExtraLibsChangeTimeout = -1;
|
||||
}
|
||||
|
||||
|
|
@ -516,6 +586,10 @@ class LanguageServiceDefaultsImpl implements LanguageServiceDefaults {
|
|||
return this._onDidExtraLibsChange.event;
|
||||
}
|
||||
|
||||
get modeConfiguration(): ModeConfiguration {
|
||||
return this._modeConfiguration;
|
||||
}
|
||||
|
||||
get workerOptions(): WorkerOptions {
|
||||
return this._workerOptions;
|
||||
}
|
||||
|
|
@ -650,22 +724,45 @@ class LanguageServiceDefaultsImpl implements LanguageServiceDefaults {
|
|||
getEagerModelSync() {
|
||||
return this._eagerModelSync;
|
||||
}
|
||||
|
||||
setModeConfiguration(modeConfiguration: ModeConfiguration): void {
|
||||
this._modeConfiguration = modeConfiguration || Object.create(null);
|
||||
this._onDidChange.fire(undefined);
|
||||
}
|
||||
}
|
||||
|
||||
export const typescriptVersion: string = tsversion;
|
||||
|
||||
const modeConfigurationDefault: Required<ModeConfiguration> = {
|
||||
completionItems: true,
|
||||
hovers: true,
|
||||
documentSymbols: true,
|
||||
definitions: true,
|
||||
references: true,
|
||||
documentHighlights: true,
|
||||
rename: true,
|
||||
diagnostics: true,
|
||||
documentRangeFormattingEdits: true,
|
||||
signatureHelp: true,
|
||||
onTypeFormattingEdits: true,
|
||||
codeActions: true,
|
||||
inlayHints: true
|
||||
};
|
||||
|
||||
export const typescriptDefaults: LanguageServiceDefaults = new LanguageServiceDefaultsImpl(
|
||||
{ allowNonTsExtensions: true, target: ScriptTarget.Latest },
|
||||
{ noSemanticValidation: false, noSyntaxValidation: false, onlyVisible: false },
|
||||
{},
|
||||
{}
|
||||
{},
|
||||
modeConfigurationDefault
|
||||
);
|
||||
|
||||
export const javascriptDefaults: LanguageServiceDefaults = new LanguageServiceDefaultsImpl(
|
||||
{ allowNonTsExtensions: true, allowJs: true, target: ScriptTarget.Latest },
|
||||
{ noSemanticValidation: true, noSyntaxValidation: false, onlyVisible: false },
|
||||
{},
|
||||
{}
|
||||
{},
|
||||
modeConfigurationDefault
|
||||
);
|
||||
|
||||
export const getTypeScriptWorker = (): Promise<(...uris: Uri[]) => Promise<TypeScriptWorker>> => {
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ import { WorkerManager } from './workerManager';
|
|||
import type { TypeScriptWorker } from './tsWorker';
|
||||
import { LanguageServiceDefaults } from './monaco.contribution';
|
||||
import * as languageFeatures from './languageFeatures';
|
||||
import { languages, Uri } from '../../fillers/monaco-editor-core';
|
||||
import { languages, IDisposable, Uri } from '../../fillers/monaco-editor-core';
|
||||
|
||||
let javaScriptWorker: (...uris: Uri[]) => Promise<TypeScriptWorker>;
|
||||
let typeScriptWorker: (...uris: Uri[]) => Promise<TypeScriptWorker>;
|
||||
|
|
@ -44,46 +44,133 @@ function setupMode(
|
|||
defaults: LanguageServiceDefaults,
|
||||
modeId: string
|
||||
): (...uris: Uri[]) => Promise<TypeScriptWorker> {
|
||||
const disposables: IDisposable[] = [];
|
||||
const providers: IDisposable[] = [];
|
||||
|
||||
const client = new WorkerManager(modeId, defaults);
|
||||
disposables.push(client);
|
||||
|
||||
const worker = (...uris: Uri[]): Promise<TypeScriptWorker> => {
|
||||
return client.getLanguageServiceWorker(...uris);
|
||||
};
|
||||
|
||||
const libFiles = new languageFeatures.LibFiles(worker);
|
||||
|
||||
languages.registerCompletionItemProvider(modeId, new languageFeatures.SuggestAdapter(worker));
|
||||
languages.registerSignatureHelpProvider(
|
||||
modeId,
|
||||
new languageFeatures.SignatureHelpAdapter(worker)
|
||||
);
|
||||
languages.registerHoverProvider(modeId, new languageFeatures.QuickInfoAdapter(worker));
|
||||
languages.registerDocumentHighlightProvider(
|
||||
modeId,
|
||||
new languageFeatures.OccurrencesAdapter(worker)
|
||||
);
|
||||
languages.registerDefinitionProvider(
|
||||
modeId,
|
||||
new languageFeatures.DefinitionAdapter(libFiles, worker)
|
||||
);
|
||||
languages.registerReferenceProvider(
|
||||
modeId,
|
||||
new languageFeatures.ReferenceAdapter(libFiles, worker)
|
||||
);
|
||||
languages.registerDocumentSymbolProvider(modeId, new languageFeatures.OutlineAdapter(worker));
|
||||
languages.registerDocumentRangeFormattingEditProvider(
|
||||
modeId,
|
||||
new languageFeatures.FormatAdapter(worker)
|
||||
);
|
||||
languages.registerOnTypeFormattingEditProvider(
|
||||
modeId,
|
||||
new languageFeatures.FormatOnTypeAdapter(worker)
|
||||
);
|
||||
languages.registerCodeActionProvider(modeId, new languageFeatures.CodeActionAdaptor(worker));
|
||||
languages.registerRenameProvider(modeId, new languageFeatures.RenameAdapter(libFiles, worker));
|
||||
languages.registerInlayHintsProvider(modeId, new languageFeatures.InlayHintsAdapter(worker));
|
||||
new languageFeatures.DiagnosticsAdapter(libFiles, defaults, modeId, worker);
|
||||
function registerProviders(): void {
|
||||
const { modeConfiguration } = defaults;
|
||||
|
||||
disposeAll(providers);
|
||||
|
||||
if (modeConfiguration.completionItems) {
|
||||
providers.push(
|
||||
languages.registerCompletionItemProvider(
|
||||
modeId,
|
||||
new languageFeatures.SuggestAdapter(worker)
|
||||
)
|
||||
);
|
||||
}
|
||||
if (modeConfiguration.signatureHelp) {
|
||||
providers.push(
|
||||
languages.registerSignatureHelpProvider(
|
||||
modeId,
|
||||
new languageFeatures.SignatureHelpAdapter(worker)
|
||||
)
|
||||
);
|
||||
}
|
||||
if (modeConfiguration.hovers) {
|
||||
providers.push(
|
||||
languages.registerHoverProvider(modeId, new languageFeatures.QuickInfoAdapter(worker))
|
||||
);
|
||||
}
|
||||
if (modeConfiguration.documentHighlights) {
|
||||
providers.push(
|
||||
languages.registerDocumentHighlightProvider(
|
||||
modeId,
|
||||
new languageFeatures.DocumentHighlightAdapter(worker)
|
||||
)
|
||||
);
|
||||
}
|
||||
if (modeConfiguration.definitions) {
|
||||
providers.push(
|
||||
languages.registerDefinitionProvider(
|
||||
modeId,
|
||||
new languageFeatures.DefinitionAdapter(libFiles, worker)
|
||||
)
|
||||
);
|
||||
}
|
||||
if (modeConfiguration.references) {
|
||||
providers.push(
|
||||
languages.registerReferenceProvider(
|
||||
modeId,
|
||||
new languageFeatures.ReferenceAdapter(libFiles, worker)
|
||||
)
|
||||
);
|
||||
}
|
||||
if (modeConfiguration.documentSymbols) {
|
||||
providers.push(
|
||||
languages.registerDocumentSymbolProvider(
|
||||
modeId,
|
||||
new languageFeatures.OutlineAdapter(worker)
|
||||
)
|
||||
);
|
||||
}
|
||||
if (modeConfiguration.rename) {
|
||||
providers.push(
|
||||
languages.registerRenameProvider(
|
||||
modeId,
|
||||
new languageFeatures.RenameAdapter(libFiles, worker)
|
||||
)
|
||||
);
|
||||
}
|
||||
if (modeConfiguration.documentRangeFormattingEdits) {
|
||||
providers.push(
|
||||
languages.registerDocumentRangeFormattingEditProvider(
|
||||
modeId,
|
||||
new languageFeatures.FormatAdapter(worker)
|
||||
)
|
||||
);
|
||||
}
|
||||
if (modeConfiguration.onTypeFormattingEdits) {
|
||||
providers.push(
|
||||
languages.registerOnTypeFormattingEditProvider(
|
||||
modeId,
|
||||
new languageFeatures.FormatOnTypeAdapter(worker)
|
||||
)
|
||||
);
|
||||
}
|
||||
if (modeConfiguration.codeActions) {
|
||||
providers.push(
|
||||
languages.registerCodeActionProvider(modeId, new languageFeatures.CodeActionAdaptor(worker))
|
||||
);
|
||||
}
|
||||
if (modeConfiguration.inlayHints) {
|
||||
providers.push(
|
||||
languages.registerInlayHintsProvider(modeId, new languageFeatures.InlayHintsAdapter(worker))
|
||||
);
|
||||
}
|
||||
if (modeConfiguration.diagnostics) {
|
||||
providers.push(new languageFeatures.DiagnosticsAdapter(libFiles, defaults, modeId, worker));
|
||||
}
|
||||
}
|
||||
|
||||
registerProviders();
|
||||
|
||||
disposables.push(asDisposable(providers));
|
||||
|
||||
//return asDisposable(disposables);
|
||||
|
||||
return worker;
|
||||
}
|
||||
|
||||
function asDisposable(disposables: IDisposable[]): IDisposable {
|
||||
return { dispose: () => disposeAll(disposables) };
|
||||
}
|
||||
|
||||
function disposeAll(disposables: IDisposable[]) {
|
||||
while (disposables.length) {
|
||||
disposables.pop()!.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
export { WorkerManager } from './workerManager';
|
||||
export * from './languageFeatures';
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ export class TypeScriptWorker implements ts.LanguageServiceHost, ITypeScriptWork
|
|||
private _extraLibs: IExtraLibs = Object.create(null);
|
||||
private _languageService = ts.createLanguageService(this);
|
||||
private _compilerOptions: ts.CompilerOptions;
|
||||
private _inlayHintsOptions?: ts.InlayHintsOptions;
|
||||
private _inlayHintsOptions?: ts.UserPreferences;
|
||||
|
||||
constructor(ctx: worker.IWorkerContext, createData: ICreateData) {
|
||||
this._ctx = ctx;
|
||||
|
|
@ -63,7 +63,7 @@ export class TypeScriptWorker implements ts.LanguageServiceHost, ITypeScriptWork
|
|||
|
||||
getScriptFileNames(): string[] {
|
||||
const allModels = this._ctx.getMirrorModels().map((model) => model.uri);
|
||||
const models = allModels.filter((uri) => !fileNameIsLib(uri)).map((uri) => uri.toString(true));
|
||||
const models = allModels.filter((uri) => !fileNameIsLib(uri)).map((uri) => uri.toString());
|
||||
return models.concat(Object.keys(this._extraLibs));
|
||||
}
|
||||
|
||||
|
|
@ -299,14 +299,15 @@ export class TypeScriptWorker implements ts.LanguageServiceHost, ITypeScriptWork
|
|||
return this._languageService.getQuickInfoAtPosition(fileName, position);
|
||||
}
|
||||
|
||||
async getOccurrencesAtPosition(
|
||||
async getDocumentHighlights(
|
||||
fileName: string,
|
||||
position: number
|
||||
): Promise<ReadonlyArray<ts.ReferenceEntry> | undefined> {
|
||||
position: number,
|
||||
filesToSearch: string[]
|
||||
): Promise<ReadonlyArray<ts.DocumentHighlights> | undefined> {
|
||||
if (fileNameIsLib(fileName)) {
|
||||
return undefined;
|
||||
}
|
||||
return this._languageService.getOccurrencesAtPosition(fileName, position);
|
||||
return this._languageService.getDocumentHighlights(fileName, position, filesToSearch);
|
||||
}
|
||||
|
||||
async getDefinitionAtPosition(
|
||||
|
|
@ -329,11 +330,11 @@ export class TypeScriptWorker implements ts.LanguageServiceHost, ITypeScriptWork
|
|||
return this._languageService.getReferencesAtPosition(fileName, position);
|
||||
}
|
||||
|
||||
async getNavigationBarItems(fileName: string): Promise<ts.NavigationBarItem[]> {
|
||||
async getNavigationTree(fileName: string): Promise<ts.NavigationTree | undefined> {
|
||||
if (fileNameIsLib(fileName)) {
|
||||
return [];
|
||||
return undefined;
|
||||
}
|
||||
return this._languageService.getNavigationBarItems(fileName);
|
||||
return this._languageService.getNavigationTree(fileName);
|
||||
}
|
||||
|
||||
async getFormattingEditsForDocument(
|
||||
|
|
@ -444,7 +445,7 @@ export class TypeScriptWorker implements ts.LanguageServiceHost, ITypeScriptWork
|
|||
if (fileNameIsLib(fileName)) {
|
||||
return [];
|
||||
}
|
||||
const preferences: ts.InlayHintsOptions = this._inlayHintsOptions ?? {};
|
||||
const preferences: ts.UserPreferences = this._inlayHintsOptions ?? {};
|
||||
const span: ts.TextSpan = {
|
||||
start,
|
||||
length: end - start
|
||||
|
|
@ -462,7 +463,7 @@ export interface ICreateData {
|
|||
compilerOptions: ts.CompilerOptions;
|
||||
extraLibs: IExtraLibs;
|
||||
customWorkerPath?: string;
|
||||
inlayHintsOptions?: ts.InlayHintsOptions;
|
||||
inlayHintsOptions?: ts.UserPreferences;
|
||||
}
|
||||
|
||||
/** The shape of the factory */
|
||||
|
|
|
|||
|
|
@ -4,8 +4,11 @@
|
|||
"lib": ["dom", "es5", "es2015.collection", "es2015.promise", "es2015.iterable"],
|
||||
"module": "amd",
|
||||
"moduleResolution": "node",
|
||||
"outDir": "../out/amd",
|
||||
"outDir": "../out/languages/amd-tsc",
|
||||
"strict": true,
|
||||
"target": "es5"
|
||||
"target": "es5",
|
||||
"sourceMap": true,
|
||||
"allowJs": true,
|
||||
"checkJs": false
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue