mirror of
https://github.com/microsoft/monaco-editor.git
synced 2025-12-22 15:05:39 +01:00
Merge branch 'main' into mdx
This commit is contained in:
commit
181f03ecce
421 changed files with 190953 additions and 358509 deletions
|
|
@ -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/,
|
||||
|
|
|
|||
|
|
@ -383,5 +383,32 @@ testTokenization('elixir', [
|
|||
{ startIndex: 15, type: 'delimiter.square.elixir' }
|
||||
]
|
||||
}
|
||||
],
|
||||
// Bitstrings
|
||||
[
|
||||
{
|
||||
line: '<<height::32-integer, width::32-integer, data::binary>>',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'delimiter.angle.special.elixir' },
|
||||
{ startIndex: 2, type: 'identifier.elixir' },
|
||||
{ startIndex: 8, type: 'operator.elixir' },
|
||||
{ startIndex: 10, type: 'number.elixir' },
|
||||
{ startIndex: 12, type: 'operator.elixir' },
|
||||
{ startIndex: 13, type: 'identifier.elixir' },
|
||||
{ startIndex: 20, type: 'punctuation.elixir' },
|
||||
{ startIndex: 21, type: 'white.elixir' },
|
||||
{ startIndex: 22, type: 'identifier.elixir' },
|
||||
{ startIndex: 27, type: 'operator.elixir' },
|
||||
{ startIndex: 29, type: 'number.elixir' },
|
||||
{ startIndex: 31, type: 'operator.elixir' },
|
||||
{ startIndex: 32, type: 'identifier.elixir' },
|
||||
{ startIndex: 39, type: 'punctuation.elixir' },
|
||||
{ startIndex: 40, type: 'white.elixir' },
|
||||
{ startIndex: 41, type: 'identifier.elixir' },
|
||||
{ startIndex: 45, type: 'operator.elixir' },
|
||||
{ startIndex: 47, type: 'identifier.elixir' },
|
||||
{ startIndex: 53, type: 'delimiter.angle.special.elixir' }
|
||||
]
|
||||
}
|
||||
]
|
||||
]);
|
||||
|
|
|
|||
|
|
@ -167,7 +167,7 @@ export const language = <languages.IMonarchLanguage>{
|
|||
// Keyword list shorthand
|
||||
|
||||
keywordsShorthand: [
|
||||
[/(@atomName)(:)/, ['constant', 'constant.punctuation']],
|
||||
[/(@atomName)(:)(\s+)/, ['constant', 'constant.punctuation', 'white']],
|
||||
// Use positive look-ahead to ensure the string is followed by :
|
||||
// and should be considered a keyword.
|
||||
[
|
||||
|
|
@ -532,6 +532,13 @@ export const language = <languages.IMonarchLanguage>{
|
|||
next: '@doubleQuotedHeredocDocstring'
|
||||
}
|
||||
],
|
||||
[
|
||||
/\@(module|type)?doc (~[sS])?'''/,
|
||||
{
|
||||
token: 'comment.block.documentation',
|
||||
next: '@singleQuotedHeredocDocstring'
|
||||
}
|
||||
],
|
||||
[
|
||||
/\@(module|type)?doc (~[sS])?"/,
|
||||
{
|
||||
|
|
@ -539,6 +546,13 @@ export const language = <languages.IMonarchLanguage>{
|
|||
next: '@doubleQuotedStringDocstring'
|
||||
}
|
||||
],
|
||||
[
|
||||
/\@(module|type)?doc (~[sS])?'/,
|
||||
{
|
||||
token: 'comment.block.documentation',
|
||||
next: '@singleQuotedStringDocstring'
|
||||
}
|
||||
],
|
||||
[/\@(module|type)?doc false/, 'comment.block.documentation'],
|
||||
// Module attributes
|
||||
[/\@(@variableName)/, 'variable']
|
||||
|
|
@ -549,11 +563,21 @@ export const language = <languages.IMonarchLanguage>{
|
|||
{ include: '@docstringContent' }
|
||||
],
|
||||
|
||||
singleQuotedHeredocDocstring: [
|
||||
[/'''/, { token: 'comment.block.documentation', next: '@pop' }],
|
||||
{ include: '@docstringContent' }
|
||||
],
|
||||
|
||||
doubleQuotedStringDocstring: [
|
||||
[/"/, { token: 'comment.block.documentation', next: '@pop' }],
|
||||
{ include: '@docstringContent' }
|
||||
],
|
||||
|
||||
singleQuotedStringDocstring: [
|
||||
[/'/, { token: 'comment.block.documentation', next: '@pop' }],
|
||||
{ include: '@docstringContent' }
|
||||
],
|
||||
|
||||
// Operators, punctuation, brackets
|
||||
|
||||
symbols: [
|
||||
|
|
|
|||
|
|
@ -396,6 +396,32 @@ testTokenization(
|
|||
}
|
||||
],
|
||||
|
||||
// Embedded Content #10
|
||||
[
|
||||
{
|
||||
line: '<script type="module">var i= 10;</script>',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'delimiter.html' },
|
||||
{ startIndex: 1, type: 'tag.html' },
|
||||
{ startIndex: 7, type: '' },
|
||||
{ startIndex: 8, type: 'attribute.name.html' },
|
||||
{ startIndex: 12, type: 'delimiter.html' },
|
||||
{ startIndex: 13, type: 'attribute.value.html' },
|
||||
{ startIndex: 21, type: 'delimiter.html' },
|
||||
{ startIndex: 22, type: 'keyword.js' },
|
||||
{ startIndex: 25, type: '' },
|
||||
{ startIndex: 26, type: 'identifier.js' },
|
||||
{ startIndex: 27, type: 'delimiter.js' },
|
||||
{ startIndex: 28, type: '' },
|
||||
{ startIndex: 29, type: 'number.js' },
|
||||
{ startIndex: 31, type: 'delimiter.js' },
|
||||
{ startIndex: 32, type: 'delimiter.html' },
|
||||
{ startIndex: 34, type: 'tag.html' },
|
||||
{ startIndex: 40, type: 'delimiter.html' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
// Tag with Attribute
|
||||
[
|
||||
{
|
||||
|
|
|
|||
|
|
@ -160,6 +160,20 @@ export const language = <languages.IMonarchLanguage>{
|
|||
|
||||
// After <script ... type =
|
||||
scriptAfterTypeEquals: [
|
||||
[
|
||||
/"module"/,
|
||||
{
|
||||
token: 'attribute.value',
|
||||
switchTo: '@scriptWithCustomType.text/javascript'
|
||||
}
|
||||
],
|
||||
[
|
||||
/'module'/,
|
||||
{
|
||||
token: 'attribute.value',
|
||||
switchTo: '@scriptWithCustomType.text/javascript'
|
||||
}
|
||||
],
|
||||
[
|
||||
/"([^"]*)"/,
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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: () => {
|
||||
|
|
|
|||
|
|
@ -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',
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ export const conf: languages.LanguageConfiguration = {
|
|||
onEnterRules: [
|
||||
{
|
||||
beforeText: new RegExp(
|
||||
'^\\s*(?:def|class|for|if|elif|else|while|try|with|finally|except|async).*?:\\s*$'
|
||||
'^\\s*(?:def|class|for|if|elif|else|while|try|with|finally|except|async|match|case).*?:\\s*$'
|
||||
),
|
||||
action: { indentAction: languages.IndentAction.Indent }
|
||||
}
|
||||
|
|
@ -52,18 +52,21 @@ export const language = <languages.IMonarchLanguage>{
|
|||
|
||||
keywords: [
|
||||
// This section is the result of running
|
||||
// `for k in keyword.kwlist: print(' "' + k + '",')` in a Python REPL,
|
||||
// `import keyword; for k in sorted(keyword.kwlist + keyword.softkwlist): print(" '" + k + "',")`
|
||||
// in a Python REPL,
|
||||
// though note that the output from Python 3 is not a strict superset of the
|
||||
// output from Python 2.
|
||||
'False', // promoted to keyword.kwlist in Python 3
|
||||
'None', // promoted to keyword.kwlist in Python 3
|
||||
'True', // promoted to keyword.kwlist in Python 3
|
||||
'_', // new in Python 3.10
|
||||
'and',
|
||||
'as',
|
||||
'assert',
|
||||
'async', // new in Python 3
|
||||
'await', // new in Python 3
|
||||
'break',
|
||||
'case', // new in Python 3.10
|
||||
'class',
|
||||
'continue',
|
||||
'def',
|
||||
|
|
@ -81,6 +84,7 @@ export const language = <languages.IMonarchLanguage>{
|
|||
'in',
|
||||
'is',
|
||||
'lambda',
|
||||
'match', // new in Python 3.10
|
||||
'nonlocal', // new in Python 3
|
||||
'not',
|
||||
'or',
|
||||
|
|
|
|||
|
|
@ -74,7 +74,8 @@ export const language = <languages.IMonarchLanguage>{
|
|||
'borrow',
|
||||
'using',
|
||||
'borrowing',
|
||||
'mutable'
|
||||
'mutable',
|
||||
'internal'
|
||||
],
|
||||
|
||||
typeKeywords: [
|
||||
|
|
|
|||
|
|
@ -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> => {
|
||||
|
|
|
|||
|
|
@ -137,6 +137,7 @@ export const language = {
|
|||
'require',
|
||||
'global',
|
||||
'return',
|
||||
'satisfies',
|
||||
'set',
|
||||
'static',
|
||||
'string',
|
||||
|
|
|
|||
|
|
@ -16,6 +16,8 @@ registerLanguage({
|
|||
'.ascx',
|
||||
'.csproj',
|
||||
'.config',
|
||||
'.props',
|
||||
'.targets',
|
||||
'.wxi',
|
||||
'.wxl',
|
||||
'.wxs',
|
||||
|
|
|
|||
|
|
@ -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',
|
||||
|
|
|
|||
|
|
@ -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, result.name)),
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
4093
src/language/typescript/lib/typescriptServices.d.ts
vendored
4093
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;
|
||||
|
|
@ -70,7 +70,8 @@ export class TypeScriptWorker implements ts.LanguageServiceHost, ITypeScriptWork
|
|||
private _getModel(fileName: string): worker.IMirrorModel | null {
|
||||
let models = this._ctx.getMirrorModels();
|
||||
for (let i = 0; i < models.length; i++) {
|
||||
if (models[i].uri.toString() === fileName) {
|
||||
const uri = models[i].uri;
|
||||
if (uri.toString() === fileName || uri.toString(true) === fileName) {
|
||||
return models[i];
|
||||
}
|
||||
}
|
||||
|
|
@ -298,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(
|
||||
|
|
@ -328,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(
|
||||
|
|
@ -443,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
|
||||
|
|
@ -461,7 +463,7 @@ export interface ICreateData {
|
|||
compilerOptions: ts.CompilerOptions;
|
||||
extraLibs: IExtraLibs;
|
||||
customWorkerPath?: string;
|
||||
inlayHintsOptions?: ts.InlayHintsOptions;
|
||||
inlayHintsOptions?: ts.UserPreferences;
|
||||
}
|
||||
|
||||
/** The shape of the factory */
|
||||
|
|
@ -486,7 +488,7 @@ export function create(ctx: worker.IWorkerContext, createData: ICreateData): Typ
|
|||
'Monaco is not using webworkers for background tasks, and that is needed to support the customWorkerPath flag'
|
||||
);
|
||||
} else {
|
||||
importScripts(createData.customWorkerPath);
|
||||
self.importScripts(createData.customWorkerPath);
|
||||
|
||||
const workerFactoryFunc: CustomTSWebWorkerFactory | undefined = self.customTSWorkerFactory;
|
||||
if (!workerFactoryFunc) {
|
||||
|
|
|
|||
|
|
@ -8,8 +8,6 @@ import type { TypeScriptWorker } from './tsWorker';
|
|||
import { editor, Uri, IDisposable } from '../../fillers/monaco-editor-core';
|
||||
|
||||
export class WorkerManager {
|
||||
private _modeId: string;
|
||||
private _defaults: LanguageServiceDefaults;
|
||||
private _configChangeListener: IDisposable;
|
||||
private _updateExtraLibsToken: number;
|
||||
private _extraLibsChangeListener: IDisposable;
|
||||
|
|
@ -17,9 +15,10 @@ export class WorkerManager {
|
|||
private _worker: editor.MonacoWebWorker<TypeScriptWorker> | null;
|
||||
private _client: Promise<TypeScriptWorker> | null;
|
||||
|
||||
constructor(modeId: string, defaults: LanguageServiceDefaults) {
|
||||
this._modeId = modeId;
|
||||
this._defaults = defaults;
|
||||
constructor(
|
||||
private readonly _modeId: string,
|
||||
private readonly _defaults: LanguageServiceDefaults
|
||||
) {
|
||||
this._worker = null;
|
||||
this._client = null;
|
||||
this._configChangeListener = this._defaults.onDidChange(() => this._stopWorker());
|
||||
|
|
@ -29,6 +28,12 @@ export class WorkerManager {
|
|||
);
|
||||
}
|
||||
|
||||
dispose(): void {
|
||||
this._configChangeListener.dispose();
|
||||
this._extraLibsChangeListener.dispose();
|
||||
this._stopWorker();
|
||||
}
|
||||
|
||||
private _stopWorker(): void {
|
||||
if (this._worker) {
|
||||
this._worker.dispose();
|
||||
|
|
@ -37,12 +42,6 @@ export class WorkerManager {
|
|||
this._client = null;
|
||||
}
|
||||
|
||||
dispose(): void {
|
||||
this._configChangeListener.dispose();
|
||||
this._extraLibsChangeListener.dispose();
|
||||
this._stopWorker();
|
||||
}
|
||||
|
||||
private async _updateExtraLibs(): Promise<void> {
|
||||
if (!this._worker) {
|
||||
return;
|
||||
|
|
@ -58,56 +57,45 @@ export class WorkerManager {
|
|||
|
||||
private _getClient(): Promise<TypeScriptWorker> {
|
||||
if (!this._client) {
|
||||
this._worker = editor.createWebWorker<TypeScriptWorker>({
|
||||
// module that exports the create() method and returns a `TypeScriptWorker` instance
|
||||
moduleId: 'vs/language/typescript/tsWorker',
|
||||
this._client = (async () => {
|
||||
this._worker = editor.createWebWorker<TypeScriptWorker>({
|
||||
// module that exports the create() method and returns a `TypeScriptWorker` instance
|
||||
moduleId: 'vs/language/typescript/tsWorker',
|
||||
|
||||
label: this._modeId,
|
||||
label: this._modeId,
|
||||
|
||||
keepIdleModels: true,
|
||||
keepIdleModels: true,
|
||||
|
||||
// passed in to the create() method
|
||||
createData: {
|
||||
compilerOptions: this._defaults.getCompilerOptions(),
|
||||
extraLibs: this._defaults.getExtraLibs(),
|
||||
customWorkerPath: this._defaults.workerOptions.customWorkerPath,
|
||||
inlayHintsOptions: this._defaults.inlayHintsOptions
|
||||
}
|
||||
});
|
||||
|
||||
let p = <Promise<TypeScriptWorker>>this._worker.getProxy();
|
||||
|
||||
if (this._defaults.getEagerModelSync()) {
|
||||
p = p.then((worker) => {
|
||||
if (this._worker) {
|
||||
return this._worker.withSyncedResources(
|
||||
editor
|
||||
.getModels()
|
||||
.filter((model) => model.getLanguageId() === this._modeId)
|
||||
.map((model) => model.uri)
|
||||
);
|
||||
// passed in to the create() method
|
||||
createData: {
|
||||
compilerOptions: this._defaults.getCompilerOptions(),
|
||||
extraLibs: this._defaults.getExtraLibs(),
|
||||
customWorkerPath: this._defaults.workerOptions.customWorkerPath,
|
||||
inlayHintsOptions: this._defaults.inlayHintsOptions
|
||||
}
|
||||
return worker;
|
||||
});
|
||||
}
|
||||
|
||||
this._client = p;
|
||||
if (this._defaults.getEagerModelSync()) {
|
||||
return await this._worker.withSyncedResources(
|
||||
editor
|
||||
.getModels()
|
||||
.filter((model) => model.getLanguageId() === this._modeId)
|
||||
.map((model) => model.uri)
|
||||
);
|
||||
}
|
||||
|
||||
return await this._worker.getProxy();
|
||||
})();
|
||||
}
|
||||
|
||||
return this._client;
|
||||
}
|
||||
|
||||
getLanguageServiceWorker(...resources: Uri[]): Promise<TypeScriptWorker> {
|
||||
let _client: TypeScriptWorker;
|
||||
return this._getClient()
|
||||
.then((client) => {
|
||||
_client = client;
|
||||
})
|
||||
.then((_) => {
|
||||
if (this._worker) {
|
||||
return this._worker.withSyncedResources(resources);
|
||||
}
|
||||
})
|
||||
.then((_) => _client);
|
||||
async getLanguageServiceWorker(...resources: Uri[]): Promise<TypeScriptWorker> {
|
||||
const client = await this._getClient();
|
||||
if (this._worker) {
|
||||
await this._worker.withSyncedResources(resources);
|
||||
}
|
||||
return client;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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