| 1 |
import { a as e, c as t, f as n, h as r, o as i, p as a } from "./toggleHighContrast-CMSNQh1Z.js"; |
| 2 |
import { t as o } from "./monaco.contribution-BJhnu3zX.js"; |
| 3 |
import { t as s } from "./workers-DEKY2TUl.js"; |
| 4 |
var c = class { |
| 5 |
constructor(e4, t2) { |
| 6 |
this._modeId = e4, this._defaults = t2, this._worker = null, this._client = null, this._configChangeListener = this._defaults.onDidChange(() => this._stopWorker()), this._updateExtraLibsToken = 0, this._extraLibsChangeListener = this._defaults.onDidExtraLibsChange(() => this._updateExtraLibs()); |
| 7 |
} |
| 8 |
dispose() { |
| 9 |
this._configChangeListener.dispose(), this._extraLibsChangeListener.dispose(), this._stopWorker(); |
| 10 |
} |
| 11 |
_stopWorker() { |
| 12 |
this._worker && (this._worker = (this._worker.dispose(), null)), this._client = null; |
| 13 |
} |
| 14 |
async _updateExtraLibs() { |
| 15 |
if (!this._worker) return; |
| 16 |
let e4 = ++this._updateExtraLibsToken, t2 = await this._worker.getProxy(); |
| 17 |
this._updateExtraLibsToken === e4 && t2.updateExtraLibs(this._defaults.getExtraLibs()); |
| 18 |
} |
| 19 |
_getClient() { |
| 20 |
return this._client || (this._client = (async () => (this._worker = s({ moduleId: `vs/language/typescript/tsWorker`, createWorker: () => new Worker(new URL(`` + new URL(`ts.worker-CDlTriQ3.js`, import.meta.url).href, `` + import.meta.url), { type: `module` }), label: this._modeId, keepIdleModels: true, createData: { compilerOptions: this._defaults.getCompilerOptions(), extraLibs: this._defaults.getExtraLibs(), customWorkerPath: this._defaults.workerOptions.customWorkerPath, inlayHintsOptions: this._defaults.inlayHintsOptions } }), this._defaults.getEagerModelSync() ? await this._worker.withSyncedResources(a.getModels().filter((e4) => e4.getLanguageId() === this._modeId).map((e4) => e4.uri)) : await this._worker.getProxy()))()), this._client; |
| 21 |
} |
| 22 |
async getLanguageServiceWorker(...e4) { |
| 23 |
let t2 = await this._getClient(); |
| 24 |
return this._worker && await this._worker.withSyncedResources(e4), t2; |
| 25 |
} |
| 26 |
}, l = {}; |
| 27 |
l[`lib.d.ts`] = true, l[`lib.decorators.d.ts`] = true, l[`lib.decorators.legacy.d.ts`] = true, l[`lib.dom.asynciterable.d.ts`] = true, l[`lib.dom.d.ts`] = true, l[`lib.dom.iterable.d.ts`] = true, l[`lib.es2015.collection.d.ts`] = true, l[`lib.es2015.core.d.ts`] = true, l[`lib.es2015.d.ts`] = true, l[`lib.es2015.generator.d.ts`] = true, l[`lib.es2015.iterable.d.ts`] = true, l[`lib.es2015.promise.d.ts`] = true, l[`lib.es2015.proxy.d.ts`] = true, l[`lib.es2015.reflect.d.ts`] = true, l[`lib.es2015.symbol.d.ts`] = true, l[`lib.es2015.symbol.wellknown.d.ts`] = true, l[`lib.es2016.array.include.d.ts`] = true, l[`lib.es2016.d.ts`] = true, l[`lib.es2016.full.d.ts`] = true, l[`lib.es2016.intl.d.ts`] = true, l[`lib.es2017.arraybuffer.d.ts`] = true, l[`lib.es2017.d.ts`] = true, l[`lib.es2017.date.d.ts`] = true, l[`lib.es2017.full.d.ts`] = true, l[`lib.es2017.intl.d.ts`] = true, l[`lib.es2017.object.d.ts`] = true, l[`lib.es2017.sharedmemory.d.ts`] = true, l[`lib.es2017.string.d.ts`] = true, l[`lib.es2017.typedarrays.d.ts`] = true, l[`lib.es2018.asyncgenerator.d.ts`] = true, l[`lib.es2018.asynciterable.d.ts`] = true, l[`lib.es2018.d.ts`] = true, l[`lib.es2018.full.d.ts`] = true, l[`lib.es2018.intl.d.ts`] = true, l[`lib.es2018.promise.d.ts`] = true, l[`lib.es2018.regexp.d.ts`] = true, l[`lib.es2019.array.d.ts`] = true, l[`lib.es2019.d.ts`] = true, l[`lib.es2019.full.d.ts`] = true, l[`lib.es2019.intl.d.ts`] = true, l[`lib.es2019.object.d.ts`] = true, l[`lib.es2019.string.d.ts`] = true, l[`lib.es2019.symbol.d.ts`] = true, l[`lib.es2020.bigint.d.ts`] = true, l[`lib.es2020.d.ts`] = true, l[`lib.es2020.date.d.ts`] = true, l[`lib.es2020.full.d.ts`] = true, l[`lib.es2020.intl.d.ts`] = true, l[`lib.es2020.number.d.ts`] = true, l[`lib.es2020.promise.d.ts`] = true, l[`lib.es2020.sharedmemory.d.ts`] = true, l[`lib.es2020.string.d.ts`] = true, l[`lib.es2020.symbol.wellknown.d.ts`] = true, l[`lib.es2021.d.ts`] = true, l[`lib.es2021.full.d.ts`] = true, l[`lib.es2021.intl.d.ts`] = true, l[`lib.es2021.promise.d.ts`] = true, l[`lib.es2021.string.d.ts`] = true, l[`lib.es2021.weakref.d.ts`] = true, l[`lib.es2022.array.d.ts`] = true, l[`lib.es2022.d.ts`] = true, l[`lib.es2022.error.d.ts`] = true, l[`lib.es2022.full.d.ts`] = true, l[`lib.es2022.intl.d.ts`] = true, l[`lib.es2022.object.d.ts`] = true, l[`lib.es2022.regexp.d.ts`] = true, l[`lib.es2022.string.d.ts`] = true, l[`lib.es2023.array.d.ts`] = true, l[`lib.es2023.collection.d.ts`] = true, l[`lib.es2023.d.ts`] = true, l[`lib.es2023.full.d.ts`] = true, l[`lib.es2023.intl.d.ts`] = true, l[`lib.es2024.arraybuffer.d.ts`] = true, l[`lib.es2024.collection.d.ts`] = true, l[`lib.es2024.d.ts`] = true, l[`lib.es2024.full.d.ts`] = true, l[`lib.es2024.object.d.ts`] = true, l[`lib.es2024.promise.d.ts`] = true, l[`lib.es2024.regexp.d.ts`] = true, l[`lib.es2024.sharedmemory.d.ts`] = true, l[`lib.es2024.string.d.ts`] = true, l[`lib.es5.d.ts`] = true, l[`lib.es6.d.ts`] = true, l[`lib.esnext.array.d.ts`] = true, l[`lib.esnext.collection.d.ts`] = true, l[`lib.esnext.d.ts`] = true, l[`lib.esnext.decorators.d.ts`] = true, l[`lib.esnext.disposable.d.ts`] = true, l[`lib.esnext.error.d.ts`] = true, l[`lib.esnext.float16.d.ts`] = true, l[`lib.esnext.full.d.ts`] = true, l[`lib.esnext.intl.d.ts`] = true, l[`lib.esnext.iterator.d.ts`] = true, l[`lib.esnext.promise.d.ts`] = true, l[`lib.esnext.sharedmemory.d.ts`] = true, l[`lib.scripthost.d.ts`] = true, l[`lib.webworker.asynciterable.d.ts`] = true, l[`lib.webworker.d.ts`] = true, l[`lib.webworker.importscripts.d.ts`] = true, l[`lib.webworker.iterable.d.ts`] = true; |
| 28 |
function u(e4, t2, n2 = 0) { |
| 29 |
if (typeof e4 == `string`) return e4; |
| 30 |
if (e4 === void 0) return ``; |
| 31 |
let r2 = ``; |
| 32 |
if (n2) { |
| 33 |
r2 += t2; |
| 34 |
for (let e5 = 0; e5 < n2; e5++) r2 += ` `; |
| 35 |
} |
| 36 |
if (r2 += e4.messageText, n2++, e4.next) for (let i2 of e4.next) r2 += u(i2, t2, n2); |
| 37 |
return r2; |
| 38 |
} |
| 39 |
function d(e4) { |
| 40 |
return e4 ? e4.map((e5) => e5.text).join(``) : ``; |
| 41 |
} |
| 42 |
var f = class { |
| 43 |
constructor(e4) { |
| 44 |
this._worker = e4; |
| 45 |
} |
| 46 |
_textSpanToRange(e4, t2) { |
| 47 |
let n2 = e4.getPositionAt(t2.start), r2 = e4.getPositionAt(t2.start + t2.length), { lineNumber: i2, column: a2 } = n2, { lineNumber: o2, column: s2 } = r2; |
| 48 |
return { startLineNumber: i2, startColumn: a2, endLineNumber: o2, endColumn: s2 }; |
| 49 |
} |
| 50 |
}, p = class { |
| 51 |
constructor(e4) { |
| 52 |
this._worker = e4, this._libFiles = {}, this._hasFetchedLibFiles = false, this._fetchLibFilesPromise = null; |
| 53 |
} |
| 54 |
isLibFile(e4) { |
| 55 |
return e4 && e4.path.indexOf(`/lib.`) === 0 ? !!l[e4.path.slice(1)] : false; |
| 56 |
} |
| 57 |
getOrCreateModel(e4) { |
| 58 |
let t2 = n.parse(e4), r2 = a.getModel(t2); |
| 59 |
if (r2) return r2; |
| 60 |
if (this.isLibFile(t2) && this._hasFetchedLibFiles) return a.createModel(this._libFiles[t2.path.slice(1)], `typescript`, t2); |
| 61 |
let i2 = o.getExtraLibs()[e4]; |
| 62 |
return i2 ? a.createModel(i2.content, `typescript`, t2) : null; |
| 63 |
} |
| 64 |
_containsLibFile(e4) { |
| 65 |
for (let t2 of e4) if (this.isLibFile(t2)) return true; |
| 66 |
return false; |
| 67 |
} |
| 68 |
async fetchLibFilesIfNecessary(e4) { |
| 69 |
this._containsLibFile(e4) && await this._fetchLibFiles(); |
| 70 |
} |
| 71 |
_fetchLibFiles() { |
| 72 |
return this._fetchLibFilesPromise || (this._fetchLibFilesPromise = this._worker().then((e4) => e4.getLibFiles()).then((e4) => { |
| 73 |
this._hasFetchedLibFiles = true, this._libFiles = e4; |
| 74 |
})), this._fetchLibFilesPromise; |
| 75 |
} |
| 76 |
}, m = class extends f { |
| 77 |
constructor(e4, t2, n2, r2) { |
| 78 |
super(r2), this._libFiles = e4, this._defaults = t2, this._selector = n2, this._disposables = [], this._listener = /* @__PURE__ */ Object.create(null); |
| 79 |
let i2 = (e5) => { |
| 80 |
if (e5.getLanguageId() !== n2) return; |
| 81 |
let t3 = () => { |
| 82 |
let { onlyVisible: t4 } = this._defaults.getDiagnosticsOptions(); |
| 83 |
t4 ? e5.isAttachedToEditor() && this._doValidate(e5) : this._doValidate(e5); |
| 84 |
}, r3, i3 = e5.onDidChangeContent(() => { |
| 85 |
clearTimeout(r3), r3 = window.setTimeout(t3, 500); |
| 86 |
}), o3 = e5.onDidChangeAttached(() => { |
| 87 |
let { onlyVisible: n3 } = this._defaults.getDiagnosticsOptions(); |
| 88 |
n3 && (e5.isAttachedToEditor() ? t3() : a.setModelMarkers(e5, this._selector, [])); |
| 89 |
}); |
| 90 |
this._listener[e5.uri.toString()] = { dispose() { |
| 91 |
i3.dispose(), o3.dispose(), clearTimeout(r3); |
| 92 |
} }, t3(); |
| 93 |
}, o2 = (e5) => { |
| 94 |
a.setModelMarkers(e5, this._selector, []); |
| 95 |
let t3 = e5.uri.toString(); |
| 96 |
this._listener[t3] && (this._listener[t3].dispose(), delete this._listener[t3]); |
| 97 |
}; |
| 98 |
this._disposables.push(a.onDidCreateModel((e5) => i2(e5))), this._disposables.push(a.onWillDisposeModel(o2)), this._disposables.push(a.onDidChangeModelLanguage((e5) => { |
| 99 |
o2(e5.model), i2(e5.model); |
| 100 |
})), this._disposables.push({ dispose() { |
| 101 |
for (let e5 of a.getModels()) o2(e5); |
| 102 |
} }); |
| 103 |
let s2 = () => { |
| 104 |
for (let e5 of a.getModels()) o2(e5), i2(e5); |
| 105 |
}; |
| 106 |
this._disposables.push(this._defaults.onDidChange(s2)), this._disposables.push(this._defaults.onDidExtraLibsChange(s2)), a.getModels().forEach((e5) => i2(e5)); |
| 107 |
} |
| 108 |
dispose() { |
| 109 |
this._disposables.forEach((e4) => e4 && e4.dispose()), this._disposables = []; |
| 110 |
} |
| 111 |
async _doValidate(e4) { |
| 112 |
let t2 = await this._worker(e4.uri); |
| 113 |
if (e4.isDisposed()) return; |
| 114 |
let r2 = [], { noSyntaxValidation: i2, noSemanticValidation: o2, noSuggestionDiagnostics: s2 } = this._defaults.getDiagnosticsOptions(); |
| 115 |
i2 || r2.push(t2.getSyntacticDiagnostics(e4.uri.toString())), o2 || r2.push(t2.getSemanticDiagnostics(e4.uri.toString())), s2 || r2.push(t2.getSuggestionDiagnostics(e4.uri.toString())); |
| 116 |
let c2 = await Promise.all(r2); |
| 117 |
if (!c2 || e4.isDisposed()) return; |
| 118 |
let l2 = c2.reduce((e5, t3) => t3.concat(e5), []).filter((e5) => (this._defaults.getDiagnosticsOptions().diagnosticCodesToIgnore || []).indexOf(e5.code) === -1), u2 = l2.map((e5) => e5.relatedInformation || []).reduce((e5, t3) => t3.concat(e5), []).map((e5) => e5.file ? n.parse(e5.file.fileName) : null); |
| 119 |
await this._libFiles.fetchLibFilesIfNecessary(u2), !e4.isDisposed() && a.setModelMarkers(e4, this._selector, l2.map((t3) => this._convertDiagnostics(e4, t3))); |
| 120 |
} |
| 121 |
_convertDiagnostics(e4, t2) { |
| 122 |
let n2 = t2.start || 0, r2 = t2.length || 1, { lineNumber: a2, column: o2 } = e4.getPositionAt(n2), { lineNumber: s2, column: c2 } = e4.getPositionAt(n2 + r2), l2 = []; |
| 123 |
return t2.reportsUnnecessary && l2.push(i.Unnecessary), t2.reportsDeprecated && l2.push(i.Deprecated), { severity: this._tsDiagnosticCategoryToMarkerSeverity(t2.category), startLineNumber: a2, startColumn: o2, endLineNumber: s2, endColumn: c2, message: u(t2.messageText, ` |
| 124 |
`), code: t2.code.toString(), tags: l2, relatedInformation: this._convertRelatedInformation(e4, t2.relatedInformation) }; |
| 125 |
} |
| 126 |
_convertRelatedInformation(e4, t2) { |
| 127 |
if (!t2) return []; |
| 128 |
let n2 = []; |
| 129 |
return t2.forEach((t3) => { |
| 130 |
let r2 = e4; |
| 131 |
if (t3.file && (r2 = this._libFiles.getOrCreateModel(t3.file.fileName)), !r2) return; |
| 132 |
let i2 = t3.start || 0, a2 = t3.length || 1, { lineNumber: o2, column: s2 } = r2.getPositionAt(i2), { lineNumber: c2, column: l2 } = r2.getPositionAt(i2 + a2); |
| 133 |
n2.push({ resource: r2.uri, startLineNumber: o2, startColumn: s2, endLineNumber: c2, endColumn: l2, message: u(t3.messageText, ` |
| 134 |
`) }); |
| 135 |
}), n2; |
| 136 |
} |
| 137 |
_tsDiagnosticCategoryToMarkerSeverity(t2) { |
| 138 |
switch (t2) { |
| 139 |
case 1: |
| 140 |
return e.Error; |
| 141 |
case 3: |
| 142 |
return e.Info; |
| 143 |
case 0: |
| 144 |
return e.Warning; |
| 145 |
case 2: |
| 146 |
return e.Hint; |
| 147 |
} |
| 148 |
return e.Info; |
| 149 |
} |
| 150 |
}, h = class e2 extends f { |
| 151 |
get triggerCharacters() { |
| 152 |
return [`.`]; |
| 153 |
} |
| 154 |
async provideCompletionItems(n2, i2, a2, o2) { |
| 155 |
let s2 = n2.getWordUntilPosition(i2), c2 = new t(i2.lineNumber, s2.startColumn, i2.lineNumber, s2.endColumn), l2 = n2.uri, u2 = n2.getOffsetAt(i2), d2 = await this._worker(l2); |
| 156 |
if (n2.isDisposed()) return; |
| 157 |
let f2 = await d2.getCompletionsAtPosition(l2.toString(), u2); |
| 158 |
if (!(!f2 || n2.isDisposed())) return { suggestions: f2.entries.map((a3) => { |
| 159 |
let o3 = c2; |
| 160 |
if (a3.replacementSpan) { |
| 161 |
let e4 = n2.getPositionAt(a3.replacementSpan.start), r2 = n2.getPositionAt(a3.replacementSpan.start + a3.replacementSpan.length); |
| 162 |
o3 = new t(e4.lineNumber, e4.column, r2.lineNumber, r2.column); |
| 163 |
} |
| 164 |
let s3 = []; |
| 165 |
return a3.kindModifiers !== void 0 && a3.kindModifiers.indexOf(`deprecated`) !== -1 && s3.push(r.CompletionItemTag.Deprecated), { uri: l2, position: i2, offset: u2, range: o3, label: a3.name, insertText: a3.name, sortText: a3.sortText, kind: e2.convertKind(a3.kind), tags: s3 }; |
| 166 |
}) }; |
| 167 |
} |
| 168 |
async resolveCompletionItem(t2, n2) { |
| 169 |
let r2 = t2, i2 = r2.uri, a2 = r2.position, o2 = r2.offset, s2 = await (await this._worker(i2)).getCompletionEntryDetails(i2.toString(), o2, r2.label); |
| 170 |
return s2 ? { uri: i2, position: a2, label: s2.name, kind: e2.convertKind(s2.kind), detail: d(s2.displayParts), documentation: { value: e2.createDocumentationString(s2) } } : r2; |
| 171 |
} |
| 172 |
static convertKind(e4) { |
| 173 |
switch (e4) { |
| 174 |
case C.primitiveType: |
| 175 |
case C.keyword: |
| 176 |
return r.CompletionItemKind.Keyword; |
| 177 |
case C.variable: |
| 178 |
case C.localVariable: |
| 179 |
return r.CompletionItemKind.Variable; |
| 180 |
case C.memberVariable: |
| 181 |
case C.memberGetAccessor: |
| 182 |
case C.memberSetAccessor: |
| 183 |
return r.CompletionItemKind.Field; |
| 184 |
case C.function: |
| 185 |
case C.memberFunction: |
| 186 |
case C.constructSignature: |
| 187 |
case C.callSignature: |
| 188 |
case C.indexSignature: |
| 189 |
return r.CompletionItemKind.Function; |
| 190 |
case C.enum: |
| 191 |
return r.CompletionItemKind.Enum; |
| 192 |
case C.module: |
| 193 |
return r.CompletionItemKind.Module; |
| 194 |
case C.class: |
| 195 |
return r.CompletionItemKind.Class; |
| 196 |
case C.interface: |
| 197 |
return r.CompletionItemKind.Interface; |
| 198 |
case C.warning: |
| 199 |
return r.CompletionItemKind.File; |
| 200 |
} |
| 201 |
return r.CompletionItemKind.Property; |
| 202 |
} |
| 203 |
static createDocumentationString(e4) { |
| 204 |
let t2 = d(e4.documentation); |
| 205 |
if (e4.tags) for (let n2 of e4.tags) t2 += ` |
| 206 |
|
| 207 |
${g(n2)}`; |
| 208 |
return t2; |
| 209 |
} |
| 210 |
}; |
| 211 |
function g(e4) { |
| 212 |
let t2 = `*@${e4.name}*`; |
| 213 |
if (e4.name === `param` && e4.text) { |
| 214 |
let [n2, ...r2] = e4.text; |
| 215 |
t2 += `\`${n2.text}\``, r2.length > 0 && (t2 += ` \u2014 ${r2.map((e5) => e5.text).join(` `)}`); |
| 216 |
} else Array.isArray(e4.text) ? t2 += ` \u2014 ${e4.text.map((e5) => e5.text).join(` `)}` : e4.text && (t2 += ` \u2014 ${e4.text}`); |
| 217 |
return t2; |
| 218 |
} |
| 219 |
var _ = class e3 extends f { |
| 220 |
constructor() { |
| 221 |
super(...arguments), this.signatureHelpTriggerCharacters = [`(`, `,`]; |
| 222 |
} |
| 223 |
static _toSignatureHelpTriggerReason(e4) { |
| 224 |
switch (e4.triggerKind) { |
| 225 |
case r.SignatureHelpTriggerKind.TriggerCharacter: |
| 226 |
return e4.triggerCharacter ? e4.isRetrigger ? { kind: `retrigger`, triggerCharacter: e4.triggerCharacter } : { kind: `characterTyped`, triggerCharacter: e4.triggerCharacter } : { kind: `invoked` }; |
| 227 |
case r.SignatureHelpTriggerKind.ContentChange: |
| 228 |
return e4.isRetrigger ? { kind: `retrigger` } : { kind: `invoked` }; |
| 229 |
case r.SignatureHelpTriggerKind.Invoke: |
| 230 |
default: |
| 231 |
return { kind: `invoked` }; |
| 232 |
} |
| 233 |
} |
| 234 |
async provideSignatureHelp(t2, n2, r2, i2) { |
| 235 |
let a2 = t2.uri, o2 = t2.getOffsetAt(n2), s2 = await this._worker(a2); |
| 236 |
if (t2.isDisposed()) return; |
| 237 |
let c2 = await s2.getSignatureHelpItems(a2.toString(), o2, { triggerReason: e3._toSignatureHelpTriggerReason(i2) }); |
| 238 |
if (!c2 || t2.isDisposed()) return; |
| 239 |
let l2 = { activeSignature: c2.selectedItemIndex, activeParameter: c2.argumentIndex, signatures: [] }; |
| 240 |
return c2.items.forEach((e4) => { |
| 241 |
let t3 = { label: ``, parameters: [] }; |
| 242 |
t3.documentation = { value: d(e4.documentation) }, t3.label += d(e4.prefixDisplayParts), e4.parameters.forEach((n3, r3, i3) => { |
| 243 |
let a3 = d(n3.displayParts), o3 = { label: a3, documentation: { value: d(n3.documentation) } }; |
| 244 |
t3.label += a3, t3.parameters.push(o3), r3 < i3.length - 1 && (t3.label += d(e4.separatorDisplayParts)); |
| 245 |
}), t3.label += d(e4.suffixDisplayParts), l2.signatures.push(t3); |
| 246 |
}), { value: l2, dispose() { |
| 247 |
} }; |
| 248 |
} |
| 249 |
}, v = class extends f { |
| 250 |
async provideHover(e4, t2, n2) { |
| 251 |
let r2 = e4.uri, i2 = e4.getOffsetAt(t2), a2 = await this._worker(r2); |
| 252 |
if (e4.isDisposed()) return; |
| 253 |
let o2 = await a2.getQuickInfoAtPosition(r2.toString(), i2); |
| 254 |
if (!o2 || e4.isDisposed()) return; |
| 255 |
let s2 = d(o2.documentation), c2 = o2.tags ? o2.tags.map((e5) => g(e5)).join(` |
| 256 |
|
| 257 |
`) : ``, l2 = d(o2.displayParts); |
| 258 |
return { range: this._textSpanToRange(e4, o2.textSpan), contents: [{ value: "```typescript\n" + l2 + "\n```\n" }, { value: s2 + (c2 ? ` |
| 259 |
|
| 260 |
` + c2 : ``) }] }; |
| 261 |
} |
| 262 |
}, y = class extends f { |
| 263 |
async provideDocumentHighlights(e4, t2, n2) { |
| 264 |
let i2 = e4.uri, a2 = e4.getOffsetAt(t2), o2 = await this._worker(i2); |
| 265 |
if (e4.isDisposed()) return; |
| 266 |
let s2 = await o2.getDocumentHighlights(i2.toString(), a2, [i2.toString()]); |
| 267 |
if (!(!s2 || e4.isDisposed())) return s2.flatMap((t3) => t3.highlightSpans.map((t4) => ({ range: this._textSpanToRange(e4, t4.textSpan), kind: t4.kind === `writtenReference` ? r.DocumentHighlightKind.Write : r.DocumentHighlightKind.Text }))); |
| 268 |
} |
| 269 |
}, b = class extends f { |
| 270 |
constructor(e4, t2) { |
| 271 |
super(t2), this._libFiles = e4; |
| 272 |
} |
| 273 |
async provideDefinition(e4, t2, r2) { |
| 274 |
let i2 = e4.uri, a2 = e4.getOffsetAt(t2), o2 = await this._worker(i2); |
| 275 |
if (e4.isDisposed()) return; |
| 276 |
let s2 = await o2.getDefinitionAtPosition(i2.toString(), a2); |
| 277 |
if (!s2 || e4.isDisposed() || (await this._libFiles.fetchLibFilesIfNecessary(s2.map((e5) => n.parse(e5.fileName))), e4.isDisposed())) return; |
| 278 |
let c2 = []; |
| 279 |
for (let e5 of s2) { |
| 280 |
let t3 = this._libFiles.getOrCreateModel(e5.fileName); |
| 281 |
t3 && c2.push({ uri: t3.uri, range: this._textSpanToRange(t3, e5.textSpan) }); |
| 282 |
} |
| 283 |
return c2; |
| 284 |
} |
| 285 |
}, x = class extends f { |
| 286 |
constructor(e4, t2) { |
| 287 |
super(t2), this._libFiles = e4; |
| 288 |
} |
| 289 |
async provideReferences(e4, t2, r2, i2) { |
| 290 |
let a2 = e4.uri, o2 = e4.getOffsetAt(t2), s2 = await this._worker(a2); |
| 291 |
if (e4.isDisposed()) return; |
| 292 |
let c2 = await s2.getReferencesAtPosition(a2.toString(), o2); |
| 293 |
if (!c2 || e4.isDisposed() || (await this._libFiles.fetchLibFilesIfNecessary(c2.map((e5) => n.parse(e5.fileName))), e4.isDisposed())) return; |
| 294 |
let l2 = []; |
| 295 |
for (let e5 of c2) { |
| 296 |
let t3 = this._libFiles.getOrCreateModel(e5.fileName); |
| 297 |
t3 && l2.push({ uri: t3.uri, range: this._textSpanToRange(t3, e5.textSpan) }); |
| 298 |
} |
| 299 |
return l2; |
| 300 |
} |
| 301 |
}, S = class extends f { |
| 302 |
async provideDocumentSymbols(e4, t2) { |
| 303 |
let n2 = e4.uri, i2 = await this._worker(n2); |
| 304 |
if (e4.isDisposed()) return; |
| 305 |
let a2 = await i2.getNavigationTree(n2.toString()); |
| 306 |
if (!a2 || e4.isDisposed()) return; |
| 307 |
let o2 = (t3, n3) => ({ name: t3.text, detail: ``, kind: w[t3.kind] || r.SymbolKind.Variable, range: this._textSpanToRange(e4, t3.spans[0]), selectionRange: this._textSpanToRange(e4, t3.spans[0]), tags: [], children: t3.childItems?.map((e5) => o2(e5, t3.text)), containerName: n3 }); |
| 308 |
return a2.childItems ? a2.childItems.map((e5) => o2(e5)) : []; |
| 309 |
} |
| 310 |
}, C = class { |
| 311 |
}; |
| 312 |
C.unknown = ``, C.keyword = `keyword`, C.script = `script`, C.module = `module`, C.class = `class`, C.interface = `interface`, C.type = `type`, C.enum = `enum`, C.variable = `var`, C.localVariable = `local var`, C.function = `function`, C.localFunction = `local function`, C.memberFunction = `method`, C.memberGetAccessor = `getter`, C.memberSetAccessor = `setter`, C.memberVariable = `property`, C.constructorImplementation = `constructor`, C.callSignature = `call`, C.indexSignature = `index`, C.constructSignature = `construct`, C.parameter = `parameter`, C.typeParameter = `type parameter`, C.primitiveType = `primitive type`, C.label = `label`, C.alias = `alias`, C.const = `const`, C.let = `let`, C.warning = `warning`; |
| 313 |
var w = /* @__PURE__ */ Object.create(null); |
| 314 |
w[C.module] = r.SymbolKind.Module, w[C.class] = r.SymbolKind.Class, w[C.enum] = r.SymbolKind.Enum, w[C.interface] = r.SymbolKind.Interface, w[C.memberFunction] = r.SymbolKind.Method, w[C.memberVariable] = r.SymbolKind.Property, w[C.memberGetAccessor] = r.SymbolKind.Property, w[C.memberSetAccessor] = r.SymbolKind.Property, w[C.variable] = r.SymbolKind.Variable, w[C.const] = r.SymbolKind.Variable, w[C.localVariable] = r.SymbolKind.Variable, w[C.variable] = r.SymbolKind.Variable, w[C.function] = r.SymbolKind.Function, w[C.localFunction] = r.SymbolKind.Function; |
| 315 |
var T = class extends f { |
| 316 |
static _convertOptions(e4) { |
| 317 |
return { ConvertTabsToSpaces: e4.insertSpaces, TabSize: e4.tabSize, IndentSize: e4.tabSize, IndentStyle: 2, NewLineCharacter: ` |
| 318 |
`, InsertSpaceAfterCommaDelimiter: true, InsertSpaceAfterSemicolonInForStatements: true, InsertSpaceBeforeAndAfterBinaryOperators: true, InsertSpaceAfterKeywordsInControlFlowStatements: true, InsertSpaceAfterFunctionKeywordForAnonymousFunctions: true, InsertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: false, InsertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets: false, InsertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces: false, PlaceOpenBraceOnNewLineForControlBlocks: false, PlaceOpenBraceOnNewLineForFunctions: false }; |
| 319 |
} |
| 320 |
_convertTextChanges(e4, t2) { |
| 321 |
return { text: t2.newText, range: this._textSpanToRange(e4, t2.span) }; |
| 322 |
} |
| 323 |
}, E = class extends T { |
| 324 |
constructor() { |
| 325 |
super(...arguments), this.canFormatMultipleRanges = false; |
| 326 |
} |
| 327 |
async provideDocumentRangeFormattingEdits(e4, t2, n2, r2) { |
| 328 |
let i2 = e4.uri, a2 = e4.getOffsetAt({ lineNumber: t2.startLineNumber, column: t2.startColumn }), o2 = e4.getOffsetAt({ lineNumber: t2.endLineNumber, column: t2.endColumn }), s2 = await this._worker(i2); |
| 329 |
if (e4.isDisposed()) return; |
| 330 |
let c2 = await s2.getFormattingEditsForRange(i2.toString(), a2, o2, T._convertOptions(n2)); |
| 331 |
if (!(!c2 || e4.isDisposed())) return c2.map((t3) => this._convertTextChanges(e4, t3)); |
| 332 |
} |
| 333 |
}, D = class extends T { |
| 334 |
get autoFormatTriggerCharacters() { |
| 335 |
return [`;`, `}`, ` |
| 336 |
`]; |
| 337 |
} |
| 338 |
async provideOnTypeFormattingEdits(e4, t2, n2, r2, i2) { |
| 339 |
let a2 = e4.uri, o2 = e4.getOffsetAt(t2), s2 = await this._worker(a2); |
| 340 |
if (e4.isDisposed()) return; |
| 341 |
let c2 = await s2.getFormattingEditsAfterKeystroke(a2.toString(), o2, n2, T._convertOptions(r2)); |
| 342 |
if (!(!c2 || e4.isDisposed())) return c2.map((t3) => this._convertTextChanges(e4, t3)); |
| 343 |
} |
| 344 |
}, O = class extends T { |
| 345 |
async provideCodeActions(e4, t2, n2, r2) { |
| 346 |
let i2 = e4.uri, a2 = e4.getOffsetAt({ lineNumber: t2.startLineNumber, column: t2.startColumn }), o2 = e4.getOffsetAt({ lineNumber: t2.endLineNumber, column: t2.endColumn }), s2 = T._convertOptions(e4.getOptions()), c2 = n2.markers.filter((e5) => e5.code).map((e5) => e5.code).map(Number), l2 = await this._worker(i2); |
| 347 |
if (e4.isDisposed()) return; |
| 348 |
let u2 = await l2.getCodeFixesAtPosition(i2.toString(), a2, o2, c2, s2); |
| 349 |
return !u2 || e4.isDisposed() ? { actions: [], dispose: () => { |
| 350 |
} } : { actions: u2.filter((e5) => e5.changes.filter((e6) => e6.isNewFile).length === 0).map((t3) => this._tsCodeFixActionToMonacoCodeAction(e4, n2, t3)), dispose: () => { |
| 351 |
} }; |
| 352 |
} |
| 353 |
_tsCodeFixActionToMonacoCodeAction(e4, t2, n2) { |
| 354 |
let r2 = []; |
| 355 |
for (let t3 of n2.changes) for (let n3 of t3.textChanges) r2.push({ resource: e4.uri, versionId: void 0, textEdit: { range: this._textSpanToRange(e4, n3.span), text: n3.newText } }); |
| 356 |
return { title: n2.description, edit: { edits: r2 }, diagnostics: t2.markers, kind: `quickfix` }; |
| 357 |
} |
| 358 |
}, k = class extends f { |
| 359 |
constructor(e4, t2) { |
| 360 |
super(t2), this._libFiles = e4; |
| 361 |
} |
| 362 |
async provideRenameEdits(e4, t2, n2, r2) { |
| 363 |
let i2 = e4.uri, a2 = i2.toString(), o2 = e4.getOffsetAt(t2), s2 = await this._worker(i2); |
| 364 |
if (e4.isDisposed()) return; |
| 365 |
let c2 = await s2.getRenameInfo(a2, o2, { allowRenameOfImportPath: false }); |
| 366 |
if (c2.canRename === false) return { edits: [], rejectReason: c2.localizedErrorMessage }; |
| 367 |
if (c2.fileToRename !== void 0) throw Error(`Renaming files is not supported.`); |
| 368 |
let l2 = await s2.findRenameLocations(a2, o2, false, false, false); |
| 369 |
if (!l2 || e4.isDisposed()) return; |
| 370 |
let u2 = []; |
| 371 |
for (let e5 of l2) { |
| 372 |
let t3 = this._libFiles.getOrCreateModel(e5.fileName); |
| 373 |
if (t3) u2.push({ resource: t3.uri, versionId: void 0, textEdit: { range: this._textSpanToRange(t3, e5.textSpan), text: n2 } }); |
| 374 |
else throw Error(`Unknown file ${e5.fileName}.`); |
| 375 |
} |
| 376 |
return { edits: u2 }; |
| 377 |
} |
| 378 |
}, A = class extends f { |
| 379 |
async provideInlayHints(e4, t2, n2) { |
| 380 |
let r2 = e4.uri, i2 = r2.toString(), a2 = e4.getOffsetAt({ lineNumber: t2.startLineNumber, column: t2.startColumn }), o2 = e4.getOffsetAt({ lineNumber: t2.endLineNumber, column: t2.endColumn }), s2 = await this._worker(r2); |
| 381 |
return e4.isDisposed() ? null : { hints: (await s2.provideInlayHints(i2, a2, o2)).map((t3) => ({ ...t3, label: t3.text, position: e4.getPositionAt(t3.position), kind: this._convertHintKind(t3.kind) })), dispose: () => { |
| 382 |
} }; |
| 383 |
} |
| 384 |
_convertHintKind(e4) { |
| 385 |
switch (e4) { |
| 386 |
case `Parameter`: |
| 387 |
return r.InlayHintKind.Parameter; |
| 388 |
case `Type`: |
| 389 |
return r.InlayHintKind.Type; |
| 390 |
default: |
| 391 |
return r.InlayHintKind.Type; |
| 392 |
} |
| 393 |
} |
| 394 |
}, j, M; |
| 395 |
function N(e4) { |
| 396 |
M = L(e4, `typescript`); |
| 397 |
} |
| 398 |
function P(e4) { |
| 399 |
j = L(e4, `javascript`); |
| 400 |
} |
| 401 |
function F() { |
| 402 |
return new Promise((e4, t2) => { |
| 403 |
if (!j) return t2(`JavaScript not registered!`); |
| 404 |
e4(j); |
| 405 |
}); |
| 406 |
} |
| 407 |
function I() { |
| 408 |
return new Promise((e4, t2) => { |
| 409 |
if (!M) return t2(`TypeScript not registered!`); |
| 410 |
e4(M); |
| 411 |
}); |
| 412 |
} |
| 413 |
function L(e4, t2) { |
| 414 |
let n2 = [], i2 = new c(t2, e4), a2 = (...e5) => i2.getLanguageServiceWorker(...e5), o2 = new p(a2); |
| 415 |
function s2() { |
| 416 |
let { modeConfiguration: i3 } = e4; |
| 417 |
R(n2), i3.completionItems && n2.push(r.registerCompletionItemProvider(t2, new h(a2))), i3.signatureHelp && n2.push(r.registerSignatureHelpProvider(t2, new _(a2))), i3.hovers && n2.push(r.registerHoverProvider(t2, new v(a2))), i3.documentHighlights && n2.push(r.registerDocumentHighlightProvider(t2, new y(a2))), i3.definitions && n2.push(r.registerDefinitionProvider(t2, new b(o2, a2))), i3.references && n2.push(r.registerReferenceProvider(t2, new x(o2, a2))), i3.documentSymbols && n2.push(r.registerDocumentSymbolProvider(t2, new S(a2))), i3.rename && n2.push(r.registerRenameProvider(t2, new k(o2, a2))), i3.documentRangeFormattingEdits && n2.push(r.registerDocumentRangeFormattingEditProvider(t2, new E(a2))), i3.onTypeFormattingEdits && n2.push(r.registerOnTypeFormattingEditProvider(t2, new D(a2))), i3.codeActions && n2.push(r.registerCodeActionProvider(t2, new O(a2))), i3.inlayHints && n2.push(r.registerInlayHintsProvider(t2, new A(a2))), i3.diagnostics && n2.push(new m(o2, e4, t2, a2)); |
| 418 |
} |
| 419 |
return s2(), a2; |
| 420 |
} |
| 421 |
function R(e4) { |
| 422 |
for (; e4.length; ) e4.pop().dispose(); |
| 423 |
} |
| 424 |
export { |
| 425 |
f as Adapter, |
| 426 |
O as CodeActionAdaptor, |
| 427 |
b as DefinitionAdapter, |
| 428 |
m as DiagnosticsAdapter, |
| 429 |
y as DocumentHighlightAdapter, |
| 430 |
E as FormatAdapter, |
| 431 |
T as FormatHelper, |
| 432 |
D as FormatOnTypeAdapter, |
| 433 |
A as InlayHintsAdapter, |
| 434 |
C as Kind, |
| 435 |
p as LibFiles, |
| 436 |
S as OutlineAdapter, |
| 437 |
v as QuickInfoAdapter, |
| 438 |
x as ReferenceAdapter, |
| 439 |
k as RenameAdapter, |
| 440 |
_ as SignatureHelpAdapter, |
| 441 |
h as SuggestAdapter, |
| 442 |
c as WorkerManager, |
| 443 |
u as flattenDiagnosticMessageText, |
| 444 |
F as getJavaScriptWorker, |
| 445 |
I as getTypeScriptWorker, |
| 446 |
P as setupJavaScript, |
| 447 |
N as setupTypeScript |
| 448 |
}; |
| 449 |
|