| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051 |
- /*!-----------------------------------------------------------------------------
- * Copyright (c) Microsoft Corporation. All rights reserved.
- * Version: 0.38.0(0e330ae453813de4e6cf272460fb79c7117073d0)
- * Released under the MIT license
- * https://github.com/microsoft/monaco-editor/blob/main/LICENSE.txt
- *-----------------------------------------------------------------------------*/
- var __defProp = Object.defineProperty;
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
- var __getOwnPropNames = Object.getOwnPropertyNames;
- var __hasOwnProp = Object.prototype.hasOwnProperty;
- var __copyProps = (to, from, except, desc) => {
- if (from && typeof from === "object" || typeof from === "function") {
- for (let key of __getOwnPropNames(from))
- if (!__hasOwnProp.call(to, key) && key !== except)
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
- }
- return to;
- };
- var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
- // src/fillers/monaco-editor-core.ts
- var monaco_editor_core_exports = {};
- __reExport(monaco_editor_core_exports, monaco_editor_core_star);
- import * as monaco_editor_core_star from "../../editor/editor.api.js";
- // src/language/html/workerManager.ts
- var STOP_WHEN_IDLE_FOR = 2 * 60 * 1e3;
- var WorkerManager = class {
- _defaults;
- _idleCheckInterval;
- _lastUsedTime;
- _configChangeListener;
- _worker;
- _client;
- constructor(defaults) {
- this._defaults = defaults;
- this._worker = null;
- this._client = null;
- this._idleCheckInterval = window.setInterval(() => this._checkIfIdle(), 30 * 1e3);
- this._lastUsedTime = 0;
- this._configChangeListener = this._defaults.onDidChange(() => this._stopWorker());
- }
- _stopWorker() {
- if (this._worker) {
- this._worker.dispose();
- this._worker = null;
- }
- this._client = null;
- }
- dispose() {
- clearInterval(this._idleCheckInterval);
- this._configChangeListener.dispose();
- this._stopWorker();
- }
- _checkIfIdle() {
- if (!this._worker) {
- return;
- }
- let timePassedSinceLastUsed = Date.now() - this._lastUsedTime;
- if (timePassedSinceLastUsed > STOP_WHEN_IDLE_FOR) {
- this._stopWorker();
- }
- }
- _getClient() {
- this._lastUsedTime = Date.now();
- if (!this._client) {
- this._worker = monaco_editor_core_exports.editor.createWebWorker({
- moduleId: "vs/language/html/htmlWorker",
- createData: {
- languageSettings: this._defaults.options,
- languageId: this._defaults.languageId
- },
- label: this._defaults.languageId
- });
- this._client = this._worker.getProxy();
- }
- return this._client;
- }
- getLanguageServiceWorker(...resources) {
- let _client;
- return this._getClient().then((client) => {
- _client = client;
- }).then((_) => {
- if (this._worker) {
- return this._worker.withSyncedResources(resources);
- }
- }).then((_) => _client);
- }
- };
- // node_modules/vscode-languageserver-types/lib/esm/main.js
- var integer;
- (function(integer2) {
- integer2.MIN_VALUE = -2147483648;
- integer2.MAX_VALUE = 2147483647;
- })(integer || (integer = {}));
- var uinteger;
- (function(uinteger2) {
- uinteger2.MIN_VALUE = 0;
- uinteger2.MAX_VALUE = 2147483647;
- })(uinteger || (uinteger = {}));
- var Position;
- (function(Position3) {
- function create(line, character) {
- if (line === Number.MAX_VALUE) {
- line = uinteger.MAX_VALUE;
- }
- if (character === Number.MAX_VALUE) {
- character = uinteger.MAX_VALUE;
- }
- return { line, character };
- }
- Position3.create = create;
- function is(value) {
- var candidate = value;
- return Is.objectLiteral(candidate) && Is.uinteger(candidate.line) && Is.uinteger(candidate.character);
- }
- Position3.is = is;
- })(Position || (Position = {}));
- var Range;
- (function(Range3) {
- function create(one, two, three, four) {
- if (Is.uinteger(one) && Is.uinteger(two) && Is.uinteger(three) && Is.uinteger(four)) {
- return { start: Position.create(one, two), end: Position.create(three, four) };
- } else if (Position.is(one) && Position.is(two)) {
- return { start: one, end: two };
- } else {
- throw new Error("Range#create called with invalid arguments[" + one + ", " + two + ", " + three + ", " + four + "]");
- }
- }
- Range3.create = create;
- function is(value) {
- var candidate = value;
- return Is.objectLiteral(candidate) && Position.is(candidate.start) && Position.is(candidate.end);
- }
- Range3.is = is;
- })(Range || (Range = {}));
- var Location;
- (function(Location2) {
- function create(uri, range) {
- return { uri, range };
- }
- Location2.create = create;
- function is(value) {
- var candidate = value;
- return Is.defined(candidate) && Range.is(candidate.range) && (Is.string(candidate.uri) || Is.undefined(candidate.uri));
- }
- Location2.is = is;
- })(Location || (Location = {}));
- var LocationLink;
- (function(LocationLink2) {
- function create(targetUri, targetRange, targetSelectionRange, originSelectionRange) {
- return { targetUri, targetRange, targetSelectionRange, originSelectionRange };
- }
- LocationLink2.create = create;
- function is(value) {
- var candidate = value;
- return Is.defined(candidate) && Range.is(candidate.targetRange) && Is.string(candidate.targetUri) && (Range.is(candidate.targetSelectionRange) || Is.undefined(candidate.targetSelectionRange)) && (Range.is(candidate.originSelectionRange) || Is.undefined(candidate.originSelectionRange));
- }
- LocationLink2.is = is;
- })(LocationLink || (LocationLink = {}));
- var Color;
- (function(Color2) {
- function create(red, green, blue, alpha) {
- return {
- red,
- green,
- blue,
- alpha
- };
- }
- Color2.create = create;
- function is(value) {
- var candidate = value;
- return Is.numberRange(candidate.red, 0, 1) && Is.numberRange(candidate.green, 0, 1) && Is.numberRange(candidate.blue, 0, 1) && Is.numberRange(candidate.alpha, 0, 1);
- }
- Color2.is = is;
- })(Color || (Color = {}));
- var ColorInformation;
- (function(ColorInformation2) {
- function create(range, color) {
- return {
- range,
- color
- };
- }
- ColorInformation2.create = create;
- function is(value) {
- var candidate = value;
- return Range.is(candidate.range) && Color.is(candidate.color);
- }
- ColorInformation2.is = is;
- })(ColorInformation || (ColorInformation = {}));
- var ColorPresentation;
- (function(ColorPresentation2) {
- function create(label, textEdit, additionalTextEdits) {
- return {
- label,
- textEdit,
- additionalTextEdits
- };
- }
- ColorPresentation2.create = create;
- function is(value) {
- var candidate = value;
- return Is.string(candidate.label) && (Is.undefined(candidate.textEdit) || TextEdit.is(candidate)) && (Is.undefined(candidate.additionalTextEdits) || Is.typedArray(candidate.additionalTextEdits, TextEdit.is));
- }
- ColorPresentation2.is = is;
- })(ColorPresentation || (ColorPresentation = {}));
- var FoldingRangeKind;
- (function(FoldingRangeKind2) {
- FoldingRangeKind2["Comment"] = "comment";
- FoldingRangeKind2["Imports"] = "imports";
- FoldingRangeKind2["Region"] = "region";
- })(FoldingRangeKind || (FoldingRangeKind = {}));
- var FoldingRange;
- (function(FoldingRange2) {
- function create(startLine, endLine, startCharacter, endCharacter, kind) {
- var result = {
- startLine,
- endLine
- };
- if (Is.defined(startCharacter)) {
- result.startCharacter = startCharacter;
- }
- if (Is.defined(endCharacter)) {
- result.endCharacter = endCharacter;
- }
- if (Is.defined(kind)) {
- result.kind = kind;
- }
- return result;
- }
- FoldingRange2.create = create;
- function is(value) {
- var candidate = value;
- return Is.uinteger(candidate.startLine) && Is.uinteger(candidate.startLine) && (Is.undefined(candidate.startCharacter) || Is.uinteger(candidate.startCharacter)) && (Is.undefined(candidate.endCharacter) || Is.uinteger(candidate.endCharacter)) && (Is.undefined(candidate.kind) || Is.string(candidate.kind));
- }
- FoldingRange2.is = is;
- })(FoldingRange || (FoldingRange = {}));
- var DiagnosticRelatedInformation;
- (function(DiagnosticRelatedInformation2) {
- function create(location, message) {
- return {
- location,
- message
- };
- }
- DiagnosticRelatedInformation2.create = create;
- function is(value) {
- var candidate = value;
- return Is.defined(candidate) && Location.is(candidate.location) && Is.string(candidate.message);
- }
- DiagnosticRelatedInformation2.is = is;
- })(DiagnosticRelatedInformation || (DiagnosticRelatedInformation = {}));
- var DiagnosticSeverity;
- (function(DiagnosticSeverity2) {
- DiagnosticSeverity2.Error = 1;
- DiagnosticSeverity2.Warning = 2;
- DiagnosticSeverity2.Information = 3;
- DiagnosticSeverity2.Hint = 4;
- })(DiagnosticSeverity || (DiagnosticSeverity = {}));
- var DiagnosticTag;
- (function(DiagnosticTag2) {
- DiagnosticTag2.Unnecessary = 1;
- DiagnosticTag2.Deprecated = 2;
- })(DiagnosticTag || (DiagnosticTag = {}));
- var CodeDescription;
- (function(CodeDescription2) {
- function is(value) {
- var candidate = value;
- return candidate !== void 0 && candidate !== null && Is.string(candidate.href);
- }
- CodeDescription2.is = is;
- })(CodeDescription || (CodeDescription = {}));
- var Diagnostic;
- (function(Diagnostic2) {
- function create(range, message, severity, code, source, relatedInformation) {
- var result = { range, message };
- if (Is.defined(severity)) {
- result.severity = severity;
- }
- if (Is.defined(code)) {
- result.code = code;
- }
- if (Is.defined(source)) {
- result.source = source;
- }
- if (Is.defined(relatedInformation)) {
- result.relatedInformation = relatedInformation;
- }
- return result;
- }
- Diagnostic2.create = create;
- function is(value) {
- var _a;
- var candidate = value;
- return Is.defined(candidate) && Range.is(candidate.range) && Is.string(candidate.message) && (Is.number(candidate.severity) || Is.undefined(candidate.severity)) && (Is.integer(candidate.code) || Is.string(candidate.code) || Is.undefined(candidate.code)) && (Is.undefined(candidate.codeDescription) || Is.string((_a = candidate.codeDescription) === null || _a === void 0 ? void 0 : _a.href)) && (Is.string(candidate.source) || Is.undefined(candidate.source)) && (Is.undefined(candidate.relatedInformation) || Is.typedArray(candidate.relatedInformation, DiagnosticRelatedInformation.is));
- }
- Diagnostic2.is = is;
- })(Diagnostic || (Diagnostic = {}));
- var Command;
- (function(Command2) {
- function create(title, command) {
- var args = [];
- for (var _i = 2; _i < arguments.length; _i++) {
- args[_i - 2] = arguments[_i];
- }
- var result = { title, command };
- if (Is.defined(args) && args.length > 0) {
- result.arguments = args;
- }
- return result;
- }
- Command2.create = create;
- function is(value) {
- var candidate = value;
- return Is.defined(candidate) && Is.string(candidate.title) && Is.string(candidate.command);
- }
- Command2.is = is;
- })(Command || (Command = {}));
- var TextEdit;
- (function(TextEdit2) {
- function replace(range, newText) {
- return { range, newText };
- }
- TextEdit2.replace = replace;
- function insert(position, newText) {
- return { range: { start: position, end: position }, newText };
- }
- TextEdit2.insert = insert;
- function del(range) {
- return { range, newText: "" };
- }
- TextEdit2.del = del;
- function is(value) {
- var candidate = value;
- return Is.objectLiteral(candidate) && Is.string(candidate.newText) && Range.is(candidate.range);
- }
- TextEdit2.is = is;
- })(TextEdit || (TextEdit = {}));
- var ChangeAnnotation;
- (function(ChangeAnnotation2) {
- function create(label, needsConfirmation, description) {
- var result = { label };
- if (needsConfirmation !== void 0) {
- result.needsConfirmation = needsConfirmation;
- }
- if (description !== void 0) {
- result.description = description;
- }
- return result;
- }
- ChangeAnnotation2.create = create;
- function is(value) {
- var candidate = value;
- return candidate !== void 0 && Is.objectLiteral(candidate) && Is.string(candidate.label) && (Is.boolean(candidate.needsConfirmation) || candidate.needsConfirmation === void 0) && (Is.string(candidate.description) || candidate.description === void 0);
- }
- ChangeAnnotation2.is = is;
- })(ChangeAnnotation || (ChangeAnnotation = {}));
- var ChangeAnnotationIdentifier;
- (function(ChangeAnnotationIdentifier2) {
- function is(value) {
- var candidate = value;
- return typeof candidate === "string";
- }
- ChangeAnnotationIdentifier2.is = is;
- })(ChangeAnnotationIdentifier || (ChangeAnnotationIdentifier = {}));
- var AnnotatedTextEdit;
- (function(AnnotatedTextEdit2) {
- function replace(range, newText, annotation) {
- return { range, newText, annotationId: annotation };
- }
- AnnotatedTextEdit2.replace = replace;
- function insert(position, newText, annotation) {
- return { range: { start: position, end: position }, newText, annotationId: annotation };
- }
- AnnotatedTextEdit2.insert = insert;
- function del(range, annotation) {
- return { range, newText: "", annotationId: annotation };
- }
- AnnotatedTextEdit2.del = del;
- function is(value) {
- var candidate = value;
- return TextEdit.is(candidate) && (ChangeAnnotation.is(candidate.annotationId) || ChangeAnnotationIdentifier.is(candidate.annotationId));
- }
- AnnotatedTextEdit2.is = is;
- })(AnnotatedTextEdit || (AnnotatedTextEdit = {}));
- var TextDocumentEdit;
- (function(TextDocumentEdit2) {
- function create(textDocument, edits) {
- return { textDocument, edits };
- }
- TextDocumentEdit2.create = create;
- function is(value) {
- var candidate = value;
- return Is.defined(candidate) && OptionalVersionedTextDocumentIdentifier.is(candidate.textDocument) && Array.isArray(candidate.edits);
- }
- TextDocumentEdit2.is = is;
- })(TextDocumentEdit || (TextDocumentEdit = {}));
- var CreateFile;
- (function(CreateFile2) {
- function create(uri, options, annotation) {
- var result = {
- kind: "create",
- uri
- };
- if (options !== void 0 && (options.overwrite !== void 0 || options.ignoreIfExists !== void 0)) {
- result.options = options;
- }
- if (annotation !== void 0) {
- result.annotationId = annotation;
- }
- return result;
- }
- CreateFile2.create = create;
- function is(value) {
- var candidate = value;
- return candidate && candidate.kind === "create" && Is.string(candidate.uri) && (candidate.options === void 0 || (candidate.options.overwrite === void 0 || Is.boolean(candidate.options.overwrite)) && (candidate.options.ignoreIfExists === void 0 || Is.boolean(candidate.options.ignoreIfExists))) && (candidate.annotationId === void 0 || ChangeAnnotationIdentifier.is(candidate.annotationId));
- }
- CreateFile2.is = is;
- })(CreateFile || (CreateFile = {}));
- var RenameFile;
- (function(RenameFile2) {
- function create(oldUri, newUri, options, annotation) {
- var result = {
- kind: "rename",
- oldUri,
- newUri
- };
- if (options !== void 0 && (options.overwrite !== void 0 || options.ignoreIfExists !== void 0)) {
- result.options = options;
- }
- if (annotation !== void 0) {
- result.annotationId = annotation;
- }
- return result;
- }
- RenameFile2.create = create;
- function is(value) {
- var candidate = value;
- return candidate && candidate.kind === "rename" && Is.string(candidate.oldUri) && Is.string(candidate.newUri) && (candidate.options === void 0 || (candidate.options.overwrite === void 0 || Is.boolean(candidate.options.overwrite)) && (candidate.options.ignoreIfExists === void 0 || Is.boolean(candidate.options.ignoreIfExists))) && (candidate.annotationId === void 0 || ChangeAnnotationIdentifier.is(candidate.annotationId));
- }
- RenameFile2.is = is;
- })(RenameFile || (RenameFile = {}));
- var DeleteFile;
- (function(DeleteFile2) {
- function create(uri, options, annotation) {
- var result = {
- kind: "delete",
- uri
- };
- if (options !== void 0 && (options.recursive !== void 0 || options.ignoreIfNotExists !== void 0)) {
- result.options = options;
- }
- if (annotation !== void 0) {
- result.annotationId = annotation;
- }
- return result;
- }
- DeleteFile2.create = create;
- function is(value) {
- var candidate = value;
- return candidate && candidate.kind === "delete" && Is.string(candidate.uri) && (candidate.options === void 0 || (candidate.options.recursive === void 0 || Is.boolean(candidate.options.recursive)) && (candidate.options.ignoreIfNotExists === void 0 || Is.boolean(candidate.options.ignoreIfNotExists))) && (candidate.annotationId === void 0 || ChangeAnnotationIdentifier.is(candidate.annotationId));
- }
- DeleteFile2.is = is;
- })(DeleteFile || (DeleteFile = {}));
- var WorkspaceEdit;
- (function(WorkspaceEdit2) {
- function is(value) {
- var candidate = value;
- return candidate && (candidate.changes !== void 0 || candidate.documentChanges !== void 0) && (candidate.documentChanges === void 0 || candidate.documentChanges.every(function(change) {
- if (Is.string(change.kind)) {
- return CreateFile.is(change) || RenameFile.is(change) || DeleteFile.is(change);
- } else {
- return TextDocumentEdit.is(change);
- }
- }));
- }
- WorkspaceEdit2.is = is;
- })(WorkspaceEdit || (WorkspaceEdit = {}));
- var TextEditChangeImpl = function() {
- function TextEditChangeImpl2(edits, changeAnnotations) {
- this.edits = edits;
- this.changeAnnotations = changeAnnotations;
- }
- TextEditChangeImpl2.prototype.insert = function(position, newText, annotation) {
- var edit;
- var id;
- if (annotation === void 0) {
- edit = TextEdit.insert(position, newText);
- } else if (ChangeAnnotationIdentifier.is(annotation)) {
- id = annotation;
- edit = AnnotatedTextEdit.insert(position, newText, annotation);
- } else {
- this.assertChangeAnnotations(this.changeAnnotations);
- id = this.changeAnnotations.manage(annotation);
- edit = AnnotatedTextEdit.insert(position, newText, id);
- }
- this.edits.push(edit);
- if (id !== void 0) {
- return id;
- }
- };
- TextEditChangeImpl2.prototype.replace = function(range, newText, annotation) {
- var edit;
- var id;
- if (annotation === void 0) {
- edit = TextEdit.replace(range, newText);
- } else if (ChangeAnnotationIdentifier.is(annotation)) {
- id = annotation;
- edit = AnnotatedTextEdit.replace(range, newText, annotation);
- } else {
- this.assertChangeAnnotations(this.changeAnnotations);
- id = this.changeAnnotations.manage(annotation);
- edit = AnnotatedTextEdit.replace(range, newText, id);
- }
- this.edits.push(edit);
- if (id !== void 0) {
- return id;
- }
- };
- TextEditChangeImpl2.prototype.delete = function(range, annotation) {
- var edit;
- var id;
- if (annotation === void 0) {
- edit = TextEdit.del(range);
- } else if (ChangeAnnotationIdentifier.is(annotation)) {
- id = annotation;
- edit = AnnotatedTextEdit.del(range, annotation);
- } else {
- this.assertChangeAnnotations(this.changeAnnotations);
- id = this.changeAnnotations.manage(annotation);
- edit = AnnotatedTextEdit.del(range, id);
- }
- this.edits.push(edit);
- if (id !== void 0) {
- return id;
- }
- };
- TextEditChangeImpl2.prototype.add = function(edit) {
- this.edits.push(edit);
- };
- TextEditChangeImpl2.prototype.all = function() {
- return this.edits;
- };
- TextEditChangeImpl2.prototype.clear = function() {
- this.edits.splice(0, this.edits.length);
- };
- TextEditChangeImpl2.prototype.assertChangeAnnotations = function(value) {
- if (value === void 0) {
- throw new Error("Text edit change is not configured to manage change annotations.");
- }
- };
- return TextEditChangeImpl2;
- }();
- var ChangeAnnotations = function() {
- function ChangeAnnotations2(annotations) {
- this._annotations = annotations === void 0 ? /* @__PURE__ */ Object.create(null) : annotations;
- this._counter = 0;
- this._size = 0;
- }
- ChangeAnnotations2.prototype.all = function() {
- return this._annotations;
- };
- Object.defineProperty(ChangeAnnotations2.prototype, "size", {
- get: function() {
- return this._size;
- },
- enumerable: false,
- configurable: true
- });
- ChangeAnnotations2.prototype.manage = function(idOrAnnotation, annotation) {
- var id;
- if (ChangeAnnotationIdentifier.is(idOrAnnotation)) {
- id = idOrAnnotation;
- } else {
- id = this.nextId();
- annotation = idOrAnnotation;
- }
- if (this._annotations[id] !== void 0) {
- throw new Error("Id " + id + " is already in use.");
- }
- if (annotation === void 0) {
- throw new Error("No annotation provided for id " + id);
- }
- this._annotations[id] = annotation;
- this._size++;
- return id;
- };
- ChangeAnnotations2.prototype.nextId = function() {
- this._counter++;
- return this._counter.toString();
- };
- return ChangeAnnotations2;
- }();
- var WorkspaceChange = function() {
- function WorkspaceChange2(workspaceEdit) {
- var _this = this;
- this._textEditChanges = /* @__PURE__ */ Object.create(null);
- if (workspaceEdit !== void 0) {
- this._workspaceEdit = workspaceEdit;
- if (workspaceEdit.documentChanges) {
- this._changeAnnotations = new ChangeAnnotations(workspaceEdit.changeAnnotations);
- workspaceEdit.changeAnnotations = this._changeAnnotations.all();
- workspaceEdit.documentChanges.forEach(function(change) {
- if (TextDocumentEdit.is(change)) {
- var textEditChange = new TextEditChangeImpl(change.edits, _this._changeAnnotations);
- _this._textEditChanges[change.textDocument.uri] = textEditChange;
- }
- });
- } else if (workspaceEdit.changes) {
- Object.keys(workspaceEdit.changes).forEach(function(key) {
- var textEditChange = new TextEditChangeImpl(workspaceEdit.changes[key]);
- _this._textEditChanges[key] = textEditChange;
- });
- }
- } else {
- this._workspaceEdit = {};
- }
- }
- Object.defineProperty(WorkspaceChange2.prototype, "edit", {
- get: function() {
- this.initDocumentChanges();
- if (this._changeAnnotations !== void 0) {
- if (this._changeAnnotations.size === 0) {
- this._workspaceEdit.changeAnnotations = void 0;
- } else {
- this._workspaceEdit.changeAnnotations = this._changeAnnotations.all();
- }
- }
- return this._workspaceEdit;
- },
- enumerable: false,
- configurable: true
- });
- WorkspaceChange2.prototype.getTextEditChange = function(key) {
- if (OptionalVersionedTextDocumentIdentifier.is(key)) {
- this.initDocumentChanges();
- if (this._workspaceEdit.documentChanges === void 0) {
- throw new Error("Workspace edit is not configured for document changes.");
- }
- var textDocument = { uri: key.uri, version: key.version };
- var result = this._textEditChanges[textDocument.uri];
- if (!result) {
- var edits = [];
- var textDocumentEdit = {
- textDocument,
- edits
- };
- this._workspaceEdit.documentChanges.push(textDocumentEdit);
- result = new TextEditChangeImpl(edits, this._changeAnnotations);
- this._textEditChanges[textDocument.uri] = result;
- }
- return result;
- } else {
- this.initChanges();
- if (this._workspaceEdit.changes === void 0) {
- throw new Error("Workspace edit is not configured for normal text edit changes.");
- }
- var result = this._textEditChanges[key];
- if (!result) {
- var edits = [];
- this._workspaceEdit.changes[key] = edits;
- result = new TextEditChangeImpl(edits);
- this._textEditChanges[key] = result;
- }
- return result;
- }
- };
- WorkspaceChange2.prototype.initDocumentChanges = function() {
- if (this._workspaceEdit.documentChanges === void 0 && this._workspaceEdit.changes === void 0) {
- this._changeAnnotations = new ChangeAnnotations();
- this._workspaceEdit.documentChanges = [];
- this._workspaceEdit.changeAnnotations = this._changeAnnotations.all();
- }
- };
- WorkspaceChange2.prototype.initChanges = function() {
- if (this._workspaceEdit.documentChanges === void 0 && this._workspaceEdit.changes === void 0) {
- this._workspaceEdit.changes = /* @__PURE__ */ Object.create(null);
- }
- };
- WorkspaceChange2.prototype.createFile = function(uri, optionsOrAnnotation, options) {
- this.initDocumentChanges();
- if (this._workspaceEdit.documentChanges === void 0) {
- throw new Error("Workspace edit is not configured for document changes.");
- }
- var annotation;
- if (ChangeAnnotation.is(optionsOrAnnotation) || ChangeAnnotationIdentifier.is(optionsOrAnnotation)) {
- annotation = optionsOrAnnotation;
- } else {
- options = optionsOrAnnotation;
- }
- var operation;
- var id;
- if (annotation === void 0) {
- operation = CreateFile.create(uri, options);
- } else {
- id = ChangeAnnotationIdentifier.is(annotation) ? annotation : this._changeAnnotations.manage(annotation);
- operation = CreateFile.create(uri, options, id);
- }
- this._workspaceEdit.documentChanges.push(operation);
- if (id !== void 0) {
- return id;
- }
- };
- WorkspaceChange2.prototype.renameFile = function(oldUri, newUri, optionsOrAnnotation, options) {
- this.initDocumentChanges();
- if (this._workspaceEdit.documentChanges === void 0) {
- throw new Error("Workspace edit is not configured for document changes.");
- }
- var annotation;
- if (ChangeAnnotation.is(optionsOrAnnotation) || ChangeAnnotationIdentifier.is(optionsOrAnnotation)) {
- annotation = optionsOrAnnotation;
- } else {
- options = optionsOrAnnotation;
- }
- var operation;
- var id;
- if (annotation === void 0) {
- operation = RenameFile.create(oldUri, newUri, options);
- } else {
- id = ChangeAnnotationIdentifier.is(annotation) ? annotation : this._changeAnnotations.manage(annotation);
- operation = RenameFile.create(oldUri, newUri, options, id);
- }
- this._workspaceEdit.documentChanges.push(operation);
- if (id !== void 0) {
- return id;
- }
- };
- WorkspaceChange2.prototype.deleteFile = function(uri, optionsOrAnnotation, options) {
- this.initDocumentChanges();
- if (this._workspaceEdit.documentChanges === void 0) {
- throw new Error("Workspace edit is not configured for document changes.");
- }
- var annotation;
- if (ChangeAnnotation.is(optionsOrAnnotation) || ChangeAnnotationIdentifier.is(optionsOrAnnotation)) {
- annotation = optionsOrAnnotation;
- } else {
- options = optionsOrAnnotation;
- }
- var operation;
- var id;
- if (annotation === void 0) {
- operation = DeleteFile.create(uri, options);
- } else {
- id = ChangeAnnotationIdentifier.is(annotation) ? annotation : this._changeAnnotations.manage(annotation);
- operation = DeleteFile.create(uri, options, id);
- }
- this._workspaceEdit.documentChanges.push(operation);
- if (id !== void 0) {
- return id;
- }
- };
- return WorkspaceChange2;
- }();
- var TextDocumentIdentifier;
- (function(TextDocumentIdentifier2) {
- function create(uri) {
- return { uri };
- }
- TextDocumentIdentifier2.create = create;
- function is(value) {
- var candidate = value;
- return Is.defined(candidate) && Is.string(candidate.uri);
- }
- TextDocumentIdentifier2.is = is;
- })(TextDocumentIdentifier || (TextDocumentIdentifier = {}));
- var VersionedTextDocumentIdentifier;
- (function(VersionedTextDocumentIdentifier2) {
- function create(uri, version) {
- return { uri, version };
- }
- VersionedTextDocumentIdentifier2.create = create;
- function is(value) {
- var candidate = value;
- return Is.defined(candidate) && Is.string(candidate.uri) && Is.integer(candidate.version);
- }
- VersionedTextDocumentIdentifier2.is = is;
- })(VersionedTextDocumentIdentifier || (VersionedTextDocumentIdentifier = {}));
- var OptionalVersionedTextDocumentIdentifier;
- (function(OptionalVersionedTextDocumentIdentifier2) {
- function create(uri, version) {
- return { uri, version };
- }
- OptionalVersionedTextDocumentIdentifier2.create = create;
- function is(value) {
- var candidate = value;
- return Is.defined(candidate) && Is.string(candidate.uri) && (candidate.version === null || Is.integer(candidate.version));
- }
- OptionalVersionedTextDocumentIdentifier2.is = is;
- })(OptionalVersionedTextDocumentIdentifier || (OptionalVersionedTextDocumentIdentifier = {}));
- var TextDocumentItem;
- (function(TextDocumentItem2) {
- function create(uri, languageId, version, text) {
- return { uri, languageId, version, text };
- }
- TextDocumentItem2.create = create;
- function is(value) {
- var candidate = value;
- return Is.defined(candidate) && Is.string(candidate.uri) && Is.string(candidate.languageId) && Is.integer(candidate.version) && Is.string(candidate.text);
- }
- TextDocumentItem2.is = is;
- })(TextDocumentItem || (TextDocumentItem = {}));
- var MarkupKind;
- (function(MarkupKind2) {
- MarkupKind2.PlainText = "plaintext";
- MarkupKind2.Markdown = "markdown";
- })(MarkupKind || (MarkupKind = {}));
- (function(MarkupKind2) {
- function is(value) {
- var candidate = value;
- return candidate === MarkupKind2.PlainText || candidate === MarkupKind2.Markdown;
- }
- MarkupKind2.is = is;
- })(MarkupKind || (MarkupKind = {}));
- var MarkupContent;
- (function(MarkupContent2) {
- function is(value) {
- var candidate = value;
- return Is.objectLiteral(value) && MarkupKind.is(candidate.kind) && Is.string(candidate.value);
- }
- MarkupContent2.is = is;
- })(MarkupContent || (MarkupContent = {}));
- var CompletionItemKind;
- (function(CompletionItemKind2) {
- CompletionItemKind2.Text = 1;
- CompletionItemKind2.Method = 2;
- CompletionItemKind2.Function = 3;
- CompletionItemKind2.Constructor = 4;
- CompletionItemKind2.Field = 5;
- CompletionItemKind2.Variable = 6;
- CompletionItemKind2.Class = 7;
- CompletionItemKind2.Interface = 8;
- CompletionItemKind2.Module = 9;
- CompletionItemKind2.Property = 10;
- CompletionItemKind2.Unit = 11;
- CompletionItemKind2.Value = 12;
- CompletionItemKind2.Enum = 13;
- CompletionItemKind2.Keyword = 14;
- CompletionItemKind2.Snippet = 15;
- CompletionItemKind2.Color = 16;
- CompletionItemKind2.File = 17;
- CompletionItemKind2.Reference = 18;
- CompletionItemKind2.Folder = 19;
- CompletionItemKind2.EnumMember = 20;
- CompletionItemKind2.Constant = 21;
- CompletionItemKind2.Struct = 22;
- CompletionItemKind2.Event = 23;
- CompletionItemKind2.Operator = 24;
- CompletionItemKind2.TypeParameter = 25;
- })(CompletionItemKind || (CompletionItemKind = {}));
- var InsertTextFormat;
- (function(InsertTextFormat2) {
- InsertTextFormat2.PlainText = 1;
- InsertTextFormat2.Snippet = 2;
- })(InsertTextFormat || (InsertTextFormat = {}));
- var CompletionItemTag;
- (function(CompletionItemTag2) {
- CompletionItemTag2.Deprecated = 1;
- })(CompletionItemTag || (CompletionItemTag = {}));
- var InsertReplaceEdit;
- (function(InsertReplaceEdit2) {
- function create(newText, insert, replace) {
- return { newText, insert, replace };
- }
- InsertReplaceEdit2.create = create;
- function is(value) {
- var candidate = value;
- return candidate && Is.string(candidate.newText) && Range.is(candidate.insert) && Range.is(candidate.replace);
- }
- InsertReplaceEdit2.is = is;
- })(InsertReplaceEdit || (InsertReplaceEdit = {}));
- var InsertTextMode;
- (function(InsertTextMode2) {
- InsertTextMode2.asIs = 1;
- InsertTextMode2.adjustIndentation = 2;
- })(InsertTextMode || (InsertTextMode = {}));
- var CompletionItem;
- (function(CompletionItem2) {
- function create(label) {
- return { label };
- }
- CompletionItem2.create = create;
- })(CompletionItem || (CompletionItem = {}));
- var CompletionList;
- (function(CompletionList2) {
- function create(items, isIncomplete) {
- return { items: items ? items : [], isIncomplete: !!isIncomplete };
- }
- CompletionList2.create = create;
- })(CompletionList || (CompletionList = {}));
- var MarkedString;
- (function(MarkedString2) {
- function fromPlainText(plainText) {
- return plainText.replace(/[\\`*_{}[\]()#+\-.!]/g, "\\$&");
- }
- MarkedString2.fromPlainText = fromPlainText;
- function is(value) {
- var candidate = value;
- return Is.string(candidate) || Is.objectLiteral(candidate) && Is.string(candidate.language) && Is.string(candidate.value);
- }
- MarkedString2.is = is;
- })(MarkedString || (MarkedString = {}));
- var Hover;
- (function(Hover2) {
- function is(value) {
- var candidate = value;
- return !!candidate && Is.objectLiteral(candidate) && (MarkupContent.is(candidate.contents) || MarkedString.is(candidate.contents) || Is.typedArray(candidate.contents, MarkedString.is)) && (value.range === void 0 || Range.is(value.range));
- }
- Hover2.is = is;
- })(Hover || (Hover = {}));
- var ParameterInformation;
- (function(ParameterInformation2) {
- function create(label, documentation) {
- return documentation ? { label, documentation } : { label };
- }
- ParameterInformation2.create = create;
- })(ParameterInformation || (ParameterInformation = {}));
- var SignatureInformation;
- (function(SignatureInformation2) {
- function create(label, documentation) {
- var parameters = [];
- for (var _i = 2; _i < arguments.length; _i++) {
- parameters[_i - 2] = arguments[_i];
- }
- var result = { label };
- if (Is.defined(documentation)) {
- result.documentation = documentation;
- }
- if (Is.defined(parameters)) {
- result.parameters = parameters;
- } else {
- result.parameters = [];
- }
- return result;
- }
- SignatureInformation2.create = create;
- })(SignatureInformation || (SignatureInformation = {}));
- var DocumentHighlightKind;
- (function(DocumentHighlightKind2) {
- DocumentHighlightKind2.Text = 1;
- DocumentHighlightKind2.Read = 2;
- DocumentHighlightKind2.Write = 3;
- })(DocumentHighlightKind || (DocumentHighlightKind = {}));
- var DocumentHighlight;
- (function(DocumentHighlight2) {
- function create(range, kind) {
- var result = { range };
- if (Is.number(kind)) {
- result.kind = kind;
- }
- return result;
- }
- DocumentHighlight2.create = create;
- })(DocumentHighlight || (DocumentHighlight = {}));
- var SymbolKind;
- (function(SymbolKind2) {
- SymbolKind2.File = 1;
- SymbolKind2.Module = 2;
- SymbolKind2.Namespace = 3;
- SymbolKind2.Package = 4;
- SymbolKind2.Class = 5;
- SymbolKind2.Method = 6;
- SymbolKind2.Property = 7;
- SymbolKind2.Field = 8;
- SymbolKind2.Constructor = 9;
- SymbolKind2.Enum = 10;
- SymbolKind2.Interface = 11;
- SymbolKind2.Function = 12;
- SymbolKind2.Variable = 13;
- SymbolKind2.Constant = 14;
- SymbolKind2.String = 15;
- SymbolKind2.Number = 16;
- SymbolKind2.Boolean = 17;
- SymbolKind2.Array = 18;
- SymbolKind2.Object = 19;
- SymbolKind2.Key = 20;
- SymbolKind2.Null = 21;
- SymbolKind2.EnumMember = 22;
- SymbolKind2.Struct = 23;
- SymbolKind2.Event = 24;
- SymbolKind2.Operator = 25;
- SymbolKind2.TypeParameter = 26;
- })(SymbolKind || (SymbolKind = {}));
- var SymbolTag;
- (function(SymbolTag2) {
- SymbolTag2.Deprecated = 1;
- })(SymbolTag || (SymbolTag = {}));
- var SymbolInformation;
- (function(SymbolInformation2) {
- function create(name, kind, range, uri, containerName) {
- var result = {
- name,
- kind,
- location: { uri, range }
- };
- if (containerName) {
- result.containerName = containerName;
- }
- return result;
- }
- SymbolInformation2.create = create;
- })(SymbolInformation || (SymbolInformation = {}));
- var DocumentSymbol;
- (function(DocumentSymbol2) {
- function create(name, detail, kind, range, selectionRange, children) {
- var result = {
- name,
- detail,
- kind,
- range,
- selectionRange
- };
- if (children !== void 0) {
- result.children = children;
- }
- return result;
- }
- DocumentSymbol2.create = create;
- function is(value) {
- var candidate = value;
- return candidate && Is.string(candidate.name) && Is.number(candidate.kind) && Range.is(candidate.range) && Range.is(candidate.selectionRange) && (candidate.detail === void 0 || Is.string(candidate.detail)) && (candidate.deprecated === void 0 || Is.boolean(candidate.deprecated)) && (candidate.children === void 0 || Array.isArray(candidate.children)) && (candidate.tags === void 0 || Array.isArray(candidate.tags));
- }
- DocumentSymbol2.is = is;
- })(DocumentSymbol || (DocumentSymbol = {}));
- var CodeActionKind;
- (function(CodeActionKind2) {
- CodeActionKind2.Empty = "";
- CodeActionKind2.QuickFix = "quickfix";
- CodeActionKind2.Refactor = "refactor";
- CodeActionKind2.RefactorExtract = "refactor.extract";
- CodeActionKind2.RefactorInline = "refactor.inline";
- CodeActionKind2.RefactorRewrite = "refactor.rewrite";
- CodeActionKind2.Source = "source";
- CodeActionKind2.SourceOrganizeImports = "source.organizeImports";
- CodeActionKind2.SourceFixAll = "source.fixAll";
- })(CodeActionKind || (CodeActionKind = {}));
- var CodeActionContext;
- (function(CodeActionContext2) {
- function create(diagnostics, only) {
- var result = { diagnostics };
- if (only !== void 0 && only !== null) {
- result.only = only;
- }
- return result;
- }
- CodeActionContext2.create = create;
- function is(value) {
- var candidate = value;
- return Is.defined(candidate) && Is.typedArray(candidate.diagnostics, Diagnostic.is) && (candidate.only === void 0 || Is.typedArray(candidate.only, Is.string));
- }
- CodeActionContext2.is = is;
- })(CodeActionContext || (CodeActionContext = {}));
- var CodeAction;
- (function(CodeAction2) {
- function create(title, kindOrCommandOrEdit, kind) {
- var result = { title };
- var checkKind = true;
- if (typeof kindOrCommandOrEdit === "string") {
- checkKind = false;
- result.kind = kindOrCommandOrEdit;
- } else if (Command.is(kindOrCommandOrEdit)) {
- result.command = kindOrCommandOrEdit;
- } else {
- result.edit = kindOrCommandOrEdit;
- }
- if (checkKind && kind !== void 0) {
- result.kind = kind;
- }
- return result;
- }
- CodeAction2.create = create;
- function is(value) {
- var candidate = value;
- return candidate && Is.string(candidate.title) && (candidate.diagnostics === void 0 || Is.typedArray(candidate.diagnostics, Diagnostic.is)) && (candidate.kind === void 0 || Is.string(candidate.kind)) && (candidate.edit !== void 0 || candidate.command !== void 0) && (candidate.command === void 0 || Command.is(candidate.command)) && (candidate.isPreferred === void 0 || Is.boolean(candidate.isPreferred)) && (candidate.edit === void 0 || WorkspaceEdit.is(candidate.edit));
- }
- CodeAction2.is = is;
- })(CodeAction || (CodeAction = {}));
- var CodeLens;
- (function(CodeLens2) {
- function create(range, data) {
- var result = { range };
- if (Is.defined(data)) {
- result.data = data;
- }
- return result;
- }
- CodeLens2.create = create;
- function is(value) {
- var candidate = value;
- return Is.defined(candidate) && Range.is(candidate.range) && (Is.undefined(candidate.command) || Command.is(candidate.command));
- }
- CodeLens2.is = is;
- })(CodeLens || (CodeLens = {}));
- var FormattingOptions;
- (function(FormattingOptions2) {
- function create(tabSize, insertSpaces) {
- return { tabSize, insertSpaces };
- }
- FormattingOptions2.create = create;
- function is(value) {
- var candidate = value;
- return Is.defined(candidate) && Is.uinteger(candidate.tabSize) && Is.boolean(candidate.insertSpaces);
- }
- FormattingOptions2.is = is;
- })(FormattingOptions || (FormattingOptions = {}));
- var DocumentLink;
- (function(DocumentLink2) {
- function create(range, target, data) {
- return { range, target, data };
- }
- DocumentLink2.create = create;
- function is(value) {
- var candidate = value;
- return Is.defined(candidate) && Range.is(candidate.range) && (Is.undefined(candidate.target) || Is.string(candidate.target));
- }
- DocumentLink2.is = is;
- })(DocumentLink || (DocumentLink = {}));
- var SelectionRange;
- (function(SelectionRange2) {
- function create(range, parent) {
- return { range, parent };
- }
- SelectionRange2.create = create;
- function is(value) {
- var candidate = value;
- return candidate !== void 0 && Range.is(candidate.range) && (candidate.parent === void 0 || SelectionRange2.is(candidate.parent));
- }
- SelectionRange2.is = is;
- })(SelectionRange || (SelectionRange = {}));
- var TextDocument;
- (function(TextDocument2) {
- function create(uri, languageId, version, content) {
- return new FullTextDocument(uri, languageId, version, content);
- }
- TextDocument2.create = create;
- function is(value) {
- var candidate = value;
- return Is.defined(candidate) && Is.string(candidate.uri) && (Is.undefined(candidate.languageId) || Is.string(candidate.languageId)) && Is.uinteger(candidate.lineCount) && Is.func(candidate.getText) && Is.func(candidate.positionAt) && Is.func(candidate.offsetAt) ? true : false;
- }
- TextDocument2.is = is;
- function applyEdits(document, edits) {
- var text = document.getText();
- var sortedEdits = mergeSort(edits, function(a, b) {
- var diff = a.range.start.line - b.range.start.line;
- if (diff === 0) {
- return a.range.start.character - b.range.start.character;
- }
- return diff;
- });
- var lastModifiedOffset = text.length;
- for (var i = sortedEdits.length - 1; i >= 0; i--) {
- var e = sortedEdits[i];
- var startOffset = document.offsetAt(e.range.start);
- var endOffset = document.offsetAt(e.range.end);
- if (endOffset <= lastModifiedOffset) {
- text = text.substring(0, startOffset) + e.newText + text.substring(endOffset, text.length);
- } else {
- throw new Error("Overlapping edit");
- }
- lastModifiedOffset = startOffset;
- }
- return text;
- }
- TextDocument2.applyEdits = applyEdits;
- function mergeSort(data, compare) {
- if (data.length <= 1) {
- return data;
- }
- var p = data.length / 2 | 0;
- var left = data.slice(0, p);
- var right = data.slice(p);
- mergeSort(left, compare);
- mergeSort(right, compare);
- var leftIdx = 0;
- var rightIdx = 0;
- var i = 0;
- while (leftIdx < left.length && rightIdx < right.length) {
- var ret = compare(left[leftIdx], right[rightIdx]);
- if (ret <= 0) {
- data[i++] = left[leftIdx++];
- } else {
- data[i++] = right[rightIdx++];
- }
- }
- while (leftIdx < left.length) {
- data[i++] = left[leftIdx++];
- }
- while (rightIdx < right.length) {
- data[i++] = right[rightIdx++];
- }
- return data;
- }
- })(TextDocument || (TextDocument = {}));
- var FullTextDocument = function() {
- function FullTextDocument2(uri, languageId, version, content) {
- this._uri = uri;
- this._languageId = languageId;
- this._version = version;
- this._content = content;
- this._lineOffsets = void 0;
- }
- Object.defineProperty(FullTextDocument2.prototype, "uri", {
- get: function() {
- return this._uri;
- },
- enumerable: false,
- configurable: true
- });
- Object.defineProperty(FullTextDocument2.prototype, "languageId", {
- get: function() {
- return this._languageId;
- },
- enumerable: false,
- configurable: true
- });
- Object.defineProperty(FullTextDocument2.prototype, "version", {
- get: function() {
- return this._version;
- },
- enumerable: false,
- configurable: true
- });
- FullTextDocument2.prototype.getText = function(range) {
- if (range) {
- var start = this.offsetAt(range.start);
- var end = this.offsetAt(range.end);
- return this._content.substring(start, end);
- }
- return this._content;
- };
- FullTextDocument2.prototype.update = function(event, version) {
- this._content = event.text;
- this._version = version;
- this._lineOffsets = void 0;
- };
- FullTextDocument2.prototype.getLineOffsets = function() {
- if (this._lineOffsets === void 0) {
- var lineOffsets = [];
- var text = this._content;
- var isLineStart = true;
- for (var i = 0; i < text.length; i++) {
- if (isLineStart) {
- lineOffsets.push(i);
- isLineStart = false;
- }
- var ch = text.charAt(i);
- isLineStart = ch === "\r" || ch === "\n";
- if (ch === "\r" && i + 1 < text.length && text.charAt(i + 1) === "\n") {
- i++;
- }
- }
- if (isLineStart && text.length > 0) {
- lineOffsets.push(text.length);
- }
- this._lineOffsets = lineOffsets;
- }
- return this._lineOffsets;
- };
- FullTextDocument2.prototype.positionAt = function(offset) {
- offset = Math.max(Math.min(offset, this._content.length), 0);
- var lineOffsets = this.getLineOffsets();
- var low = 0, high = lineOffsets.length;
- if (high === 0) {
- return Position.create(0, offset);
- }
- while (low < high) {
- var mid = Math.floor((low + high) / 2);
- if (lineOffsets[mid] > offset) {
- high = mid;
- } else {
- low = mid + 1;
- }
- }
- var line = low - 1;
- return Position.create(line, offset - lineOffsets[line]);
- };
- FullTextDocument2.prototype.offsetAt = function(position) {
- var lineOffsets = this.getLineOffsets();
- if (position.line >= lineOffsets.length) {
- return this._content.length;
- } else if (position.line < 0) {
- return 0;
- }
- var lineOffset = lineOffsets[position.line];
- var nextLineOffset = position.line + 1 < lineOffsets.length ? lineOffsets[position.line + 1] : this._content.length;
- return Math.max(Math.min(lineOffset + position.character, nextLineOffset), lineOffset);
- };
- Object.defineProperty(FullTextDocument2.prototype, "lineCount", {
- get: function() {
- return this.getLineOffsets().length;
- },
- enumerable: false,
- configurable: true
- });
- return FullTextDocument2;
- }();
- var Is;
- (function(Is2) {
- var toString = Object.prototype.toString;
- function defined(value) {
- return typeof value !== "undefined";
- }
- Is2.defined = defined;
- function undefined2(value) {
- return typeof value === "undefined";
- }
- Is2.undefined = undefined2;
- function boolean(value) {
- return value === true || value === false;
- }
- Is2.boolean = boolean;
- function string(value) {
- return toString.call(value) === "[object String]";
- }
- Is2.string = string;
- function number(value) {
- return toString.call(value) === "[object Number]";
- }
- Is2.number = number;
- function numberRange(value, min, max) {
- return toString.call(value) === "[object Number]" && min <= value && value <= max;
- }
- Is2.numberRange = numberRange;
- function integer2(value) {
- return toString.call(value) === "[object Number]" && -2147483648 <= value && value <= 2147483647;
- }
- Is2.integer = integer2;
- function uinteger2(value) {
- return toString.call(value) === "[object Number]" && 0 <= value && value <= 2147483647;
- }
- Is2.uinteger = uinteger2;
- function func(value) {
- return toString.call(value) === "[object Function]";
- }
- Is2.func = func;
- function objectLiteral(value) {
- return value !== null && typeof value === "object";
- }
- Is2.objectLiteral = objectLiteral;
- function typedArray(value, check) {
- return Array.isArray(value) && value.every(check);
- }
- Is2.typedArray = typedArray;
- })(Is || (Is = {}));
- // src/language/common/lspLanguageFeatures.ts
- var DiagnosticsAdapter = class {
- constructor(_languageId, _worker, configChangeEvent) {
- this._languageId = _languageId;
- this._worker = _worker;
- const onModelAdd = (model) => {
- let modeId = model.getLanguageId();
- if (modeId !== this._languageId) {
- return;
- }
- let handle;
- this._listener[model.uri.toString()] = model.onDidChangeContent(() => {
- window.clearTimeout(handle);
- handle = window.setTimeout(() => this._doValidate(model.uri, modeId), 500);
- });
- this._doValidate(model.uri, modeId);
- };
- const onModelRemoved = (model) => {
- monaco_editor_core_exports.editor.setModelMarkers(model, this._languageId, []);
- let uriStr = model.uri.toString();
- let listener = this._listener[uriStr];
- if (listener) {
- listener.dispose();
- delete this._listener[uriStr];
- }
- };
- this._disposables.push(monaco_editor_core_exports.editor.onDidCreateModel(onModelAdd));
- this._disposables.push(monaco_editor_core_exports.editor.onWillDisposeModel(onModelRemoved));
- this._disposables.push(monaco_editor_core_exports.editor.onDidChangeModelLanguage((event) => {
- onModelRemoved(event.model);
- onModelAdd(event.model);
- }));
- this._disposables.push(configChangeEvent((_) => {
- monaco_editor_core_exports.editor.getModels().forEach((model) => {
- if (model.getLanguageId() === this._languageId) {
- onModelRemoved(model);
- onModelAdd(model);
- }
- });
- }));
- this._disposables.push({
- dispose: () => {
- monaco_editor_core_exports.editor.getModels().forEach(onModelRemoved);
- for (let key in this._listener) {
- this._listener[key].dispose();
- }
- }
- });
- monaco_editor_core_exports.editor.getModels().forEach(onModelAdd);
- }
- _disposables = [];
- _listener = /* @__PURE__ */ Object.create(null);
- dispose() {
- this._disposables.forEach((d) => d && d.dispose());
- this._disposables.length = 0;
- }
- _doValidate(resource, languageId) {
- this._worker(resource).then((worker) => {
- return worker.doValidation(resource.toString());
- }).then((diagnostics) => {
- const markers = diagnostics.map((d) => toDiagnostics(resource, d));
- let model = monaco_editor_core_exports.editor.getModel(resource);
- if (model && model.getLanguageId() === languageId) {
- monaco_editor_core_exports.editor.setModelMarkers(model, languageId, markers);
- }
- }).then(void 0, (err) => {
- console.error(err);
- });
- }
- };
- function toSeverity(lsSeverity) {
- switch (lsSeverity) {
- case DiagnosticSeverity.Error:
- return monaco_editor_core_exports.MarkerSeverity.Error;
- case DiagnosticSeverity.Warning:
- return monaco_editor_core_exports.MarkerSeverity.Warning;
- case DiagnosticSeverity.Information:
- return monaco_editor_core_exports.MarkerSeverity.Info;
- case DiagnosticSeverity.Hint:
- return monaco_editor_core_exports.MarkerSeverity.Hint;
- default:
- return monaco_editor_core_exports.MarkerSeverity.Info;
- }
- }
- function toDiagnostics(resource, diag) {
- let code = typeof diag.code === "number" ? String(diag.code) : diag.code;
- return {
- severity: toSeverity(diag.severity),
- startLineNumber: diag.range.start.line + 1,
- startColumn: diag.range.start.character + 1,
- endLineNumber: diag.range.end.line + 1,
- endColumn: diag.range.end.character + 1,
- message: diag.message,
- code,
- source: diag.source
- };
- }
- var CompletionAdapter = class {
- constructor(_worker, _triggerCharacters) {
- this._worker = _worker;
- this._triggerCharacters = _triggerCharacters;
- }
- get triggerCharacters() {
- return this._triggerCharacters;
- }
- provideCompletionItems(model, position, context, token) {
- const resource = model.uri;
- return this._worker(resource).then((worker) => {
- return worker.doComplete(resource.toString(), fromPosition(position));
- }).then((info) => {
- if (!info) {
- return;
- }
- const wordInfo = model.getWordUntilPosition(position);
- const wordRange = new monaco_editor_core_exports.Range(position.lineNumber, wordInfo.startColumn, position.lineNumber, wordInfo.endColumn);
- const items = info.items.map((entry) => {
- const item = {
- label: entry.label,
- insertText: entry.insertText || entry.label,
- sortText: entry.sortText,
- filterText: entry.filterText,
- documentation: entry.documentation,
- detail: entry.detail,
- command: toCommand(entry.command),
- range: wordRange,
- kind: toCompletionItemKind(entry.kind)
- };
- if (entry.textEdit) {
- if (isInsertReplaceEdit(entry.textEdit)) {
- item.range = {
- insert: toRange(entry.textEdit.insert),
- replace: toRange(entry.textEdit.replace)
- };
- } else {
- item.range = toRange(entry.textEdit.range);
- }
- item.insertText = entry.textEdit.newText;
- }
- if (entry.additionalTextEdits) {
- item.additionalTextEdits = entry.additionalTextEdits.map(toTextEdit);
- }
- if (entry.insertTextFormat === InsertTextFormat.Snippet) {
- item.insertTextRules = monaco_editor_core_exports.languages.CompletionItemInsertTextRule.InsertAsSnippet;
- }
- return item;
- });
- return {
- isIncomplete: info.isIncomplete,
- suggestions: items
- };
- });
- }
- };
- function fromPosition(position) {
- if (!position) {
- return void 0;
- }
- return { character: position.column - 1, line: position.lineNumber - 1 };
- }
- function fromRange(range) {
- if (!range) {
- return void 0;
- }
- return {
- start: {
- line: range.startLineNumber - 1,
- character: range.startColumn - 1
- },
- end: { line: range.endLineNumber - 1, character: range.endColumn - 1 }
- };
- }
- function toRange(range) {
- if (!range) {
- return void 0;
- }
- return new monaco_editor_core_exports.Range(range.start.line + 1, range.start.character + 1, range.end.line + 1, range.end.character + 1);
- }
- function isInsertReplaceEdit(edit) {
- return typeof edit.insert !== "undefined" && typeof edit.replace !== "undefined";
- }
- function toCompletionItemKind(kind) {
- const mItemKind = monaco_editor_core_exports.languages.CompletionItemKind;
- switch (kind) {
- case CompletionItemKind.Text:
- return mItemKind.Text;
- case CompletionItemKind.Method:
- return mItemKind.Method;
- case CompletionItemKind.Function:
- return mItemKind.Function;
- case CompletionItemKind.Constructor:
- return mItemKind.Constructor;
- case CompletionItemKind.Field:
- return mItemKind.Field;
- case CompletionItemKind.Variable:
- return mItemKind.Variable;
- case CompletionItemKind.Class:
- return mItemKind.Class;
- case CompletionItemKind.Interface:
- return mItemKind.Interface;
- case CompletionItemKind.Module:
- return mItemKind.Module;
- case CompletionItemKind.Property:
- return mItemKind.Property;
- case CompletionItemKind.Unit:
- return mItemKind.Unit;
- case CompletionItemKind.Value:
- return mItemKind.Value;
- case CompletionItemKind.Enum:
- return mItemKind.Enum;
- case CompletionItemKind.Keyword:
- return mItemKind.Keyword;
- case CompletionItemKind.Snippet:
- return mItemKind.Snippet;
- case CompletionItemKind.Color:
- return mItemKind.Color;
- case CompletionItemKind.File:
- return mItemKind.File;
- case CompletionItemKind.Reference:
- return mItemKind.Reference;
- }
- return mItemKind.Property;
- }
- function toTextEdit(textEdit) {
- if (!textEdit) {
- return void 0;
- }
- return {
- range: toRange(textEdit.range),
- text: textEdit.newText
- };
- }
- function toCommand(c) {
- return c && c.command === "editor.action.triggerSuggest" ? { id: c.command, title: c.title, arguments: c.arguments } : void 0;
- }
- var HoverAdapter = class {
- constructor(_worker) {
- this._worker = _worker;
- }
- provideHover(model, position, token) {
- let resource = model.uri;
- return this._worker(resource).then((worker) => {
- return worker.doHover(resource.toString(), fromPosition(position));
- }).then((info) => {
- if (!info) {
- return;
- }
- return {
- range: toRange(info.range),
- contents: toMarkedStringArray(info.contents)
- };
- });
- }
- };
- function isMarkupContent(thing) {
- return thing && typeof thing === "object" && typeof thing.kind === "string";
- }
- function toMarkdownString(entry) {
- if (typeof entry === "string") {
- return {
- value: entry
- };
- }
- if (isMarkupContent(entry)) {
- if (entry.kind === "plaintext") {
- return {
- value: entry.value.replace(/[\\`*_{}[\]()#+\-.!]/g, "\\$&")
- };
- }
- return {
- value: entry.value
- };
- }
- return { value: "```" + entry.language + "\n" + entry.value + "\n```\n" };
- }
- function toMarkedStringArray(contents) {
- if (!contents) {
- return void 0;
- }
- if (Array.isArray(contents)) {
- return contents.map(toMarkdownString);
- }
- return [toMarkdownString(contents)];
- }
- var DocumentHighlightAdapter = class {
- constructor(_worker) {
- this._worker = _worker;
- }
- provideDocumentHighlights(model, position, token) {
- const resource = model.uri;
- return this._worker(resource).then((worker) => worker.findDocumentHighlights(resource.toString(), fromPosition(position))).then((entries) => {
- if (!entries) {
- return;
- }
- return entries.map((entry) => {
- return {
- range: toRange(entry.range),
- kind: toDocumentHighlightKind(entry.kind)
- };
- });
- });
- }
- };
- function toDocumentHighlightKind(kind) {
- switch (kind) {
- case DocumentHighlightKind.Read:
- return monaco_editor_core_exports.languages.DocumentHighlightKind.Read;
- case DocumentHighlightKind.Write:
- return monaco_editor_core_exports.languages.DocumentHighlightKind.Write;
- case DocumentHighlightKind.Text:
- return monaco_editor_core_exports.languages.DocumentHighlightKind.Text;
- }
- return monaco_editor_core_exports.languages.DocumentHighlightKind.Text;
- }
- var DefinitionAdapter = class {
- constructor(_worker) {
- this._worker = _worker;
- }
- provideDefinition(model, position, token) {
- const resource = model.uri;
- return this._worker(resource).then((worker) => {
- return worker.findDefinition(resource.toString(), fromPosition(position));
- }).then((definition) => {
- if (!definition) {
- return;
- }
- return [toLocation(definition)];
- });
- }
- };
- function toLocation(location) {
- return {
- uri: monaco_editor_core_exports.Uri.parse(location.uri),
- range: toRange(location.range)
- };
- }
- var ReferenceAdapter = class {
- constructor(_worker) {
- this._worker = _worker;
- }
- provideReferences(model, position, context, token) {
- const resource = model.uri;
- return this._worker(resource).then((worker) => {
- return worker.findReferences(resource.toString(), fromPosition(position));
- }).then((entries) => {
- if (!entries) {
- return;
- }
- return entries.map(toLocation);
- });
- }
- };
- var RenameAdapter = class {
- constructor(_worker) {
- this._worker = _worker;
- }
- provideRenameEdits(model, position, newName, token) {
- const resource = model.uri;
- return this._worker(resource).then((worker) => {
- return worker.doRename(resource.toString(), fromPosition(position), newName);
- }).then((edit) => {
- return toWorkspaceEdit(edit);
- });
- }
- };
- function toWorkspaceEdit(edit) {
- if (!edit || !edit.changes) {
- return void 0;
- }
- let resourceEdits = [];
- for (let uri in edit.changes) {
- const _uri = monaco_editor_core_exports.Uri.parse(uri);
- for (let e of edit.changes[uri]) {
- resourceEdits.push({
- resource: _uri,
- versionId: void 0,
- textEdit: {
- range: toRange(e.range),
- text: e.newText
- }
- });
- }
- }
- return {
- edits: resourceEdits
- };
- }
- var DocumentSymbolAdapter = class {
- constructor(_worker) {
- this._worker = _worker;
- }
- provideDocumentSymbols(model, token) {
- const resource = model.uri;
- return this._worker(resource).then((worker) => worker.findDocumentSymbols(resource.toString())).then((items) => {
- if (!items) {
- return;
- }
- return items.map((item) => ({
- name: item.name,
- detail: "",
- containerName: item.containerName,
- kind: toSymbolKind(item.kind),
- range: toRange(item.location.range),
- selectionRange: toRange(item.location.range),
- tags: []
- }));
- });
- }
- };
- function toSymbolKind(kind) {
- let mKind = monaco_editor_core_exports.languages.SymbolKind;
- switch (kind) {
- case SymbolKind.File:
- return mKind.Array;
- case SymbolKind.Module:
- return mKind.Module;
- case SymbolKind.Namespace:
- return mKind.Namespace;
- case SymbolKind.Package:
- return mKind.Package;
- case SymbolKind.Class:
- return mKind.Class;
- case SymbolKind.Method:
- return mKind.Method;
- case SymbolKind.Property:
- return mKind.Property;
- case SymbolKind.Field:
- return mKind.Field;
- case SymbolKind.Constructor:
- return mKind.Constructor;
- case SymbolKind.Enum:
- return mKind.Enum;
- case SymbolKind.Interface:
- return mKind.Interface;
- case SymbolKind.Function:
- return mKind.Function;
- case SymbolKind.Variable:
- return mKind.Variable;
- case SymbolKind.Constant:
- return mKind.Constant;
- case SymbolKind.String:
- return mKind.String;
- case SymbolKind.Number:
- return mKind.Number;
- case SymbolKind.Boolean:
- return mKind.Boolean;
- case SymbolKind.Array:
- return mKind.Array;
- }
- return mKind.Function;
- }
- var DocumentLinkAdapter = class {
- constructor(_worker) {
- this._worker = _worker;
- }
- provideLinks(model, token) {
- const resource = model.uri;
- return this._worker(resource).then((worker) => worker.findDocumentLinks(resource.toString())).then((items) => {
- if (!items) {
- return;
- }
- return {
- links: items.map((item) => ({
- range: toRange(item.range),
- url: item.target
- }))
- };
- });
- }
- };
- var DocumentFormattingEditProvider = class {
- constructor(_worker) {
- this._worker = _worker;
- }
- provideDocumentFormattingEdits(model, options, token) {
- const resource = model.uri;
- return this._worker(resource).then((worker) => {
- return worker.format(resource.toString(), null, fromFormattingOptions(options)).then((edits) => {
- if (!edits || edits.length === 0) {
- return;
- }
- return edits.map(toTextEdit);
- });
- });
- }
- };
- var DocumentRangeFormattingEditProvider = class {
- constructor(_worker) {
- this._worker = _worker;
- }
- canFormatMultipleRanges = false;
- provideDocumentRangeFormattingEdits(model, range, options, token) {
- const resource = model.uri;
- return this._worker(resource).then((worker) => {
- return worker.format(resource.toString(), fromRange(range), fromFormattingOptions(options)).then((edits) => {
- if (!edits || edits.length === 0) {
- return;
- }
- return edits.map(toTextEdit);
- });
- });
- }
- };
- function fromFormattingOptions(options) {
- return {
- tabSize: options.tabSize,
- insertSpaces: options.insertSpaces
- };
- }
- var DocumentColorAdapter = class {
- constructor(_worker) {
- this._worker = _worker;
- }
- provideDocumentColors(model, token) {
- const resource = model.uri;
- return this._worker(resource).then((worker) => worker.findDocumentColors(resource.toString())).then((infos) => {
- if (!infos) {
- return;
- }
- return infos.map((item) => ({
- color: item.color,
- range: toRange(item.range)
- }));
- });
- }
- provideColorPresentations(model, info, token) {
- const resource = model.uri;
- return this._worker(resource).then((worker) => worker.getColorPresentations(resource.toString(), info.color, fromRange(info.range))).then((presentations) => {
- if (!presentations) {
- return;
- }
- return presentations.map((presentation) => {
- let item = {
- label: presentation.label
- };
- if (presentation.textEdit) {
- item.textEdit = toTextEdit(presentation.textEdit);
- }
- if (presentation.additionalTextEdits) {
- item.additionalTextEdits = presentation.additionalTextEdits.map(toTextEdit);
- }
- return item;
- });
- });
- }
- };
- var FoldingRangeAdapter = class {
- constructor(_worker) {
- this._worker = _worker;
- }
- provideFoldingRanges(model, context, token) {
- const resource = model.uri;
- return this._worker(resource).then((worker) => worker.getFoldingRanges(resource.toString(), context)).then((ranges) => {
- if (!ranges) {
- return;
- }
- return ranges.map((range) => {
- const result = {
- start: range.startLine + 1,
- end: range.endLine + 1
- };
- if (typeof range.kind !== "undefined") {
- result.kind = toFoldingRangeKind(range.kind);
- }
- return result;
- });
- });
- }
- };
- function toFoldingRangeKind(kind) {
- switch (kind) {
- case FoldingRangeKind.Comment:
- return monaco_editor_core_exports.languages.FoldingRangeKind.Comment;
- case FoldingRangeKind.Imports:
- return monaco_editor_core_exports.languages.FoldingRangeKind.Imports;
- case FoldingRangeKind.Region:
- return monaco_editor_core_exports.languages.FoldingRangeKind.Region;
- }
- return void 0;
- }
- var SelectionRangeAdapter = class {
- constructor(_worker) {
- this._worker = _worker;
- }
- provideSelectionRanges(model, positions, token) {
- const resource = model.uri;
- return this._worker(resource).then((worker) => worker.getSelectionRanges(resource.toString(), positions.map(fromPosition))).then((selectionRanges) => {
- if (!selectionRanges) {
- return;
- }
- return selectionRanges.map((selectionRange) => {
- const result = [];
- while (selectionRange) {
- result.push({ range: toRange(selectionRange.range) });
- selectionRange = selectionRange.parent;
- }
- return result;
- });
- });
- }
- };
- // src/language/html/htmlMode.ts
- var HTMLCompletionAdapter = class extends CompletionAdapter {
- constructor(worker) {
- super(worker, [".", ":", "<", '"', "=", "/"]);
- }
- };
- function setupMode1(defaults) {
- const client = new WorkerManager(defaults);
- const worker = (...uris) => {
- return client.getLanguageServiceWorker(...uris);
- };
- let languageId = defaults.languageId;
- monaco_editor_core_exports.languages.registerCompletionItemProvider(languageId, new HTMLCompletionAdapter(worker));
- monaco_editor_core_exports.languages.registerHoverProvider(languageId, new HoverAdapter(worker));
- monaco_editor_core_exports.languages.registerDocumentHighlightProvider(languageId, new DocumentHighlightAdapter(worker));
- monaco_editor_core_exports.languages.registerLinkProvider(languageId, new DocumentLinkAdapter(worker));
- monaco_editor_core_exports.languages.registerFoldingRangeProvider(languageId, new FoldingRangeAdapter(worker));
- monaco_editor_core_exports.languages.registerDocumentSymbolProvider(languageId, new DocumentSymbolAdapter(worker));
- monaco_editor_core_exports.languages.registerSelectionRangeProvider(languageId, new SelectionRangeAdapter(worker));
- monaco_editor_core_exports.languages.registerRenameProvider(languageId, new RenameAdapter(worker));
- if (languageId === "html") {
- monaco_editor_core_exports.languages.registerDocumentFormattingEditProvider(languageId, new DocumentFormattingEditProvider(worker));
- monaco_editor_core_exports.languages.registerDocumentRangeFormattingEditProvider(languageId, new DocumentRangeFormattingEditProvider(worker));
- }
- }
- function setupMode(defaults) {
- const disposables = [];
- const providers = [];
- const client = new WorkerManager(defaults);
- disposables.push(client);
- const worker = (...uris) => {
- return client.getLanguageServiceWorker(...uris);
- };
- function registerProviders() {
- const { languageId, modeConfiguration } = defaults;
- disposeAll(providers);
- if (modeConfiguration.completionItems) {
- providers.push(monaco_editor_core_exports.languages.registerCompletionItemProvider(languageId, new HTMLCompletionAdapter(worker)));
- }
- if (modeConfiguration.hovers) {
- providers.push(monaco_editor_core_exports.languages.registerHoverProvider(languageId, new HoverAdapter(worker)));
- }
- if (modeConfiguration.documentHighlights) {
- providers.push(monaco_editor_core_exports.languages.registerDocumentHighlightProvider(languageId, new DocumentHighlightAdapter(worker)));
- }
- if (modeConfiguration.links) {
- providers.push(monaco_editor_core_exports.languages.registerLinkProvider(languageId, new DocumentLinkAdapter(worker)));
- }
- if (modeConfiguration.documentSymbols) {
- providers.push(monaco_editor_core_exports.languages.registerDocumentSymbolProvider(languageId, new DocumentSymbolAdapter(worker)));
- }
- if (modeConfiguration.rename) {
- providers.push(monaco_editor_core_exports.languages.registerRenameProvider(languageId, new RenameAdapter(worker)));
- }
- if (modeConfiguration.foldingRanges) {
- providers.push(monaco_editor_core_exports.languages.registerFoldingRangeProvider(languageId, new FoldingRangeAdapter(worker)));
- }
- if (modeConfiguration.selectionRanges) {
- providers.push(monaco_editor_core_exports.languages.registerSelectionRangeProvider(languageId, new SelectionRangeAdapter(worker)));
- }
- if (modeConfiguration.documentFormattingEdits) {
- providers.push(monaco_editor_core_exports.languages.registerDocumentFormattingEditProvider(languageId, new DocumentFormattingEditProvider(worker)));
- }
- if (modeConfiguration.documentRangeFormattingEdits) {
- providers.push(monaco_editor_core_exports.languages.registerDocumentRangeFormattingEditProvider(languageId, new DocumentRangeFormattingEditProvider(worker)));
- }
- }
- registerProviders();
- disposables.push(asDisposable(providers));
- return asDisposable(disposables);
- }
- function asDisposable(disposables) {
- return { dispose: () => disposeAll(disposables) };
- }
- function disposeAll(disposables) {
- while (disposables.length) {
- disposables.pop().dispose();
- }
- }
- export {
- CompletionAdapter,
- DefinitionAdapter,
- DiagnosticsAdapter,
- DocumentColorAdapter,
- DocumentFormattingEditProvider,
- DocumentHighlightAdapter,
- DocumentLinkAdapter,
- DocumentRangeFormattingEditProvider,
- DocumentSymbolAdapter,
- FoldingRangeAdapter,
- HoverAdapter,
- ReferenceAdapter,
- RenameAdapter,
- SelectionRangeAdapter,
- WorkerManager,
- fromPosition,
- fromRange,
- setupMode,
- setupMode1,
- toRange,
- toTextEdit
- };
|