-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Position", function() { return Position; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Range", function() { return Range; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Location", function() { return Location; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LocationLink", function() { return LocationLink; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Color", function() { return Color; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColorInformation", function() { return ColorInformation; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColorPresentation", function() { return ColorPresentation; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FoldingRangeKind", function() { return FoldingRangeKind; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FoldingRange", function() { return FoldingRange; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DiagnosticRelatedInformation", function() { return DiagnosticRelatedInformation; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DiagnosticSeverity", function() { return DiagnosticSeverity; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DiagnosticTag", function() { return DiagnosticTag; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Diagnostic", function() { return Diagnostic; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Command", function() { return Command; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextEdit", function() { return TextEdit; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextDocumentEdit", function() { return TextDocumentEdit; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CreateFile", function() { return CreateFile; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RenameFile", function() { return RenameFile; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DeleteFile", function() { return DeleteFile; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WorkspaceEdit", function() { return WorkspaceEdit; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WorkspaceChange", function() { return WorkspaceChange; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextDocumentIdentifier", function() { return TextDocumentIdentifier; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VersionedTextDocumentIdentifier", function() { return VersionedTextDocumentIdentifier; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextDocumentItem", function() { return TextDocumentItem; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MarkupKind", function() { return MarkupKind; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MarkupContent", function() { return MarkupContent; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CompletionItemKind", function() { return CompletionItemKind; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InsertTextFormat", function() { return InsertTextFormat; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CompletionItem", function() { return CompletionItem; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CompletionList", function() { return CompletionList; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MarkedString", function() { return MarkedString; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Hover", function() { return Hover; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ParameterInformation", function() { return ParameterInformation; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SignatureInformation", function() { return SignatureInformation; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DocumentHighlightKind", function() { return DocumentHighlightKind; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DocumentHighlight", function() { return DocumentHighlight; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SymbolKind", function() { return SymbolKind; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SymbolInformation", function() { return SymbolInformation; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DocumentSymbol", function() { return DocumentSymbol; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CodeActionKind", function() { return CodeActionKind; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CodeActionContext", function() { return CodeActionContext; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CodeAction", function() { return CodeAction; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CodeLens", function() { return CodeLens; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FormattingOptions", function() { return FormattingOptions; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DocumentLink", function() { return DocumentLink; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EOL", function() { return EOL; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextDocument", function() { return TextDocument; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextDocumentSaveReason", function() { return TextDocumentSaveReason; });
-/* --------------------------------------------------------------------------------------------\r
- * Copyright (c) Microsoft Corporation. All rights reserved.\r
- * Licensed under the MIT License. See License.txt in the project root for license information.\r
- * ------------------------------------------------------------------------------------------ */\r
-\r
-/**\r
- * The Position namespace provides helper functions to work with\r
- * [Position](#Position) literals.\r
- */\r
-var Position;\r
-(function (Position) {\r
- /**\r
- * Creates a new Position literal from the given line and character.\r
- * @param line The position's line.\r
- * @param character The position's character.\r
- */\r
- function create(line, character) {\r
- return { line: line, character: character };\r
- }\r
- Position.create = create;\r
- /**\r
- * Checks whether the given liternal conforms to the [Position](#Position) interface.\r
- */\r
- function is(value) {\r
- var candidate = value;\r
- return Is.objectLiteral(candidate) && Is.number(candidate.line) && Is.number(candidate.character);\r
- }\r
- Position.is = is;\r
-})(Position || (Position = {}));\r
-/**\r
- * The Range namespace provides helper functions to work with\r
- * [Range](#Range) literals.\r
- */\r
-var Range;\r
-(function (Range) {\r
- function create(one, two, three, four) {\r
- if (Is.number(one) && Is.number(two) && Is.number(three) && Is.number(four)) {\r
- return { start: Position.create(one, two), end: Position.create(three, four) };\r
- }\r
- else if (Position.is(one) && Position.is(two)) {\r
- return { start: one, end: two };\r
- }\r
- else {\r
- throw new Error("Range#create called with invalid arguments[" + one + ", " + two + ", " + three + ", " + four + "]");\r
- }\r
- }\r
- Range.create = create;\r
- /**\r
- * Checks whether the given literal conforms to the [Range](#Range) interface.\r
- */\r
- function is(value) {\r
- var candidate = value;\r
- return Is.objectLiteral(candidate) && Position.is(candidate.start) && Position.is(candidate.end);\r
- }\r
- Range.is = is;\r
-})(Range || (Range = {}));\r
-/**\r
- * The Location namespace provides helper functions to work with\r
- * [Location](#Location) literals.\r
- */\r
-var Location;\r
-(function (Location) {\r
- /**\r
- * Creates a Location literal.\r
- * @param uri The location's uri.\r
- * @param range The location's range.\r
- */\r
- function create(uri, range) {\r
- return { uri: uri, range: range };\r
- }\r
- Location.create = create;\r
- /**\r
- * Checks whether the given literal conforms to the [Location](#Location) interface.\r
- */\r
- function is(value) {\r
- var candidate = value;\r
- return Is.defined(candidate) && Range.is(candidate.range) && (Is.string(candidate.uri) || Is.undefined(candidate.uri));\r
- }\r
- Location.is = is;\r
-})(Location || (Location = {}));\r
-/**\r
- * The LocationLink namespace provides helper functions to work with\r
- * [LocationLink](#LocationLink) literals.\r
- */\r
-var LocationLink;\r
-(function (LocationLink) {\r
- /**\r
- * Creates a LocationLink literal.\r
- * @param targetUri The definition's uri.\r
- * @param targetRange The full range of the definition.\r
- * @param targetSelectionRange The span of the symbol definition at the target.\r
- * @param originSelectionRange The span of the symbol being defined in the originating source file.\r
- */\r
- function create(targetUri, targetRange, targetSelectionRange, originSelectionRange) {\r
- return { targetUri: targetUri, targetRange: targetRange, targetSelectionRange: targetSelectionRange, originSelectionRange: originSelectionRange };\r
- }\r
- LocationLink.create = create;\r
- /**\r
- * Checks whether the given literal conforms to the [LocationLink](#LocationLink) interface.\r
- */\r
- function is(value) {\r
- var candidate = value;\r
- return Is.defined(candidate) && Range.is(candidate.targetRange) && Is.string(candidate.targetUri)\r
- && (Range.is(candidate.targetSelectionRange) || Is.undefined(candidate.targetSelectionRange))\r
- && (Range.is(candidate.originSelectionRange) || Is.undefined(candidate.originSelectionRange));\r
- }\r
- LocationLink.is = is;\r
-})(LocationLink || (LocationLink = {}));\r
-/**\r
- * The Color namespace provides helper functions to work with\r
- * [Color](#Color) literals.\r
- */\r
-var Color;\r
-(function (Color) {\r
- /**\r
- * Creates a new Color literal.\r
- */\r
- function create(red, green, blue, alpha) {\r
- return {\r
- red: red,\r
- green: green,\r
- blue: blue,\r
- alpha: alpha,\r
- };\r
- }\r
- Color.create = create;\r
- /**\r
- * Checks whether the given literal conforms to the [Color](#Color) interface.\r
- */\r
- function is(value) {\r
- var candidate = value;\r
- return Is.number(candidate.red)\r
- && Is.number(candidate.green)\r
- && Is.number(candidate.blue)\r
- && Is.number(candidate.alpha);\r
- }\r
- Color.is = is;\r
-})(Color || (Color = {}));\r
-/**\r
- * The ColorInformation namespace provides helper functions to work with\r
- * [ColorInformation](#ColorInformation) literals.\r
- */\r
-var ColorInformation;\r
-(function (ColorInformation) {\r
- /**\r
- * Creates a new ColorInformation literal.\r
- */\r
- function create(range, color) {\r
- return {\r
- range: range,\r
- color: color,\r
- };\r
- }\r
- ColorInformation.create = create;\r
- /**\r
- * Checks whether the given literal conforms to the [ColorInformation](#ColorInformation) interface.\r
- */\r
- function is(value) {\r
- var candidate = value;\r
- return Range.is(candidate.range) && Color.is(candidate.color);\r
- }\r
- ColorInformation.is = is;\r
-})(ColorInformation || (ColorInformation = {}));\r
-/**\r
- * The Color namespace provides helper functions to work with\r
- * [ColorPresentation](#ColorPresentation) literals.\r
- */\r
-var ColorPresentation;\r
-(function (ColorPresentation) {\r
- /**\r
- * Creates a new ColorInformation literal.\r
- */\r
- function create(label, textEdit, additionalTextEdits) {\r
- return {\r
- label: label,\r
- textEdit: textEdit,\r
- additionalTextEdits: additionalTextEdits,\r
- };\r
- }\r
- ColorPresentation.create = create;\r
- /**\r
- * Checks whether the given literal conforms to the [ColorInformation](#ColorInformation) interface.\r
- */\r
- function is(value) {\r
- var candidate = value;\r
- return Is.string(candidate.label)\r
- && (Is.undefined(candidate.textEdit) || TextEdit.is(candidate))\r
- && (Is.undefined(candidate.additionalTextEdits) || Is.typedArray(candidate.additionalTextEdits, TextEdit.is));\r
- }\r
- ColorPresentation.is = is;\r
-})(ColorPresentation || (ColorPresentation = {}));\r
-/**\r
- * Enum of known range kinds\r
- */\r
-var FoldingRangeKind;\r
-(function (FoldingRangeKind) {\r
- /**\r
- * Folding range for a comment\r
- */\r
- FoldingRangeKind["Comment"] = "comment";\r
- /**\r
- * Folding range for a imports or includes\r
- */\r
- FoldingRangeKind["Imports"] = "imports";\r
- /**\r
- * Folding range for a region (e.g. `#region`)\r
- */\r
- FoldingRangeKind["Region"] = "region";\r
-})(FoldingRangeKind || (FoldingRangeKind = {}));\r
-/**\r
- * The folding range namespace provides helper functions to work with\r
- * [FoldingRange](#FoldingRange) literals.\r
- */\r
-var FoldingRange;\r
-(function (FoldingRange) {\r
- /**\r
- * Creates a new FoldingRange literal.\r
- */\r
- function create(startLine, endLine, startCharacter, endCharacter, kind) {\r
- var result = {\r
- startLine: startLine,\r
- endLine: endLine\r
- };\r
- if (Is.defined(startCharacter)) {\r
- result.startCharacter = startCharacter;\r
- }\r
- if (Is.defined(endCharacter)) {\r
- result.endCharacter = endCharacter;\r
- }\r
- if (Is.defined(kind)) {\r
- result.kind = kind;\r
- }\r
- return result;\r
- }\r
- FoldingRange.create = create;\r
- /**\r
- * Checks whether the given literal conforms to the [FoldingRange](#FoldingRange) interface.\r
- */\r
- function is(value) {\r
- var candidate = value;\r
- return Is.number(candidate.startLine) && Is.number(candidate.startLine)\r
- && (Is.undefined(candidate.startCharacter) || Is.number(candidate.startCharacter))\r
- && (Is.undefined(candidate.endCharacter) || Is.number(candidate.endCharacter))\r
- && (Is.undefined(candidate.kind) || Is.string(candidate.kind));\r
- }\r
- FoldingRange.is = is;\r
-})(FoldingRange || (FoldingRange = {}));\r
-/**\r
- * The DiagnosticRelatedInformation namespace provides helper functions to work with\r
- * [DiagnosticRelatedInformation](#DiagnosticRelatedInformation) literals.\r
- */\r
-var DiagnosticRelatedInformation;\r
-(function (DiagnosticRelatedInformation) {\r
- /**\r
- * Creates a new DiagnosticRelatedInformation literal.\r
- */\r
- function create(location, message) {\r
- return {\r
- location: location,\r
- message: message\r
- };\r
- }\r
- DiagnosticRelatedInformation.create = create;\r
- /**\r
- * Checks whether the given literal conforms to the [DiagnosticRelatedInformation](#DiagnosticRelatedInformation) interface.\r
- */\r
- function is(value) {\r
- var candidate = value;\r
- return Is.defined(candidate) && Location.is(candidate.location) && Is.string(candidate.message);\r
- }\r
- DiagnosticRelatedInformation.is = is;\r
-})(DiagnosticRelatedInformation || (DiagnosticRelatedInformation = {}));\r
-/**\r
- * The diagnostic's severity.\r
- */\r
-var DiagnosticSeverity;\r
-(function (DiagnosticSeverity) {\r
- /**\r
- * Reports an error.\r
- */\r
- DiagnosticSeverity.Error = 1;\r
- /**\r
- * Reports a warning.\r
- */\r
- DiagnosticSeverity.Warning = 2;\r
- /**\r
- * Reports an information.\r
- */\r
- DiagnosticSeverity.Information = 3;\r
- /**\r
- * Reports a hint.\r
- */\r
- DiagnosticSeverity.Hint = 4;\r
-})(DiagnosticSeverity || (DiagnosticSeverity = {}));\r
-var DiagnosticTag;\r
-(function (DiagnosticTag) {\r
- /**\r
- * Unused or unnecessary code.\r
- *\r
- * Clients are allowed to render diagnostics with this tag faded out instead of having\r
- * an error squiggle.\r
- */\r
- DiagnosticTag.Unnecessary = 1;\r
-})(DiagnosticTag || (DiagnosticTag = {}));\r
-/**\r
- * The Diagnostic namespace provides helper functions to work with\r
- * [Diagnostic](#Diagnostic) literals.\r
- */\r
-var Diagnostic;\r
-(function (Diagnostic) {\r
- /**\r
- * Creates a new Diagnostic literal.\r
- */\r
- function create(range, message, severity, code, source, relatedInformation) {\r
- var result = { range: range, message: message };\r
- if (Is.defined(severity)) {\r
- result.severity = severity;\r
- }\r
- if (Is.defined(code)) {\r
- result.code = code;\r
- }\r
- if (Is.defined(source)) {\r
- result.source = source;\r
- }\r
- if (Is.defined(relatedInformation)) {\r
- result.relatedInformation = relatedInformation;\r
- }\r
- return result;\r
- }\r
- Diagnostic.create = create;\r
- /**\r
- * Checks whether the given literal conforms to the [Diagnostic](#Diagnostic) interface.\r
- */\r
- function is(value) {\r
- var candidate = value;\r
- return Is.defined(candidate)\r
- && Range.is(candidate.range)\r
- && Is.string(candidate.message)\r
- && (Is.number(candidate.severity) || Is.undefined(candidate.severity))\r
- && (Is.number(candidate.code) || Is.string(candidate.code) || Is.undefined(candidate.code))\r
- && (Is.string(candidate.source) || Is.undefined(candidate.source))\r
- && (Is.undefined(candidate.relatedInformation) || Is.typedArray(candidate.relatedInformation, DiagnosticRelatedInformation.is));\r
- }\r
- Diagnostic.is = is;\r
-})(Diagnostic || (Diagnostic = {}));\r
-/**\r
- * The Command namespace provides helper functions to work with\r
- * [Command](#Command) literals.\r
- */\r
-var Command;\r
-(function (Command) {\r
- /**\r
- * Creates a new Command literal.\r
- */\r
- function create(title, command) {\r
- var args = [];\r
- for (var _i = 2; _i < arguments.length; _i++) {\r
- args[_i - 2] = arguments[_i];\r
- }\r
- var result = { title: title, command: command };\r
- if (Is.defined(args) && args.length > 0) {\r
- result.arguments = args;\r
- }\r
- return result;\r
- }\r
- Command.create = create;\r
- /**\r
- * Checks whether the given literal conforms to the [Command](#Command) interface.\r
- */\r
- function is(value) {\r
- var candidate = value;\r
- return Is.defined(candidate) && Is.string(candidate.title) && Is.string(candidate.command);\r
- }\r
- Command.is = is;\r
-})(Command || (Command = {}));\r
-/**\r
- * The TextEdit namespace provides helper function to create replace,\r
- * insert and delete edits more easily.\r
- */\r
-var TextEdit;\r
-(function (TextEdit) {\r
- /**\r
- * Creates a replace text edit.\r
- * @param range The range of text to be replaced.\r
- * @param newText The new text.\r
- */\r
- function replace(range, newText) {\r
- return { range: range, newText: newText };\r
- }\r
- TextEdit.replace = replace;\r
- /**\r
- * Creates a insert text edit.\r
- * @param position The position to insert the text at.\r
- * @param newText The text to be inserted.\r
- */\r
- function insert(position, newText) {\r
- return { range: { start: position, end: position }, newText: newText };\r
- }\r
- TextEdit.insert = insert;\r
- /**\r
- * Creates a delete text edit.\r
- * @param range The range of text to be deleted.\r
- */\r
- function del(range) {\r
- return { range: range, newText: '' };\r
- }\r
- TextEdit.del = del;\r
- function is(value) {\r
- var candidate = value;\r
- return Is.objectLiteral(candidate)\r
- && Is.string(candidate.newText)\r
- && Range.is(candidate.range);\r
- }\r
- TextEdit.is = is;\r
-})(TextEdit || (TextEdit = {}));\r
-/**\r
- * The TextDocumentEdit namespace provides helper function to create\r
- * an edit that manipulates a text document.\r
- */\r
-var TextDocumentEdit;\r
-(function (TextDocumentEdit) {\r
- /**\r
- * Creates a new `TextDocumentEdit`\r
- */\r
- function create(textDocument, edits) {\r
- return { textDocument: textDocument, edits: edits };\r
- }\r
- TextDocumentEdit.create = create;\r
- function is(value) {\r
- var candidate = value;\r
- return Is.defined(candidate)\r
- && VersionedTextDocumentIdentifier.is(candidate.textDocument)\r
- && Array.isArray(candidate.edits);\r
- }\r
- TextDocumentEdit.is = is;\r
-})(TextDocumentEdit || (TextDocumentEdit = {}));\r
-var CreateFile;\r
-(function (CreateFile) {\r
- function create(uri, options) {\r
- var result = {\r
- kind: 'create',\r
- uri: uri\r
- };\r
- if (options !== void 0 && (options.overwrite !== void 0 || options.ignoreIfExists !== void 0)) {\r
- result.options = options;\r
- }\r
- return result;\r
- }\r
- CreateFile.create = create;\r
- function is(value) {\r
- var candidate = value;\r
- return candidate && candidate.kind === 'create' && Is.string(candidate.uri) &&\r
- (candidate.options === void 0 ||\r
- ((candidate.options.overwrite === void 0 || Is.boolean(candidate.options.overwrite)) && (candidate.options.ignoreIfExists === void 0 || Is.boolean(candidate.options.ignoreIfExists))));\r
- }\r
- CreateFile.is = is;\r
-})(CreateFile || (CreateFile = {}));\r
-var RenameFile;\r
-(function (RenameFile) {\r
- function create(oldUri, newUri, options) {\r
- var result = {\r
- kind: 'rename',\r
- oldUri: oldUri,\r
- newUri: newUri\r
- };\r
- if (options !== void 0 && (options.overwrite !== void 0 || options.ignoreIfExists !== void 0)) {\r
- result.options = options;\r
- }\r
- return result;\r
- }\r
- RenameFile.create = create;\r
- function is(value) {\r
- var candidate = value;\r
- return candidate && candidate.kind === 'rename' && Is.string(candidate.oldUri) && Is.string(candidate.newUri) &&\r
- (candidate.options === void 0 ||\r
- ((candidate.options.overwrite === void 0 || Is.boolean(candidate.options.overwrite)) && (candidate.options.ignoreIfExists === void 0 || Is.boolean(candidate.options.ignoreIfExists))));\r
- }\r
- RenameFile.is = is;\r
-})(RenameFile || (RenameFile = {}));\r
-var DeleteFile;\r
-(function (DeleteFile) {\r
- function create(uri, options) {\r
- var result = {\r
- kind: 'delete',\r
- uri: uri\r
- };\r
- if (options !== void 0 && (options.recursive !== void 0 || options.ignoreIfNotExists !== void 0)) {\r
- result.options = options;\r
- }\r
- return result;\r
- }\r
- DeleteFile.create = create;\r
- function is(value) {\r
- var candidate = value;\r
- return candidate && candidate.kind === 'delete' && Is.string(candidate.uri) &&\r
- (candidate.options === void 0 ||\r
- ((candidate.options.recursive === void 0 || Is.boolean(candidate.options.recursive)) && (candidate.options.ignoreIfNotExists === void 0 || Is.boolean(candidate.options.ignoreIfNotExists))));\r
- }\r
- DeleteFile.is = is;\r
-})(DeleteFile || (DeleteFile = {}));\r
-var WorkspaceEdit;\r
-(function (WorkspaceEdit) {\r
- function is(value) {\r
- var candidate = value;\r
- return candidate &&\r
- (candidate.changes !== void 0 || candidate.documentChanges !== void 0) &&\r
- (candidate.documentChanges === void 0 || candidate.documentChanges.every(function (change) {\r
- if (Is.string(change.kind)) {\r
- return CreateFile.is(change) || RenameFile.is(change) || DeleteFile.is(change);\r
- }\r
- else {\r
- return TextDocumentEdit.is(change);\r
- }\r
- }));\r
- }\r
- WorkspaceEdit.is = is;\r
-})(WorkspaceEdit || (WorkspaceEdit = {}));\r
-var TextEditChangeImpl = /** @class */ (function () {\r
- function TextEditChangeImpl(edits) {\r
- this.edits = edits;\r
- }\r
- TextEditChangeImpl.prototype.insert = function (position, newText) {\r
- this.edits.push(TextEdit.insert(position, newText));\r
- };\r
- TextEditChangeImpl.prototype.replace = function (range, newText) {\r
- this.edits.push(TextEdit.replace(range, newText));\r
- };\r
- TextEditChangeImpl.prototype.delete = function (range) {\r
- this.edits.push(TextEdit.del(range));\r
- };\r
- TextEditChangeImpl.prototype.add = function (edit) {\r
- this.edits.push(edit);\r
- };\r
- TextEditChangeImpl.prototype.all = function () {\r
- return this.edits;\r
- };\r
- TextEditChangeImpl.prototype.clear = function () {\r
- this.edits.splice(0, this.edits.length);\r
- };\r
- return TextEditChangeImpl;\r
-}());\r
-/**\r
- * A workspace change helps constructing changes to a workspace.\r
- */\r
-var WorkspaceChange = /** @class */ (function () {\r
- function WorkspaceChange(workspaceEdit) {\r
- var _this = this;\r
- this._textEditChanges = Object.create(null);\r
- if (workspaceEdit) {\r
- this._workspaceEdit = workspaceEdit;\r
- if (workspaceEdit.documentChanges) {\r
- workspaceEdit.documentChanges.forEach(function (change) {\r
- if (TextDocumentEdit.is(change)) {\r
- var textEditChange = new TextEditChangeImpl(change.edits);\r
- _this._textEditChanges[change.textDocument.uri] = textEditChange;\r
- }\r
- });\r
- }\r
- else if (workspaceEdit.changes) {\r
- Object.keys(workspaceEdit.changes).forEach(function (key) {\r
- var textEditChange = new TextEditChangeImpl(workspaceEdit.changes[key]);\r
- _this._textEditChanges[key] = textEditChange;\r
- });\r
- }\r
- }\r
- }\r
- Object.defineProperty(WorkspaceChange.prototype, "edit", {\r
- /**\r
- * Returns the underlying [WorkspaceEdit](#WorkspaceEdit) literal\r
- * use to be returned from a workspace edit operation like rename.\r
- */\r
- get: function () {\r
- return this._workspaceEdit;\r
- },\r
- enumerable: true,\r
- configurable: true\r
- });\r
- WorkspaceChange.prototype.getTextEditChange = function (key) {\r
- if (VersionedTextDocumentIdentifier.is(key)) {\r
- if (!this._workspaceEdit) {\r
- this._workspaceEdit = {\r
- documentChanges: []\r
- };\r
- }\r
- if (!this._workspaceEdit.documentChanges) {\r
- throw new Error('Workspace edit is not configured for document changes.');\r
- }\r
- var textDocument = key;\r
- var result = this._textEditChanges[textDocument.uri];\r
- if (!result) {\r
- var edits = [];\r
- var textDocumentEdit = {\r
- textDocument: textDocument,\r
- edits: edits\r
- };\r
- this._workspaceEdit.documentChanges.push(textDocumentEdit);\r
- result = new TextEditChangeImpl(edits);\r
- this._textEditChanges[textDocument.uri] = result;\r
- }\r
- return result;\r
- }\r
- else {\r
- if (!this._workspaceEdit) {\r
- this._workspaceEdit = {\r
- changes: Object.create(null)\r
- };\r
- }\r
- if (!this._workspaceEdit.changes) {\r
- throw new Error('Workspace edit is not configured for normal text edit changes.');\r
- }\r
- var result = this._textEditChanges[key];\r
- if (!result) {\r
- var edits = [];\r
- this._workspaceEdit.changes[key] = edits;\r
- result = new TextEditChangeImpl(edits);\r
- this._textEditChanges[key] = result;\r
- }\r
- return result;\r
- }\r
- };\r
- WorkspaceChange.prototype.createFile = function (uri, options) {\r
- this.checkDocumentChanges();\r
- this._workspaceEdit.documentChanges.push(CreateFile.create(uri, options));\r
- };\r
- WorkspaceChange.prototype.renameFile = function (oldUri, newUri, options) {\r
- this.checkDocumentChanges();\r
- this._workspaceEdit.documentChanges.push(RenameFile.create(oldUri, newUri, options));\r
- };\r
- WorkspaceChange.prototype.deleteFile = function (uri, options) {\r
- this.checkDocumentChanges();\r
- this._workspaceEdit.documentChanges.push(DeleteFile.create(uri, options));\r
- };\r
- WorkspaceChange.prototype.checkDocumentChanges = function () {\r
- if (!this._workspaceEdit || !this._workspaceEdit.documentChanges) {\r
- throw new Error('Workspace edit is not configured for document changes.');\r
- }\r
- };\r
- return WorkspaceChange;\r
-}());\r
-\r
-/**\r
- * The TextDocumentIdentifier namespace provides helper functions to work with\r
- * [TextDocumentIdentifier](#TextDocumentIdentifier) literals.\r
- */\r
-var TextDocumentIdentifier;\r
-(function (TextDocumentIdentifier) {\r
- /**\r
- * Creates a new TextDocumentIdentifier literal.\r
- * @param uri The document's uri.\r
- */\r
- function create(uri) {\r
- return { uri: uri };\r
- }\r
- TextDocumentIdentifier.create = create;\r
- /**\r
- * Checks whether the given literal conforms to the [TextDocumentIdentifier](#TextDocumentIdentifier) interface.\r
- */\r
- function is(value) {\r
- var candidate = value;\r
- return Is.defined(candidate) && Is.string(candidate.uri);\r
- }\r
- TextDocumentIdentifier.is = is;\r
-})(TextDocumentIdentifier || (TextDocumentIdentifier = {}));\r
-/**\r
- * The VersionedTextDocumentIdentifier namespace provides helper functions to work with\r
- * [VersionedTextDocumentIdentifier](#VersionedTextDocumentIdentifier) literals.\r
- */\r
-var VersionedTextDocumentIdentifier;\r
-(function (VersionedTextDocumentIdentifier) {\r
- /**\r
- * Creates a new VersionedTextDocumentIdentifier literal.\r
- * @param uri The document's uri.\r
- * @param uri The document's text.\r
- */\r
- function create(uri, version) {\r
- return { uri: uri, version: version };\r
- }\r
- VersionedTextDocumentIdentifier.create = create;\r
- /**\r
- * Checks whether the given literal conforms to the [VersionedTextDocumentIdentifier](#VersionedTextDocumentIdentifier) interface.\r
- */\r
- function is(value) {\r
- var candidate = value;\r
- return Is.defined(candidate) && Is.string(candidate.uri) && (candidate.version === null || Is.number(candidate.version));\r
- }\r
- VersionedTextDocumentIdentifier.is = is;\r
-})(VersionedTextDocumentIdentifier || (VersionedTextDocumentIdentifier = {}));\r
-/**\r
- * The TextDocumentItem namespace provides helper functions to work with\r
- * [TextDocumentItem](#TextDocumentItem) literals.\r
- */\r
-var TextDocumentItem;\r
-(function (TextDocumentItem) {\r
- /**\r
- * Creates a new TextDocumentItem literal.\r
- * @param uri The document's uri.\r
- * @param languageId The document's language identifier.\r
- * @param version The document's version number.\r
- * @param text The document's text.\r
- */\r
- function create(uri, languageId, version, text) {\r
- return { uri: uri, languageId: languageId, version: version, text: text };\r
- }\r
- TextDocumentItem.create = create;\r
- /**\r
- * Checks whether the given literal conforms to the [TextDocumentItem](#TextDocumentItem) interface.\r
- */\r
- function is(value) {\r
- var candidate = value;\r
- return Is.defined(candidate) && Is.string(candidate.uri) && Is.string(candidate.languageId) && Is.number(candidate.version) && Is.string(candidate.text);\r
- }\r
- TextDocumentItem.is = is;\r
-})(TextDocumentItem || (TextDocumentItem = {}));\r
-/**\r
- * Describes the content type that a client supports in various\r
- * result literals like `Hover`, `ParameterInfo` or `CompletionItem`.\r
- *\r
- * Please note that `MarkupKinds` must not start with a `$`. This kinds\r
- * are reserved for internal usage.\r
- */\r
-var MarkupKind;\r
-(function (MarkupKind) {\r
- /**\r
- * Plain text is supported as a content format\r
- */\r
- MarkupKind.PlainText = 'plaintext';\r
- /**\r
- * Markdown is supported as a content format\r
- */\r
- MarkupKind.Markdown = 'markdown';\r
-})(MarkupKind || (MarkupKind = {}));\r
-(function (MarkupKind) {\r
- /**\r
- * Checks whether the given value is a value of the [MarkupKind](#MarkupKind) type.\r
- */\r
- function is(value) {\r
- var candidate = value;\r
- return candidate === MarkupKind.PlainText || candidate === MarkupKind.Markdown;\r
- }\r
- MarkupKind.is = is;\r
-})(MarkupKind || (MarkupKind = {}));\r
-var MarkupContent;\r
-(function (MarkupContent) {\r
- /**\r
- * Checks whether the given value conforms to the [MarkupContent](#MarkupContent) interface.\r
- */\r
- function is(value) {\r
- var candidate = value;\r
- return Is.objectLiteral(value) && MarkupKind.is(candidate.kind) && Is.string(candidate.value);\r
- }\r
- MarkupContent.is = is;\r
-})(MarkupContent || (MarkupContent = {}));\r
-/**\r
- * The kind of a completion entry.\r
- */\r
-var CompletionItemKind;\r
-(function (CompletionItemKind) {\r
- CompletionItemKind.Text = 1;\r
- CompletionItemKind.Method = 2;\r
- CompletionItemKind.Function = 3;\r
- CompletionItemKind.Constructor = 4;\r
- CompletionItemKind.Field = 5;\r
- CompletionItemKind.Variable = 6;\r
- CompletionItemKind.Class = 7;\r
- CompletionItemKind.Interface = 8;\r
- CompletionItemKind.Module = 9;\r
- CompletionItemKind.Property = 10;\r
- CompletionItemKind.Unit = 11;\r
- CompletionItemKind.Value = 12;\r
- CompletionItemKind.Enum = 13;\r
- CompletionItemKind.Keyword = 14;\r
- CompletionItemKind.Snippet = 15;\r
- CompletionItemKind.Color = 16;\r
- CompletionItemKind.File = 17;\r
- CompletionItemKind.Reference = 18;\r
- CompletionItemKind.Folder = 19;\r
- CompletionItemKind.EnumMember = 20;\r
- CompletionItemKind.Constant = 21;\r
- CompletionItemKind.Struct = 22;\r
- CompletionItemKind.Event = 23;\r
- CompletionItemKind.Operator = 24;\r
- CompletionItemKind.TypeParameter = 25;\r
-})(CompletionItemKind || (CompletionItemKind = {}));\r
-/**\r
- * Defines whether the insert text in a completion item should be interpreted as\r
- * plain text or a snippet.\r
- */\r
-var InsertTextFormat;\r
-(function (InsertTextFormat) {\r
- /**\r
- * The primary text to be inserted is treated as a plain string.\r
- */\r
- InsertTextFormat.PlainText = 1;\r
- /**\r
- * The primary text to be inserted is treated as a snippet.\r
- *\r
- * A snippet can define tab stops and placeholders with `$1`, `$2`\r
- * and `${3:foo}`. `$0` defines the final tab stop, it defaults to\r
- * the end of the snippet. Placeholders with equal identifiers are linked,\r
- * that is typing in one will update others too.\r
- *\r
- * See also: https://github.com/Microsoft/vscode/blob/master/src/vs/editor/contrib/snippet/common/snippet.md\r
- */\r
- InsertTextFormat.Snippet = 2;\r
-})(InsertTextFormat || (InsertTextFormat = {}));\r
-/**\r
- * The CompletionItem namespace provides functions to deal with\r
- * completion items.\r
- */\r
-var CompletionItem;\r
-(function (CompletionItem) {\r
- /**\r
- * Create a completion item and seed it with a label.\r
- * @param label The completion item's label\r
- */\r
- function create(label) {\r
- return { label: label };\r
- }\r
- CompletionItem.create = create;\r
-})(CompletionItem || (CompletionItem = {}));\r
-/**\r
- * The CompletionList namespace provides functions to deal with\r
- * completion lists.\r
- */\r
-var CompletionList;\r
-(function (CompletionList) {\r
- /**\r
- * Creates a new completion list.\r
- *\r
- * @param items The completion items.\r
- * @param isIncomplete The list is not complete.\r
- */\r
- function create(items, isIncomplete) {\r
- return { items: items ? items : [], isIncomplete: !!isIncomplete };\r
- }\r
- CompletionList.create = create;\r
-})(CompletionList || (CompletionList = {}));\r
-var MarkedString;\r
-(function (MarkedString) {\r
- /**\r
- * Creates a marked string from plain text.\r
- *\r
- * @param plainText The plain text.\r
- */\r
- function fromPlainText(plainText) {\r
- return plainText.replace(/[\\`*_{}[\]()#+\-.!]/g, "\\$&"); // escape markdown syntax tokens: http://daringfireball.net/projects/markdown/syntax#backslash\r
- }\r
- MarkedString.fromPlainText = fromPlainText;\r
- /**\r
- * Checks whether the given value conforms to the [MarkedString](#MarkedString) type.\r
- */\r
- function is(value) {\r
- var candidate = value;\r
- return Is.string(candidate) || (Is.objectLiteral(candidate) && Is.string(candidate.language) && Is.string(candidate.value));\r
- }\r
- MarkedString.is = is;\r
-})(MarkedString || (MarkedString = {}));\r
-var Hover;\r
-(function (Hover) {\r
- /**\r
- * Checks whether the given value conforms to the [Hover](#Hover) interface.\r
- */\r
- function is(value) {\r
- var candidate = value;\r
- return !!candidate && Is.objectLiteral(candidate) && (MarkupContent.is(candidate.contents) ||\r
- MarkedString.is(candidate.contents) ||\r
- Is.typedArray(candidate.contents, MarkedString.is)) && (value.range === void 0 || Range.is(value.range));\r
- }\r
- Hover.is = is;\r
-})(Hover || (Hover = {}));\r
-/**\r
- * The ParameterInformation namespace provides helper functions to work with\r
- * [ParameterInformation](#ParameterInformation) literals.\r
- */\r
-var ParameterInformation;\r
-(function (ParameterInformation) {\r
- /**\r
- * Creates a new parameter information literal.\r
- *\r
- * @param label A label string.\r
- * @param documentation A doc string.\r
- */\r
- function create(label, documentation) {\r
- return documentation ? { label: label, documentation: documentation } : { label: label };\r
- }\r
- ParameterInformation.create = create;\r
- ;\r
-})(ParameterInformation || (ParameterInformation = {}));\r
-/**\r
- * The SignatureInformation namespace provides helper functions to work with\r
- * [SignatureInformation](#SignatureInformation) literals.\r
- */\r
-var SignatureInformation;\r
-(function (SignatureInformation) {\r
- function create(label, documentation) {\r
- var parameters = [];\r
- for (var _i = 2; _i < arguments.length; _i++) {\r
- parameters[_i - 2] = arguments[_i];\r
- }\r
- var result = { label: label };\r
- if (Is.defined(documentation)) {\r
- result.documentation = documentation;\r
- }\r
- if (Is.defined(parameters)) {\r
- result.parameters = parameters;\r
- }\r
- else {\r
- result.parameters = [];\r
- }\r
- return result;\r
- }\r
- SignatureInformation.create = create;\r
-})(SignatureInformation || (SignatureInformation = {}));\r
-/**\r
- * A document highlight kind.\r
- */\r
-var DocumentHighlightKind;\r
-(function (DocumentHighlightKind) {\r
- /**\r
- * A textual occurrence.\r
- */\r
- DocumentHighlightKind.Text = 1;\r
- /**\r
- * Read-access of a symbol, like reading a variable.\r
- */\r
- DocumentHighlightKind.Read = 2;\r
- /**\r
- * Write-access of a symbol, like writing to a variable.\r
- */\r
- DocumentHighlightKind.Write = 3;\r
-})(DocumentHighlightKind || (DocumentHighlightKind = {}));\r
-/**\r
- * DocumentHighlight namespace to provide helper functions to work with\r
- * [DocumentHighlight](#DocumentHighlight) literals.\r
- */\r
-var DocumentHighlight;\r
-(function (DocumentHighlight) {\r
- /**\r
- * Create a DocumentHighlight object.\r
- * @param range The range the highlight applies to.\r
- */\r
- function create(range, kind) {\r
- var result = { range: range };\r
- if (Is.number(kind)) {\r
- result.kind = kind;\r
- }\r
- return result;\r
- }\r
- DocumentHighlight.create = create;\r
-})(DocumentHighlight || (DocumentHighlight = {}));\r
-/**\r
- * A symbol kind.\r
- */\r
-var SymbolKind;\r
-(function (SymbolKind) {\r
- SymbolKind.File = 1;\r
- SymbolKind.Module = 2;\r
- SymbolKind.Namespace = 3;\r
- SymbolKind.Package = 4;\r
- SymbolKind.Class = 5;\r
- SymbolKind.Method = 6;\r
- SymbolKind.Property = 7;\r
- SymbolKind.Field = 8;\r
- SymbolKind.Constructor = 9;\r
- SymbolKind.Enum = 10;\r
- SymbolKind.Interface = 11;\r
- SymbolKind.Function = 12;\r
- SymbolKind.Variable = 13;\r
- SymbolKind.Constant = 14;\r
- SymbolKind.String = 15;\r
- SymbolKind.Number = 16;\r
- SymbolKind.Boolean = 17;\r
- SymbolKind.Array = 18;\r
- SymbolKind.Object = 19;\r
- SymbolKind.Key = 20;\r
- SymbolKind.Null = 21;\r
- SymbolKind.EnumMember = 22;\r
- SymbolKind.Struct = 23;\r
- SymbolKind.Event = 24;\r
- SymbolKind.Operator = 25;\r
- SymbolKind.TypeParameter = 26;\r
-})(SymbolKind || (SymbolKind = {}));\r
-var SymbolInformation;\r
-(function (SymbolInformation) {\r
- /**\r
- * Creates a new symbol information literal.\r
- *\r
- * @param name The name of the symbol.\r
- * @param kind The kind of the symbol.\r
- * @param range The range of the location of the symbol.\r
- * @param uri The resource of the location of symbol, defaults to the current document.\r
- * @param containerName The name of the symbol containing the symbol.\r
- */\r
- function create(name, kind, range, uri, containerName) {\r
- var result = {\r
- name: name,\r
- kind: kind,\r
- location: { uri: uri, range: range }\r
- };\r
- if (containerName) {\r
- result.containerName = containerName;\r
- }\r
- return result;\r
- }\r
- SymbolInformation.create = create;\r
-})(SymbolInformation || (SymbolInformation = {}));\r
-/**\r
- * Represents programming constructs like variables, classes, interfaces etc.\r
- * that appear in a document. Document symbols can be hierarchical and they\r
- * have two ranges: one that encloses its definition and one that points to\r
- * its most interesting range, e.g. the range of an identifier.\r
- */\r
-var DocumentSymbol = /** @class */ (function () {\r
- function DocumentSymbol() {\r
- }\r
- return DocumentSymbol;\r
-}());\r
-\r
-(function (DocumentSymbol) {\r
- /**\r
- * Creates a new symbol information literal.\r
- *\r
- * @param name The name of the symbol.\r
- * @param detail The detail of the symbol.\r
- * @param kind The kind of the symbol.\r
- * @param range The range of the symbol.\r
- * @param selectionRange The selectionRange of the symbol.\r
- * @param children Children of the symbol.\r
- */\r
- function create(name, detail, kind, range, selectionRange, children) {\r
- var result = {\r
- name: name,\r
- detail: detail,\r
- kind: kind,\r
- range: range,\r
- selectionRange: selectionRange\r
- };\r
- if (children !== void 0) {\r
- result.children = children;\r
- }\r
- return result;\r
- }\r
- DocumentSymbol.create = create;\r
- /**\r
- * Checks whether the given literal conforms to the [DocumentSymbol](#DocumentSymbol) interface.\r
- */\r
- function is(value) {\r
- var candidate = value;\r
- return candidate &&\r
- Is.string(candidate.name) && Is.number(candidate.kind) &&\r
- Range.is(candidate.range) && Range.is(candidate.selectionRange) &&\r
- (candidate.detail === void 0 || Is.string(candidate.detail)) &&\r
- (candidate.deprecated === void 0 || Is.boolean(candidate.deprecated)) &&\r
- (candidate.children === void 0 || Array.isArray(candidate.children));\r
- }\r
- DocumentSymbol.is = is;\r
-})(DocumentSymbol || (DocumentSymbol = {}));\r
-/**\r
- * A set of predefined code action kinds\r
- */\r
-var CodeActionKind;\r
-(function (CodeActionKind) {\r
- /**\r
- * Base kind for quickfix actions: 'quickfix'\r
- */\r
- CodeActionKind.QuickFix = 'quickfix';\r
- /**\r
- * Base kind for refactoring actions: 'refactor'\r
- */\r
- CodeActionKind.Refactor = 'refactor';\r
- /**\r
- * Base kind for refactoring extraction actions: 'refactor.extract'\r
- *\r
- * Example extract actions:\r
- *\r
- * - Extract method\r
- * - Extract function\r
- * - Extract variable\r
- * - Extract interface from class\r
- * - ...\r
- */\r
- CodeActionKind.RefactorExtract = 'refactor.extract';\r
- /**\r
- * Base kind for refactoring inline actions: 'refactor.inline'\r
- *\r
- * Example inline actions:\r
- *\r
- * - Inline function\r
- * - Inline variable\r
- * - Inline constant\r
- * - ...\r
- */\r
- CodeActionKind.RefactorInline = 'refactor.inline';\r
- /**\r
- * Base kind for refactoring rewrite actions: 'refactor.rewrite'\r
- *\r
- * Example rewrite actions:\r
- *\r
- * - Convert JavaScript function to class\r
- * - Add or remove parameter\r
- * - Encapsulate field\r
- * - Make method static\r
- * - Move method to base class\r
- * - ...\r
- */\r
- CodeActionKind.RefactorRewrite = 'refactor.rewrite';\r
- /**\r
- * Base kind for source actions: `source`\r
- *\r
- * Source code actions apply to the entire file.\r
- */\r
- CodeActionKind.Source = 'source';\r
- /**\r
- * Base kind for an organize imports source action: `source.organizeImports`\r
- */\r
- CodeActionKind.SourceOrganizeImports = 'source.organizeImports';\r
-})(CodeActionKind || (CodeActionKind = {}));\r
-/**\r
- * The CodeActionContext namespace provides helper functions to work with\r
- * [CodeActionContext](#CodeActionContext) literals.\r
- */\r
-var CodeActionContext;\r
-(function (CodeActionContext) {\r
- /**\r
- * Creates a new CodeActionContext literal.\r
- */\r
- function create(diagnostics, only) {\r
- var result = { diagnostics: diagnostics };\r
- if (only !== void 0 && only !== null) {\r
- result.only = only;\r
- }\r
- return result;\r
- }\r
- CodeActionContext.create = create;\r
- /**\r
- * Checks whether the given literal conforms to the [CodeActionContext](#CodeActionContext) interface.\r
- */\r
- function is(value) {\r
- var candidate = value;\r
- return Is.defined(candidate) && Is.typedArray(candidate.diagnostics, Diagnostic.is) && (candidate.only === void 0 || Is.typedArray(candidate.only, Is.string));\r
- }\r
- CodeActionContext.is = is;\r
-})(CodeActionContext || (CodeActionContext = {}));\r
-var CodeAction;\r
-(function (CodeAction) {\r
- function create(title, commandOrEdit, kind) {\r
- var result = { title: title };\r
- if (Command.is(commandOrEdit)) {\r
- result.command = commandOrEdit;\r
- }\r
- else {\r
- result.edit = commandOrEdit;\r
- }\r
- if (kind !== void null) {\r
- result.kind = kind;\r
- }\r
- return result;\r
- }\r
- CodeAction.create = create;\r
- function is(value) {\r
- var candidate = value;\r
- return candidate && Is.string(candidate.title) &&\r
- (candidate.diagnostics === void 0 || Is.typedArray(candidate.diagnostics, Diagnostic.is)) &&\r
- (candidate.kind === void 0 || Is.string(candidate.kind)) &&\r
- (candidate.edit !== void 0 || candidate.command !== void 0) &&\r
- (candidate.command === void 0 || Command.is(candidate.command)) &&\r
- (candidate.edit === void 0 || WorkspaceEdit.is(candidate.edit));\r
- }\r
- CodeAction.is = is;\r
-})(CodeAction || (CodeAction = {}));\r
-/**\r
- * The CodeLens namespace provides helper functions to work with\r
- * [CodeLens](#CodeLens) literals.\r
- */\r
-var CodeLens;\r
-(function (CodeLens) {\r
- /**\r
- * Creates a new CodeLens literal.\r
- */\r
- function create(range, data) {\r
- var result = { range: range };\r
- if (Is.defined(data))\r
- result.data = data;\r
- return result;\r
- }\r
- CodeLens.create = create;\r
- /**\r
- * Checks whether the given literal conforms to the [CodeLens](#CodeLens) interface.\r
- */\r
- function is(value) {\r
- var candidate = value;\r
- return Is.defined(candidate) && Range.is(candidate.range) && (Is.undefined(candidate.command) || Command.is(candidate.command));\r
- }\r
- CodeLens.is = is;\r
-})(CodeLens || (CodeLens = {}));\r
-/**\r
- * The FormattingOptions namespace provides helper functions to work with\r
- * [FormattingOptions](#FormattingOptions) literals.\r
- */\r
-var FormattingOptions;\r
-(function (FormattingOptions) {\r
- /**\r
- * Creates a new FormattingOptions literal.\r
- */\r
- function create(tabSize, insertSpaces) {\r
- return { tabSize: tabSize, insertSpaces: insertSpaces };\r
- }\r
- FormattingOptions.create = create;\r
- /**\r
- * Checks whether the given literal conforms to the [FormattingOptions](#FormattingOptions) interface.\r
- */\r
- function is(value) {\r
- var candidate = value;\r
- return Is.defined(candidate) && Is.number(candidate.tabSize) && Is.boolean(candidate.insertSpaces);\r
- }\r
- FormattingOptions.is = is;\r
-})(FormattingOptions || (FormattingOptions = {}));\r
-/**\r
- * A document link is a range in a text document that links to an internal or external resource, like another\r
- * text document or a web site.\r
- */\r
-var DocumentLink = /** @class */ (function () {\r
- function DocumentLink() {\r
- }\r
- return DocumentLink;\r
-}());\r
-\r
-/**\r
- * The DocumentLink namespace provides helper functions to work with\r
- * [DocumentLink](#DocumentLink) literals.\r
- */\r
-(function (DocumentLink) {\r
- /**\r
- * Creates a new DocumentLink literal.\r
- */\r
- function create(range, target, data) {\r
- return { range: range, target: target, data: data };\r
- }\r
- DocumentLink.create = create;\r
- /**\r
- * Checks whether the given literal conforms to the [DocumentLink](#DocumentLink) interface.\r
- */\r
- function is(value) {\r
- var candidate = value;\r
- return Is.defined(candidate) && Range.is(candidate.range) && (Is.undefined(candidate.target) || Is.string(candidate.target));\r
- }\r
- DocumentLink.is = is;\r
-})(DocumentLink || (DocumentLink = {}));\r
-var EOL = ['\n', '\r\n', '\r'];\r
-var TextDocument;\r
-(function (TextDocument) {\r
- /**\r
- * Creates a new ITextDocument literal from the given uri and content.\r
- * @param uri The document's uri.\r
- * @param languageId The document's language Id.\r
- * @param content The document's content.\r
- */\r
- function create(uri, languageId, version, content) {\r
- return new FullTextDocument(uri, languageId, version, content);\r
- }\r
- TextDocument.create = create;\r
- /**\r
- * Checks whether the given literal conforms to the [ITextDocument](#ITextDocument) interface.\r
- */\r
- function is(value) {\r
- var candidate = value;\r
- return Is.defined(candidate) && Is.string(candidate.uri) && (Is.undefined(candidate.languageId) || Is.string(candidate.languageId)) && Is.number(candidate.lineCount)\r
- && Is.func(candidate.getText) && Is.func(candidate.positionAt) && Is.func(candidate.offsetAt) ? true : false;\r
- }\r
- TextDocument.is = is;\r
- function applyEdits(document, edits) {\r
- var text = document.getText();\r
- var sortedEdits = mergeSort(edits, function (a, b) {\r
- var diff = a.range.start.line - b.range.start.line;\r
- if (diff === 0) {\r
- return a.range.start.character - b.range.start.character;\r
- }\r
- return diff;\r
- });\r
- var lastModifiedOffset = text.length;\r
- for (var i = sortedEdits.length - 1; i >= 0; i--) {\r
- var e = sortedEdits[i];\r
- var startOffset = document.offsetAt(e.range.start);\r
- var endOffset = document.offsetAt(e.range.end);\r
- if (endOffset <= lastModifiedOffset) {\r
- text = text.substring(0, startOffset) + e.newText + text.substring(endOffset, text.length);\r
- }\r
- else {\r
- throw new Error('Overlapping edit');\r
- }\r
- lastModifiedOffset = startOffset;\r
- }\r
- return text;\r
- }\r
- TextDocument.applyEdits = applyEdits;\r
- function mergeSort(data, compare) {\r
- if (data.length <= 1) {\r
- // sorted\r
- return data;\r
- }\r
- var p = (data.length / 2) | 0;\r
- var left = data.slice(0, p);\r
- var right = data.slice(p);\r
- mergeSort(left, compare);\r
- mergeSort(right, compare);\r
- var leftIdx = 0;\r
- var rightIdx = 0;\r
- var i = 0;\r
- while (leftIdx < left.length && rightIdx < right.length) {\r
- var ret = compare(left[leftIdx], right[rightIdx]);\r
- if (ret <= 0) {\r
- // smaller_equal -> take left to preserve order\r
- data[i++] = left[leftIdx++];\r
- }\r
- else {\r
- // greater -> take right\r
- data[i++] = right[rightIdx++];\r
- }\r
- }\r
- while (leftIdx < left.length) {\r
- data[i++] = left[leftIdx++];\r
- }\r
- while (rightIdx < right.length) {\r
- data[i++] = right[rightIdx++];\r
- }\r
- return data;\r
- }\r
-})(TextDocument || (TextDocument = {}));\r
-/**\r
- * Represents reasons why a text document is saved.\r
- */\r
-var TextDocumentSaveReason;\r
-(function (TextDocumentSaveReason) {\r
- /**\r
- * Manually triggered, e.g. by the user pressing save, by starting debugging,\r
- * or by an API call.\r
- */\r
- TextDocumentSaveReason.Manual = 1;\r
- /**\r
- * Automatic after a delay.\r
- */\r
- TextDocumentSaveReason.AfterDelay = 2;\r
- /**\r
- * When the editor lost focus.\r
- */\r
- TextDocumentSaveReason.FocusOut = 3;\r
-})(TextDocumentSaveReason || (TextDocumentSaveReason = {}));\r
-var FullTextDocument = /** @class */ (function () {\r
- function FullTextDocument(uri, languageId, version, content) {\r
- this._uri = uri;\r
- this._languageId = languageId;\r
- this._version = version;\r
- this._content = content;\r
- this._lineOffsets = null;\r
- }\r
- Object.defineProperty(FullTextDocument.prototype, "uri", {\r
- get: function () {\r
- return this._uri;\r
- },\r
- enumerable: true,\r
- configurable: true\r
- });\r
- Object.defineProperty(FullTextDocument.prototype, "languageId", {\r
- get: function () {\r
- return this._languageId;\r
- },\r
- enumerable: true,\r
- configurable: true\r
- });\r
- Object.defineProperty(FullTextDocument.prototype, "version", {\r
- get: function () {\r
- return this._version;\r
- },\r
- enumerable: true,\r
- configurable: true\r
- });\r
- FullTextDocument.prototype.getText = function (range) {\r
- if (range) {\r
- var start = this.offsetAt(range.start);\r
- var end = this.offsetAt(range.end);\r
- return this._content.substring(start, end);\r
- }\r
- return this._content;\r
- };\r
- FullTextDocument.prototype.update = function (event, version) {\r
- this._content = event.text;\r
- this._version = version;\r
- this._lineOffsets = null;\r
- };\r
- FullTextDocument.prototype.getLineOffsets = function () {\r
- if (this._lineOffsets === null) {\r
- var lineOffsets = [];\r
- var text = this._content;\r
- var isLineStart = true;\r
- for (var i = 0; i < text.length; i++) {\r
- if (isLineStart) {\r
- lineOffsets.push(i);\r
- isLineStart = false;\r
- }\r
- var ch = text.charAt(i);\r
- isLineStart = (ch === '\r' || ch === '\n');\r
- if (ch === '\r' && i + 1 < text.length && text.charAt(i + 1) === '\n') {\r
- i++;\r
- }\r
- }\r
- if (isLineStart && text.length > 0) {\r
- lineOffsets.push(text.length);\r
- }\r
- this._lineOffsets = lineOffsets;\r
- }\r
- return this._lineOffsets;\r
- };\r
- FullTextDocument.prototype.positionAt = function (offset) {\r
- offset = Math.max(Math.min(offset, this._content.length), 0);\r
- var lineOffsets = this.getLineOffsets();\r
- var low = 0, high = lineOffsets.length;\r
- if (high === 0) {\r
- return Position.create(0, offset);\r
- }\r
- while (low < high) {\r
- var mid = Math.floor((low + high) / 2);\r
- if (lineOffsets[mid] > offset) {\r
- high = mid;\r
- }\r
- else {\r
- low = mid + 1;\r
- }\r
- }\r
- // low is the least x for which the line offset is larger than the current offset\r
- // or array.length if no line offset is larger than the current offset\r
- var line = low - 1;\r
- return Position.create(line, offset - lineOffsets[line]);\r
- };\r
- FullTextDocument.prototype.offsetAt = function (position) {\r
- var lineOffsets = this.getLineOffsets();\r
- if (position.line >= lineOffsets.length) {\r
- return this._content.length;\r
- }\r
- else if (position.line < 0) {\r
- return 0;\r
- }\r
- var lineOffset = lineOffsets[position.line];\r
- var nextLineOffset = (position.line + 1 < lineOffsets.length) ? lineOffsets[position.line + 1] : this._content.length;\r
- return Math.max(Math.min(lineOffset + position.character, nextLineOffset), lineOffset);\r
- };\r
- Object.defineProperty(FullTextDocument.prototype, "lineCount", {\r
- get: function () {\r
- return this.getLineOffsets().length;\r
- },\r
- enumerable: true,\r
- configurable: true\r
- });\r
- return FullTextDocument;\r
-}());\r
-var Is;\r
-(function (Is) {\r
- var toString = Object.prototype.toString;\r
- function defined(value) {\r
- return typeof value !== 'undefined';\r
- }\r
- Is.defined = defined;\r
- function undefined(value) {\r
- return typeof value === 'undefined';\r
- }\r
- Is.undefined = undefined;\r
- function boolean(value) {\r
- return value === true || value === false;\r
- }\r
- Is.boolean = boolean;\r
- function string(value) {\r
- return toString.call(value) === '[object String]';\r
- }\r
- Is.string = string;\r
- function number(value) {\r
- return toString.call(value) === '[object Number]';\r
- }\r
- Is.number = number;\r
- function func(value) {\r
- return toString.call(value) === '[object Function]';\r
- }\r
- Is.func = func;\r
- function objectLiteral(value) {\r
- // Strictly speaking class instances pass this check as well. Since the LSP\r
- // doesn't use classes we ignore this for now. If we do we need to add something\r
- // like this: `Object.getPrototypeOf(Object.getPrototypeOf(x)) === null`\r
- return value !== null && typeof value === 'object';\r
- }\r
- Is.objectLiteral = objectLiteral;\r
- function typedArray(value, check) {\r
- return Array.isArray(value) && value.every(check);\r
- }\r
- Is.typedArray = typedArray;\r
-})(Is || (Is = {}));\r
-
-
-/***/ }),
-/* 18 */
-/***/ (function(module, exports, __webpack_require__) {
-
-"use strict";
-/* --------------------------------------------------------------------------------------------\r
- * Copyright (c) Microsoft Corporation. All rights reserved.\r
- * Licensed under the MIT License. See License.txt in the project root for license information.\r
- * ------------------------------------------------------------------------------------------ */\r
-\r
-Object.defineProperty(exports, "__esModule", { value: true });\r
-const Is = __webpack_require__(19);\r
-const vscode_jsonrpc_1 = __webpack_require__(4);\r
-const protocol_implementation_1 = __webpack_require__(20);\r
-exports.ImplementationRequest = protocol_implementation_1.ImplementationRequest;\r
-const protocol_typeDefinition_1 = __webpack_require__(21);\r
-exports.TypeDefinitionRequest = protocol_typeDefinition_1.TypeDefinitionRequest;\r
-const protocol_workspaceFolders_1 = __webpack_require__(22);\r
-exports.WorkspaceFoldersRequest = protocol_workspaceFolders_1.WorkspaceFoldersRequest;\r
-exports.DidChangeWorkspaceFoldersNotification = protocol_workspaceFolders_1.DidChangeWorkspaceFoldersNotification;\r
-const protocol_configuration_1 = __webpack_require__(23);\r
-exports.ConfigurationRequest = protocol_configuration_1.ConfigurationRequest;\r
-const protocol_colorProvider_1 = __webpack_require__(24);\r
-exports.DocumentColorRequest = protocol_colorProvider_1.DocumentColorRequest;\r
-exports.ColorPresentationRequest = protocol_colorProvider_1.ColorPresentationRequest;\r
-const protocol_foldingRange_1 = __webpack_require__(25);\r
-exports.FoldingRangeRequest = protocol_foldingRange_1.FoldingRangeRequest;\r
-const protocol_declaration_1 = __webpack_require__(26);\r
-exports.DeclarationRequest = protocol_declaration_1.DeclarationRequest;\r
-// @ts-ignore: to avoid inlining LocatioLink as dynamic import\r
-let __noDynamicImport;\r
-var DocumentFilter;\r
-(function (DocumentFilter) {\r
- function is(value) {\r
- let candidate = value;\r
- return Is.string(candidate.language) || Is.string(candidate.scheme) || Is.string(candidate.pattern);\r
- }\r
- DocumentFilter.is = is;\r
-})(DocumentFilter = exports.DocumentFilter || (exports.DocumentFilter = {}));\r
-/**\r
- * The `client/registerCapability` request is sent from the server to the client to register a new capability\r
- * handler on the client side.\r
- */\r
-var RegistrationRequest;\r
-(function (RegistrationRequest) {\r
- RegistrationRequest.type = new vscode_jsonrpc_1.RequestType('client/registerCapability');\r
-})(RegistrationRequest = exports.RegistrationRequest || (exports.RegistrationRequest = {}));\r
-/**\r
- * The `client/unregisterCapability` request is sent from the server to the client to unregister a previously registered capability\r
- * handler on the client side.\r
- */\r
-var UnregistrationRequest;\r
-(function (UnregistrationRequest) {\r
- UnregistrationRequest.type = new vscode_jsonrpc_1.RequestType('client/unregisterCapability');\r
-})(UnregistrationRequest = exports.UnregistrationRequest || (exports.UnregistrationRequest = {}));\r
-var ResourceOperationKind;\r
-(function (ResourceOperationKind) {\r
- /**\r
- * Supports creating new files and folders.\r
- */\r
- ResourceOperationKind.Create = 'create';\r
- /**\r
- * Supports renaming existing files and folders.\r
- */\r
- ResourceOperationKind.Rename = 'rename';\r
- /**\r
- * Supports deleting existing files and folders.\r
- */\r
- ResourceOperationKind.Delete = 'delete';\r
-})(ResourceOperationKind = exports.ResourceOperationKind || (exports.ResourceOperationKind = {}));\r
-var FailureHandlingKind;\r
-(function (FailureHandlingKind) {\r
- /**\r
- * Applying the workspace change is simply aborted if one of the changes provided\r
- * fails. All operations executed before the failing operation stay executed.\r
- */\r
- FailureHandlingKind.Abort = 'abort';\r
- /**\r
- * All operations are executed transactional. That means they either all\r
- * succeed or no changes at all are applied to the workspace.\r
- */\r
- FailureHandlingKind.Transactional = 'transactional';\r
- /**\r
- * If the workspace edit contains only textual file changes they are executed transactional.\r
- * If resource changes (create, rename or delete file) are part of the change the failure\r
- * handling startegy is abort.\r
- */\r
- FailureHandlingKind.TextOnlyTransactional = 'textOnlyTransactional';\r
- /**\r
- * The client tries to undo the operations already executed. But there is no\r
- * guaruntee that this is succeeding.\r
- */\r
- FailureHandlingKind.Undo = 'undo';\r
-})(FailureHandlingKind = exports.FailureHandlingKind || (exports.FailureHandlingKind = {}));\r
-/**\r
- * Defines how the host (editor) should sync\r
- * document changes to the language server.\r
- */\r
-var TextDocumentSyncKind;\r
-(function (TextDocumentSyncKind) {\r
- /**\r
- * Documents should not be synced at all.\r
- */\r
- TextDocumentSyncKind.None = 0;\r
- /**\r
- * Documents are synced by always sending the full content\r
- * of the document.\r
- */\r
- TextDocumentSyncKind.Full = 1;\r
- /**\r
- * Documents are synced by sending the full content on open.\r
- * After that only incremental updates to the document are\r
- * send.\r
- */\r
- TextDocumentSyncKind.Incremental = 2;\r
-})(TextDocumentSyncKind = exports.TextDocumentSyncKind || (exports.TextDocumentSyncKind = {}));\r
-/**\r
- * The initialize request is sent from the client to the server.\r
- * It is sent once as the request after starting up the server.\r
- * The requests parameter is of type [InitializeParams](#InitializeParams)\r
- * the response if of type [InitializeResult](#InitializeResult) of a Thenable that\r
- * resolves to such.\r
- */\r
-var InitializeRequest;\r
-(function (InitializeRequest) {\r
- InitializeRequest.type = new vscode_jsonrpc_1.RequestType('initialize');\r
-})(InitializeRequest = exports.InitializeRequest || (exports.InitializeRequest = {}));\r
-/**\r
- * Known error codes for an `InitializeError`;\r
- */\r
-var InitializeError;\r
-(function (InitializeError) {\r
- /**\r
- * If the protocol version provided by the client can't be handled by the server.\r
- * @deprecated This initialize error got replaced by client capabilities. There is\r
- * no version handshake in version 3.0x\r
- */\r
- InitializeError.unknownProtocolVersion = 1;\r
-})(InitializeError = exports.InitializeError || (exports.InitializeError = {}));\r
-/**\r
- * The intialized notification is sent from the client to the\r
- * server after the client is fully initialized and the server\r
- * is allowed to send requests from the server to the client.\r
- */\r
-var InitializedNotification;\r
-(function (InitializedNotification) {\r
- InitializedNotification.type = new vscode_jsonrpc_1.NotificationType('initialized');\r
-})(InitializedNotification = exports.InitializedNotification || (exports.InitializedNotification = {}));\r
-//---- Shutdown Method ----\r
-/**\r
- * A shutdown request is sent from the client to the server.\r
- * It is sent once when the client decides to shutdown the\r
- * server. The only notification that is sent after a shutdown request\r
- * is the exit event.\r
- */\r
-var ShutdownRequest;\r
-(function (ShutdownRequest) {\r
- ShutdownRequest.type = new vscode_jsonrpc_1.RequestType0('shutdown');\r
-})(ShutdownRequest = exports.ShutdownRequest || (exports.ShutdownRequest = {}));\r
-//---- Exit Notification ----\r
-/**\r
- * The exit event is sent from the client to the server to\r
- * ask the server to exit its process.\r
- */\r
-var ExitNotification;\r
-(function (ExitNotification) {\r
- ExitNotification.type = new vscode_jsonrpc_1.NotificationType0('exit');\r
-})(ExitNotification = exports.ExitNotification || (exports.ExitNotification = {}));\r
-//---- Configuration notification ----\r
-/**\r
- * The configuration change notification is sent from the client to the server\r
- * when the client's configuration has changed. The notification contains\r
- * the changed configuration as defined by the language client.\r
- */\r
-var DidChangeConfigurationNotification;\r
-(function (DidChangeConfigurationNotification) {\r
- DidChangeConfigurationNotification.type = new vscode_jsonrpc_1.NotificationType('workspace/didChangeConfiguration');\r
-})(DidChangeConfigurationNotification = exports.DidChangeConfigurationNotification || (exports.DidChangeConfigurationNotification = {}));\r
-//---- Message show and log notifications ----\r
-/**\r
- * The message type\r
- */\r
-var MessageType;\r
-(function (MessageType) {\r
- /**\r
- * An error message.\r
- */\r
- MessageType.Error = 1;\r
- /**\r
- * A warning message.\r
- */\r
- MessageType.Warning = 2;\r
- /**\r
- * An information message.\r
- */\r
- MessageType.Info = 3;\r
- /**\r
- * A log message.\r
- */\r
- MessageType.Log = 4;\r
-})(MessageType = exports.MessageType || (exports.MessageType = {}));\r
-/**\r
- * The show message notification is sent from a server to a client to ask\r
- * the client to display a particular message in the user interface.\r
- */\r
-var ShowMessageNotification;\r
-(function (ShowMessageNotification) {\r
- ShowMessageNotification.type = new vscode_jsonrpc_1.NotificationType('window/showMessage');\r
-})(ShowMessageNotification = exports.ShowMessageNotification || (exports.ShowMessageNotification = {}));\r
-/**\r
- * The show message request is sent from the server to the client to show a message\r
- * and a set of options actions to the user.\r
- */\r
-var ShowMessageRequest;\r
-(function (ShowMessageRequest) {\r
- ShowMessageRequest.type = new vscode_jsonrpc_1.RequestType('window/showMessageRequest');\r
-})(ShowMessageRequest = exports.ShowMessageRequest || (exports.ShowMessageRequest = {}));\r
-/**\r
- * The log message notification is sent from the server to the client to ask\r
- * the client to log a particular message.\r
- */\r
-var LogMessageNotification;\r
-(function (LogMessageNotification) {\r
- LogMessageNotification.type = new vscode_jsonrpc_1.NotificationType('window/logMessage');\r
-})(LogMessageNotification = exports.LogMessageNotification || (exports.LogMessageNotification = {}));\r
-//---- Telemetry notification\r
-/**\r
- * The telemetry event notification is sent from the server to the client to ask\r
- * the client to log telemetry data.\r
- */\r
-var TelemetryEventNotification;\r
-(function (TelemetryEventNotification) {\r
- TelemetryEventNotification.type = new vscode_jsonrpc_1.NotificationType('telemetry/event');\r
-})(TelemetryEventNotification = exports.TelemetryEventNotification || (exports.TelemetryEventNotification = {}));\r
-/**\r
- * The document open notification is sent from the client to the server to signal\r
- * newly opened text documents. The document's truth is now managed by the client\r
- * and the server must not try to read the document's truth using the document's\r
- * uri. Open in this sense means it is managed by the client. It doesn't necessarily\r
- * mean that its content is presented in an editor. An open notification must not\r
- * be sent more than once without a corresponding close notification send before.\r
- * This means open and close notification must be balanced and the max open count\r
- * is one.\r
- */\r
-var DidOpenTextDocumentNotification;\r
-(function (DidOpenTextDocumentNotification) {\r
- DidOpenTextDocumentNotification.type = new vscode_jsonrpc_1.NotificationType('textDocument/didOpen');\r
-})(DidOpenTextDocumentNotification = exports.DidOpenTextDocumentNotification || (exports.DidOpenTextDocumentNotification = {}));\r
-/**\r
- * The document change notification is sent from the client to the server to signal\r
- * changes to a text document.\r
- */\r
-var DidChangeTextDocumentNotification;\r
-(function (DidChangeTextDocumentNotification) {\r
- DidChangeTextDocumentNotification.type = new vscode_jsonrpc_1.NotificationType('textDocument/didChange');\r
-})(DidChangeTextDocumentNotification = exports.DidChangeTextDocumentNotification || (exports.DidChangeTextDocumentNotification = {}));\r
-/**\r
- * The document close notification is sent from the client to the server when\r
- * the document got closed in the client. The document's truth now exists where\r
- * the document's uri points to (e.g. if the document's uri is a file uri the\r
- * truth now exists on disk). As with the open notification the close notification\r
- * is about managing the document's content. Receiving a close notification\r
- * doesn't mean that the document was open in an editor before. A close\r
- * notification requires a previous open notification to be sent.\r
- */\r
-var DidCloseTextDocumentNotification;\r
-(function (DidCloseTextDocumentNotification) {\r
- DidCloseTextDocumentNotification.type = new vscode_jsonrpc_1.NotificationType('textDocument/didClose');\r
-})(DidCloseTextDocumentNotification = exports.DidCloseTextDocumentNotification || (exports.DidCloseTextDocumentNotification = {}));\r
-/**\r
- * The document save notification is sent from the client to the server when\r
- * the document got saved in the client.\r
- */\r
-var DidSaveTextDocumentNotification;\r
-(function (DidSaveTextDocumentNotification) {\r
- DidSaveTextDocumentNotification.type = new vscode_jsonrpc_1.NotificationType('textDocument/didSave');\r
-})(DidSaveTextDocumentNotification = exports.DidSaveTextDocumentNotification || (exports.DidSaveTextDocumentNotification = {}));\r
-/**\r
- * A document will save notification is sent from the client to the server before\r
- * the document is actually saved.\r
- */\r
-var WillSaveTextDocumentNotification;\r
-(function (WillSaveTextDocumentNotification) {\r
- WillSaveTextDocumentNotification.type = new vscode_jsonrpc_1.NotificationType('textDocument/willSave');\r
-})(WillSaveTextDocumentNotification = exports.WillSaveTextDocumentNotification || (exports.WillSaveTextDocumentNotification = {}));\r
-/**\r
- * A document will save request is sent from the client to the server before\r
- * the document is actually saved. The request can return an array of TextEdits\r
- * which will be applied to the text document before it is saved. Please note that\r
- * clients might drop results if computing the text edits took too long or if a\r
- * server constantly fails on this request. This is done to keep the save fast and\r
- * reliable.\r
- */\r
-var WillSaveTextDocumentWaitUntilRequest;\r
-(function (WillSaveTextDocumentWaitUntilRequest) {\r
- WillSaveTextDocumentWaitUntilRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/willSaveWaitUntil');\r
-})(WillSaveTextDocumentWaitUntilRequest = exports.WillSaveTextDocumentWaitUntilRequest || (exports.WillSaveTextDocumentWaitUntilRequest = {}));\r
-//---- File eventing ----\r
-/**\r
- * The watched files notification is sent from the client to the server when\r
- * the client detects changes to file watched by the language client.\r
- */\r
-var DidChangeWatchedFilesNotification;\r
-(function (DidChangeWatchedFilesNotification) {\r
- DidChangeWatchedFilesNotification.type = new vscode_jsonrpc_1.NotificationType('workspace/didChangeWatchedFiles');\r
-})(DidChangeWatchedFilesNotification = exports.DidChangeWatchedFilesNotification || (exports.DidChangeWatchedFilesNotification = {}));\r
-/**\r
- * The file event type\r
- */\r
-var FileChangeType;\r
-(function (FileChangeType) {\r
- /**\r
- * The file got created.\r
- */\r
- FileChangeType.Created = 1;\r
- /**\r
- * The file got changed.\r
- */\r
- FileChangeType.Changed = 2;\r
- /**\r
- * The file got deleted.\r
- */\r
- FileChangeType.Deleted = 3;\r
-})(FileChangeType = exports.FileChangeType || (exports.FileChangeType = {}));\r
-var WatchKind;\r
-(function (WatchKind) {\r
- /**\r
- * Interested in create events.\r
- */\r
- WatchKind.Create = 1;\r
- /**\r
- * Interested in change events\r
- */\r
- WatchKind.Change = 2;\r
- /**\r
- * Interested in delete events\r
- */\r
- WatchKind.Delete = 4;\r
-})(WatchKind = exports.WatchKind || (exports.WatchKind = {}));\r
-//---- Diagnostic notification ----\r
-/**\r
- * Diagnostics notification are sent from the server to the client to signal\r
- * results of validation runs.\r
- */\r
-var PublishDiagnosticsNotification;\r
-(function (PublishDiagnosticsNotification) {\r
- PublishDiagnosticsNotification.type = new vscode_jsonrpc_1.NotificationType('textDocument/publishDiagnostics');\r
-})(PublishDiagnosticsNotification = exports.PublishDiagnosticsNotification || (exports.PublishDiagnosticsNotification = {}));\r
-/**\r
- * How a completion was triggered\r
- */\r
-var CompletionTriggerKind;\r
-(function (CompletionTriggerKind) {\r
- /**\r
- * Completion was triggered by typing an identifier (24x7 code\r
- * complete), manual invocation (e.g Ctrl+Space) or via API.\r
- */\r
- CompletionTriggerKind.Invoked = 1;\r
- /**\r
- * Completion was triggered by a trigger character specified by\r
- * the `triggerCharacters` properties of the `CompletionRegistrationOptions`.\r
- */\r
- CompletionTriggerKind.TriggerCharacter = 2;\r
- /**\r
- * Completion was re-triggered as current completion list is incomplete\r
- */\r
- CompletionTriggerKind.TriggerForIncompleteCompletions = 3;\r
-})(CompletionTriggerKind = exports.CompletionTriggerKind || (exports.CompletionTriggerKind = {}));\r
-/**\r
- * Request to request completion at a given text document position. The request's\r
- * parameter is of type [TextDocumentPosition](#TextDocumentPosition) the response\r
- * is of type [CompletionItem[]](#CompletionItem) or [CompletionList](#CompletionList)\r
- * or a Thenable that resolves to such.\r
- *\r
- * The request can delay the computation of the [`detail`](#CompletionItem.detail)\r
- * and [`documentation`](#CompletionItem.documentation) properties to the `completionItem/resolve`\r
- * request. However, properties that are needed for the initial sorting and filtering, like `sortText`,\r
- * `filterText`, `insertText`, and `textEdit`, must not be changed during resolve.\r
- */\r
-var CompletionRequest;\r
-(function (CompletionRequest) {\r
- CompletionRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/completion');\r
-})(CompletionRequest = exports.CompletionRequest || (exports.CompletionRequest = {}));\r
-/**\r
- * Request to resolve additional information for a given completion item.The request's\r
- * parameter is of type [CompletionItem](#CompletionItem) the response\r
- * is of type [CompletionItem](#CompletionItem) or a Thenable that resolves to such.\r
- */\r
-var CompletionResolveRequest;\r
-(function (CompletionResolveRequest) {\r
- CompletionResolveRequest.type = new vscode_jsonrpc_1.RequestType('completionItem/resolve');\r
-})(CompletionResolveRequest = exports.CompletionResolveRequest || (exports.CompletionResolveRequest = {}));\r
-//---- Hover Support -------------------------------\r
-/**\r
- * Request to request hover information at a given text document position. The request's\r
- * parameter is of type [TextDocumentPosition](#TextDocumentPosition) the response is of\r
- * type [Hover](#Hover) or a Thenable that resolves to such.\r
- */\r
-var HoverRequest;\r
-(function (HoverRequest) {\r
- HoverRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/hover');\r
-})(HoverRequest = exports.HoverRequest || (exports.HoverRequest = {}));\r
-var SignatureHelpRequest;\r
-(function (SignatureHelpRequest) {\r
- SignatureHelpRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/signatureHelp');\r
-})(SignatureHelpRequest = exports.SignatureHelpRequest || (exports.SignatureHelpRequest = {}));\r
-//---- Goto Definition -------------------------------------\r
-/**\r
- * A request to resolve the definition location of a symbol at a given text\r
- * document position. The request's parameter is of type [TextDocumentPosition]\r
- * (#TextDocumentPosition) the response is of either type [Definition](#Definition)\r
- * or a typed array of [DefinitionLink](#DefinitionLink) or a Thenable that resolves\r
- * to such.\r
- */\r
-var DefinitionRequest;\r
-(function (DefinitionRequest) {\r
- DefinitionRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/definition');\r
-})(DefinitionRequest = exports.DefinitionRequest || (exports.DefinitionRequest = {}));\r
-/**\r
- * A request to resolve project-wide references for the symbol denoted\r
- * by the given text document position. The request's parameter is of\r
- * type [ReferenceParams](#ReferenceParams) the response is of type\r
- * [Location[]](#Location) or a Thenable that resolves to such.\r
- */\r
-var ReferencesRequest;\r
-(function (ReferencesRequest) {\r
- ReferencesRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/references');\r
-})(ReferencesRequest = exports.ReferencesRequest || (exports.ReferencesRequest = {}));\r
-//---- Document Highlight ----------------------------------\r
-/**\r
- * Request to resolve a [DocumentHighlight](#DocumentHighlight) for a given\r
- * text document position. The request's parameter is of type [TextDocumentPosition]\r
- * (#TextDocumentPosition) the request response is of type [DocumentHighlight[]]\r
- * (#DocumentHighlight) or a Thenable that resolves to such.\r
- */\r
-var DocumentHighlightRequest;\r
-(function (DocumentHighlightRequest) {\r
- DocumentHighlightRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/documentHighlight');\r
-})(DocumentHighlightRequest = exports.DocumentHighlightRequest || (exports.DocumentHighlightRequest = {}));\r
-//---- Document Symbol Provider ---------------------------\r
-/**\r
- * A request to list all symbols found in a given text document. The request's\r
- * parameter is of type [TextDocumentIdentifier](#TextDocumentIdentifier) the\r
- * response is of type [SymbolInformation[]](#SymbolInformation) or a Thenable\r
- * that resolves to such.\r
- */\r
-var DocumentSymbolRequest;\r
-(function (DocumentSymbolRequest) {\r
- DocumentSymbolRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/documentSymbol');\r
-})(DocumentSymbolRequest = exports.DocumentSymbolRequest || (exports.DocumentSymbolRequest = {}));\r
-//---- Workspace Symbol Provider ---------------------------\r
-/**\r
- * A request to list project-wide symbols matching the query string given\r
- * by the [WorkspaceSymbolParams](#WorkspaceSymbolParams). The response is\r
- * of type [SymbolInformation[]](#SymbolInformation) or a Thenable that\r
- * resolves to such.\r
- */\r
-var WorkspaceSymbolRequest;\r
-(function (WorkspaceSymbolRequest) {\r
- WorkspaceSymbolRequest.type = new vscode_jsonrpc_1.RequestType('workspace/symbol');\r
-})(WorkspaceSymbolRequest = exports.WorkspaceSymbolRequest || (exports.WorkspaceSymbolRequest = {}));\r
-/**\r
- * A request to provide commands for the given text document and range.\r
- */\r
-var CodeActionRequest;\r
-(function (CodeActionRequest) {\r
- CodeActionRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/codeAction');\r
-})(CodeActionRequest = exports.CodeActionRequest || (exports.CodeActionRequest = {}));\r
-/**\r
- * A request to provide code lens for the given text document.\r
- */\r
-var CodeLensRequest;\r
-(function (CodeLensRequest) {\r
- CodeLensRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/codeLens');\r
-})(CodeLensRequest = exports.CodeLensRequest || (exports.CodeLensRequest = {}));\r
-/**\r
- * A request to resolve a command for a given code lens.\r
- */\r
-var CodeLensResolveRequest;\r
-(function (CodeLensResolveRequest) {\r
- CodeLensResolveRequest.type = new vscode_jsonrpc_1.RequestType('codeLens/resolve');\r
-})(CodeLensResolveRequest = exports.CodeLensResolveRequest || (exports.CodeLensResolveRequest = {}));\r
-/**\r
- * A request to to format a whole document.\r
- */\r
-var DocumentFormattingRequest;\r
-(function (DocumentFormattingRequest) {\r
- DocumentFormattingRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/formatting');\r
-})(DocumentFormattingRequest = exports.DocumentFormattingRequest || (exports.DocumentFormattingRequest = {}));\r
-/**\r
- * A request to to format a range in a document.\r
- */\r
-var DocumentRangeFormattingRequest;\r
-(function (DocumentRangeFormattingRequest) {\r
- DocumentRangeFormattingRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/rangeFormatting');\r
-})(DocumentRangeFormattingRequest = exports.DocumentRangeFormattingRequest || (exports.DocumentRangeFormattingRequest = {}));\r
-/**\r
- * A request to format a document on type.\r
- */\r
-var DocumentOnTypeFormattingRequest;\r
-(function (DocumentOnTypeFormattingRequest) {\r
- DocumentOnTypeFormattingRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/onTypeFormatting');\r
-})(DocumentOnTypeFormattingRequest = exports.DocumentOnTypeFormattingRequest || (exports.DocumentOnTypeFormattingRequest = {}));\r
-/**\r
- * A request to rename a symbol.\r
- */\r
-var RenameRequest;\r
-(function (RenameRequest) {\r
- RenameRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/rename');\r
-})(RenameRequest = exports.RenameRequest || (exports.RenameRequest = {}));\r
-/**\r
- * A request to test and perform the setup necessary for a rename.\r
- */\r
-var PrepareRenameRequest;\r
-(function (PrepareRenameRequest) {\r
- PrepareRenameRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/prepareRename');\r
-})(PrepareRenameRequest = exports.PrepareRenameRequest || (exports.PrepareRenameRequest = {}));\r
-/**\r
- * A request to provide document links\r
- */\r
-var DocumentLinkRequest;\r
-(function (DocumentLinkRequest) {\r
- DocumentLinkRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/documentLink');\r
-})(DocumentLinkRequest = exports.DocumentLinkRequest || (exports.DocumentLinkRequest = {}));\r
-/**\r
- * Request to resolve additional information for a given document link. The request's\r
- * parameter is of type [DocumentLink](#DocumentLink) the response\r
- * is of type [DocumentLink](#DocumentLink) or a Thenable that resolves to such.\r
- */\r
-var DocumentLinkResolveRequest;\r
-(function (DocumentLinkResolveRequest) {\r
- DocumentLinkResolveRequest.type = new vscode_jsonrpc_1.RequestType('documentLink/resolve');\r
-})(DocumentLinkResolveRequest = exports.DocumentLinkResolveRequest || (exports.DocumentLinkResolveRequest = {}));\r
-/**\r
- * A request send from the client to the server to execute a command. The request might return\r
- * a workspace edit which the client will apply to the workspace.\r
- */\r
-var ExecuteCommandRequest;\r
-(function (ExecuteCommandRequest) {\r
- ExecuteCommandRequest.type = new vscode_jsonrpc_1.RequestType('workspace/executeCommand');\r
-})(ExecuteCommandRequest = exports.ExecuteCommandRequest || (exports.ExecuteCommandRequest = {}));\r
-/**\r
- * A request sent from the server to the client to modified certain resources.\r
- */\r
-var ApplyWorkspaceEditRequest;\r
-(function (ApplyWorkspaceEditRequest) {\r
- ApplyWorkspaceEditRequest.type = new vscode_jsonrpc_1.RequestType('workspace/applyEdit');\r
-})(ApplyWorkspaceEditRequest = exports.ApplyWorkspaceEditRequest || (exports.ApplyWorkspaceEditRequest = {}));\r
-
-
-/***/ }),
-/* 19 */
-/***/ (function(module, exports, __webpack_require__) {
-
-"use strict";
-/* --------------------------------------------------------------------------------------------\r
- * Copyright (c) Microsoft Corporation. All rights reserved.\r
- * Licensed under the MIT License. See License.txt in the project root for license information.\r
- * ------------------------------------------------------------------------------------------ */\r
-\r
-Object.defineProperty(exports, "__esModule", { value: true });\r
-function boolean(value) {\r
- return value === true || value === false;\r
-}\r
-exports.boolean = boolean;\r
-function string(value) {\r
- return typeof value === 'string' || value instanceof String;\r
-}\r
-exports.string = string;\r
-function number(value) {\r
- return typeof value === 'number' || value instanceof Number;\r
-}\r
-exports.number = number;\r
-function error(value) {\r
- return value instanceof Error;\r
-}\r
-exports.error = error;\r
-function func(value) {\r
- return typeof value === 'function';\r
-}\r
-exports.func = func;\r
-function array(value) {\r
- return Array.isArray(value);\r
-}\r
-exports.array = array;\r
-function stringArray(value) {\r
- return array(value) && value.every(elem => string(elem));\r
-}\r
-exports.stringArray = stringArray;\r
-function typedArray(value, check) {\r
- return Array.isArray(value) && value.every(check);\r
-}\r
-exports.typedArray = typedArray;\r
-function thenable(value) {\r
- return value && func(value.then);\r
-}\r
-exports.thenable = thenable;\r
-
-
-/***/ }),
-/* 20 */
-/***/ (function(module, exports, __webpack_require__) {
-
-"use strict";
-/* --------------------------------------------------------------------------------------------\r
- * Copyright (c) Microsoft Corporation. All rights reserved.\r
- * Licensed under the MIT License. See License.txt in the project root for license information.\r
- * ------------------------------------------------------------------------------------------ */\r
-\r
-Object.defineProperty(exports, "__esModule", { value: true });\r
-const vscode_jsonrpc_1 = __webpack_require__(4);\r
-// @ts-ignore: to avoid inlining LocatioLink as dynamic import\r
-let __noDynamicImport;\r
-/**\r
- * A request to resolve the implementation locations of a symbol at a given text\r
- * document position. The request's parameter is of type [TextDocumentPositioParams]\r
- * (#TextDocumentPositionParams) the response is of type [Definition](#Definition) or a\r
- * Thenable that resolves to such.\r
- */\r
-var ImplementationRequest;\r
-(function (ImplementationRequest) {\r
- ImplementationRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/implementation');\r
-})(ImplementationRequest = exports.ImplementationRequest || (exports.ImplementationRequest = {}));\r
-
-
-/***/ }),
-/* 21 */
-/***/ (function(module, exports, __webpack_require__) {
-
-"use strict";
-/* --------------------------------------------------------------------------------------------\r
- * Copyright (c) Microsoft Corporation. All rights reserved.\r
- * Licensed under the MIT License. See License.txt in the project root for license information.\r
- * ------------------------------------------------------------------------------------------ */\r
-\r
-Object.defineProperty(exports, "__esModule", { value: true });\r
-const vscode_jsonrpc_1 = __webpack_require__(4);\r
-// @ts-ignore: to avoid inlining LocatioLink as dynamic import\r
-let __noDynamicImport;\r
-/**\r
- * A request to resolve the type definition locations of a symbol at a given text\r
- * document position. The request's parameter is of type [TextDocumentPositioParams]\r
- * (#TextDocumentPositionParams) the response is of type [Definition](#Definition) or a\r
- * Thenable that resolves to such.\r
- */\r
-var TypeDefinitionRequest;\r
-(function (TypeDefinitionRequest) {\r
- TypeDefinitionRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/typeDefinition');\r
-})(TypeDefinitionRequest = exports.TypeDefinitionRequest || (exports.TypeDefinitionRequest = {}));\r
-
-
-/***/ }),
-/* 22 */
-/***/ (function(module, exports, __webpack_require__) {
-
-"use strict";
-/* --------------------------------------------------------------------------------------------\r
- * Copyright (c) Microsoft Corporation. All rights reserved.\r
- * Licensed under the MIT License. See License.txt in the project root for license information.\r
- * ------------------------------------------------------------------------------------------ */\r
-\r
-Object.defineProperty(exports, "__esModule", { value: true });\r
-const vscode_jsonrpc_1 = __webpack_require__(4);\r
-/**\r
- * The `workspace/workspaceFolders` is sent from the server to the client to fetch the open workspace folders.\r
- */\r
-var WorkspaceFoldersRequest;\r
-(function (WorkspaceFoldersRequest) {\r
- WorkspaceFoldersRequest.type = new vscode_jsonrpc_1.RequestType0('workspace/workspaceFolders');\r
-})(WorkspaceFoldersRequest = exports.WorkspaceFoldersRequest || (exports.WorkspaceFoldersRequest = {}));\r
-/**\r
- * The `workspace/didChangeWorkspaceFolders` notification is sent from the client to the server when the workspace\r
- * folder configuration changes.\r
- */\r
-var DidChangeWorkspaceFoldersNotification;\r
-(function (DidChangeWorkspaceFoldersNotification) {\r
- DidChangeWorkspaceFoldersNotification.type = new vscode_jsonrpc_1.NotificationType('workspace/didChangeWorkspaceFolders');\r
-})(DidChangeWorkspaceFoldersNotification = exports.DidChangeWorkspaceFoldersNotification || (exports.DidChangeWorkspaceFoldersNotification = {}));\r
-
-
-/***/ }),
-/* 23 */
-/***/ (function(module, exports, __webpack_require__) {
-
-"use strict";
-/* --------------------------------------------------------------------------------------------\r
- * Copyright (c) Microsoft Corporation. All rights reserved.\r
- * Licensed under the MIT License. See License.txt in the project root for license information.\r
- * ------------------------------------------------------------------------------------------ */\r
-\r
-Object.defineProperty(exports, "__esModule", { value: true });\r
-const vscode_jsonrpc_1 = __webpack_require__(4);\r
-/**\r
- * The 'workspace/configuration' request is sent from the server to the client to fetch a certain\r
- * configuration setting.\r
- *\r
- * This pull model replaces the old push model were the client signaled configuration change via an\r
- * event. If the server still needs to react to configuration changes (since the server caches the\r
- * result of `workspace/configuration` requests) the server should register for an empty configuration\r
- * change event and empty the cache if such an event is received.\r
- */\r
-var ConfigurationRequest;\r
-(function (ConfigurationRequest) {\r
- ConfigurationRequest.type = new vscode_jsonrpc_1.RequestType('workspace/configuration');\r
-})(ConfigurationRequest = exports.ConfigurationRequest || (exports.ConfigurationRequest = {}));\r
-
-
-/***/ }),
-/* 24 */
-/***/ (function(module, exports, __webpack_require__) {
-
-"use strict";
-/* --------------------------------------------------------------------------------------------\r
- * Copyright (c) Microsoft Corporation. All rights reserved.\r
- * Licensed under the MIT License. See License.txt in the project root for license information.\r
- * ------------------------------------------------------------------------------------------ */\r
-\r
-Object.defineProperty(exports, "__esModule", { value: true });\r
-const vscode_jsonrpc_1 = __webpack_require__(4);\r
-/**\r
- * A request to list all color symbols found in a given text document. The request's\r
- * parameter is of type [DocumentColorParams](#DocumentColorParams) the\r
- * response is of type [ColorInformation[]](#ColorInformation) or a Thenable\r
- * that resolves to such.\r
- */\r
-var DocumentColorRequest;\r
-(function (DocumentColorRequest) {\r
- DocumentColorRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/documentColor');\r
-})(DocumentColorRequest = exports.DocumentColorRequest || (exports.DocumentColorRequest = {}));\r
-/**\r
- * A request to list all presentation for a color. The request's\r
- * parameter is of type [ColorPresentationParams](#ColorPresentationParams) the\r
- * response is of type [ColorInformation[]](#ColorInformation) or a Thenable\r
- * that resolves to such.\r
- */\r
-var ColorPresentationRequest;\r
-(function (ColorPresentationRequest) {\r
- ColorPresentationRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/colorPresentation');\r
-})(ColorPresentationRequest = exports.ColorPresentationRequest || (exports.ColorPresentationRequest = {}));\r
-
-
-/***/ }),
-/* 25 */
-/***/ (function(module, exports, __webpack_require__) {
-
-"use strict";
-\r
-/*---------------------------------------------------------------------------------------------\r
- * Copyright (c) Microsoft Corporation. All rights reserved.\r
- * Licensed under the MIT License. See License.txt in the project root for license information.\r
- *--------------------------------------------------------------------------------------------*/\r
-Object.defineProperty(exports, "__esModule", { value: true });\r
-const vscode_jsonrpc_1 = __webpack_require__(4);\r
-/**\r
- * Enum of known range kinds\r
- */\r
-var FoldingRangeKind;\r
-(function (FoldingRangeKind) {\r
- /**\r
- * Folding range for a comment\r
- */\r
- FoldingRangeKind["Comment"] = "comment";\r
- /**\r
- * Folding range for a imports or includes\r
- */\r
- FoldingRangeKind["Imports"] = "imports";\r
- /**\r
- * Folding range for a region (e.g. `#region`)\r
- */\r
- FoldingRangeKind["Region"] = "region";\r
-})(FoldingRangeKind = exports.FoldingRangeKind || (exports.FoldingRangeKind = {}));\r
-/**\r
- * A request to provide folding ranges in a document. The request's\r
- * parameter is of type [FoldingRangeParams](#FoldingRangeParams), the\r
- * response is of type [FoldingRangeList](#FoldingRangeList) or a Thenable\r
- * that resolves to such.\r
- */\r
-var FoldingRangeRequest;\r
-(function (FoldingRangeRequest) {\r
- FoldingRangeRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/foldingRange');\r
-})(FoldingRangeRequest = exports.FoldingRangeRequest || (exports.FoldingRangeRequest = {}));\r
-
-
-/***/ }),
-/* 26 */
-/***/ (function(module, exports, __webpack_require__) {
-
-"use strict";
-/* --------------------------------------------------------------------------------------------\r
- * Copyright (c) Microsoft Corporation. All rights reserved.\r
- * Licensed under the MIT License. See License.txt in the project root for license information.\r
- * ------------------------------------------------------------------------------------------ */\r
-\r
-Object.defineProperty(exports, "__esModule", { value: true });\r
-const vscode_jsonrpc_1 = __webpack_require__(4);\r
-// @ts-ignore: to avoid inlining LocatioLink as dynamic import\r
-let __noDynamicImport;\r
-/**\r
- * A request to resolve the type definition locations of a symbol at a given text\r
- * document position. The request's parameter is of type [TextDocumentPositioParams]\r
- * (#TextDocumentPositionParams) the response is of type [Declaration](#Declaration)\r
- * or a typed array of [DeclarationLink](#DeclarationLink) or a Thenable that resolves\r
- * to such.\r
- */\r
-var DeclarationRequest;\r
-(function (DeclarationRequest) {\r
- DeclarationRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/declaration');\r
-})(DeclarationRequest = exports.DeclarationRequest || (exports.DeclarationRequest = {}));\r
-
-
-/***/ }),
-/* 27 */
-/***/ (function(module, exports, __webpack_require__) {
-
-"use strict";
-/* --------------------------------------------------------------------------------------------\r
- * Copyright (c) TypeFox and others. All rights reserved.\r
- * Licensed under the MIT License. See License.txt in the project root for license information.\r
- * ------------------------------------------------------------------------------------------ */\r
-\r
-Object.defineProperty(exports, "__esModule", { value: true });\r
-const vscode_jsonrpc_1 = __webpack_require__(4);\r
-/**\r
- * The direction of a call hierarchy request.\r
- */\r
-var CallHierarchyDirection;\r
-(function (CallHierarchyDirection) {\r
- /**\r
- * The callers\r
- */\r
- CallHierarchyDirection.CallsFrom = 1;\r
- /**\r
- * The callees\r
- */\r
- CallHierarchyDirection.CallsTo = 2;\r
-})(CallHierarchyDirection = exports.CallHierarchyDirection || (exports.CallHierarchyDirection = {}));\r
-/**\r
- * Request to provide the call hierarchy at a given text document position.\r
- *\r
- * The request's parameter is of type [CallHierarchyParams](#CallHierarchyParams). The response\r
- * is of type [CallHierarchyCall[]](#CallHierarchyCall) or a Thenable that resolves to such.\r
- *\r
- * Evaluates the symbol defined (or referenced) at the given position, and returns all incoming or outgoing calls to the symbol(s).\r
- */\r
-var CallHierarchyRequest;\r
-(function (CallHierarchyRequest) {\r
- CallHierarchyRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/callHierarchy');\r
-})(CallHierarchyRequest = exports.CallHierarchyRequest || (exports.CallHierarchyRequest = {}));\r
-
-
-/***/ }),
-/* 28 */
-/***/ (function(module, exports, __webpack_require__) {
-
-"use strict";
-/* --------------------------------------------------------------------------------------------\r
- * Copyright (c) Microsoft Corporation. All rights reserved.\r
- * Licensed under the MIT License. See License.txt in the project root for license information.\r
- * ------------------------------------------------------------------------------------------ */\r
-\r
-Object.defineProperty(exports, "__esModule", { value: true });\r
-const vscode_jsonrpc_1 = __webpack_require__(4);\r
-/**\r
- * The `window/progress/start` notification is sent from the server to the client\r
- * to initiate a progress.\r
- */\r
-var ProgressStartNotification;\r
-(function (ProgressStartNotification) {\r
- ProgressStartNotification.type = new vscode_jsonrpc_1.NotificationType('window/progress/start');\r
-})(ProgressStartNotification = exports.ProgressStartNotification || (exports.ProgressStartNotification = {}));\r
-/**\r
- * The `window/progress/report` notification is sent from the server to the client\r
- * to initiate a progress.\r
- */\r
-var ProgressReportNotification;\r
-(function (ProgressReportNotification) {\r
- ProgressReportNotification.type = new vscode_jsonrpc_1.NotificationType('window/progress/report');\r
-})(ProgressReportNotification = exports.ProgressReportNotification || (exports.ProgressReportNotification = {}));\r
-/**\r
- * The `window/progress/done` notification is sent from the server to the client\r
- * to initiate a progress.\r
- */\r
-var ProgressDoneNotification;\r
-(function (ProgressDoneNotification) {\r
- ProgressDoneNotification.type = new vscode_jsonrpc_1.NotificationType('window/progress/done');\r
-})(ProgressDoneNotification = exports.ProgressDoneNotification || (exports.ProgressDoneNotification = {}));\r
-/**\r
- * The `window/progress/cancel` notification is sent client to the server to cancel a progress\r
- * initiated on the server side.\r
- */\r
-var ProgressCancelNotification;\r
-(function (ProgressCancelNotification) {\r
- ProgressCancelNotification.type = new vscode_jsonrpc_1.NotificationType('window/progress/cancel');\r
-})(ProgressCancelNotification = exports.ProgressCancelNotification || (exports.ProgressCancelNotification = {}));\r
-
-
-/***/ }),
-/* 29 */
-/***/ (function(module, exports, __webpack_require__) {
-
-"use strict";
-\r
-/*---------------------------------------------------------------------------------------------\r
- * Copyright (c) Microsoft Corporation. All rights reserved.\r
- * Licensed under the MIT License. See License.txt in the project root for license information.\r
- *--------------------------------------------------------------------------------------------*/\r
-Object.defineProperty(exports, "__esModule", { value: true });\r
-const vscode_jsonrpc_1 = __webpack_require__(4);\r
-const vscode_languageserver_types_1 = __webpack_require__(17);\r
-/**\r
- * The SelectionRange namespace provides helper function to work with\r
- * SelectionRange literals.\r
- */\r
-var SelectionRange;\r
-(function (SelectionRange) {\r
- /**\r
- * Creates a new SelectionRange\r
- * @param range the range.\r
- * @param parent an optional parent.\r
- */\r
- function create(range, parent) {\r
- return { range, parent };\r
- }\r
- SelectionRange.create = create;\r
- function is(value) {\r
- let candidate = value;\r
- return candidate !== undefined && vscode_languageserver_types_1.Range.is(candidate.range) && (candidate.parent === undefined || SelectionRange.is(candidate.parent));\r
- }\r
- SelectionRange.is = is;\r
-})(SelectionRange = exports.SelectionRange || (exports.SelectionRange = {}));\r
-/**\r
- * A request to provide selection ranges in a document. The request's\r
- * parameter is of type [SelectionRangeParams](#SelectionRangeParams), the\r
- * response is of type [SelectionRange[]](#SelectionRange[]) or a Thenable\r
- * that resolves to such.\r
- */\r
-var SelectionRangeRequest;\r
-(function (SelectionRangeRequest) {\r
- SelectionRangeRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/selectionRange');\r
-})(SelectionRangeRequest = exports.SelectionRangeRequest || (exports.SelectionRangeRequest = {}));\r
-
-
-/***/ }),
-/* 30 */,
-/* 31 */,
-/* 32 */,
-/* 33 */
-/***/ (function(module, exports, __webpack_require__) {
-
-"use strict";
-
-/*---------------------------------------------------------------------------------------------
- * Copyright (c) Microsoft Corporation. All rights reserved.
- * Licensed under the MIT License. See License.txt in the project root for license information.
- *--------------------------------------------------------------------------------------------*/
-var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
- return new (P || (P = Promise))(function (resolve, reject) {
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
- function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
- step((generator = generator.apply(thisArg, _arguments || [])).next());
- });
-};
-var __importStar = (this && this.__importStar) || function (mod) {
- if (mod && mod.__esModule) return mod;
- var result = {};
- if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
- result["default"] = mod;
- return result;
-};
-Object.defineProperty(exports, "__esModule", { value: true });
-const vscode_languageserver_1 = __webpack_require__(34);
-const request_light_1 = __webpack_require__(49);
-const fs = __importStar(__webpack_require__(2));
-const vscode_uri_1 = __webpack_require__(77);
-const URL = __importStar(__webpack_require__(40));
-const runner_1 = __webpack_require__(78);
-const vscode_json_languageservice_1 = __webpack_require__(79);
-const languageModelCache_1 = __webpack_require__(101);
-var SchemaAssociationNotification;
-(function (SchemaAssociationNotification) {
- SchemaAssociationNotification.type = new vscode_languageserver_1.NotificationType('json/schemaAssociations');
-})(SchemaAssociationNotification || (SchemaAssociationNotification = {}));
-var VSCodeContentRequest;
-(function (VSCodeContentRequest) {
- VSCodeContentRequest.type = new vscode_languageserver_1.RequestType('vscode/content');
-})(VSCodeContentRequest || (VSCodeContentRequest = {}));
-var SchemaContentChangeNotification;
-(function (SchemaContentChangeNotification) {
- SchemaContentChangeNotification.type = new vscode_languageserver_1.NotificationType('json/schemaContent');
-})(SchemaContentChangeNotification || (SchemaContentChangeNotification = {}));
-var ForceValidateRequest;
-(function (ForceValidateRequest) {
- ForceValidateRequest.type = new vscode_languageserver_1.RequestType('json/validate');
-})(ForceValidateRequest || (ForceValidateRequest = {}));
-// Create a connection for the server
-const connection = vscode_languageserver_1.createConnection();
-process.on('unhandledRejection', (e) => {
- console.error(runner_1.formatError(`Unhandled exception`, e));
-});
-process.on('uncaughtException', (e) => {
- console.error(runner_1.formatError(`Unhandled exception`, e));
-});
-console.log = connection.console.log.bind(connection.console);
-console.error = connection.console.error.bind(connection.console);
-const workspaceContext = {
- resolveRelativePath: (relativePath, resource) => {
- return URL.resolve(resource, relativePath);
- }
-};
-function getSchemaRequestService(handledSchemas) {
- return (uri) => {
- const protocol = uri.substr(0, uri.indexOf(':'));
- if (!handledSchemas || handledSchemas[protocol]) {
- if (protocol === 'file') {
- const fsPath = vscode_uri_1.URI.parse(uri).fsPath;
- return new Promise((c, e) => {
- fs.readFile(fsPath, 'UTF-8', (err, result) => {
- err ? e(err.message || err.toString()) : c(result.toString());
- });
- });
- }
- else if (protocol === 'http' || protocol === 'https') {
- if (uri.indexOf('//schema.management.azure.com/') !== -1) {
- /* __GDPR__
- "json.schema" : {
- "schemaURL" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" }
- }
- */
- connection.telemetry.logEvent({
- key: 'json.schema',
- value: {
- schemaURL: uri
- }
- });
- }
- const headers = { 'Accept-Encoding': 'gzip, deflate' };
- return request_light_1.xhr({ url: uri, followRedirects: 5, headers }).then(response => {
- return response.responseText;
- }, (error) => {
- return Promise.reject(error.responseText || request_light_1.getErrorStatusDescription(error.status) || error.toString());
- });
- }
- }
- return connection.sendRequest(VSCodeContentRequest.type, uri).then(responseText => {
- return responseText;
- }, error => {
- return Promise.reject(error.message);
- });
- };
-}
-// create the JSON language service
-let languageService = vscode_json_languageservice_1.getLanguageService({
- workspaceContext,
- contributions: [],
-});
-// Create a simple text document manager. The text document manager
-// supports full document sync only
-const documents = new vscode_languageserver_1.TextDocuments();
-// Make the text document manager listen on the connection
-// for open, change and close text document events
-documents.listen(connection);
-let clientSnippetSupport = false;
-let clientDynamicRegisterSupport = false;
-let foldingRangeLimit = Number.MAX_VALUE;
-let hierarchicalDocumentSymbolSupport = false;
-// After the server has started the client sends an initialize request. The server receives
-// in the passed params the rootPath of the workspace plus the client capabilities.
-connection.onInitialize((params) => {
- const handledProtocols = params.initializationOptions && params.initializationOptions['handledSchemaProtocols'];
- languageService = vscode_json_languageservice_1.getLanguageService({
- schemaRequestService: getSchemaRequestService(handledProtocols),
- workspaceContext,
- contributions: [],
- clientCapabilities: params.capabilities
- });
- function getClientCapability(name, def) {
- const keys = name.split('.');
- let c = params.capabilities;
- for (let i = 0; c && i < keys.length; i++) {
- if (!c.hasOwnProperty(keys[i])) {
- return def;
- }
- c = c[keys[i]];
- }
- return c;
- }
- clientSnippetSupport = getClientCapability('textDocument.completion.completionItem.snippetSupport', false);
- clientDynamicRegisterSupport = getClientCapability('workspace.symbol.dynamicRegistration', false);
- foldingRangeLimit = getClientCapability('textDocument.foldingRange.rangeLimit', Number.MAX_VALUE);
- hierarchicalDocumentSymbolSupport = getClientCapability('textDocument.documentSymbol.hierarchicalDocumentSymbolSupport', false);
- const capabilities = {
- // Tell the client that the server works in FULL text document sync mode
- textDocumentSync: documents.syncKind,
- completionProvider: clientSnippetSupport ? { resolveProvider: true, triggerCharacters: ['"', ':'] } : undefined,
- hoverProvider: true,
- documentSymbolProvider: true,
- documentRangeFormattingProvider: false,
- colorProvider: {},
- foldingRangeProvider: true
- };
- return { capabilities };
-});
-let jsonConfigurationSettings = undefined;
-let schemaAssociations = undefined;
-let formatterRegistration = null;
-// The settings have changed. Is send on server activation as well.
-connection.onDidChangeConfiguration((change) => {
- let settings = change.settings;
- request_light_1.configure(settings.http && settings.http.proxy, settings.http && settings.http.proxyStrictSSL);
- jsonConfigurationSettings = settings.json && settings.json.schemas;
- updateConfiguration();
- // dynamically enable & disable the formatter
- if (clientDynamicRegisterSupport) {
- const enableFormatter = settings && settings.json && settings.json.format && settings.json.format.enable;
- if (enableFormatter) {
- if (!formatterRegistration) {
- formatterRegistration = connection.client.register(vscode_languageserver_1.DocumentRangeFormattingRequest.type, { documentSelector: [{ language: 'json' }, { language: 'jsonc' }] });
- }
- }
- else if (formatterRegistration) {
- formatterRegistration.then(r => r.dispose());
- formatterRegistration = null;
- }
- }
-});
-// The jsonValidation extension configuration has changed
-connection.onNotification(SchemaAssociationNotification.type, associations => {
- schemaAssociations = associations;
- updateConfiguration();
-});
-// A schema has changed
-connection.onNotification(SchemaContentChangeNotification.type, uri => {
- languageService.resetSchema(uri);
-});
-// Retry schema validation on all open documents
-connection.onRequest(ForceValidateRequest.type, uri => {
- return new Promise(resolve => {
- const document = documents.get(uri);
- if (document) {
- updateConfiguration();
- validateTextDocument(document, diagnostics => {
- resolve(diagnostics);
- });
- }
- else {
- resolve([]);
- }
- });
-});
-function updateConfiguration() {
- const languageSettings = {
- validate: true,
- allowComments: true,
- schemas: new Array()
- };
- if (schemaAssociations) {
- for (const pattern in schemaAssociations) {
- const association = schemaAssociations[pattern];
- if (Array.isArray(association)) {
- association.forEach(uri => {
- languageSettings.schemas.push({ uri, fileMatch: [pattern] });
- });
- }
- }
- }
- if (jsonConfigurationSettings) {
- jsonConfigurationSettings.forEach((schema, index) => {
- let uri = schema.url;
- if (!uri && schema.schema) {
- uri = schema.schema.id || `vscode://schemas/custom/${index}`;
- }
- if (uri) {
- languageSettings.schemas.push({ uri, fileMatch: schema.fileMatch, schema: schema.schema });
- }
- });
- }
- languageService.configure(languageSettings);
- // Revalidate any open text documents
- documents.all().forEach(triggerValidation);
-}
-// The content of a text document has changed. This event is emitted
-// when the text document first opened or when its content has changed.
-documents.onDidChangeContent((change) => {
- triggerValidation(change.document);
-});
-// a document has closed: clear all diagnostics
-documents.onDidClose(event => {
- cleanPendingValidation(event.document);
- connection.sendDiagnostics({ uri: event.document.uri, diagnostics: [] });
-});
-const pendingValidationRequests = {};
-const validationDelayMs = 500;
-function cleanPendingValidation(textDocument) {
- const request = pendingValidationRequests[textDocument.uri];
- if (request) {
- clearTimeout(request);
- delete pendingValidationRequests[textDocument.uri];
- }
-}
-function triggerValidation(textDocument) {
- cleanPendingValidation(textDocument);
- pendingValidationRequests[textDocument.uri] = setTimeout(() => {
- delete pendingValidationRequests[textDocument.uri];
- validateTextDocument(textDocument);
- }, validationDelayMs);
-}
-function validateTextDocument(textDocument, callback) {
- const respond = (diagnostics) => {
- connection.sendDiagnostics({ uri: textDocument.uri, diagnostics });
- if (callback) {
- callback(diagnostics);
- }
- };
- if (textDocument.getText().length === 0) {
- respond([]); // ignore empty documents
- return;
- }
- const jsonDocument = getJSONDocument(textDocument);
- const version = textDocument.version;
- const documentSettings = textDocument.languageId === 'jsonc' ? { comments: 'ignore', trailingCommas: 'ignore' } : { comments: 'error', trailingCommas: 'error' };
- languageService.doValidation(textDocument, jsonDocument, documentSettings).then(diagnostics => {
- setTimeout(() => {
- const currDocument = documents.get(textDocument.uri);
- if (currDocument && currDocument.version === version) {
- respond(diagnostics); // Send the computed diagnostics to VSCode.
- }
- }, 100);
- }, error => {
- connection.console.error(runner_1.formatError(`Error while validating ${textDocument.uri}`, error));
- });
-}
-connection.onDidChangeWatchedFiles((change) => {
- // Monitored files have changed in VSCode
- let hasChanges = false;
- change.changes.forEach(c => {
- if (languageService.resetSchema(c.uri)) {
- hasChanges = true;
- }
- });
- if (hasChanges) {
- documents.all().forEach(triggerValidation);
- }
-});
-const jsonDocuments = languageModelCache_1.getLanguageModelCache(10, 60, document => languageService.parseJSONDocument(document));
-documents.onDidClose(e => {
- jsonDocuments.onDocumentRemoved(e.document);
-});
-connection.onShutdown(() => {
- jsonDocuments.dispose();
-});
-function getJSONDocument(document) {
- return jsonDocuments.get(document);
-}
-connection.onCompletion((textDocumentPosition, token) => {
- return runner_1.runSafeAsync(() => __awaiter(this, void 0, void 0, function* () {
- const document = documents.get(textDocumentPosition.textDocument.uri);
- if (document) {
- const jsonDocument = getJSONDocument(document);
- return languageService.doComplete(document, textDocumentPosition.position, jsonDocument);
- }
- return null;
- }), null, `Error while computing completions for ${textDocumentPosition.textDocument.uri}`, token);
-});
-connection.onCompletionResolve((completionItem, token) => {
- return runner_1.runSafeAsync(() => {
- return languageService.doResolve(completionItem);
- }, completionItem, `Error while resolving completion proposal`, token);
-});
-connection.onHover((textDocumentPositionParams, token) => {
- return runner_1.runSafeAsync(() => __awaiter(this, void 0, void 0, function* () {
- const document = documents.get(textDocumentPositionParams.textDocument.uri);
- if (document) {
- const jsonDocument = getJSONDocument(document);
- return languageService.doHover(document, textDocumentPositionParams.position, jsonDocument);
- }
- return null;
- }), null, `Error while computing hover for ${textDocumentPositionParams.textDocument.uri}`, token);
-});
-connection.onDocumentSymbol((documentSymbolParams, token) => {
- return runner_1.runSafe(() => {
- const document = documents.get(documentSymbolParams.textDocument.uri);
- if (document) {
- const jsonDocument = getJSONDocument(document);
- if (hierarchicalDocumentSymbolSupport) {
- return languageService.findDocumentSymbols2(document, jsonDocument);
- }
- else {
- return languageService.findDocumentSymbols(document, jsonDocument);
- }
- }
- return [];
- }, [], `Error while computing document symbols for ${documentSymbolParams.textDocument.uri}`, token);
-});
-connection.onDocumentRangeFormatting((formatParams, token) => {
- return runner_1.runSafe(() => {
- const document = documents.get(formatParams.textDocument.uri);
- if (document) {
- return languageService.format(document, formatParams.range, formatParams.options);
- }
- return [];
- }, [], `Error while formatting range for ${formatParams.textDocument.uri}`, token);
-});
-connection.onDocumentColor((params, token) => {
- return runner_1.runSafeAsync(() => __awaiter(this, void 0, void 0, function* () {
- const document = documents.get(params.textDocument.uri);
- if (document) {
- const jsonDocument = getJSONDocument(document);
- return languageService.findDocumentColors(document, jsonDocument);
- }
- return [];
- }), [], `Error while computing document colors for ${params.textDocument.uri}`, token);
-});
-connection.onColorPresentation((params, token) => {
- return runner_1.runSafe(() => {
- const document = documents.get(params.textDocument.uri);
- if (document) {
- const jsonDocument = getJSONDocument(document);
- return languageService.getColorPresentations(document, jsonDocument, params.color, params.range);
- }
- return [];
- }, [], `Error while computing color presentations for ${params.textDocument.uri}`, token);
-});
-connection.onFoldingRanges((params, token) => {
- return runner_1.runSafe(() => {
- const document = documents.get(params.textDocument.uri);
- if (document) {
- return languageService.getFoldingRanges(document, { rangeLimit: foldingRangeLimit });
- }
- return null;
- }, null, `Error while computing folding ranges for ${params.textDocument.uri}`, token);
-});
-connection.onRequest('$/textDocument/selectionRanges', (params, token) => __awaiter(this, void 0, void 0, function* () {
- return runner_1.runSafe(() => {
- const document = documents.get(params.textDocument.uri);
- if (document) {
- const jsonDocument = getJSONDocument(document);
- return languageService.getSelectionRanges(document, params.positions, jsonDocument);
- }
- return [];
- }, [], `Error while computing selection ranges for ${params.textDocument.uri}`, token);
-}));
-// Listen on the connection
-connection.listen();
-
-
-/***/ }),
-/* 34 */
-/***/ (function(module, exports, __webpack_require__) {
-
-"use strict";
-/* --------------------------------------------------------------------------------------------\r
- * Copyright (c) Microsoft Corporation. All rights reserved.\r
- * Licensed under the MIT License. See License.txt in the project root for license information.\r
- * ------------------------------------------------------------------------------------------ */\r
-/// <reference path="./thenable.ts" />\r
-\r
-function __export(m) {\r
- for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];\r
-}\r
-Object.defineProperty(exports, "__esModule", { value: true });\r
-const vscode_languageserver_protocol_1 = __webpack_require__(3);\r
-exports.Event = vscode_languageserver_protocol_1.Event;\r
-const configuration_1 = __webpack_require__(35);\r
-const workspaceFolders_1 = __webpack_require__(37);\r
-const Is = __webpack_require__(36);\r
-const UUID = __webpack_require__(38);\r
-// ------------- Reexport the API surface of the language worker API ----------------------\r
-__export(__webpack_require__(3));\r
-const fm = __webpack_require__(39);\r
-const vscode_textbuffer_1 = __webpack_require__(42);\r
-const range_1 = __webpack_require__(47);\r
-var Files;\r
-(function (Files) {\r
- Files.uriToFilePath = fm.uriToFilePath;\r
- Files.resolveGlobalNodePath = fm.resolveGlobalNodePath;\r
- Files.resolveGlobalYarnPath = fm.resolveGlobalYarnPath;\r
- Files.resolve = fm.resolve;\r
- Files.resolveModulePath = fm.resolveModulePath;\r
-})(Files = exports.Files || (exports.Files = {}));\r
-let shutdownReceived = false;\r
-let exitTimer = undefined;\r
-function setupExitTimer() {\r
- const argName = '--clientProcessId';\r
- function runTimer(value) {\r
- try {\r
- let processId = parseInt(value);\r
- if (!isNaN(processId)) {\r
- exitTimer = setInterval(() => {\r
- try {\r
- process.kill(processId, 0);\r
- }\r
- catch (ex) {\r
- // Parent process doesn't exist anymore. Exit the server.\r
- process.exit(shutdownReceived ? 0 : 1);\r
- }\r
- }, 3000);\r
- }\r
- }\r
- catch (e) {\r
- // Ignore errors;\r
- }\r
- }\r
- for (let i = 2; i < process.argv.length; i++) {\r
- let arg = process.argv[i];\r
- if (arg === argName && i + 1 < process.argv.length) {\r
- runTimer(process.argv[i + 1]);\r
- return;\r
- }\r
- else {\r
- let args = arg.split('=');\r
- if (args[0] === argName) {\r
- runTimer(args[1]);\r
- }\r
- }\r
- }\r
-}\r
-setupExitTimer();\r
-function null2Undefined(value) {\r
- if (value === null) {\r
- return void 0;\r
- }\r
- return value;\r
-}\r
-/**\r
- * Incrementally-synchronized Text Document implementation that leverages a\r
- * "Piece Tree" as text buffer. See the following for details:\r
- * - https://github.com/microsoft/vscode-textbuffer\r
- * - https://code.visualstudio.com/blogs/2018/03/23/text-buffer-reimplementation\r
- *\r
- * This text document implementation only supports "Incremental" text document\r
- * sync. If you wish to use "Full" text document sync, use FullTextDocument, as it\r
- * uses a simple JS string as an underlying text buffer, since the full text gets\r
- * swapped out on every update.\r
- */\r
-class IncrementalTextDocument {\r
- constructor(uri, languageId, version, content) {\r
- this._uri = uri;\r
- this._languageId = languageId;\r
- this._version = version;\r
- // Prepare Piece Tree\r
- const ptBuilder = new vscode_textbuffer_1.PieceTreeTextBufferBuilder();\r
- ptBuilder.acceptChunk(content);\r
- const ptFactory = ptBuilder.finish(true);\r
- this._tree = ptFactory.create(1 /* LF */);\r
- }\r
- get uri() {\r
- return this._uri;\r
- }\r
- get languageId() {\r
- return this._languageId;\r
- }\r
- get version() {\r
- return this._version;\r
- }\r
- getText(range) {\r
- if (range) {\r
- const { start, end } = range;\r
- // Clamp last line and last character appropriately when\r
- // given range is beyond the document's end\r
- const [clampedEndLine, clampedEndChar] = end.line + 1 > this.lineCount\r
- ? [this.lineCount, this._tree.getLineLength(this.lineCount) + 1]\r
- : [end.line + 1, end.character + 1];\r
- const ptRange = new range_1.Range(start.line + 1, start.character + 1, clampedEndLine, clampedEndChar);\r
- return this._tree.getValueInRange(ptRange);\r
- }\r
- return this._tree.getLinesRawContent();\r
- }\r
- update(event, version) {\r
- const { text, range } = event;\r
- if (range == null) {\r
- throw new Error(`FullPieceTreeTextDocument#update called with invalid event range ${range}`);\r
- }\r
- const startOffset = this.offsetAt(range.start);\r
- const endOffset = this.offsetAt(range.end);\r
- // Delete previous text at range and insert new text at appropriate offset\r
- this._tree.delete(startOffset, endOffset - startOffset);\r
- this._tree.insert(startOffset, text);\r
- this._version = version;\r
- }\r
- positionAt(offset) {\r
- const clampedOffset = Math.min(offset, this._tree.getLength());\r
- const ptPosition = this._tree.getPositionAt(clampedOffset);\r
- return vscode_languageserver_protocol_1.Position.create(ptPosition.lineNumber - 1, ptPosition.column - 1);\r
- }\r
- offsetAt(position) {\r
- if (position.line < 0) {\r
- return 0;\r
- }\r
- const clampedChar = Math.max(1, position.character + 1);\r
- return Math.min(this._tree.getOffsetAt(position.line + 1, clampedChar), this._tree.getLength());\r
- }\r
- get lineCount() {\r
- return this._tree.getLineCount();\r
- }\r
-}\r
-/**\r
- * A manager for simple text documents\r
- */\r
-class TextDocuments {\r
- /**\r
- * Create a new text document manager.\r
- */\r
- constructor(syncKind = vscode_languageserver_protocol_1.TextDocumentSyncKind.Full) {\r
- this._documents = Object.create(null);\r
- this._syncKind = syncKind;\r
- this._onDidChangeContent = new vscode_languageserver_protocol_1.Emitter();\r
- this._onDidOpen = new vscode_languageserver_protocol_1.Emitter();\r
- this._onDidClose = new vscode_languageserver_protocol_1.Emitter();\r
- this._onDidSave = new vscode_languageserver_protocol_1.Emitter();\r
- this._onWillSave = new vscode_languageserver_protocol_1.Emitter();\r
- }\r
- /**\r
- * Returns the [TextDocumentSyncKind](#TextDocumentSyncKind) used by\r
- * this text document manager.\r
- */\r
- get syncKind() {\r
- return this._syncKind;\r
- }\r
- /**\r
- * An event that fires when a text document managed by this manager\r
- * has been opened or the content changes.\r
- */\r
- get onDidChangeContent() {\r
- return this._onDidChangeContent.event;\r
- }\r
- /**\r
- * An event that fires when a text document managed by this manager\r
- * has been opened.\r
- */\r
- get onDidOpen() {\r
- return this._onDidOpen.event;\r
- }\r
- /**\r
- * An event that fires when a text document managed by this manager\r
- * will be saved.\r
- */\r
- get onWillSave() {\r
- return this._onWillSave.event;\r
- }\r
- /**\r
- * Sets a handler that will be called if a participant wants to provide\r
- * edits during a text document save.\r
- */\r
- onWillSaveWaitUntil(handler) {\r
- this._willSaveWaitUntil = handler;\r
- }\r
- /**\r
- * An event that fires when a text document managed by this manager\r
- * has been saved.\r
- */\r
- get onDidSave() {\r
- return this._onDidSave.event;\r
- }\r
- /**\r
- * An event that fires when a text document managed by this manager\r
- * has been closed.\r
- */\r
- get onDidClose() {\r
- return this._onDidClose.event;\r
- }\r
- /**\r
- * Returns the document for the given URI. Returns undefined if\r
- * the document is not mananged by this instance.\r
- *\r
- * @param uri The text document's URI to retrieve.\r
- * @return the text document or `undefined`.\r
- */\r
- get(uri) {\r
- return this._documents[uri];\r
- }\r
- /**\r
- * Returns all text documents managed by this instance.\r
- *\r
- * @return all text documents.\r
- */\r
- all() {\r
- return Object.keys(this._documents).map(key => this._documents[key]);\r
- }\r
- /**\r
- * Returns the URIs of all text documents managed by this instance.\r
- *\r
- * @return the URI's of all text documents.\r
- */\r
- keys() {\r
- return Object.keys(this._documents);\r
- }\r
- /**\r
- * Listens for `low level` notification on the given connection to\r
- * update the text documents managed by this instance.\r
- *\r
- * @param connection The connection to listen on.\r
- */\r
- listen(connection) {\r
- function isUpdateableDocument(value) {\r
- return Is.func(value.update);\r
- }\r
- connection.__textDocumentSync = vscode_languageserver_protocol_1.TextDocumentSyncKind.Full;\r
- connection.onDidOpenTextDocument((event) => {\r
- let td = event.textDocument;\r
- let document;\r
- switch (this.syncKind) {\r
- case vscode_languageserver_protocol_1.TextDocumentSyncKind.Full:\r
- document = vscode_languageserver_protocol_1.TextDocument.create(td.uri, td.languageId, td.version, td.text);\r
- break;\r
- case vscode_languageserver_protocol_1.TextDocumentSyncKind.Incremental:\r
- document = new IncrementalTextDocument(td.uri, td.languageId, td.version, td.text);\r
- break;\r
- default:\r
- throw new Error(`Invalid TextDocumentSyncKind: ${this.syncKind}`);\r
- }\r
- this._documents[td.uri] = document;\r
- let toFire = Object.freeze({ document });\r
- this._onDidOpen.fire(toFire);\r
- this._onDidChangeContent.fire(toFire);\r
- });\r
- connection.onDidChangeTextDocument((event) => {\r
- let td = event.textDocument;\r
- let changes = event.contentChanges;\r
- if (changes.length === 0) {\r
- return;\r
- }\r
- let document = this._documents[td.uri];\r
- if (!document || !isUpdateableDocument(document)) {\r
- return;\r
- }\r
- const { version } = td;\r
- if (version == null || version === void 0) {\r
- throw new Error(`Received document change event for ${td.uri} without valid version identifier`);\r
- }\r
- switch (this.syncKind) {\r
- case vscode_languageserver_protocol_1.TextDocumentSyncKind.Full:\r
- let last = changes[changes.length - 1];\r
- document.update(last, version);\r
- this._onDidChangeContent.fire(Object.freeze({ document }));\r
- break;\r
- case vscode_languageserver_protocol_1.TextDocumentSyncKind.Incremental:\r
- let updatedDoc = changes.reduce((workingTextDoc, change) => {\r
- workingTextDoc.update(change, version);\r
- return workingTextDoc;\r
- }, document);\r
- this._onDidChangeContent.fire(Object.freeze({ document: updatedDoc }));\r
- break;\r
- case vscode_languageserver_protocol_1.TextDocumentSyncKind.None:\r
- break;\r
- }\r
- });\r
- connection.onDidCloseTextDocument((event) => {\r
- let document = this._documents[event.textDocument.uri];\r
- if (document) {\r
- delete this._documents[event.textDocument.uri];\r
- this._onDidClose.fire(Object.freeze({ document }));\r
- }\r
- });\r
- connection.onWillSaveTextDocument((event) => {\r
- let document = this._documents[event.textDocument.uri];\r
- if (document) {\r
- this._onWillSave.fire(Object.freeze({ document, reason: event.reason }));\r
- }\r
- });\r
- connection.onWillSaveTextDocumentWaitUntil((event, token) => {\r
- let document = this._documents[event.textDocument.uri];\r
- if (document && this._willSaveWaitUntil) {\r
- return this._willSaveWaitUntil(Object.freeze({ document, reason: event.reason }), token);\r
- }\r
- else {\r
- return [];\r
- }\r
- });\r
- connection.onDidSaveTextDocument((event) => {\r
- let document = this._documents[event.textDocument.uri];\r
- if (document) {\r
- this._onDidSave.fire(Object.freeze({ document }));\r
- }\r
- });\r
- }\r
-}\r
-exports.TextDocuments = TextDocuments;\r
-/**\r
- * Helps tracking error message. Equal occurences of the same\r
- * message are only stored once. This class is for example\r
- * useful if text documents are validated in a loop and equal\r
- * error message should be folded into one.\r
- */\r
-class ErrorMessageTracker {\r
- constructor() {\r
- this._messages = Object.create(null);\r
- }\r
- /**\r
- * Add a message to the tracker.\r
- *\r
- * @param message The message to add.\r
- */\r
- add(message) {\r
- let count = this._messages[message];\r
- if (!count) {\r
- count = 0;\r
- }\r
- count++;\r
- this._messages[message] = count;\r
- }\r
- /**\r
- * Send all tracked messages to the connection's window.\r
- *\r
- * @param connection The connection established between client and server.\r
- */\r
- sendErrors(connection) {\r
- Object.keys(this._messages).forEach(message => {\r
- connection.window.showErrorMessage(message);\r
- });\r
- }\r
-}\r
-exports.ErrorMessageTracker = ErrorMessageTracker;\r
-var BulkRegistration;\r
-(function (BulkRegistration) {\r
- /**\r
- * Creates a new bulk registration.\r
- * @return an empty bulk registration.\r
- */\r
- function create() {\r
- return new BulkRegistrationImpl();\r
- }\r
- BulkRegistration.create = create;\r
-})(BulkRegistration = exports.BulkRegistration || (exports.BulkRegistration = {}));\r
-class BulkRegistrationImpl {\r
- constructor() {\r
- this._registrations = [];\r
- this._registered = new Set();\r
- }\r
- add(type, registerOptions) {\r
- const method = Is.string(type) ? type : type.method;\r
- if (this._registered.has(method)) {\r
- throw new Error(`${method} is already added to this registration`);\r
- }\r
- const id = UUID.generateUuid();\r
- this._registrations.push({\r
- id: id,\r
- method: method,\r
- registerOptions: registerOptions || {}\r
- });\r
- this._registered.add(method);\r
- }\r
- asRegistrationParams() {\r
- return {\r
- registrations: this._registrations\r
- };\r
- }\r
-}\r
-var BulkUnregistration;\r
-(function (BulkUnregistration) {\r
- function create() {\r
- return new BulkUnregistrationImpl(undefined, []);\r
- }\r
- BulkUnregistration.create = create;\r
-})(BulkUnregistration = exports.BulkUnregistration || (exports.BulkUnregistration = {}));\r
-class BulkUnregistrationImpl {\r
- constructor(_connection, unregistrations) {\r
- this._connection = _connection;\r
- this._unregistrations = new Map();\r
- unregistrations.forEach(unregistration => {\r
- this._unregistrations.set(unregistration.method, unregistration);\r
- });\r
- }\r
- get isAttached() {\r
- return !!this._connection;\r
- }\r
- attach(connection) {\r
- this._connection = connection;\r
- }\r
- add(unregistration) {\r
- this._unregistrations.set(unregistration.method, unregistration);\r
- }\r
- dispose() {\r
- let unregistrations = [];\r
- for (let unregistration of this._unregistrations.values()) {\r
- unregistrations.push(unregistration);\r
- }\r
- let params = {\r
- unregisterations: unregistrations\r
- };\r
- this._connection.sendRequest(vscode_languageserver_protocol_1.UnregistrationRequest.type, params).then(undefined, (_error) => {\r
- this._connection.console.info(`Bulk unregistration failed.`);\r
- });\r
- }\r
- disposeSingle(arg) {\r
- const method = Is.string(arg) ? arg : arg.method;\r
- const unregistration = this._unregistrations.get(method);\r
- if (!unregistration) {\r
- return false;\r
- }\r
- let params = {\r
- unregisterations: [unregistration]\r
- };\r
- this._connection.sendRequest(vscode_languageserver_protocol_1.UnregistrationRequest.type, params).then(() => {\r
- this._unregistrations.delete(method);\r
- }, (_error) => {\r
- this._connection.console.info(`Unregistering request handler for ${unregistration.id} failed.`);\r
- });\r
- return true;\r
- }\r
-}\r
-class ConnectionLogger {\r
- constructor() {\r
- }\r
- rawAttach(connection) {\r
- this._rawConnection = connection;\r
- }\r
- attach(connection) {\r
- this._connection = connection;\r
- }\r
- get connection() {\r
- if (!this._connection) {\r
- throw new Error('Remote is not attached to a connection yet.');\r
- }\r
- return this._connection;\r
- }\r
- fillServerCapabilities(_capabilities) {\r
- }\r
- initialize(_capabilities) {\r
- }\r
- error(message) {\r
- this.send(vscode_languageserver_protocol_1.MessageType.Error, message);\r
- }\r
- warn(message) {\r
- this.send(vscode_languageserver_protocol_1.MessageType.Warning, message);\r
- }\r
- info(message) {\r
- this.send(vscode_languageserver_protocol_1.MessageType.Info, message);\r
- }\r
- log(message) {\r
- this.send(vscode_languageserver_protocol_1.MessageType.Log, message);\r
- }\r
- send(type, message) {\r
- if (this._rawConnection) {\r
- this._rawConnection.sendNotification(vscode_languageserver_protocol_1.LogMessageNotification.type, { type, message });\r
- }\r
- }\r
-}\r
-class RemoteWindowImpl {\r
- constructor() {\r
- }\r
- attach(connection) {\r
- this._connection = connection;\r
- }\r
- get connection() {\r
- if (!this._connection) {\r
- throw new Error('Remote is not attached to a connection yet.');\r
- }\r
- return this._connection;\r
- }\r
- initialize(_capabilities) {\r
- }\r
- fillServerCapabilities(_capabilities) {\r
- }\r
- showErrorMessage(message, ...actions) {\r
- let params = { type: vscode_languageserver_protocol_1.MessageType.Error, message, actions };\r
- return this._connection.sendRequest(vscode_languageserver_protocol_1.ShowMessageRequest.type, params).then(null2Undefined);\r
- }\r
- showWarningMessage(message, ...actions) {\r
- let params = { type: vscode_languageserver_protocol_1.MessageType.Warning, message, actions };\r
- return this._connection.sendRequest(vscode_languageserver_protocol_1.ShowMessageRequest.type, params).then(null2Undefined);\r
- }\r
- showInformationMessage(message, ...actions) {\r
- let params = { type: vscode_languageserver_protocol_1.MessageType.Info, message, actions };\r
- return this._connection.sendRequest(vscode_languageserver_protocol_1.ShowMessageRequest.type, params).then(null2Undefined);\r
- }\r
-}\r
-class RemoteClientImpl {\r
- attach(connection) {\r
- this._connection = connection;\r
- }\r
- get connection() {\r
- if (!this._connection) {\r
- throw new Error('Remote is not attached to a connection yet.');\r
- }\r
- return this._connection;\r
- }\r
- initialize(_capabilities) {\r
- }\r
- fillServerCapabilities(_capabilities) {\r
- }\r
- register(typeOrRegistrations, registerOptionsOrType, registerOptions) {\r
- if (typeOrRegistrations instanceof BulkRegistrationImpl) {\r
- return this.registerMany(typeOrRegistrations);\r
- }\r
- else if (typeOrRegistrations instanceof BulkUnregistrationImpl) {\r
- return this.registerSingle1(typeOrRegistrations, registerOptionsOrType, registerOptions);\r
- }\r
- else {\r
- return this.registerSingle2(typeOrRegistrations, registerOptionsOrType);\r
- }\r
- }\r
- registerSingle1(unregistration, type, registerOptions) {\r
- const method = Is.string(type) ? type : type.method;\r
- const id = UUID.generateUuid();\r
- let params = {\r
- registrations: [{ id, method, registerOptions: registerOptions || {} }]\r
- };\r
- if (!unregistration.isAttached) {\r
- unregistration.attach(this._connection);\r
- }\r
- return this._connection.sendRequest(vscode_languageserver_protocol_1.RegistrationRequest.type, params).then((_result) => {\r
- unregistration.add({ id: id, method: method });\r
- return unregistration;\r
- }, (_error) => {\r
- this.connection.console.info(`Registering request handler for ${method} failed.`);\r
- return Promise.reject(_error);\r
- });\r
- }\r
- registerSingle2(type, registerOptions) {\r
- const method = Is.string(type) ? type : type.method;\r
- const id = UUID.generateUuid();\r
- let params = {\r
- registrations: [{ id, method, registerOptions: registerOptions || {} }]\r
- };\r
- return this._connection.sendRequest(vscode_languageserver_protocol_1.RegistrationRequest.type, params).then((_result) => {\r
- return vscode_languageserver_protocol_1.Disposable.create(() => {\r
- this.unregisterSingle(id, method);\r
- });\r
- }, (_error) => {\r
- this.connection.console.info(`Registering request handler for ${method} failed.`);\r
- return Promise.reject(_error);\r
- });\r
- }\r
- unregisterSingle(id, method) {\r
- let params = {\r
- unregisterations: [{ id, method }]\r
- };\r
- return this._connection.sendRequest(vscode_languageserver_protocol_1.UnregistrationRequest.type, params).then(undefined, (_error) => {\r
- this.connection.console.info(`Unregistering request handler for ${id} failed.`);\r
- });\r
- }\r
- registerMany(registrations) {\r
- let params = registrations.asRegistrationParams();\r
- return this._connection.sendRequest(vscode_languageserver_protocol_1.RegistrationRequest.type, params).then(() => {\r
- return new BulkUnregistrationImpl(this._connection, params.registrations.map(registration => { return { id: registration.id, method: registration.method }; }));\r
- }, (_error) => {\r
- this.connection.console.info(`Bulk registration failed.`);\r
- return Promise.reject(_error);\r
- });\r
- }\r
-}\r
-class _RemoteWorkspaceImpl {\r
- constructor() {\r
- }\r
- attach(connection) {\r
- this._connection = connection;\r
- }\r
- get connection() {\r
- if (!this._connection) {\r
- throw new Error('Remote is not attached to a connection yet.');\r
- }\r
- return this._connection;\r
- }\r
- initialize(_capabilities) {\r
- }\r
- fillServerCapabilities(_capabilities) {\r
- }\r
- applyEdit(paramOrEdit) {\r
- function isApplyWorkspaceEditParams(value) {\r
- return value && !!value.edit;\r
- }\r
- let params = isApplyWorkspaceEditParams(paramOrEdit) ? paramOrEdit : { edit: paramOrEdit };\r
- return this._connection.sendRequest(vscode_languageserver_protocol_1.ApplyWorkspaceEditRequest.type, params);\r
- }\r
-}\r
-const RemoteWorkspaceImpl = workspaceFolders_1.WorkspaceFoldersFeature(configuration_1.ConfigurationFeature(_RemoteWorkspaceImpl));\r
-class TracerImpl {\r
- constructor() {\r
- this._trace = vscode_languageserver_protocol_1.Trace.Off;\r
- }\r
- attach(connection) {\r
- this._connection = connection;\r
- }\r
- get connection() {\r
- if (!this._connection) {\r
- throw new Error('Remote is not attached to a connection yet.');\r
- }\r
- return this._connection;\r
- }\r
- initialize(_capabilities) {\r
- }\r
- fillServerCapabilities(_capabilities) {\r
- }\r
- set trace(value) {\r
- this._trace = value;\r
- }\r
- log(message, verbose) {\r
- if (this._trace === vscode_languageserver_protocol_1.Trace.Off) {\r
- return;\r
- }\r
- this._connection.sendNotification(vscode_languageserver_protocol_1.LogTraceNotification.type, {\r
- message: message,\r
- verbose: this._trace === vscode_languageserver_protocol_1.Trace.Verbose ? verbose : undefined\r
- });\r
- }\r
-}\r
-class TelemetryImpl {\r
- constructor() {\r
- }\r
- attach(connection) {\r
- this._connection = connection;\r
- }\r
- get connection() {\r
- if (!this._connection) {\r
- throw new Error('Remote is not attached to a connection yet.');\r
- }\r
- return this._connection;\r
- }\r
- initialize(_capabilities) {\r
- }\r
- fillServerCapabilities(_capabilities) {\r
- }\r
- logEvent(data) {\r
- this._connection.sendNotification(vscode_languageserver_protocol_1.TelemetryEventNotification.type, data);\r
- }\r
-}\r
-function combineConsoleFeatures(one, two) {\r
- return function (Base) {\r
- return two(one(Base));\r
- };\r
-}\r
-exports.combineConsoleFeatures = combineConsoleFeatures;\r
-function combineTelemetryFeatures(one, two) {\r
- return function (Base) {\r
- return two(one(Base));\r
- };\r
-}\r
-exports.combineTelemetryFeatures = combineTelemetryFeatures;\r
-function combineTracerFeatures(one, two) {\r
- return function (Base) {\r
- return two(one(Base));\r
- };\r
-}\r
-exports.combineTracerFeatures = combineTracerFeatures;\r
-function combineClientFeatures(one, two) {\r
- return function (Base) {\r
- return two(one(Base));\r
- };\r
-}\r
-exports.combineClientFeatures = combineClientFeatures;\r
-function combineWindowFeatures(one, two) {\r
- return function (Base) {\r
- return two(one(Base));\r
- };\r
-}\r
-exports.combineWindowFeatures = combineWindowFeatures;\r
-function combineWorkspaceFeatures(one, two) {\r
- return function (Base) {\r
- return two(one(Base));\r
- };\r
-}\r
-exports.combineWorkspaceFeatures = combineWorkspaceFeatures;\r
-function combineFeatures(one, two) {\r
- function combine(one, two, func) {\r
- if (one && two) {\r
- return func(one, two);\r
- }\r
- else if (one) {\r
- return one;\r
- }\r
- else {\r
- return two;\r
- }\r
- }\r
- let result = {\r
- __brand: 'features',\r
- console: combine(one.console, two.console, combineConsoleFeatures),\r
- tracer: combine(one.tracer, two.tracer, combineTracerFeatures),\r
- telemetry: combine(one.telemetry, two.telemetry, combineTelemetryFeatures),\r
- client: combine(one.client, two.client, combineClientFeatures),\r
- window: combine(one.window, two.window, combineWindowFeatures),\r
- workspace: combine(one.workspace, two.workspace, combineWorkspaceFeatures)\r
- };\r
- return result;\r
-}\r
-exports.combineFeatures = combineFeatures;\r
-function createConnection(arg1, arg2, arg3, arg4) {\r
- let factories;\r
- let input;\r
- let output;\r
- let strategy;\r
- if (arg1 !== void 0 && arg1.__brand === 'features') {\r
- factories = arg1;\r
- arg1 = arg2;\r
- arg2 = arg3;\r
- arg3 = arg4;\r
- }\r
- if (vscode_languageserver_protocol_1.ConnectionStrategy.is(arg1)) {\r
- strategy = arg1;\r
- }\r
- else {\r
- input = arg1;\r
- output = arg2;\r
- strategy = arg3;\r
- }\r
- return _createConnection(input, output, strategy, factories);\r
-}\r
-exports.createConnection = createConnection;\r
-function _createConnection(input, output, strategy, factories) {\r
- if (!input && !output && process.argv.length > 2) {\r
- let port = void 0;\r
- let pipeName = void 0;\r
- let argv = process.argv.slice(2);\r
- for (let i = 0; i < argv.length; i++) {\r
- let arg = argv[i];\r
- if (arg === '--node-ipc') {\r
- input = new vscode_languageserver_protocol_1.IPCMessageReader(process);\r
- output = new vscode_languageserver_protocol_1.IPCMessageWriter(process);\r
- break;\r
- }\r
- else if (arg === '--stdio') {\r
- input = process.stdin;\r
- output = process.stdout;\r
- break;\r
- }\r
- else if (arg === '--socket') {\r
- port = parseInt(argv[i + 1]);\r
- break;\r
- }\r
- else if (arg === '--pipe') {\r
- pipeName = argv[i + 1];\r
- break;\r
- }\r
- else {\r
- var args = arg.split('=');\r
- if (args[0] === '--socket') {\r
- port = parseInt(args[1]);\r
- break;\r
- }\r
- else if (args[0] === '--pipe') {\r
- pipeName = args[1];\r
- break;\r
- }\r
- }\r
- }\r
- if (port) {\r
- let transport = vscode_languageserver_protocol_1.createServerSocketTransport(port);\r
- input = transport[0];\r
- output = transport[1];\r
- }\r
- else if (pipeName) {\r
- let transport = vscode_languageserver_protocol_1.createServerPipeTransport(pipeName);\r
- input = transport[0];\r
- output = transport[1];\r
- }\r
- }\r
- var commandLineMessage = "Use arguments of createConnection or set command line parameters: '--node-ipc', '--stdio' or '--socket={number}'";\r
- if (!input) {\r
- throw new Error("Connection input stream is not set. " + commandLineMessage);\r
- }\r
- if (!output) {\r
- throw new Error("Connection output stream is not set. " + commandLineMessage);\r
- }\r
- // Backwards compatibility\r
- if (Is.func(input.read) && Is.func(input.on)) {\r
- let inputStream = input;\r
- inputStream.on('end', () => {\r
- process.exit(shutdownReceived ? 0 : 1);\r
- });\r
- inputStream.on('close', () => {\r
- process.exit(shutdownReceived ? 0 : 1);\r
- });\r
- }\r
- const logger = (factories && factories.console ? new (factories.console(ConnectionLogger))() : new ConnectionLogger());\r
- const connection = vscode_languageserver_protocol_1.createProtocolConnection(input, output, logger, strategy);\r
- logger.rawAttach(connection);\r
- const tracer = (factories && factories.tracer ? new (factories.tracer(TracerImpl))() : new TracerImpl());\r
- const telemetry = (factories && factories.telemetry ? new (factories.telemetry(TelemetryImpl))() : new TelemetryImpl());\r
- const client = (factories && factories.client ? new (factories.client(RemoteClientImpl))() : new RemoteClientImpl());\r
- const remoteWindow = (factories && factories.window ? new (factories.window(RemoteWindowImpl))() : new RemoteWindowImpl());\r
- const workspace = (factories && factories.workspace ? new (factories.workspace(RemoteWorkspaceImpl))() : new RemoteWorkspaceImpl());\r
- const allRemotes = [logger, tracer, telemetry, client, remoteWindow, workspace];\r
- function asThenable(value) {\r
- if (Is.thenable(value)) {\r
- return value;\r
- }\r
- else {\r
- return Promise.resolve(value);\r
- }\r
- }\r
- let shutdownHandler = undefined;\r
- let initializeHandler = undefined;\r
- let exitHandler = undefined;\r
- let protocolConnection = {\r
- listen: () => connection.listen(),\r
- sendRequest: (type, ...params) => connection.sendRequest(Is.string(type) ? type : type.method, ...params),\r
- onRequest: (type, handler) => connection.onRequest(type, handler),\r
- sendNotification: (type, param) => {\r
- const method = Is.string(type) ? type : type.method;\r
- if (arguments.length === 1) {\r
- connection.sendNotification(method);\r
- }\r
- else {\r
- connection.sendNotification(method, param);\r
- }\r
- },\r
- onNotification: (type, handler) => connection.onNotification(type, handler),\r
- onInitialize: (handler) => initializeHandler = handler,\r
- onInitialized: (handler) => connection.onNotification(vscode_languageserver_protocol_1.InitializedNotification.type, handler),\r
- onShutdown: (handler) => shutdownHandler = handler,\r
- onExit: (handler) => exitHandler = handler,\r
- get console() { return logger; },\r
- get telemetry() { return telemetry; },\r
- get tracer() { return tracer; },\r
- get client() { return client; },\r
- get window() { return remoteWindow; },\r
- get workspace() { return workspace; },\r
- onDidChangeConfiguration: (handler) => connection.onNotification(vscode_languageserver_protocol_1.DidChangeConfigurationNotification.type, handler),\r
- onDidChangeWatchedFiles: (handler) => connection.onNotification(vscode_languageserver_protocol_1.DidChangeWatchedFilesNotification.type, handler),\r
- __textDocumentSync: undefined,\r
- onDidOpenTextDocument: (handler) => connection.onNotification(vscode_languageserver_protocol_1.DidOpenTextDocumentNotification.type, handler),\r
- onDidChangeTextDocument: (handler) => connection.onNotification(vscode_languageserver_protocol_1.DidChangeTextDocumentNotification.type, handler),\r
- onDidCloseTextDocument: (handler) => connection.onNotification(vscode_languageserver_protocol_1.DidCloseTextDocumentNotification.type, handler),\r
- onWillSaveTextDocument: (handler) => connection.onNotification(vscode_languageserver_protocol_1.WillSaveTextDocumentNotification.type, handler),\r
- onWillSaveTextDocumentWaitUntil: (handler) => connection.onRequest(vscode_languageserver_protocol_1.WillSaveTextDocumentWaitUntilRequest.type, handler),\r
- onDidSaveTextDocument: (handler) => connection.onNotification(vscode_languageserver_protocol_1.DidSaveTextDocumentNotification.type, handler),\r
- sendDiagnostics: (params) => connection.sendNotification(vscode_languageserver_protocol_1.PublishDiagnosticsNotification.type, params),\r
- onHover: (handler) => connection.onRequest(vscode_languageserver_protocol_1.HoverRequest.type, handler),\r
- onCompletion: (handler) => connection.onRequest(vscode_languageserver_protocol_1.CompletionRequest.type, handler),\r
- onCompletionResolve: (handler) => connection.onRequest(vscode_languageserver_protocol_1.CompletionResolveRequest.type, handler),\r
- onSignatureHelp: (handler) => connection.onRequest(vscode_languageserver_protocol_1.SignatureHelpRequest.type, handler),\r
- onDeclaration: (handler) => connection.onRequest(vscode_languageserver_protocol_1.DeclarationRequest.type, handler),\r
- onDefinition: (handler) => connection.onRequest(vscode_languageserver_protocol_1.DefinitionRequest.type, handler),\r
- onTypeDefinition: (handler) => connection.onRequest(vscode_languageserver_protocol_1.TypeDefinitionRequest.type, handler),\r
- onImplementation: (handler) => connection.onRequest(vscode_languageserver_protocol_1.ImplementationRequest.type, handler),\r
- onReferences: (handler) => connection.onRequest(vscode_languageserver_protocol_1.ReferencesRequest.type, handler),\r
- onDocumentHighlight: (handler) => connection.onRequest(vscode_languageserver_protocol_1.DocumentHighlightRequest.type, handler),\r
- onDocumentSymbol: (handler) => connection.onRequest(vscode_languageserver_protocol_1.DocumentSymbolRequest.type, handler),\r
- onWorkspaceSymbol: (handler) => connection.onRequest(vscode_languageserver_protocol_1.WorkspaceSymbolRequest.type, handler),\r
- onCodeAction: (handler) => connection.onRequest(vscode_languageserver_protocol_1.CodeActionRequest.type, handler),\r
- onCodeLens: (handler) => connection.onRequest(vscode_languageserver_protocol_1.CodeLensRequest.type, handler),\r
- onCodeLensResolve: (handler) => connection.onRequest(vscode_languageserver_protocol_1.CodeLensResolveRequest.type, handler),\r
- onDocumentFormatting: (handler) => connection.onRequest(vscode_languageserver_protocol_1.DocumentFormattingRequest.type, handler),\r
- onDocumentRangeFormatting: (handler) => connection.onRequest(vscode_languageserver_protocol_1.DocumentRangeFormattingRequest.type, handler),\r
- onDocumentOnTypeFormatting: (handler) => connection.onRequest(vscode_languageserver_protocol_1.DocumentOnTypeFormattingRequest.type, handler),\r
- onRenameRequest: (handler) => connection.onRequest(vscode_languageserver_protocol_1.RenameRequest.type, handler),\r
- onPrepareRename: (handler) => connection.onRequest(vscode_languageserver_protocol_1.PrepareRenameRequest.type, handler),\r
- onDocumentLinks: (handler) => connection.onRequest(vscode_languageserver_protocol_1.DocumentLinkRequest.type, handler),\r
- onDocumentLinkResolve: (handler) => connection.onRequest(vscode_languageserver_protocol_1.DocumentLinkResolveRequest.type, handler),\r
- onDocumentColor: (handler) => connection.onRequest(vscode_languageserver_protocol_1.DocumentColorRequest.type, handler),\r
- onColorPresentation: (handler) => connection.onRequest(vscode_languageserver_protocol_1.ColorPresentationRequest.type, handler),\r
- onFoldingRanges: (handler) => connection.onRequest(vscode_languageserver_protocol_1.FoldingRangeRequest.type, handler),\r
- onExecuteCommand: (handler) => connection.onRequest(vscode_languageserver_protocol_1.ExecuteCommandRequest.type, handler),\r
- dispose: () => connection.dispose()\r
- };\r
- for (let remote of allRemotes) {\r
- remote.attach(protocolConnection);\r
- }\r
- connection.onRequest(vscode_languageserver_protocol_1.InitializeRequest.type, (params) => {\r
- const processId = params.processId;\r
- if (Is.number(processId) && exitTimer === void 0) {\r
- // We received a parent process id. Set up a timer to periodically check\r
- // if the parent is still alive.\r
- setInterval(() => {\r
- try {\r
- process.kill(processId, 0);\r
- }\r
- catch (ex) {\r
- // Parent process doesn't exist anymore. Exit the server.\r
- process.exit(shutdownReceived ? 0 : 1);\r
- }\r
- }, 3000);\r
- }\r
- if (Is.string(params.trace)) {\r
- tracer.trace = vscode_languageserver_protocol_1.Trace.fromString(params.trace);\r
- }\r
- for (let remote of allRemotes) {\r
- remote.initialize(params.capabilities);\r
- }\r
- if (initializeHandler) {\r
- let result = initializeHandler(params, new vscode_languageserver_protocol_1.CancellationTokenSource().token);\r
- return asThenable(result).then((value) => {\r
- if (value instanceof vscode_languageserver_protocol_1.ResponseError) {\r
- return value;\r
- }\r
- let result = value;\r
- if (!result) {\r
- result = { capabilities: {} };\r
- }\r
- let capabilities = result.capabilities;\r
- if (!capabilities) {\r
- capabilities = {};\r
- result.capabilities = capabilities;\r
- }\r
- if (capabilities.textDocumentSync === void 0 || capabilities.textDocumentSync === null) {\r
- capabilities.textDocumentSync = Is.number(protocolConnection.__textDocumentSync) ? protocolConnection.__textDocumentSync : vscode_languageserver_protocol_1.TextDocumentSyncKind.None;\r
- }\r
- else if (!Is.number(capabilities.textDocumentSync) && !Is.number(capabilities.textDocumentSync.change)) {\r
- capabilities.textDocumentSync.change = Is.number(protocolConnection.__textDocumentSync) ? protocolConnection.__textDocumentSync : vscode_languageserver_protocol_1.TextDocumentSyncKind.None;\r
- }\r
- for (let remote of allRemotes) {\r
- remote.fillServerCapabilities(capabilities);\r
- }\r
- return result;\r
- });\r
- }\r
- else {\r
- let result = { capabilities: { textDocumentSync: vscode_languageserver_protocol_1.TextDocumentSyncKind.None } };\r
- for (let remote of allRemotes) {\r
- remote.fillServerCapabilities(result.capabilities);\r
- }\r
- return result;\r
- }\r
- });\r
- connection.onRequest(vscode_languageserver_protocol_1.ShutdownRequest.type, () => {\r
- shutdownReceived = true;\r
- if (shutdownHandler) {\r
- return shutdownHandler(new vscode_languageserver_protocol_1.CancellationTokenSource().token);\r
- }\r
- else {\r
- return undefined;\r
- }\r
- });\r
- connection.onNotification(vscode_languageserver_protocol_1.ExitNotification.type, () => {\r
- try {\r
- if (exitHandler) {\r
- exitHandler();\r
- }\r
- }\r
- finally {\r
- if (shutdownReceived) {\r
- process.exit(0);\r
- }\r
- else {\r
- process.exit(1);\r
- }\r
- }\r
- });\r
- connection.onNotification(vscode_languageserver_protocol_1.SetTraceNotification.type, (params) => {\r
- tracer.trace = vscode_languageserver_protocol_1.Trace.fromString(params.value);\r
- });\r
- return protocolConnection;\r
-}\r
-// Export the protocol currently in proposed state.\r
-const proposed_progress_1 = __webpack_require__(48);\r
-var ProposedFeatures;\r
-(function (ProposedFeatures) {\r
- ProposedFeatures.all = {\r
- __brand: 'features',\r
- window: proposed_progress_1.ProgressFeature\r
- };\r
-})(ProposedFeatures = exports.ProposedFeatures || (exports.ProposedFeatures = {}));\r
-
-
-/***/ }),
-/* 35 */
-/***/ (function(module, exports, __webpack_require__) {
-
-"use strict";
-/* --------------------------------------------------------------------------------------------\r
- * Copyright (c) Microsoft Corporation. All rights reserved.\r
- * Licensed under the MIT License. See License.txt in the project root for license information.\r
- * ------------------------------------------------------------------------------------------ */\r
-\r
-Object.defineProperty(exports, "__esModule", { value: true });\r
-const vscode_languageserver_protocol_1 = __webpack_require__(3);\r
-const Is = __webpack_require__(36);\r
-exports.ConfigurationFeature = (Base) => {\r
- return class extends Base {\r
- getConfiguration(arg) {\r
- if (!arg) {\r
- return this._getConfiguration({});\r
- }\r
- else if (Is.string(arg)) {\r
- return this._getConfiguration({ section: arg });\r
- }\r
- else {\r
- return this._getConfiguration(arg);\r
- }\r
- }\r
- _getConfiguration(arg) {\r
- let params = {\r
- items: Array.isArray(arg) ? arg : [arg]\r
- };\r
- return this.connection.sendRequest(vscode_languageserver_protocol_1.ConfigurationRequest.type, params).then((result) => {\r
- return Array.isArray(arg) ? result : result[0];\r
- });\r
- }\r
- };\r
-};\r
-
-
-/***/ }),
-/* 36 */
-/***/ (function(module, exports, __webpack_require__) {
-
-"use strict";
-/* --------------------------------------------------------------------------------------------\r
- * Copyright (c) Microsoft Corporation. All rights reserved.\r
- * Licensed under the MIT License. See License.txt in the project root for license information.\r
- * ------------------------------------------------------------------------------------------ */\r
-\r
-Object.defineProperty(exports, "__esModule", { value: true });\r
-function boolean(value) {\r
- return value === true || value === false;\r
-}\r
-exports.boolean = boolean;\r
-function string(value) {\r
- return typeof value === 'string' || value instanceof String;\r
-}\r
-exports.string = string;\r
-function number(value) {\r
- return typeof value === 'number' || value instanceof Number;\r
-}\r
-exports.number = number;\r
-function error(value) {\r
- return value instanceof Error;\r
-}\r
-exports.error = error;\r
-function func(value) {\r
- return typeof value === 'function';\r
-}\r
-exports.func = func;\r
-function array(value) {\r
- return Array.isArray(value);\r
-}\r
-exports.array = array;\r
-function stringArray(value) {\r
- return array(value) && value.every(elem => string(elem));\r
-}\r
-exports.stringArray = stringArray;\r
-function typedArray(value, check) {\r
- return Array.isArray(value) && value.every(check);\r
-}\r
-exports.typedArray = typedArray;\r
-function thenable(value) {\r
- return value && func(value.then);\r
-}\r
-exports.thenable = thenable;\r
-
-
-/***/ }),
-/* 37 */
-/***/ (function(module, exports, __webpack_require__) {
-
-"use strict";
-/* --------------------------------------------------------------------------------------------\r
- * Copyright (c) Microsoft Corporation. All rights reserved.\r
- * Licensed under the MIT License. See License.txt in the project root for license information.\r
- * ------------------------------------------------------------------------------------------ */\r
-\r
-Object.defineProperty(exports, "__esModule", { value: true });\r
-const vscode_languageserver_protocol_1 = __webpack_require__(3);\r
-exports.WorkspaceFoldersFeature = (Base) => {\r
- return class extends Base {\r
- initialize(capabilities) {\r
- let workspaceCapabilities = capabilities.workspace;\r
- if (workspaceCapabilities && workspaceCapabilities.workspaceFolders) {\r
- this._onDidChangeWorkspaceFolders = new vscode_languageserver_protocol_1.Emitter();\r
- this.connection.onNotification(vscode_languageserver_protocol_1.DidChangeWorkspaceFoldersNotification.type, (params) => {\r
- this._onDidChangeWorkspaceFolders.fire(params.event);\r
- });\r
- }\r
- }\r
- getWorkspaceFolders() {\r
- return this.connection.sendRequest(vscode_languageserver_protocol_1.WorkspaceFoldersRequest.type);\r
- }\r
- get onDidChangeWorkspaceFolders() {\r
- if (!this._onDidChangeWorkspaceFolders) {\r
- throw new Error('Client doesn\'t support sending workspace folder change events.');\r
- }\r
- if (!this._unregistration) {\r
- this._unregistration = this.connection.client.register(vscode_languageserver_protocol_1.DidChangeWorkspaceFoldersNotification.type);\r
- }\r
- return this._onDidChangeWorkspaceFolders.event;\r
- }\r
- };\r
-};\r
-
-
-/***/ }),
-/* 38 */
-/***/ (function(module, exports, __webpack_require__) {
-
-"use strict";
-/*---------------------------------------------------------------------------------------------\r
- * Copyright (c) Microsoft Corporation. All rights reserved.\r
- * Licensed under the MIT License. See License.txt in the project root for license information.\r
- *--------------------------------------------------------------------------------------------*/\r
-\r
-Object.defineProperty(exports, "__esModule", { value: true });\r
-class ValueUUID {\r
- constructor(_value) {\r
- this._value = _value;\r
- // empty\r
- }\r
- asHex() {\r
- return this._value;\r
- }\r
- equals(other) {\r
- return this.asHex() === other.asHex();\r
- }\r
-}\r
-class V4UUID extends ValueUUID {\r
- constructor() {\r
- super([\r
- V4UUID._randomHex(),\r
- V4UUID._randomHex(),\r
- V4UUID._randomHex(),\r
- V4UUID._randomHex(),\r
- V4UUID._randomHex(),\r
- V4UUID._randomHex(),\r
- V4UUID._randomHex(),\r
- V4UUID._randomHex(),\r
- '-',\r
- V4UUID._randomHex(),\r
- V4UUID._randomHex(),\r
- V4UUID._randomHex(),\r
- V4UUID._randomHex(),\r
- '-',\r
- '4',\r
- V4UUID._randomHex(),\r
- V4UUID._randomHex(),\r
- V4UUID._randomHex(),\r
- '-',\r
- V4UUID._oneOf(V4UUID._timeHighBits),\r
- V4UUID._randomHex(),\r
- V4UUID._randomHex(),\r
- V4UUID._randomHex(),\r
- '-',\r
- V4UUID._randomHex(),\r
- V4UUID._randomHex(),\r
- V4UUID._randomHex(),\r
- V4UUID._randomHex(),\r
- V4UUID._randomHex(),\r
- V4UUID._randomHex(),\r
- V4UUID._randomHex(),\r
- V4UUID._randomHex(),\r
- V4UUID._randomHex(),\r
- V4UUID._randomHex(),\r
- V4UUID._randomHex(),\r
- V4UUID._randomHex(),\r
- ].join(''));\r
- }\r
- static _oneOf(array) {\r
- return array[Math.floor(array.length * Math.random())];\r
- }\r
- static _randomHex() {\r
- return V4UUID._oneOf(V4UUID._chars);\r
- }\r
-}\r
-V4UUID._chars = ['0', '1', '2', '3', '4', '5', '6', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'];\r
-V4UUID._timeHighBits = ['8', '9', 'a', 'b'];\r
-/**\r
- * An empty UUID that contains only zeros.\r
- */\r
-exports.empty = new ValueUUID('00000000-0000-0000-0000-000000000000');\r
-function v4() {\r
- return new V4UUID();\r
-}\r
-exports.v4 = v4;\r
-const _UUIDPattern = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;\r
-function isUUID(value) {\r
- return _UUIDPattern.test(value);\r
-}\r
-exports.isUUID = isUUID;\r
-/**\r
- * Parses a UUID that is of the format xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.\r
- * @param value A uuid string.\r
- */\r
-function parse(value) {\r
- if (!isUUID(value)) {\r
- throw new Error('invalid uuid');\r
- }\r
- return new ValueUUID(value);\r
-}\r
-exports.parse = parse;\r
-function generateUuid() {\r
- return v4().asHex();\r
-}\r
-exports.generateUuid = generateUuid;\r
-
-
-/***/ }),
-/* 39 */
-/***/ (function(module, exports, __webpack_require__) {
-
-"use strict";
-/* WEBPACK VAR INJECTION */(function(__filename) {/* --------------------------------------------------------------------------------------------\r
- * Copyright (c) Microsoft Corporation. All rights reserved.\r
- * Licensed under the MIT License. See License.txt in the project root for license information.\r
- * ------------------------------------------------------------------------------------------ */\r
-\r
-Object.defineProperty(exports, "__esModule", { value: true });\r
-const url = __webpack_require__(40);\r
-const path = __webpack_require__(1);\r
-const fs = __webpack_require__(2);\r
-const child_process_1 = __webpack_require__(41);\r
-/**\r
- * @deprecated Use the `vscode-uri` npm module which provides a more\r
- * complete implementation of handling VS Code URIs.\r
- */\r
-function uriToFilePath(uri) {\r
- let parsed = url.parse(uri);\r
- if (parsed.protocol !== 'file:' || !parsed.path) {\r
- return undefined;\r
- }\r
- let segments = parsed.path.split('/');\r
- for (var i = 0, len = segments.length; i < len; i++) {\r
- segments[i] = decodeURIComponent(segments[i]);\r
- }\r
- if (process.platform === 'win32' && segments.length > 1) {\r
- let first = segments[0];\r
- let second = segments[1];\r
- // Do we have a drive letter and we started with a / which is the\r
- // case if the first segement is empty (see split above)\r
- if (first.length === 0 && second.length > 1 && second[1] === ':') {\r
- // Remove first slash\r
- segments.shift();\r
- }\r
- }\r
- return path.normalize(segments.join('/'));\r
-}\r
-exports.uriToFilePath = uriToFilePath;\r
-function isWindows() {\r
- return process.platform === 'win32';\r
-}\r
-function resolve(moduleName, nodePath, cwd, tracer) {\r
- const nodePathKey = 'NODE_PATH';\r
- const app = [\r
- "var p = process;",\r
- "p.on('message',function(m){",\r
- "if(m.c==='e'){",\r
- "p.exit(0);",\r
- "}",\r
- "else if(m.c==='rs'){",\r
- "try{",\r
- "var r=require.resolve(m.a);",\r
- "p.send({c:'r',s:true,r:r});",\r
- "}",\r
- "catch(err){",\r
- "p.send({c:'r',s:false});",\r
- "}",\r
- "}",\r
- "});"\r
- ].join('');\r
- return new Promise((resolve, reject) => {\r
- let env = process.env;\r
- let newEnv = Object.create(null);\r
- Object.keys(env).forEach(key => newEnv[key] = env[key]);\r
- if (nodePath) {\r
- if (newEnv[nodePathKey]) {\r
- newEnv[nodePathKey] = nodePath + path.delimiter + newEnv[nodePathKey];\r
- }\r
- else {\r
- newEnv[nodePathKey] = nodePath;\r
- }\r
- if (tracer) {\r
- tracer(`NODE_PATH value is: ${newEnv[nodePathKey]}`);\r
- }\r
- }\r
- newEnv['ELECTRON_RUN_AS_NODE'] = '1';\r
- try {\r
- let cp = child_process_1.fork('', [], {\r
- cwd: cwd,\r
- env: newEnv,\r
- execArgv: ['-e', app]\r
- });\r
- if (cp.pid === void 0) {\r
- reject(new Error(`Starting process to resolve node module ${moduleName} failed`));\r
- return;\r
- }\r
- cp.on('error', (error) => {\r
- reject(error);\r
- });\r
- cp.on('message', (message) => {\r
- if (message.c === 'r') {\r
- cp.send({ c: 'e' });\r
- if (message.s) {\r
- resolve(message.r);\r
- }\r
- else {\r
- reject(new Error(`Failed to resolve module: ${moduleName}`));\r
- }\r
- }\r
- });\r
- let message = {\r
- c: 'rs',\r
- a: moduleName\r
- };\r
- cp.send(message);\r
- }\r
- catch (error) {\r
- reject(error);\r
- }\r
- });\r
-}\r
-exports.resolve = resolve;\r
-function resolveGlobalNodePath(tracer) {\r
- let npmCommand = 'npm';\r
- let options = {\r
- encoding: 'utf8'\r
- };\r
- if (isWindows()) {\r
- npmCommand = 'npm.cmd';\r
- options.shell = true;\r
- }\r
- let handler = () => { };\r
- try {\r
- process.on('SIGPIPE', handler);\r
- let stdout = child_process_1.spawnSync(npmCommand, ['config', 'get', 'prefix'], options).stdout;\r
- if (!stdout) {\r
- if (tracer) {\r
- tracer(`'npm config get prefix' didn't return a value.`);\r
- }\r
- return undefined;\r
- }\r
- let prefix = stdout.trim();\r
- if (tracer) {\r
- tracer(`'npm config get prefix' value is: ${prefix}`);\r
- }\r
- if (prefix.length > 0) {\r
- if (isWindows()) {\r
- return path.join(prefix, 'node_modules');\r
- }\r
- else {\r
- return path.join(prefix, 'lib', 'node_modules');\r
- }\r
- }\r
- return undefined;\r
- }\r
- catch (err) {\r
- return undefined;\r
- }\r
- finally {\r
- process.removeListener('SIGPIPE', handler);\r
- }\r
-}\r
-exports.resolveGlobalNodePath = resolveGlobalNodePath;\r
-function resolveGlobalYarnPath(tracer) {\r
- let yarnCommand = 'yarn';\r
- let options = {\r
- encoding: 'utf8'\r
- };\r
- if (isWindows()) {\r
- yarnCommand = 'yarn.cmd';\r
- options.shell = true;\r
- }\r
- let handler = () => { };\r
- try {\r
- process.on('SIGPIPE', handler);\r
- let results = child_process_1.spawnSync(yarnCommand, ['global', 'dir', '--json'], options);\r
- let stdout = results.stdout;\r
- if (!stdout) {\r
- if (tracer) {\r
- tracer(`'yarn global dir' didn't return a value.`);\r
- if (results.stderr) {\r
- tracer(results.stderr);\r
- }\r
- }\r
- return undefined;\r
- }\r
- let lines = stdout.trim().split(/\r?\n/);\r
- for (let line of lines) {\r
- try {\r
- let yarn = JSON.parse(line);\r
- if (yarn.type === 'log') {\r
- return path.join(yarn.data, 'node_modules');\r
- }\r
- }\r
- catch (e) {\r
- // Do nothing. Ignore the line\r
- }\r
- }\r
- return undefined;\r
- }\r
- catch (err) {\r
- return undefined;\r
- }\r
- finally {\r
- process.removeListener('SIGPIPE', handler);\r
- }\r
-}\r
-exports.resolveGlobalYarnPath = resolveGlobalYarnPath;\r
-var FileSystem;\r
-(function (FileSystem) {\r
- let _isCaseSensitive = undefined;\r
- function isCaseSensitive() {\r
- if (_isCaseSensitive !== void 0) {\r
- return _isCaseSensitive;\r
- }\r
- if (process.platform === 'win32') {\r
- _isCaseSensitive = false;\r
- }\r
- else {\r
- // convert current file name to upper case / lower case and check if file exists\r
- // (guards against cases when name is already all uppercase or lowercase)\r
- _isCaseSensitive = !fs.existsSync(__filename.toUpperCase()) || !fs.existsSync(__filename.toLowerCase());\r
- }\r
- return _isCaseSensitive;\r
- }\r
- FileSystem.isCaseSensitive = isCaseSensitive;\r
- function isParent(parent, child) {\r
- if (isCaseSensitive()) {\r
- return path.normalize(child).indexOf(path.normalize(parent)) === 0;\r
- }\r
- else {\r
- return path.normalize(child).toLowerCase().indexOf(path.normalize(parent).toLowerCase()) == 0;\r
- }\r
- }\r
- FileSystem.isParent = isParent;\r
-})(FileSystem = exports.FileSystem || (exports.FileSystem = {}));\r
-function resolveModulePath(workspaceRoot, moduleName, nodePath, tracer) {\r
- if (nodePath) {\r
- if (!path.isAbsolute(nodePath)) {\r
- nodePath = path.join(workspaceRoot, nodePath);\r
- }\r
- return resolve(moduleName, nodePath, nodePath, tracer).then((value) => {\r
- if (FileSystem.isParent(nodePath, value)) {\r
- return value;\r
- }\r
- else {\r
- return Promise.reject(new Error(`Failed to load ${moduleName} from node path location.`));\r
- }\r
- }).then(undefined, (_error) => {\r
- return resolve(moduleName, resolveGlobalNodePath(tracer), workspaceRoot, tracer);\r
- });\r
- }\r
- else {\r
- return resolve(moduleName, resolveGlobalNodePath(tracer), workspaceRoot, tracer);\r
- }\r
-}\r
-exports.resolveModulePath = resolveModulePath;\r
-
-/* WEBPACK VAR INJECTION */}.call(this, "/index.js"))
-
-/***/ }),
-/* 40 */
-/***/ (function(module, exports) {
-
-module.exports = require("url");
-
-/***/ }),
-/* 41 */
-/***/ (function(module, exports) {
-
-module.exports = require("child_process");
-
-/***/ }),
-/* 42 */
-/***/ (function(module, exports, __webpack_require__) {
-
-"use strict";
-
-function __export(m) {
- for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
-}
-Object.defineProperty(exports, "__esModule", { value: true });
-__export(__webpack_require__(43));
-__export(__webpack_require__(46));
-
-
-/***/ }),
-/* 43 */
-/***/ (function(module, exports, __webpack_require__) {
-
-"use strict";
-
-/*---------------------------------------------------------------------------------------------
- * Copyright (c) Microsoft Corporation. All rights reserved.
- * Licensed under the MIT License. See License.txt in the project root for license information.
- *--------------------------------------------------------------------------------------------*/
-Object.defineProperty(exports, "__esModule", { value: true });
-const position_1 = __webpack_require__(44);
-const rbTreeBase_1 = __webpack_require__(45);
-// const lfRegex = new RegExp(/\r\n|\r|\n/g);
-exports.AverageBufferSize = 65535;
-function createUintArray(arr) {
- let r;
- if (arr[arr.length - 1] < 65536) {
- r = new Uint16Array(arr.length);
- }
- else {
- r = new Uint32Array(arr.length);
- }
- r.set(arr, 0);
- return r;
-}
-exports.createUintArray = createUintArray;
-class LineStarts {
- constructor(lineStarts, cr, lf, crlf, isBasicASCII) {
- this.lineStarts = lineStarts;
- this.cr = cr;
- this.lf = lf;
- this.crlf = crlf;
- this.isBasicASCII = isBasicASCII;
- }
-}
-exports.LineStarts = LineStarts;
-function createLineStartsFast(str, readonly = true) {
- let r = [0], rLength = 1;
- for (let i = 0, len = str.length; i < len; i++) {
- const chr = str.charCodeAt(i);
- if (chr === 13 /* CarriageReturn */) {
- if (i + 1 < len && str.charCodeAt(i + 1) === 10 /* LineFeed */) {
- // \r\n... case
- r[rLength++] = i + 2;
- i++; // skip \n
- }
- else {
- // \r... case
- r[rLength++] = i + 1;
- }
- }
- else if (chr === 10 /* LineFeed */) {
- r[rLength++] = i + 1;
- }
- }
- if (readonly) {
- return createUintArray(r);
- }
- else {
- return r;
- }
-}
-exports.createLineStartsFast = createLineStartsFast;
-function createLineStarts(r, str) {
- r.length = 0;
- r[0] = 0;
- let rLength = 1;
- let cr = 0, lf = 0, crlf = 0;
- let isBasicASCII = true;
- for (let i = 0, len = str.length; i < len; i++) {
- const chr = str.charCodeAt(i);
- if (chr === 13 /* CarriageReturn */) {
- if (i + 1 < len && str.charCodeAt(i + 1) === 10 /* LineFeed */) {
- // \r\n... case
- crlf++;
- r[rLength++] = i + 2;
- i++; // skip \n
- }
- else {
- cr++;
- // \r... case
- r[rLength++] = i + 1;
- }
- }
- else if (chr === 10 /* LineFeed */) {
- lf++;
- r[rLength++] = i + 1;
- }
- else {
- if (isBasicASCII) {
- if (chr !== 9 /* Tab */ && (chr < 32 || chr > 126)) {
- isBasicASCII = false;
- }
- }
- }
- }
- const result = new LineStarts(createUintArray(r), cr, lf, crlf, isBasicASCII);
- r.length = 0;
- return result;
-}
-exports.createLineStarts = createLineStarts;
-class Piece {
- constructor(bufferIndex, start, end, lineFeedCnt, length) {
- this.bufferIndex = bufferIndex;
- this.start = start;
- this.end = end;
- this.lineFeedCnt = lineFeedCnt;
- this.length = length;
- }
-}
-exports.Piece = Piece;
-class StringBuffer {
- constructor(buffer, lineStarts) {
- this.buffer = buffer;
- this.lineStarts = lineStarts;
- }
-}
-exports.StringBuffer = StringBuffer;
-/**
- * Readonly snapshot for piece tree.
- * In a real multiple thread environment, to make snapshot reading always work correctly, we need to
- * 1. Make TreeNode.piece immutable, then reading and writing can run in parallel.
- * 2. TreeNode/Buffers normalization should not happen during snapshot reading.
- */
-class PieceTreeSnapshot {
- constructor(tree, BOM) {
- this._pieces = [];
- this._tree = tree;
- this._BOM = BOM;
- this._index = 0;
- if (tree.root !== rbTreeBase_1.SENTINEL) {
- tree.iterate(tree.root, node => {
- if (node !== rbTreeBase_1.SENTINEL) {
- this._pieces.push(node.piece);
- }
- return true;
- });
- }
- }
- read() {
- if (this._pieces.length === 0) {
- if (this._index === 0) {
- this._index++;
- return this._BOM;
- }
- else {
- return null;
- }
- }
- if (this._index > this._pieces.length - 1) {
- return null;
- }
- if (this._index === 0) {
- return this._BOM + this._tree.getPieceContent(this._pieces[this._index++]);
- }
- return this._tree.getPieceContent(this._pieces[this._index++]);
- }
-}
-class PieceTreeSearchCache {
- constructor(limit) {
- this._limit = limit;
- this._cache = [];
- }
- get(offset) {
- for (let i = this._cache.length - 1; i >= 0; i--) {
- let nodePos = this._cache[i];
- if (nodePos.nodeStartOffset <= offset && nodePos.nodeStartOffset + nodePos.node.piece.length >= offset) {
- return nodePos;
- }
- }
- return null;
- }
- get2(lineNumber) {
- for (let i = this._cache.length - 1; i >= 0; i--) {
- let nodePos = this._cache[i];
- if (nodePos.nodeStartLineNumber && nodePos.nodeStartLineNumber < lineNumber && nodePos.nodeStartLineNumber + nodePos.node.piece.lineFeedCnt >= lineNumber) {
- return nodePos;
- }
- }
- return null;
- }
- set(nodePosition) {
- if (this._cache.length >= this._limit) {
- this._cache.shift();
- }
- this._cache.push(nodePosition);
- }
- valdiate(offset) {
- let hasInvalidVal = false;
- let tmp = this._cache;
- for (let i = 0; i < tmp.length; i++) {
- let nodePos = tmp[i];
- if (nodePos.node.parent === null || nodePos.nodeStartOffset >= offset) {
- tmp[i] = null;
- hasInvalidVal = true;
- continue;
- }
- }
- if (hasInvalidVal) {
- let newArr = [];
- for (const entry of tmp) {
- if (entry !== null) {
- newArr.push(entry);
- }
- }
- this._cache = newArr;
- }
- }
-}
-class PieceTreeBase {
- constructor(chunks, eol, eolNormalized) {
- this.create(chunks, eol, eolNormalized);
- }
- create(chunks, eol, eolNormalized) {
- this._buffers = [
- new StringBuffer('', [0])
- ];
- this._lastChangeBufferPos = { line: 0, column: 0 };
- this.root = rbTreeBase_1.SENTINEL;
- this._lineCnt = 1;
- this._length = 0;
- this._EOL = eol;
- this._EOLLength = eol.length;
- this._EOLNormalized = eolNormalized;
- let lastNode = null;
- for (let i = 0, len = chunks.length; i < len; i++) {
- if (chunks[i].buffer.length > 0) {
- if (!chunks[i].lineStarts) {
- chunks[i].lineStarts = createLineStartsFast(chunks[i].buffer);
- }
- let piece = new Piece(i + 1, { line: 0, column: 0 }, { line: chunks[i].lineStarts.length - 1, column: chunks[i].buffer.length - chunks[i].lineStarts[chunks[i].lineStarts.length - 1] }, chunks[i].lineStarts.length - 1, chunks[i].buffer.length);
- this._buffers.push(chunks[i]);
- lastNode = this.rbInsertRight(lastNode, piece);
- }
- }
- this._searchCache = new PieceTreeSearchCache(1);
- this._lastVisitedLine = { lineNumber: 0, value: '' };
- this.computeBufferMetadata();
- }
- normalizeEOL(eol) {
- let averageBufferSize = exports.AverageBufferSize;
- let min = averageBufferSize - Math.floor(averageBufferSize / 3);
- let max = min * 2;
- let tempChunk = '';
- let tempChunkLen = 0;
- let chunks = [];
- this.iterate(this.root, node => {
- let str = this.getNodeContent(node);
- let len = str.length;
- if (tempChunkLen <= min || tempChunkLen + len < max) {
- tempChunk += str;
- tempChunkLen += len;
- return true;
- }
- // flush anyways
- let text = tempChunk.replace(/\r\n|\r|\n/g, eol);
- chunks.push(new StringBuffer(text, createLineStartsFast(text)));
- tempChunk = str;
- tempChunkLen = len;
- return true;
- });
- if (tempChunkLen > 0) {
- let text = tempChunk.replace(/\r\n|\r|\n/g, eol);
- chunks.push(new StringBuffer(text, createLineStartsFast(text)));
- }
- this.create(chunks, eol, true);
- }
- // #region Buffer API
- getEOL() {
- return this._EOL;
- }
- setEOL(newEOL) {
- this._EOL = newEOL;
- this._EOLLength = this._EOL.length;
- this.normalizeEOL(newEOL);
- }
- createSnapshot(BOM) {
- return new PieceTreeSnapshot(this, BOM);
- }
- equal(other) {
- if (this.getLength() !== other.getLength()) {
- return false;
- }
- if (this.getLineCount() !== other.getLineCount()) {
- return false;
- }
- let offset = 0;
- let ret = this.iterate(this.root, node => {
- if (node === rbTreeBase_1.SENTINEL) {
- return true;
- }
- let str = this.getNodeContent(node);
- let len = str.length;
- let startPosition = other.nodeAt(offset);
- let endPosition = other.nodeAt(offset + len);
- let val = other.getValueInRange2(startPosition, endPosition);
- return str === val;
- });
- return ret;
- }
- getOffsetAt(lineNumber, column) {
- let leftLen = 0; // inorder
- let x = this.root;
- while (x !== rbTreeBase_1.SENTINEL) {
- if (x.left !== rbTreeBase_1.SENTINEL && x.lf_left + 1 >= lineNumber) {
- x = x.left;
- }
- else if (x.lf_left + x.piece.lineFeedCnt + 1 >= lineNumber) {
- leftLen += x.size_left;
- // lineNumber >= 2
- let accumualtedValInCurrentIndex = this.getAccumulatedValue(x, lineNumber - x.lf_left - 2);
- return leftLen += accumualtedValInCurrentIndex + column - 1;
- }
- else {
- lineNumber -= x.lf_left + x.piece.lineFeedCnt;
- leftLen += x.size_left + x.piece.length;
- x = x.right;
- }
- }
- return leftLen;
- }
- getPositionAt(offset) {
- offset = Math.floor(offset);
- offset = Math.max(0, offset);
- let x = this.root;
- let lfCnt = 0;
- let originalOffset = offset;
- while (x !== rbTreeBase_1.SENTINEL) {
- if (x.size_left !== 0 && x.size_left >= offset) {
- x = x.left;
- }
- else if (x.size_left + x.piece.length >= offset) {
- let out = this.getIndexOf(x, offset - x.size_left);
- lfCnt += x.lf_left + out.index;
- if (out.index === 0) {
- let lineStartOffset = this.getOffsetAt(lfCnt + 1, 1);
- let column = originalOffset - lineStartOffset;
- return new position_1.Position(lfCnt + 1, column + 1);
- }
- return new position_1.Position(lfCnt + 1, out.remainder + 1);
- }
- else {
- offset -= x.size_left + x.piece.length;
- lfCnt += x.lf_left + x.piece.lineFeedCnt;
- if (x.right === rbTreeBase_1.SENTINEL) {
- // last node
- let lineStartOffset = this.getOffsetAt(lfCnt + 1, 1);
- let column = originalOffset - offset - lineStartOffset;
- return new position_1.Position(lfCnt + 1, column + 1);
- }
- else {
- x = x.right;
- }
- }
- }
- return new position_1.Position(1, 1);
- }
- getValueInRange(range, eol) {
- if (range.startLineNumber === range.endLineNumber && range.startColumn === range.endColumn) {
- return '';
- }
- let startPosition = this.nodeAt2(range.startLineNumber, range.startColumn);
- let endPosition = this.nodeAt2(range.endLineNumber, range.endColumn);
- let value = this.getValueInRange2(startPosition, endPosition);
- if (eol) {
- if (eol !== this._EOL || !this._EOLNormalized) {
- return value.replace(/\r\n|\r|\n/g, eol);
- }
- if (eol === this.getEOL() && this._EOLNormalized) {
- if (eol === '\r\n') {
- }
- return value;
- }
- return value.replace(/\r\n|\r|\n/g, eol);
- }
- return value;
- }
- getValueInRange2(startPosition, endPosition) {
- if (startPosition.node === endPosition.node) {
- let node = startPosition.node;
- let buffer = this._buffers[node.piece.bufferIndex].buffer;
- let startOffset = this.offsetInBuffer(node.piece.bufferIndex, node.piece.start);
- return buffer.substring(startOffset + startPosition.remainder, startOffset + endPosition.remainder);
- }
- let x = startPosition.node;
- let buffer = this._buffers[x.piece.bufferIndex].buffer;
- let startOffset = this.offsetInBuffer(x.piece.bufferIndex, x.piece.start);
- let ret = buffer.substring(startOffset + startPosition.remainder, startOffset + x.piece.length);
- x = x.next();
- while (x !== rbTreeBase_1.SENTINEL) {
- let buffer = this._buffers[x.piece.bufferIndex].buffer;
- let startOffset = this.offsetInBuffer(x.piece.bufferIndex, x.piece.start);
- if (x === endPosition.node) {
- ret += buffer.substring(startOffset, startOffset + endPosition.remainder);
- break;
- }
- else {
- ret += buffer.substr(startOffset, x.piece.length);
- }
- x = x.next();
- }
- return ret;
- }
- getLinesContent() {
- return this.getContentOfSubTree(this.root).split(/\r\n|\r|\n/);
- }
- getLength() {
- return this._length;
- }
- getLineCount() {
- return this._lineCnt;
- }
- /**
- * @param lineNumber 1 based
- */
- getLineContent(lineNumber) {
- if (this._lastVisitedLine.lineNumber === lineNumber) {
- return this._lastVisitedLine.value;
- }
- this._lastVisitedLine.lineNumber = lineNumber;
- if (lineNumber === this._lineCnt) {
- this._lastVisitedLine.value = this.getLineRawContent(lineNumber);
- }
- else if (this._EOLNormalized) {
- this._lastVisitedLine.value = this.getLineRawContent(lineNumber, this._EOLLength);
- }
- else {
- this._lastVisitedLine.value = this.getLineRawContent(lineNumber).replace(/(\r\n|\r|\n)$/, '');
- }
- return this._lastVisitedLine.value;
- }
- getLineCharCode(lineNumber, index) {
- let nodePos = this.nodeAt2(lineNumber, index + 1);
- if (nodePos.remainder === nodePos.node.piece.length) {
- // the char we want to fetch is at the head of next node.
- let matchingNode = nodePos.node.next();
- if (!matchingNode) {
- return 0;
- }
- let buffer = this._buffers[matchingNode.piece.bufferIndex];
- let startOffset = this.offsetInBuffer(matchingNode.piece.bufferIndex, matchingNode.piece.start);
- return buffer.buffer.charCodeAt(startOffset);
- }
- else {
- let buffer = this._buffers[nodePos.node.piece.bufferIndex];
- let startOffset = this.offsetInBuffer(nodePos.node.piece.bufferIndex, nodePos.node.piece.start);
- let targetOffset = startOffset + nodePos.remainder;
- return buffer.buffer.charCodeAt(targetOffset);
- }
- }
- getLineLength(lineNumber) {
- if (lineNumber === this.getLineCount()) {
- let startOffset = this.getOffsetAt(lineNumber, 1);
- return this.getLength() - startOffset;
- }
- return this.getOffsetAt(lineNumber + 1, 1) - this.getOffsetAt(lineNumber, 1) - this._EOLLength;
- }
- // #endregion
- // #region Piece Table
- insert(offset, value, eolNormalized = false) {
- this._EOLNormalized = this._EOLNormalized && eolNormalized;
- this._lastVisitedLine.lineNumber = 0;
- this._lastVisitedLine.value = '';
- if (this.root !== rbTreeBase_1.SENTINEL) {
- let { node, remainder, nodeStartOffset } = this.nodeAt(offset);
- let piece = node.piece;
- let bufferIndex = piece.bufferIndex;
- let insertPosInBuffer = this.positionInBuffer(node, remainder);
- if (node.piece.bufferIndex === 0 &&
- piece.end.line === this._lastChangeBufferPos.line &&
- piece.end.column === this._lastChangeBufferPos.column &&
- (nodeStartOffset + piece.length === offset) &&
- value.length < exports.AverageBufferSize) {
- // changed buffer
- this.appendToNode(node, value);
- this.computeBufferMetadata();
- return;
- }
- if (nodeStartOffset === offset) {
- this.insertContentToNodeLeft(value, node);
- this._searchCache.valdiate(offset);
- }
- else if (nodeStartOffset + node.piece.length > offset) {
- // we are inserting into the middle of a node.
- let nodesToDel = [];
- let newRightPiece = new Piece(piece.bufferIndex, insertPosInBuffer, piece.end, this.getLineFeedCnt(piece.bufferIndex, insertPosInBuffer, piece.end), this.offsetInBuffer(bufferIndex, piece.end) - this.offsetInBuffer(bufferIndex, insertPosInBuffer));
- if (this.shouldCheckCRLF() && this.endWithCR(value)) {
- let headOfRight = this.nodeCharCodeAt(node, remainder);
- if (headOfRight === 10 /** \n */) {
- let newStart = { line: newRightPiece.start.line + 1, column: 0 };
- newRightPiece = new Piece(newRightPiece.bufferIndex, newStart, newRightPiece.end, this.getLineFeedCnt(newRightPiece.bufferIndex, newStart, newRightPiece.end), newRightPiece.length - 1);
- value += '\n';
- }
- }
- // reuse node for content before insertion point.
- if (this.shouldCheckCRLF() && this.startWithLF(value)) {
- let tailOfLeft = this.nodeCharCodeAt(node, remainder - 1);
- if (tailOfLeft === 13 /** \r */) {
- let previousPos = this.positionInBuffer(node, remainder - 1);
- this.deleteNodeTail(node, previousPos);
- value = '\r' + value;
- if (node.piece.length === 0) {
- nodesToDel.push(node);
- }
- }
- else {
- this.deleteNodeTail(node, insertPosInBuffer);
- }
- }
- else {
- this.deleteNodeTail(node, insertPosInBuffer);
- }
- let newPieces = this.createNewPieces(value);
- if (newRightPiece.length > 0) {
- this.rbInsertRight(node, newRightPiece);
- }
- let tmpNode = node;
- for (let k = 0; k < newPieces.length; k++) {
- tmpNode = this.rbInsertRight(tmpNode, newPieces[k]);
- }
- this.deleteNodes(nodesToDel);
- }
- else {
- this.insertContentToNodeRight(value, node);
- }
- }
- else {
- // insert new node
- let pieces = this.createNewPieces(value);
- let node = this.rbInsertLeft(null, pieces[0]);
- for (let k = 1; k < pieces.length; k++) {
- node = this.rbInsertRight(node, pieces[k]);
- }
- }
- // todo, this is too brutal. Total line feed count should be updated the same way as lf_left.
- this.computeBufferMetadata();
- }
- delete(offset, cnt) {
- this._lastVisitedLine.lineNumber = 0;
- this._lastVisitedLine.value = '';
- if (cnt <= 0 || this.root === rbTreeBase_1.SENTINEL) {
- return;
- }
- let startPosition = this.nodeAt(offset);
- let endPosition = this.nodeAt(offset + cnt);
- let startNode = startPosition.node;
- let endNode = endPosition.node;
- if (startNode === endNode) {
- let startSplitPosInBuffer = this.positionInBuffer(startNode, startPosition.remainder);
- let endSplitPosInBuffer = this.positionInBuffer(startNode, endPosition.remainder);
- if (startPosition.nodeStartOffset === offset) {
- if (cnt === startNode.piece.length) { // delete node
- let next = startNode.next();
- rbTreeBase_1.rbDelete(this, startNode);
- this.validateCRLFWithPrevNode(next);
- this.computeBufferMetadata();
- return;
- }
- this.deleteNodeHead(startNode, endSplitPosInBuffer);
- this._searchCache.valdiate(offset);
- this.validateCRLFWithPrevNode(startNode);
- this.computeBufferMetadata();
- return;
- }
- if (startPosition.nodeStartOffset + startNode.piece.length === offset + cnt) {
- this.deleteNodeTail(startNode, startSplitPosInBuffer);
- this.validateCRLFWithNextNode(startNode);
- this.computeBufferMetadata();
- return;
- }
- // delete content in the middle, this node will be splitted to nodes
- this.shrinkNode(startNode, startSplitPosInBuffer, endSplitPosInBuffer);
- this.computeBufferMetadata();
- return;
- }
- let nodesToDel = [];
- let startSplitPosInBuffer = this.positionInBuffer(startNode, startPosition.remainder);
- this.deleteNodeTail(startNode, startSplitPosInBuffer);
- this._searchCache.valdiate(offset);
- if (startNode.piece.length === 0) {
- nodesToDel.push(startNode);
- }
- // update last touched node
- let endSplitPosInBuffer = this.positionInBuffer(endNode, endPosition.remainder);
- this.deleteNodeHead(endNode, endSplitPosInBuffer);
- if (endNode.piece.length === 0) {
- nodesToDel.push(endNode);
- }
- // delete nodes in between
- let secondNode = startNode.next();
- for (let node = secondNode; node !== rbTreeBase_1.SENTINEL && node !== endNode; node = node.next()) {
- nodesToDel.push(node);
- }
- let prev = startNode.piece.length === 0 ? startNode.prev() : startNode;
- this.deleteNodes(nodesToDel);
- this.validateCRLFWithNextNode(prev);
- this.computeBufferMetadata();
- }
- insertContentToNodeLeft(value, node) {
- // we are inserting content to the beginning of node
- let nodesToDel = [];
- if (this.shouldCheckCRLF() && this.endWithCR(value) && this.startWithLF(node)) {
- // move `\n` to new node.
- let piece = node.piece;
- let newStart = { line: piece.start.line + 1, column: 0 };
- let nPiece = new Piece(piece.bufferIndex, newStart, piece.end, this.getLineFeedCnt(piece.bufferIndex, newStart, piece.end), piece.length - 1);
- node.piece = nPiece;
- value += '\n';
- rbTreeBase_1.updateTreeMetadata(this, node, -1, -1);
- if (node.piece.length === 0) {
- nodesToDel.push(node);
- }
- }
- let newPieces = this.createNewPieces(value);
- let newNode = this.rbInsertLeft(node, newPieces[newPieces.length - 1]);
- for (let k = newPieces.length - 2; k >= 0; k--) {
- newNode = this.rbInsertLeft(newNode, newPieces[k]);
- }
- this.validateCRLFWithPrevNode(newNode);
- this.deleteNodes(nodesToDel);
- }
- insertContentToNodeRight(value, node) {
- // we are inserting to the right of this node.
- if (this.adjustCarriageReturnFromNext(value, node)) {
- // move \n to the new node.
- value += '\n';
- }
- let newPieces = this.createNewPieces(value);
- let newNode = this.rbInsertRight(node, newPieces[0]);
- let tmpNode = newNode;
- for (let k = 1; k < newPieces.length; k++) {
- tmpNode = this.rbInsertRight(tmpNode, newPieces[k]);
- }
- this.validateCRLFWithPrevNode(newNode);
- }
- positionInBuffer(node, remainder, ret) {
- let piece = node.piece;
- let bufferIndex = node.piece.bufferIndex;
- let lineStarts = this._buffers[bufferIndex].lineStarts;
- let startOffset = lineStarts[piece.start.line] + piece.start.column;
- let offset = startOffset + remainder;
- // binary search offset between startOffset and endOffset
- let low = piece.start.line;
- let high = piece.end.line;
- let mid = 0;
- let midStop = 0;
- let midStart = 0;
- while (low <= high) {
- mid = low + ((high - low) / 2) | 0;
- midStart = lineStarts[mid];
- if (mid === high) {
- break;
- }
- midStop = lineStarts[mid + 1];
- if (offset < midStart) {
- high = mid - 1;
- }
- else if (offset >= midStop) {
- low = mid + 1;
- }
- else {
- break;
- }
- }
- if (ret) {
- ret.line = mid;
- ret.column = offset - midStart;
- return null;
- }
- return {
- line: mid,
- column: offset - midStart
- };
- }
- getLineFeedCnt(bufferIndex, start, end) {
- // we don't need to worry about start: abc\r|\n, or abc|\r, or abc|\n, or abc|\r\n doesn't change the fact that, there is one line break after start.
- // now let's take care of end: abc\r|\n, if end is in between \r and \n, we need to add line feed count by 1
- if (end.column === 0) {
- return end.line - start.line;
- }
- let lineStarts = this._buffers[bufferIndex].lineStarts;
- if (end.line === lineStarts.length - 1) { // it means, there is no \n after end, otherwise, there will be one more lineStart.
- return end.line - start.line;
- }
- let nextLineStartOffset = lineStarts[end.line + 1];
- let endOffset = lineStarts[end.line] + end.column;
- if (nextLineStartOffset > endOffset + 1) { // there are more than 1 character after end, which means it can't be \n
- return end.line - start.line;
- }
- // endOffset + 1 === nextLineStartOffset
- // character at endOffset is \n, so we check the character before first
- // if character at endOffset is \r, end.column is 0 and we can't get here.
- let previousCharOffset = endOffset - 1; // end.column > 0 so it's okay.
- let buffer = this._buffers[bufferIndex].buffer;
- if (buffer.charCodeAt(previousCharOffset) === 13) {
- return end.line - start.line + 1;
- }
- else {
- return end.line - start.line;
- }
- }
- offsetInBuffer(bufferIndex, cursor) {
- let lineStarts = this._buffers[bufferIndex].lineStarts;
- return lineStarts[cursor.line] + cursor.column;
- }
- deleteNodes(nodes) {
- for (let i = 0; i < nodes.length; i++) {
- rbTreeBase_1.rbDelete(this, nodes[i]);
- }
- }
- createNewPieces(text) {
- if (text.length > exports.AverageBufferSize) {
- // the content is large, operations like substring, charCode becomes slow
- // so here we split it into smaller chunks, just like what we did for CR/LF normalization
- let newPieces = [];
- while (text.length > exports.AverageBufferSize) {
- const lastChar = text.charCodeAt(exports.AverageBufferSize - 1);
- let splitText;
- if (lastChar === 13 /* CarriageReturn */ || (lastChar >= 0xD800 && lastChar <= 0xDBFF)) {
- // last character is \r or a high surrogate => keep it back
- splitText = text.substring(0, exports.AverageBufferSize - 1);
- text = text.substring(exports.AverageBufferSize - 1);
- }
- else {
- splitText = text.substring(0, exports.AverageBufferSize);
- text = text.substring(exports.AverageBufferSize);
- }
- let lineStarts = createLineStartsFast(splitText);
- newPieces.push(new Piece(this._buffers.length, /* buffer index */ { line: 0, column: 0 }, { line: lineStarts.length - 1, column: splitText.length - lineStarts[lineStarts.length - 1] }, lineStarts.length - 1, splitText.length));
- this._buffers.push(new StringBuffer(splitText, lineStarts));
- }
- let lineStarts = createLineStartsFast(text);
- newPieces.push(new Piece(this._buffers.length, /* buffer index */ { line: 0, column: 0 }, { line: lineStarts.length - 1, column: text.length - lineStarts[lineStarts.length - 1] }, lineStarts.length - 1, text.length));
- this._buffers.push(new StringBuffer(text, lineStarts));
- return newPieces;
- }
- let startOffset = this._buffers[0].buffer.length;
- const lineStarts = createLineStartsFast(text, false);
- let start = this._lastChangeBufferPos;
- if (this._buffers[0].lineStarts[this._buffers[0].lineStarts.length - 1] === startOffset
- && startOffset !== 0
- && this.startWithLF(text)
- && this.endWithCR(this._buffers[0].buffer) // todo, we can check this._lastChangeBufferPos's column as it's the last one
- ) {
- this._lastChangeBufferPos = { line: this._lastChangeBufferPos.line, column: this._lastChangeBufferPos.column + 1 };
- start = this._lastChangeBufferPos;
- for (let i = 0; i < lineStarts.length; i++) {
- lineStarts[i] += startOffset + 1;
- }
- this._buffers[0].lineStarts = this._buffers[0].lineStarts.concat(lineStarts.slice(1));
- this._buffers[0].buffer += '_' + text;
- startOffset += 1;
- }
- else {
- if (startOffset !== 0) {
- for (let i = 0; i < lineStarts.length; i++) {
- lineStarts[i] += startOffset;
- }
- }
- this._buffers[0].lineStarts = this._buffers[0].lineStarts.concat(lineStarts.slice(1));
- this._buffers[0].buffer += text;
- }
- const endOffset = this._buffers[0].buffer.length;
- let endIndex = this._buffers[0].lineStarts.length - 1;
- let endColumn = endOffset - this._buffers[0].lineStarts[endIndex];
- let endPos = { line: endIndex, column: endColumn };
- let newPiece = new Piece(0, /** todo@peng */ start, endPos, this.getLineFeedCnt(0, start, endPos), endOffset - startOffset);
- this._lastChangeBufferPos = endPos;
- return [newPiece];
- }
- getLinesRawContent() {
- return this.getContentOfSubTree(this.root);
- }
- getLineRawContent(lineNumber, endOffset = 0) {
- let x = this.root;
- let ret = '';
- let cache = this._searchCache.get2(lineNumber);
- if (cache) {
- x = cache.node;
- let prevAccumualtedValue = this.getAccumulatedValue(x, lineNumber - cache.nodeStartLineNumber - 1);
- let buffer = this._buffers[x.piece.bufferIndex].buffer;
- let startOffset = this.offsetInBuffer(x.piece.bufferIndex, x.piece.start);
- if (cache.nodeStartLineNumber + x.piece.lineFeedCnt === lineNumber) {
- ret = buffer.substring(startOffset + prevAccumualtedValue, startOffset + x.piece.length);
- }
- else {
- let accumualtedValue = this.getAccumulatedValue(x, lineNumber - cache.nodeStartLineNumber);
- return buffer.substring(startOffset + prevAccumualtedValue, startOffset + accumualtedValue - endOffset);
- }
- }
- else {
- let nodeStartOffset = 0;
- const originalLineNumber = lineNumber;
- while (x !== rbTreeBase_1.SENTINEL) {
- if (x.left !== rbTreeBase_1.SENTINEL && x.lf_left >= lineNumber - 1) {
- x = x.left;
- }
- else if (x.lf_left + x.piece.lineFeedCnt > lineNumber - 1) {
- let prevAccumualtedValue = this.getAccumulatedValue(x, lineNumber - x.lf_left - 2);
- let accumualtedValue = this.getAccumulatedValue(x, lineNumber - x.lf_left - 1);
- let buffer = this._buffers[x.piece.bufferIndex].buffer;
- let startOffset = this.offsetInBuffer(x.piece.bufferIndex, x.piece.start);
- nodeStartOffset += x.size_left;
- this._searchCache.set({
- node: x,
- nodeStartOffset,
- nodeStartLineNumber: originalLineNumber - (lineNumber - 1 - x.lf_left)
- });
- return buffer.substring(startOffset + prevAccumualtedValue, startOffset + accumualtedValue - endOffset);
- }
- else if (x.lf_left + x.piece.lineFeedCnt === lineNumber - 1) {
- let prevAccumualtedValue = this.getAccumulatedValue(x, lineNumber - x.lf_left - 2);
- let buffer = this._buffers[x.piece.bufferIndex].buffer;
- let startOffset = this.offsetInBuffer(x.piece.bufferIndex, x.piece.start);
- ret = buffer.substring(startOffset + prevAccumualtedValue, startOffset + x.piece.length);
- break;
- }
- else {
- lineNumber -= x.lf_left + x.piece.lineFeedCnt;
- nodeStartOffset += x.size_left + x.piece.length;
- x = x.right;
- }
- }
- }
- // search in order, to find the node contains end column
- x = x.next();
- while (x !== rbTreeBase_1.SENTINEL) {
- let buffer = this._buffers[x.piece.bufferIndex].buffer;
- if (x.piece.lineFeedCnt > 0) {
- let accumualtedValue = this.getAccumulatedValue(x, 0);
- let startOffset = this.offsetInBuffer(x.piece.bufferIndex, x.piece.start);
- ret += buffer.substring(startOffset, startOffset + accumualtedValue - endOffset);
- return ret;
- }
- else {
- let startOffset = this.offsetInBuffer(x.piece.bufferIndex, x.piece.start);
- ret += buffer.substr(startOffset, x.piece.length);
- }
- x = x.next();
- }
- return ret;
- }
- computeBufferMetadata() {
- let x = this.root;
- let lfCnt = 1;
- let len = 0;
- while (x !== rbTreeBase_1.SENTINEL) {
- lfCnt += x.lf_left + x.piece.lineFeedCnt;
- len += x.size_left + x.piece.length;
- x = x.right;
- }
- this._lineCnt = lfCnt;
- this._length = len;
- this._searchCache.valdiate(this._length);
- }
- // #region node operations
- getIndexOf(node, accumulatedValue) {
- let piece = node.piece;
- let pos = this.positionInBuffer(node, accumulatedValue);
- let lineCnt = pos.line - piece.start.line;
- if (this.offsetInBuffer(piece.bufferIndex, piece.end) - this.offsetInBuffer(piece.bufferIndex, piece.start) === accumulatedValue) {
- // we are checking the end of this node, so a CRLF check is necessary.
- let realLineCnt = this.getLineFeedCnt(node.piece.bufferIndex, piece.start, pos);
- if (realLineCnt !== lineCnt) {
- // aha yes, CRLF
- return { index: realLineCnt, remainder: 0 };
- }
- }
- return { index: lineCnt, remainder: pos.column };
- }
- getAccumulatedValue(node, index) {
- if (index < 0) {
- return 0;
- }
- let piece = node.piece;
- let lineStarts = this._buffers[piece.bufferIndex].lineStarts;
- let expectedLineStartIndex = piece.start.line + index + 1;
- if (expectedLineStartIndex > piece.end.line) {
- return lineStarts[piece.end.line] + piece.end.column - lineStarts[piece.start.line] - piece.start.column;
- }
- else {
- return lineStarts[expectedLineStartIndex] - lineStarts[piece.start.line] - piece.start.column;
- }
- }
- deleteNodeTail(node, pos) {
- const piece = node.piece;
- const originalLFCnt = piece.lineFeedCnt;
- const originalEndOffset = this.offsetInBuffer(piece.bufferIndex, piece.end);
- const newEnd = pos;
- const newEndOffset = this.offsetInBuffer(piece.bufferIndex, newEnd);
- const newLineFeedCnt = this.getLineFeedCnt(piece.bufferIndex, piece.start, newEnd);
- const lf_delta = newLineFeedCnt - originalLFCnt;
- const size_delta = newEndOffset - originalEndOffset;
- const newLength = piece.length + size_delta;
- node.piece = new Piece(piece.bufferIndex, piece.start, newEnd, newLineFeedCnt, newLength);
- rbTreeBase_1.updateTreeMetadata(this, node, size_delta, lf_delta);
- }
- deleteNodeHead(node, pos) {
- const piece = node.piece;
- const originalLFCnt = piece.lineFeedCnt;
- const originalStartOffset = this.offsetInBuffer(piece.bufferIndex, piece.start);
- const newStart = pos;
- const newLineFeedCnt = this.getLineFeedCnt(piece.bufferIndex, newStart, piece.end);
- const newStartOffset = this.offsetInBuffer(piece.bufferIndex, newStart);
- const lf_delta = newLineFeedCnt - originalLFCnt;
- const size_delta = originalStartOffset - newStartOffset;
- const newLength = piece.length + size_delta;
- node.piece = new Piece(piece.bufferIndex, newStart, piece.end, newLineFeedCnt, newLength);
- rbTreeBase_1.updateTreeMetadata(this, node, size_delta, lf_delta);
- }
- shrinkNode(node, start, end) {
- const piece = node.piece;
- const originalStartPos = piece.start;
- const originalEndPos = piece.end;
- // old piece, originalStartPos, start
- const oldLength = piece.length;
- const oldLFCnt = piece.lineFeedCnt;
- const newEnd = start;
- const newLineFeedCnt = this.getLineFeedCnt(piece.bufferIndex, piece.start, newEnd);
- const newLength = this.offsetInBuffer(piece.bufferIndex, start) - this.offsetInBuffer(piece.bufferIndex, originalStartPos);
- node.piece = new Piece(piece.bufferIndex, piece.start, newEnd, newLineFeedCnt, newLength);
- rbTreeBase_1.updateTreeMetadata(this, node, newLength - oldLength, newLineFeedCnt - oldLFCnt);
- // new right piece, end, originalEndPos
- let newPiece = new Piece(piece.bufferIndex, end, originalEndPos, this.getLineFeedCnt(piece.bufferIndex, end, originalEndPos), this.offsetInBuffer(piece.bufferIndex, originalEndPos) - this.offsetInBuffer(piece.bufferIndex, end));
- let newNode = this.rbInsertRight(node, newPiece);
- this.validateCRLFWithPrevNode(newNode);
- }
- appendToNode(node, value) {
- if (this.adjustCarriageReturnFromNext(value, node)) {
- value += '\n';
- }
- const hitCRLF = this.shouldCheckCRLF() && this.startWithLF(value) && this.endWithCR(node);
- const startOffset = this._buffers[0].buffer.length;
- this._buffers[0].buffer += value;
- const lineStarts = createLineStartsFast(value, false);
- for (let i = 0; i < lineStarts.length; i++) {
- lineStarts[i] += startOffset;
- }
- if (hitCRLF) {
- let prevStartOffset = this._buffers[0].lineStarts[this._buffers[0].lineStarts.length - 2];
- this._buffers[0].lineStarts.pop();
- // _lastChangeBufferPos is already wrong
- this._lastChangeBufferPos = { line: this._lastChangeBufferPos.line - 1, column: startOffset - prevStartOffset };
- }
- this._buffers[0].lineStarts = this._buffers[0].lineStarts.concat(lineStarts.slice(1));
- const endIndex = this._buffers[0].lineStarts.length - 1;
- const endColumn = this._buffers[0].buffer.length - this._buffers[0].lineStarts[endIndex];
- const newEnd = { line: endIndex, column: endColumn };
- const newLength = node.piece.length + value.length;
- const oldLineFeedCnt = node.piece.lineFeedCnt;
- const newLineFeedCnt = this.getLineFeedCnt(0, node.piece.start, newEnd);
- const lf_delta = newLineFeedCnt - oldLineFeedCnt;
- node.piece = new Piece(node.piece.bufferIndex, node.piece.start, newEnd, newLineFeedCnt, newLength);
- this._lastChangeBufferPos = newEnd;
- rbTreeBase_1.updateTreeMetadata(this, node, value.length, lf_delta);
- }
- nodeAt(offset) {
- let x = this.root;
- let cache = this._searchCache.get(offset);
- if (cache) {
- return {
- node: cache.node,
- nodeStartOffset: cache.nodeStartOffset,
- remainder: offset - cache.nodeStartOffset
- };
- }
- let nodeStartOffset = 0;
- while (x !== rbTreeBase_1.SENTINEL) {
- if (x.size_left > offset) {
- x = x.left;
- }
- else if (x.size_left + x.piece.length >= offset) {
- nodeStartOffset += x.size_left;
- let ret = {
- node: x,
- remainder: offset - x.size_left,
- nodeStartOffset
- };
- this._searchCache.set(ret);
- return ret;
- }
- else {
- offset -= x.size_left + x.piece.length;
- nodeStartOffset += x.size_left + x.piece.length;
- x = x.right;
- }
- }
- return null;
- }
- nodeAt2(lineNumber, column) {
- let x = this.root;
- let nodeStartOffset = 0;
- while (x !== rbTreeBase_1.SENTINEL) {
- if (x.left !== rbTreeBase_1.SENTINEL && x.lf_left >= lineNumber - 1) {
- x = x.left;
- }
- else if (x.lf_left + x.piece.lineFeedCnt > lineNumber - 1) {
- let prevAccumualtedValue = this.getAccumulatedValue(x, lineNumber - x.lf_left - 2);
- let accumualtedValue = this.getAccumulatedValue(x, lineNumber - x.lf_left - 1);
- nodeStartOffset += x.size_left;
- return {
- node: x,
- remainder: Math.min(prevAccumualtedValue + column - 1, accumualtedValue),
- nodeStartOffset
- };
- }
- else if (x.lf_left + x.piece.lineFeedCnt === lineNumber - 1) {
- let prevAccumualtedValue = this.getAccumulatedValue(x, lineNumber - x.lf_left - 2);
- if (prevAccumualtedValue + column - 1 <= x.piece.length) {
- return {
- node: x,
- remainder: prevAccumualtedValue + column - 1,
- nodeStartOffset
- };
- }
- else {
- column -= x.piece.length - prevAccumualtedValue;
- break;
- }
- }
- else {
- lineNumber -= x.lf_left + x.piece.lineFeedCnt;
- nodeStartOffset += x.size_left + x.piece.length;
- x = x.right;
- }
- }
- // search in order, to find the node contains position.column
- x = x.next();
- while (x !== rbTreeBase_1.SENTINEL) {
- if (x.piece.lineFeedCnt > 0) {
- let accumualtedValue = this.getAccumulatedValue(x, 0);
- let nodeStartOffset = this.offsetOfNode(x);
- return {
- node: x,
- remainder: Math.min(column - 1, accumualtedValue),
- nodeStartOffset
- };
- }
- else {
- if (x.piece.length >= column - 1) {
- let nodeStartOffset = this.offsetOfNode(x);
- return {
- node: x,
- remainder: column - 1,
- nodeStartOffset
- };
- }
- else {
- column -= x.piece.length;
- }
- }
- x = x.next();
- }
- return null;
- }
- nodeCharCodeAt(node, offset) {
- if (node.piece.lineFeedCnt < 1) {
- return -1;
- }
- let buffer = this._buffers[node.piece.bufferIndex];
- let newOffset = this.offsetInBuffer(node.piece.bufferIndex, node.piece.start) + offset;
- return buffer.buffer.charCodeAt(newOffset);
- }
- offsetOfNode(node) {
- if (!node) {
- return 0;
- }
- let pos = node.size_left;
- while (node !== this.root) {
- if (node.parent.right === node) {
- pos += node.parent.size_left + node.parent.piece.length;
- }
- node = node.parent;
- }
- return pos;
- }
- // #endregion
- // #region CRLF
- shouldCheckCRLF() {
- return !(this._EOLNormalized && this._EOL === '\n');
- }
- startWithLF(val) {
- if (typeof val === 'string') {
- return val.charCodeAt(0) === 10;
- }
- if (val === rbTreeBase_1.SENTINEL || val.piece.lineFeedCnt === 0) {
- return false;
- }
- let piece = val.piece;
- let lineStarts = this._buffers[piece.bufferIndex].lineStarts;
- let line = piece.start.line;
- let startOffset = lineStarts[line] + piece.start.column;
- if (line === lineStarts.length - 1) {
- // last line, so there is no line feed at the end of this line
- return false;
- }
- let nextLineOffset = lineStarts[line + 1];
- if (nextLineOffset > startOffset + 1) {
- return false;
- }
- return this._buffers[piece.bufferIndex].buffer.charCodeAt(startOffset) === 10;
- }
- endWithCR(val) {
- if (typeof val === 'string') {
- return val.charCodeAt(val.length - 1) === 13;
- }
- if (val === rbTreeBase_1.SENTINEL || val.piece.lineFeedCnt === 0) {
- return false;
- }
- return this.nodeCharCodeAt(val, val.piece.length - 1) === 13;
- }
- validateCRLFWithPrevNode(nextNode) {
- if (this.shouldCheckCRLF() && this.startWithLF(nextNode)) {
- let node = nextNode.prev();
- if (this.endWithCR(node)) {
- this.fixCRLF(node, nextNode);
- }
- }
- }
- validateCRLFWithNextNode(node) {
- if (this.shouldCheckCRLF() && this.endWithCR(node)) {
- let nextNode = node.next();
- if (this.startWithLF(nextNode)) {
- this.fixCRLF(node, nextNode);
- }
- }
- }
- fixCRLF(prev, next) {
- let nodesToDel = [];
- // update node
- let lineStarts = this._buffers[prev.piece.bufferIndex].lineStarts;
- let newEnd;
- if (prev.piece.end.column === 0) {
- // it means, last line ends with \r, not \r\n
- newEnd = { line: prev.piece.end.line - 1, column: lineStarts[prev.piece.end.line] - lineStarts[prev.piece.end.line - 1] - 1 };
- }
- else {
- // \r\n
- newEnd = { line: prev.piece.end.line, column: prev.piece.end.column - 1 };
- }
- const prevNewLength = prev.piece.length - 1;
- const prevNewLFCnt = prev.piece.lineFeedCnt - 1;
- prev.piece = new Piece(prev.piece.bufferIndex, prev.piece.start, newEnd, prevNewLFCnt, prevNewLength);
- rbTreeBase_1.updateTreeMetadata(this, prev, -1, -1);
- if (prev.piece.length === 0) {
- nodesToDel.push(prev);
- }
- // update nextNode
- let newStart = { line: next.piece.start.line + 1, column: 0 };
- const newLength = next.piece.length - 1;
- const newLineFeedCnt = this.getLineFeedCnt(next.piece.bufferIndex, newStart, next.piece.end);
- next.piece = new Piece(next.piece.bufferIndex, newStart, next.piece.end, newLineFeedCnt, newLength);
- rbTreeBase_1.updateTreeMetadata(this, next, -1, -1);
- if (next.piece.length === 0) {
- nodesToDel.push(next);
- }
- // create new piece which contains \r\n
- let pieces = this.createNewPieces('\r\n');
- this.rbInsertRight(prev, pieces[0]);
- // delete empty nodes
- for (let i = 0; i < nodesToDel.length; i++) {
- rbTreeBase_1.rbDelete(this, nodesToDel[i]);
- }
- }
- adjustCarriageReturnFromNext(value, node) {
- if (this.shouldCheckCRLF() && this.endWithCR(value)) {
- let nextNode = node.next();
- if (this.startWithLF(nextNode)) {
- // move `\n` forward
- value += '\n';
- if (nextNode.piece.length === 1) {
- rbTreeBase_1.rbDelete(this, nextNode);
- }
- else {
- const piece = nextNode.piece;
- const newStart = { line: piece.start.line + 1, column: 0 };
- const newLength = piece.length - 1;
- const newLineFeedCnt = this.getLineFeedCnt(piece.bufferIndex, newStart, piece.end);
- nextNode.piece = new Piece(piece.bufferIndex, newStart, piece.end, newLineFeedCnt, newLength);
- rbTreeBase_1.updateTreeMetadata(this, nextNode, -1, -1);
- }
- return true;
- }
- }
- return false;
- }
- // #endregion
- // #endregion
- // #region Tree operations
- iterate(node, callback) {
- if (node === rbTreeBase_1.SENTINEL) {
- return callback(rbTreeBase_1.SENTINEL);
- }
- let leftRet = this.iterate(node.left, callback);
- if (!leftRet) {
- return leftRet;
- }
- return callback(node) && this.iterate(node.right, callback);
- }
- getNodeContent(node) {
- if (node === rbTreeBase_1.SENTINEL) {
- return '';
- }
- let buffer = this._buffers[node.piece.bufferIndex];
- let currentContent;
- let piece = node.piece;
- let startOffset = this.offsetInBuffer(piece.bufferIndex, piece.start);
- let endOffset = this.offsetInBuffer(piece.bufferIndex, piece.end);
- currentContent = buffer.buffer.substring(startOffset, endOffset);
- return currentContent;
- }
- getPieceContent(piece) {
- let buffer = this._buffers[piece.bufferIndex];
- let startOffset = this.offsetInBuffer(piece.bufferIndex, piece.start);
- let endOffset = this.offsetInBuffer(piece.bufferIndex, piece.end);
- let currentContent = buffer.buffer.substring(startOffset, endOffset);
- return currentContent;
- }
- /**
- * node node
- * / \ / \
- * a b <---- a b
- * /
- * z
- */
- rbInsertRight(node, p) {
- let z = new rbTreeBase_1.TreeNode(p, 1 /* Red */);
- z.left = rbTreeBase_1.SENTINEL;
- z.right = rbTreeBase_1.SENTINEL;
- z.parent = rbTreeBase_1.SENTINEL;
- z.size_left = 0;
- z.lf_left = 0;
- let x = this.root;
- if (x === rbTreeBase_1.SENTINEL) {
- this.root = z;
- z.color = 0 /* Black */;
- }
- else if (node.right === rbTreeBase_1.SENTINEL) {
- node.right = z;
- z.parent = node;
- }
- else {
- let nextNode = rbTreeBase_1.leftest(node.right);
- nextNode.left = z;
- z.parent = nextNode;
- }
- rbTreeBase_1.fixInsert(this, z);
- return z;
- }
- /**
- * node node
- * / \ / \
- * a b ----> a b
- * \
- * z
- */
- rbInsertLeft(node, p) {
- let z = new rbTreeBase_1.TreeNode(p, 1 /* Red */);
- z.left = rbTreeBase_1.SENTINEL;
- z.right = rbTreeBase_1.SENTINEL;
- z.parent = rbTreeBase_1.SENTINEL;
- z.size_left = 0;
- z.lf_left = 0;
- if (this.root === rbTreeBase_1.SENTINEL) {
- this.root = z;
- z.color = 0 /* Black */;
- }
- else if (node.left === rbTreeBase_1.SENTINEL) {
- node.left = z;
- z.parent = node;
- }
- else {
- let prevNode = rbTreeBase_1.righttest(node.left); // a
- prevNode.right = z;
- z.parent = prevNode;
- }
- rbTreeBase_1.fixInsert(this, z);
- return z;
- }
- getContentOfSubTree(node) {
- let str = '';
- this.iterate(node, node => {
- str += this.getNodeContent(node);
- return true;
- });
- return str;
- }
-}
-exports.PieceTreeBase = PieceTreeBase;
-
-
-/***/ }),
-/* 44 */
-/***/ (function(module, exports, __webpack_require__) {
-
-"use strict";
-
-/*---------------------------------------------------------------------------------------------
- * Copyright (c) Microsoft Corporation. All rights reserved.
- * Licensed under the MIT License. See License.txt in the project root for license information.
- *--------------------------------------------------------------------------------------------*/
-Object.defineProperty(exports, "__esModule", { value: true });
-/**
- * A position in the editor.
- */
-class Position {
- constructor(lineNumber, column) {
- this.lineNumber = lineNumber;
- this.column = column;
- }
- /**
- * Create a new postion from this position.
- *
- * @param newLineNumber new line number
- * @param newColumn new column
- */
- with(newLineNumber = this.lineNumber, newColumn = this.column) {
- if (newLineNumber === this.lineNumber && newColumn === this.column) {
- return this;
- }
- else {
- return new Position(newLineNumber, newColumn);
- }
- }
- /**
- * Derive a new position from this position.
- *
- * @param deltaLineNumber line number delta
- * @param deltaColumn column delta
- */
- delta(deltaLineNumber = 0, deltaColumn = 0) {
- return this.with(this.lineNumber + deltaLineNumber, this.column + deltaColumn);
- }
- /**
- * Test if this position equals other position
- */
- equals(other) {
- return Position.equals(this, other);
- }
- /**
- * Test if position `a` equals position `b`
- */
- static equals(a, b) {
- if (!a && !b) {
- return true;
- }
- return (!!a &&
- !!b &&
- a.lineNumber === b.lineNumber &&
- a.column === b.column);
- }
- /**
- * Test if this position is before other position.
- * If the two positions are equal, the result will be false.
- */
- isBefore(other) {
- return Position.isBefore(this, other);
- }
- /**
- * Test if position `a` is before position `b`.
- * If the two positions are equal, the result will be false.
- */
- static isBefore(a, b) {
- if (a.lineNumber < b.lineNumber) {
- return true;
- }
- if (b.lineNumber < a.lineNumber) {
- return false;
- }
- return a.column < b.column;
- }
- /**
- * Test if this position is before other position.
- * If the two positions are equal, the result will be true.
- */
- isBeforeOrEqual(other) {
- return Position.isBeforeOrEqual(this, other);
- }
- /**
- * Test if position `a` is before position `b`.
- * If the two positions are equal, the result will be true.
- */
- static isBeforeOrEqual(a, b) {
- if (a.lineNumber < b.lineNumber) {
- return true;
- }
- if (b.lineNumber < a.lineNumber) {
- return false;
- }
- return a.column <= b.column;
- }
- /**
- * A function that compares positions, useful for sorting
- */
- static compare(a, b) {
- let aLineNumber = a.lineNumber | 0;
- let bLineNumber = b.lineNumber | 0;
- if (aLineNumber === bLineNumber) {
- let aColumn = a.column | 0;
- let bColumn = b.column | 0;
- return aColumn - bColumn;
- }
- return aLineNumber - bLineNumber;
- }
- /**
- * Clone this position.
- */
- clone() {
- return new Position(this.lineNumber, this.column);
- }
- /**
- * Convert to a human-readable representation.
- */
- toString() {
- return '(' + this.lineNumber + ',' + this.column + ')';
- }
- // ---
- /**
- * Create a `Position` from an `IPosition`.
- */
- static lift(pos) {
- return new Position(pos.lineNumber, pos.column);
- }
- /**
- * Test if `obj` is an `IPosition`.
- */
- static isIPosition(obj) {
- return (obj
- && (typeof obj.lineNumber === 'number')
- && (typeof obj.column === 'number'));
- }
-}
-exports.Position = Position;
-
-
-/***/ }),
-/* 45 */
-/***/ (function(module, exports, __webpack_require__) {
-
-"use strict";
-
-/*---------------------------------------------------------------------------------------------
- * Copyright (c) Microsoft Corporation. All rights reserved.
- * Licensed under the MIT License. See License.txt in the project root for license information.
- *--------------------------------------------------------------------------------------------*/
-Object.defineProperty(exports, "__esModule", { value: true });
-class TreeNode {
- constructor(piece, color) {
- this.piece = piece;
- this.color = color;
- this.size_left = 0;
- this.lf_left = 0;
- this.parent = this;
- this.left = this;
- this.right = this;
- }
- next() {
- if (this.right !== exports.SENTINEL) {
- return leftest(this.right);
- }
- let node = this;
- while (node.parent !== exports.SENTINEL) {
- if (node.parent.left === node) {
- break;
- }
- node = node.parent;
- }
- if (node.parent === exports.SENTINEL) {
- return exports.SENTINEL;
- }
- else {
- return node.parent;
- }
- }
- prev() {
- if (this.left !== exports.SENTINEL) {
- return righttest(this.left);
- }
- let node = this;
- while (node.parent !== exports.SENTINEL) {
- if (node.parent.right === node) {
- break;
- }
- node = node.parent;
- }
- if (node.parent === exports.SENTINEL) {
- return exports.SENTINEL;
- }
- else {
- return node.parent;
- }
- }
- detach() {
- this.parent = null;
- this.left = null;
- this.right = null;
- }
-}
-exports.TreeNode = TreeNode;
-exports.SENTINEL = new TreeNode(null, 0 /* Black */);
-exports.SENTINEL.parent = exports.SENTINEL;
-exports.SENTINEL.left = exports.SENTINEL;
-exports.SENTINEL.right = exports.SENTINEL;
-exports.SENTINEL.color = 0 /* Black */;
-function leftest(node) {
- while (node.left !== exports.SENTINEL) {
- node = node.left;
- }
- return node;
-}
-exports.leftest = leftest;
-function righttest(node) {
- while (node.right !== exports.SENTINEL) {
- node = node.right;
- }
- return node;
-}
-exports.righttest = righttest;
-function calculateSize(node) {
- if (node === exports.SENTINEL) {
- return 0;
- }
- return node.size_left + node.piece.length + calculateSize(node.right);
-}
-exports.calculateSize = calculateSize;
-function calculateLF(node) {
- if (node === exports.SENTINEL) {
- return 0;
- }
- return node.lf_left + node.piece.lineFeedCnt + calculateLF(node.right);
-}
-exports.calculateLF = calculateLF;
-function resetSentinel() {
- exports.SENTINEL.parent = exports.SENTINEL;
-}
-exports.resetSentinel = resetSentinel;
-function leftRotate(tree, x) {
- let y = x.right;
- // fix size_left
- y.size_left += x.size_left + (x.piece ? x.piece.length : 0);
- y.lf_left += x.lf_left + (x.piece ? x.piece.lineFeedCnt : 0);
- x.right = y.left;
- if (y.left !== exports.SENTINEL) {
- y.left.parent = x;
- }
- y.parent = x.parent;
- if (x.parent === exports.SENTINEL) {
- tree.root = y;
- }
- else if (x.parent.left === x) {
- x.parent.left = y;
- }
- else {
- x.parent.right = y;
- }
- y.left = x;
- x.parent = y;
-}
-exports.leftRotate = leftRotate;
-function rightRotate(tree, y) {
- let x = y.left;
- y.left = x.right;
- if (x.right !== exports.SENTINEL) {
- x.right.parent = y;
- }
- x.parent = y.parent;
- // fix size_left
- y.size_left -= x.size_left + (x.piece ? x.piece.length : 0);
- y.lf_left -= x.lf_left + (x.piece ? x.piece.lineFeedCnt : 0);
- if (y.parent === exports.SENTINEL) {
- tree.root = x;
- }
- else if (y === y.parent.right) {
- y.parent.right = x;
- }
- else {
- y.parent.left = x;
- }
- x.right = y;
- y.parent = x;
-}
-exports.rightRotate = rightRotate;
-function rbDelete(tree, z) {
- let x;
- let y;
- if (z.left === exports.SENTINEL) {
- y = z;
- x = y.right;
- }
- else if (z.right === exports.SENTINEL) {
- y = z;
- x = y.left;
- }
- else {
- y = leftest(z.right);
- x = y.right;
- }
- if (y === tree.root) {
- tree.root = x;
- // if x is null, we are removing the only node
- x.color = 0 /* Black */;
- z.detach();
- resetSentinel();
- tree.root.parent = exports.SENTINEL;
- return;
- }
- let yWasRed = (y.color === 1 /* Red */);
- if (y === y.parent.left) {
- y.parent.left = x;
- }
- else {
- y.parent.right = x;
- }
- if (y === z) {
- x.parent = y.parent;
- recomputeTreeMetadata(tree, x);
- }
- else {
- if (y.parent === z) {
- x.parent = y;
- }
- else {
- x.parent = y.parent;
- }
- // as we make changes to x's hierarchy, update size_left of subtree first
- recomputeTreeMetadata(tree, x);
- y.left = z.left;
- y.right = z.right;
- y.parent = z.parent;
- y.color = z.color;
- if (z === tree.root) {
- tree.root = y;
- }
- else {
- if (z === z.parent.left) {
- z.parent.left = y;
- }
- else {
- z.parent.right = y;
- }
- }
- if (y.left !== exports.SENTINEL) {
- y.left.parent = y;
- }
- if (y.right !== exports.SENTINEL) {
- y.right.parent = y;
- }
- // update metadata
- // we replace z with y, so in this sub tree, the length change is z.item.length
- y.size_left = z.size_left;
- y.lf_left = z.lf_left;
- recomputeTreeMetadata(tree, y);
- }
- z.detach();
- if (x.parent.left === x) {
- let newSizeLeft = calculateSize(x);
- let newLFLeft = calculateLF(x);
- if (newSizeLeft !== x.parent.size_left || newLFLeft !== x.parent.lf_left) {
- let delta = newSizeLeft - x.parent.size_left;
- let lf_delta = newLFLeft - x.parent.lf_left;
- x.parent.size_left = newSizeLeft;
- x.parent.lf_left = newLFLeft;
- updateTreeMetadata(tree, x.parent, delta, lf_delta);
- }
- }
- recomputeTreeMetadata(tree, x.parent);
- if (yWasRed) {
- resetSentinel();
- return;
- }
- // RB-DELETE-FIXUP
- let w;
- while (x !== tree.root && x.color === 0 /* Black */) {
- if (x === x.parent.left) {
- w = x.parent.right;
- if (w.color === 1 /* Red */) {
- w.color = 0 /* Black */;
- x.parent.color = 1 /* Red */;
- leftRotate(tree, x.parent);
- w = x.parent.right;
- }
- if (w.left.color === 0 /* Black */ && w.right.color === 0 /* Black */) {
- w.color = 1 /* Red */;
- x = x.parent;
- }
- else {
- if (w.right.color === 0 /* Black */) {
- w.left.color = 0 /* Black */;
- w.color = 1 /* Red */;
- rightRotate(tree, w);
- w = x.parent.right;
- }
- w.color = x.parent.color;
- x.parent.color = 0 /* Black */;
- w.right.color = 0 /* Black */;
- leftRotate(tree, x.parent);
- x = tree.root;
- }
- }
- else {
- w = x.parent.left;
- if (w.color === 1 /* Red */) {
- w.color = 0 /* Black */;
- x.parent.color = 1 /* Red */;
- rightRotate(tree, x.parent);
- w = x.parent.left;
- }
- if (w.left.color === 0 /* Black */ && w.right.color === 0 /* Black */) {
- w.color = 1 /* Red */;
- x = x.parent;
- }
- else {
- if (w.left.color === 0 /* Black */) {
- w.right.color = 0 /* Black */;
- w.color = 1 /* Red */;
- leftRotate(tree, w);
- w = x.parent.left;
- }
- w.color = x.parent.color;
- x.parent.color = 0 /* Black */;
- w.left.color = 0 /* Black */;
- rightRotate(tree, x.parent);
- x = tree.root;
- }
- }
- }
- x.color = 0 /* Black */;
- resetSentinel();
-}
-exports.rbDelete = rbDelete;
-function fixInsert(tree, x) {
- recomputeTreeMetadata(tree, x);
- while (x !== tree.root && x.parent.color === 1 /* Red */) {
- if (x.parent === x.parent.parent.left) {
- const y = x.parent.parent.right;
- if (y.color === 1 /* Red */) {
- x.parent.color = 0 /* Black */;
- y.color = 0 /* Black */;
- x.parent.parent.color = 1 /* Red */;
- x = x.parent.parent;
- }
- else {
- if (x === x.parent.right) {
- x = x.parent;
- leftRotate(tree, x);
- }
- x.parent.color = 0 /* Black */;
- x.parent.parent.color = 1 /* Red */;
- rightRotate(tree, x.parent.parent);
- }
- }
- else {
- const y = x.parent.parent.left;
- if (y.color === 1 /* Red */) {
- x.parent.color = 0 /* Black */;
- y.color = 0 /* Black */;
- x.parent.parent.color = 1 /* Red */;
- x = x.parent.parent;
- }
- else {
- if (x === x.parent.left) {
- x = x.parent;
- rightRotate(tree, x);
- }
- x.parent.color = 0 /* Black */;
- x.parent.parent.color = 1 /* Red */;
- leftRotate(tree, x.parent.parent);
- }
- }
- }
- tree.root.color = 0 /* Black */;
-}
-exports.fixInsert = fixInsert;
-function updateTreeMetadata(tree, x, delta, lineFeedCntDelta) {
- // node length change or line feed count change
- while (x !== tree.root && x !== exports.SENTINEL) {
- if (x.parent.left === x) {
- x.parent.size_left += delta;
- x.parent.lf_left += lineFeedCntDelta;
- }
- x = x.parent;
- }
-}
-exports.updateTreeMetadata = updateTreeMetadata;
-function recomputeTreeMetadata(tree, x) {
- let delta = 0;
- let lf_delta = 0;
- if (x === tree.root) {
- return;
- }
- if (delta === 0) {
- // go upwards till the node whose left subtree is changed.
- while (x !== tree.root && x === x.parent.right) {
- x = x.parent;
- }
- if (x === tree.root) {
- // well, it means we add a node to the end (inorder)
- return;
- }
- // x is the node whose right subtree is changed.
- x = x.parent;
- delta = calculateSize(x.left) - x.size_left;
- lf_delta = calculateLF(x.left) - x.lf_left;
- x.size_left += delta;
- x.lf_left += lf_delta;
- }
- // go upwards till root. O(logN)
- while (x !== tree.root && (delta !== 0 || lf_delta !== 0)) {
- if (x.parent.left === x) {
- x.parent.size_left += delta;
- x.parent.lf_left += lf_delta;
- }
- x = x.parent;
- }
-}
-exports.recomputeTreeMetadata = recomputeTreeMetadata;
-
-
-/***/ }),
-/* 46 */
-/***/ (function(module, exports, __webpack_require__) {
-
-"use strict";
-
-/*---------------------------------------------------------------------------------------------
- * Copyright (c) Microsoft Corporation. All rights reserved.
- * Licensed under the MIT License. See License.txt in the project root for license information.
- *--------------------------------------------------------------------------------------------*/
-Object.defineProperty(exports, "__esModule", { value: true });
-const pieceTreeBase_1 = __webpack_require__(43);
-exports.UTF8_BOM_CHARACTER = String.fromCharCode(65279 /* UTF8_BOM */);
-function startsWithUTF8BOM(str) {
- return !!(str && str.length > 0 && str.charCodeAt(0) === 65279 /* UTF8_BOM */);
-}
-exports.startsWithUTF8BOM = startsWithUTF8BOM;
-class PieceTreeTextBufferFactory {
- constructor(_chunks, _bom, _cr, _lf, _crlf, _normalizeEOL) {
- this._chunks = _chunks;
- this._bom = _bom;
- this._cr = _cr;
- this._lf = _lf;
- this._crlf = _crlf;
- this._normalizeEOL = _normalizeEOL;
- }
- _getEOL(defaultEOL) {
- const totalEOLCount = this._cr + this._lf + this._crlf;
- const totalCRCount = this._cr + this._crlf;
- if (totalEOLCount === 0) {
- // This is an empty file or a file with precisely one line
- return (defaultEOL === 1 /* LF */ ? '\n' : '\r\n');
- }
- if (totalCRCount > totalEOLCount / 2) {
- // More than half of the file contains \r\n ending lines
- return '\r\n';
- }
- // At least one line more ends in \n
- return '\n';
- }
- create(defaultEOL) {
- const eol = this._getEOL(defaultEOL);
- let chunks = this._chunks;
- if (this._normalizeEOL &&
- ((eol === '\r\n' && (this._cr > 0 || this._lf > 0))
- || (eol === '\n' && (this._cr > 0 || this._crlf > 0)))) {
- // Normalize pieces
- for (let i = 0, len = chunks.length; i < len; i++) {
- let str = chunks[i].buffer.replace(/\r\n|\r|\n/g, eol);
- let newLineStart = pieceTreeBase_1.createLineStartsFast(str);
- chunks[i] = new pieceTreeBase_1.StringBuffer(str, newLineStart);
- }
- }
- return new pieceTreeBase_1.PieceTreeBase(chunks, eol, this._normalizeEOL);
- }
- getFirstLineText(lengthLimit) {
- return this._chunks[0].buffer.substr(0, 100).split(/\r\n|\r|\n/)[0];
- }
-}
-exports.PieceTreeTextBufferFactory = PieceTreeTextBufferFactory;
-class PieceTreeTextBufferBuilder {
- constructor() {
- this.chunks = [];
- this.BOM = '';
- this._hasPreviousChar = false;
- this._previousChar = 0;
- this._tmpLineStarts = [];
- this.cr = 0;
- this.lf = 0;
- this.crlf = 0;
- }
- acceptChunk(chunk) {
- if (chunk.length === 0) {
- return;
- }
- if (this.chunks.length === 0) {
- if (startsWithUTF8BOM(chunk)) {
- this.BOM = exports.UTF8_BOM_CHARACTER;
- chunk = chunk.substr(1);
- }
- }
- const lastChar = chunk.charCodeAt(chunk.length - 1);
- if (lastChar === 13 /* CarriageReturn */ || (lastChar >= 0xD800 && lastChar <= 0xDBFF)) {
- // last character is \r or a high surrogate => keep it back
- this._acceptChunk1(chunk.substr(0, chunk.length - 1), false);
- this._hasPreviousChar = true;
- this._previousChar = lastChar;
- }
- else {
- this._acceptChunk1(chunk, false);
- this._hasPreviousChar = false;
- this._previousChar = lastChar;
- }
- }
- _acceptChunk1(chunk, allowEmptyStrings) {
- if (!allowEmptyStrings && chunk.length === 0) {
- // Nothing to do
- return;
- }
- if (this._hasPreviousChar) {
- this._acceptChunk2(String.fromCharCode(this._previousChar) + chunk);
- }
- else {
- this._acceptChunk2(chunk);
- }
- }
- _acceptChunk2(chunk) {
- const lineStarts = pieceTreeBase_1.createLineStarts(this._tmpLineStarts, chunk);
- this.chunks.push(new pieceTreeBase_1.StringBuffer(chunk, lineStarts.lineStarts));
- this.cr += lineStarts.cr;
- this.lf += lineStarts.lf;
- this.crlf += lineStarts.crlf;
- }
- finish(normalizeEOL = true) {
- this._finish();
- return new PieceTreeTextBufferFactory(this.chunks, this.BOM, this.cr, this.lf, this.crlf, normalizeEOL);
- }
- _finish() {
- if (this.chunks.length === 0) {
- this._acceptChunk1('', true);
- }
- if (this._hasPreviousChar) {
- this._hasPreviousChar = false;
- // recreate last chunk
- let lastChunk = this.chunks[this.chunks.length - 1];
- lastChunk.buffer += String.fromCharCode(this._previousChar);
- let newLineStarts = pieceTreeBase_1.createLineStartsFast(lastChunk.buffer);
- lastChunk.lineStarts = newLineStarts;
- if (this._previousChar === 13 /* CarriageReturn */) {
- this.cr++;
- }
- }
- }
-}
-exports.PieceTreeTextBufferBuilder = PieceTreeTextBufferBuilder;
-
-
-/***/ }),
-/* 47 */
-/***/ (function(module, exports, __webpack_require__) {
-
-"use strict";
-
-/*---------------------------------------------------------------------------------------------
- * Copyright (c) Microsoft Corporation. All rights reserved.
- * Licensed under the MIT License. See License.txt in the project root for license information.
- *--------------------------------------------------------------------------------------------*/
-Object.defineProperty(exports, "__esModule", { value: true });
-const position_1 = __webpack_require__(44);
-/**
- * A range in the editor. (startLineNumber,startColumn) is <= (endLineNumber,endColumn)
- */
-class Range {
- constructor(startLineNumber, startColumn, endLineNumber, endColumn) {
- if ((startLineNumber > endLineNumber) || (startLineNumber === endLineNumber && startColumn > endColumn)) {
- this.startLineNumber = endLineNumber;
- this.startColumn = endColumn;
- this.endLineNumber = startLineNumber;
- this.endColumn = startColumn;
- }
- else {
- this.startLineNumber = startLineNumber;
- this.startColumn = startColumn;
- this.endLineNumber = endLineNumber;
- this.endColumn = endColumn;
- }
- }
- /**
- * Test if this range is empty.
- */
- isEmpty() {
- return Range.isEmpty(this);
- }
- /**
- * Test if `range` is empty.
- */
- static isEmpty(range) {
- return (range.startLineNumber === range.endLineNumber && range.startColumn === range.endColumn);
- }
- /**
- * Test if position is in this range. If the position is at the edges, will return true.
- */
- containsPosition(position) {
- return Range.containsPosition(this, position);
- }
- /**
- * Test if `position` is in `range`. If the position is at the edges, will return true.
- */
- static containsPosition(range, position) {
- if (position.lineNumber < range.startLineNumber || position.lineNumber > range.endLineNumber) {
- return false;
- }
- if (position.lineNumber === range.startLineNumber && position.column < range.startColumn) {
- return false;
- }
- if (position.lineNumber === range.endLineNumber && position.column > range.endColumn) {
- return false;
- }
- return true;
- }
- /**
- * Test if range is in this range. If the range is equal to this range, will return true.
- */
- containsRange(range) {
- return Range.containsRange(this, range);
- }
- /**
- * Test if `otherRange` is in `range`. If the ranges are equal, will return true.
- */
- static containsRange(range, otherRange) {
- if (otherRange.startLineNumber < range.startLineNumber || otherRange.endLineNumber < range.startLineNumber) {
- return false;
- }
- if (otherRange.startLineNumber > range.endLineNumber || otherRange.endLineNumber > range.endLineNumber) {
- return false;
- }
- if (otherRange.startLineNumber === range.startLineNumber && otherRange.startColumn < range.startColumn) {
- return false;
- }
- if (otherRange.endLineNumber === range.endLineNumber && otherRange.endColumn > range.endColumn) {
- return false;
- }
- return true;
- }
- /**
- * A reunion of the two ranges.
- * The smallest position will be used as the start point, and the largest one as the end point.
- */
- plusRange(range) {
- return Range.plusRange(this, range);
- }
- /**
- * A reunion of the two ranges.
- * The smallest position will be used as the start point, and the largest one as the end point.
- */
- static plusRange(a, b) {
- let startLineNumber;
- let startColumn;
- let endLineNumber;
- let endColumn;
- if (b.startLineNumber < a.startLineNumber) {
- startLineNumber = b.startLineNumber;
- startColumn = b.startColumn;
- }
- else if (b.startLineNumber === a.startLineNumber) {
- startLineNumber = b.startLineNumber;
- startColumn = Math.min(b.startColumn, a.startColumn);
- }
- else {
- startLineNumber = a.startLineNumber;
- startColumn = a.startColumn;
- }
- if (b.endLineNumber > a.endLineNumber) {
- endLineNumber = b.endLineNumber;
- endColumn = b.endColumn;
- }
- else if (b.endLineNumber === a.endLineNumber) {
- endLineNumber = b.endLineNumber;
- endColumn = Math.max(b.endColumn, a.endColumn);
- }
- else {
- endLineNumber = a.endLineNumber;
- endColumn = a.endColumn;
- }
- return new Range(startLineNumber, startColumn, endLineNumber, endColumn);
- }
- /**
- * A intersection of the two ranges.
- */
- intersectRanges(range) {
- return Range.intersectRanges(this, range);
- }
- /**
- * A intersection of the two ranges.
- */
- static intersectRanges(a, b) {
- let resultStartLineNumber = a.startLineNumber;
- let resultStartColumn = a.startColumn;
- let resultEndLineNumber = a.endLineNumber;
- let resultEndColumn = a.endColumn;
- let otherStartLineNumber = b.startLineNumber;
- let otherStartColumn = b.startColumn;
- let otherEndLineNumber = b.endLineNumber;
- let otherEndColumn = b.endColumn;
- if (resultStartLineNumber < otherStartLineNumber) {
- resultStartLineNumber = otherStartLineNumber;
- resultStartColumn = otherStartColumn;
- }
- else if (resultStartLineNumber === otherStartLineNumber) {
- resultStartColumn = Math.max(resultStartColumn, otherStartColumn);
- }
- if (resultEndLineNumber > otherEndLineNumber) {
- resultEndLineNumber = otherEndLineNumber;
- resultEndColumn = otherEndColumn;
- }
- else if (resultEndLineNumber === otherEndLineNumber) {
- resultEndColumn = Math.min(resultEndColumn, otherEndColumn);
- }
- // Check if selection is now empty
- if (resultStartLineNumber > resultEndLineNumber) {
- return null;
- }
- if (resultStartLineNumber === resultEndLineNumber && resultStartColumn > resultEndColumn) {
- return null;
- }
- return new Range(resultStartLineNumber, resultStartColumn, resultEndLineNumber, resultEndColumn);
- }
- /**
- * Test if this range equals other.
- */
- equalsRange(other) {
- return Range.equalsRange(this, other);
- }
- /**
- * Test if range `a` equals `b`.
- */
- static equalsRange(a, b) {
- return (!!a &&
- !!b &&
- a.startLineNumber === b.startLineNumber &&
- a.startColumn === b.startColumn &&
- a.endLineNumber === b.endLineNumber &&
- a.endColumn === b.endColumn);
- }
- /**
- * Return the end position (which will be after or equal to the start position)
- */
- getEndPosition() {
- return new position_1.Position(this.endLineNumber, this.endColumn);
- }
- /**
- * Return the start position (which will be before or equal to the end position)
- */
- getStartPosition() {
- return new position_1.Position(this.startLineNumber, this.startColumn);
- }
- /**
- * Transform to a user presentable string representation.
- */
- toString() {
- return '[' + this.startLineNumber + ',' + this.startColumn + ' -> ' + this.endLineNumber + ',' + this.endColumn + ']';
- }
- /**
- * Create a new range using this range's start position, and using endLineNumber and endColumn as the end position.
- */
- setEndPosition(endLineNumber, endColumn) {
- return new Range(this.startLineNumber, this.startColumn, endLineNumber, endColumn);
- }
- /**
- * Create a new range using this range's end position, and using startLineNumber and startColumn as the start position.
- */
- setStartPosition(startLineNumber, startColumn) {
- return new Range(startLineNumber, startColumn, this.endLineNumber, this.endColumn);
- }
- /**
- * Create a new empty range using this range's start position.
- */
- collapseToStart() {
- return Range.collapseToStart(this);
- }
- /**
- * Create a new empty range using this range's start position.
- */
- static collapseToStart(range) {
- return new Range(range.startLineNumber, range.startColumn, range.startLineNumber, range.startColumn);
- }
- // ---
- static fromPositions(start, end = start) {
- return new Range(start.lineNumber, start.column, end.lineNumber, end.column);
- }
- static lift(range) {
- if (!range) {
- return null;
- }
- return new Range(range.startLineNumber, range.startColumn, range.endLineNumber, range.endColumn);
- }
- /**
- * Test if `obj` is an `IRange`.
- */
- static isIRange(obj) {
- return (obj
- && (typeof obj.startLineNumber === 'number')
- && (typeof obj.startColumn === 'number')
- && (typeof obj.endLineNumber === 'number')
- && (typeof obj.endColumn === 'number'));
- }
- /**
- * Test if the two ranges are touching in any way.
- */
- static areIntersectingOrTouching(a, b) {
- // Check if `a` is before `b`
- if (a.endLineNumber < b.startLineNumber || (a.endLineNumber === b.startLineNumber && a.endColumn < b.startColumn)) {
- return false;
- }
- // Check if `b` is before `a`
- if (b.endLineNumber < a.startLineNumber || (b.endLineNumber === a.startLineNumber && b.endColumn < a.startColumn)) {
- return false;
- }
- // These ranges must intersect
- return true;
- }
- /**
- * Test if the two ranges are intersecting. If the ranges are touching it returns true.
- */
- static areIntersecting(a, b) {
- // Check if `a` is before `b`
- if (a.endLineNumber < b.startLineNumber || (a.endLineNumber === b.startLineNumber && a.endColumn <= b.startColumn)) {
- return false;
- }
- // Check if `b` is before `a`
- if (b.endLineNumber < a.startLineNumber || (b.endLineNumber === a.startLineNumber && b.endColumn <= a.startColumn)) {
- return false;
- }
- // These ranges must intersect
- return true;
- }
- /**
- * A function that compares ranges, useful for sorting ranges
- * It will first compare ranges on the startPosition and then on the endPosition
- */
- static compareRangesUsingStarts(a, b) {
- if (a && b) {
- const aStartLineNumber = a.startLineNumber | 0;
- const bStartLineNumber = b.startLineNumber | 0;
- if (aStartLineNumber === bStartLineNumber) {
- const aStartColumn = a.startColumn | 0;
- const bStartColumn = b.startColumn | 0;
- if (aStartColumn === bStartColumn) {
- const aEndLineNumber = a.endLineNumber | 0;
- const bEndLineNumber = b.endLineNumber | 0;
- if (aEndLineNumber === bEndLineNumber) {
- const aEndColumn = a.endColumn | 0;
- const bEndColumn = b.endColumn | 0;
- return aEndColumn - bEndColumn;
- }
- return aEndLineNumber - bEndLineNumber;
- }
- return aStartColumn - bStartColumn;
- }
- return aStartLineNumber - bStartLineNumber;
- }
- const aExists = (a ? 1 : 0);
- const bExists = (b ? 1 : 0);
- return aExists - bExists;
- }
- /**
- * A function that compares ranges, useful for sorting ranges
- * It will first compare ranges on the endPosition and then on the startPosition
- */
- static compareRangesUsingEnds(a, b) {
- if (a.endLineNumber === b.endLineNumber) {
- if (a.endColumn === b.endColumn) {
- if (a.startLineNumber === b.startLineNumber) {
- return a.startColumn - b.startColumn;
- }
- return a.startLineNumber - b.startLineNumber;
- }
- return a.endColumn - b.endColumn;
- }
- return a.endLineNumber - b.endLineNumber;
- }
- /**
- * Test if the range spans multiple lines.
- */
- static spansMultipleLines(range) {
- return range.endLineNumber > range.startLineNumber;
- }
-}
-exports.Range = Range;
-
-
-/***/ }),
-/* 48 */
-/***/ (function(module, exports, __webpack_require__) {
-
-"use strict";
-/* --------------------------------------------------------------------------------------------\r
- * Copyright (c) Microsoft Corporation. All rights reserved.\r
- * Licensed under the MIT License. See License.txt in the project root for license information.\r
- * ------------------------------------------------------------------------------------------ */\r
-\r
-Object.defineProperty(exports, "__esModule", { value: true });\r
-const vscode_languageserver_protocol_1 = __webpack_require__(3);\r
-const uuid_1 = __webpack_require__(38);\r
-class ProgressImpl {\r
- constructor(_connection, title, percentage, message, cancellable) {\r
- this._connection = _connection;\r
- this._id = uuid_1.generateUuid();\r
- let params = {\r
- id: this._id,\r
- title,\r
- cancellable\r
- };\r
- if (percentage !== undefined) {\r
- params.percentage = percentage;\r
- }\r
- if (message !== undefined) {\r
- params.message = message;\r
- }\r
- if (cancellable !== undefined) {\r
- params.cancellable = cancellable;\r
- }\r
- ProgressImpl.Instances.set(this._id, this);\r
- this._source = new vscode_languageserver_protocol_1.CancellationTokenSource();\r
- this._connection.sendNotification(vscode_languageserver_protocol_1.Proposed.ProgressStartNotification.type, params);\r
- }\r
- get token() {\r
- return this._source.token;\r
- }\r
- report(arg0, arg1) {\r
- let percentage;\r
- let message;\r
- if (typeof arg0 === 'number') {\r
- percentage = arg0;\r
- if (arg1 !== undefined) {\r
- message = arg1;\r
- }\r
- }\r
- else {\r
- message = arg0;\r
- }\r
- this._connection.sendNotification(vscode_languageserver_protocol_1.Proposed.ProgressReportNotification.type, { id: this._id, percentage, message });\r
- }\r
- done() {\r
- ProgressImpl.Instances.delete(this._id);\r
- this._source.dispose();\r
- this._connection.sendNotification(vscode_languageserver_protocol_1.Proposed.ProgressDoneNotification.type, { id: this._id });\r
- }\r
- cancel() {\r
- this._source.cancel();\r
- }\r
-}\r
-ProgressImpl.Instances = new Map();\r
-class NullProgress {\r
- constructor() {\r
- this._source = new vscode_languageserver_protocol_1.CancellationTokenSource();\r
- }\r
- get token() {\r
- return this._source.token;\r
- }\r
- report() {\r
- }\r
- done() {\r
- }\r
-}\r
-exports.ProgressFeature = (Base) => {\r
- return class extends Base {\r
- initialize(cap) {\r
- let capabilities = cap;\r
- if (capabilities.window && capabilities.window.progress) {\r
- this._progressSupported = true;\r
- this.connection.onNotification(vscode_languageserver_protocol_1.Proposed.ProgressCancelNotification.type, (params) => {\r
- let progress = ProgressImpl.Instances.get(params.id);\r
- if (progress !== undefined) {\r
- progress.cancel();\r
- }\r
- });\r
- }\r
- }\r
- createProgress(title, percentage, message, cancellable) {\r
- if (this._progressSupported) {\r
- return new ProgressImpl(this.connection, title, percentage, message, cancellable);\r
- }\r
- else {\r
- return new NullProgress();\r
- }\r
- }\r
- };\r
-};\r
-
-
-/***/ }),
-/* 49 */
-/***/ (function(module, exports, __webpack_require__) {
-
-"use strict";
-/*---------------------------------------------------------------------------------------------
- * Copyright (c) Microsoft Corporation. All rights reserved.
- * Licensed under the MIT License. See License.txt in the project root for license information.
- *--------------------------------------------------------------------------------------------*/
-
-Object.defineProperty(exports, "__esModule", { value: true });
-var url_1 = __webpack_require__(40);
-var https = __webpack_require__(50);
-var http = __webpack_require__(51);
-var HttpProxyAgent = __webpack_require__(52);
-var HttpsProxyAgent = __webpack_require__(69);
-var zlib = __webpack_require__(75);
-var nls = __webpack_require__(76);
-nls.config(process.env['VSCODE_NLS_CONFIG']);
-var localize = nls.loadMessageBundle();
-var proxyUrl = null;
-var strictSSL = true;
-function configure(_proxyUrl, _strictSSL) {
- proxyUrl = _proxyUrl;
- strictSSL = _strictSSL;
-}
-exports.configure = configure;
-function xhr(options) {
- var agent = getProxyAgent(options.url, { proxyUrl: proxyUrl, strictSSL: strictSSL });
- options = assign({}, options);
- options = assign(options, { agent: agent, strictSSL: strictSSL });
- if (typeof options.followRedirects !== 'number') {
- options.followRedirects = 5;
- }
- return request(options).then(function (result) { return new Promise(function (c, e) {
- var res = result.res;
- var readable = res;
- var encoding = res.headers && res.headers['content-encoding'];
- var isCompleted = false;
- if (encoding === 'gzip') {
- var gunzip = zlib.createGunzip();
- res.pipe(gunzip);
- readable = gunzip;
- }
- else if (encoding === 'deflate') {
- var inflate = zlib.createInflate();
- res.pipe(inflate);
- readable = inflate;
- }
- var data = [];
- readable.on('data', function (c) { return data.push(c); });
- readable.on('end', function () {
- if (isCompleted) {
- return;
- }
- isCompleted = true;
- if (options.followRedirects > 0 && (res.statusCode >= 300 && res.statusCode <= 303 || res.statusCode === 307)) {
- var location = res.headers['location'];
- if (location) {
- var newOptions = {
- type: options.type, url: location, user: options.user, password: options.password, responseType: options.responseType, headers: options.headers,
- timeout: options.timeout, followRedirects: options.followRedirects - 1, data: options.data
- };
- xhr(newOptions).then(c, e);
- return;
- }
- }
- var response = {
- responseText: data.join(''),
- status: res.statusCode
- };
- if ((res.statusCode >= 200 && res.statusCode < 300) || res.statusCode === 1223) {
- c(response);
- }
- else {
- e(response);
- }
- });
- readable.on('error', function (err) {
- var response = {
- responseText: localize('error', 'Unable to access {0}. Error: {1}', options.url, err.message),
- status: 500
- };
- isCompleted = true;
- e(response);
- });
- }); }, function (err) {
- var message;
- if (agent) {
- message = localize('error.cannot.connect.proxy', 'Unable to connect to {0} through a proxy . Error: {1}', options.url, err.message);
- }
- else {
- message = localize('error.cannot.connect', 'Unable to connect to {0}. Error: {1}', options.url, err.message);
- }
- return Promise.reject({
- responseText: message,
- status: 404
- });
- });
-}
-exports.xhr = xhr;
-function assign(destination) {
- var sources = [];
- for (var _i = 1; _i < arguments.length; _i++) {
- sources[_i - 1] = arguments[_i];
- }
- sources.forEach(function (source) { return Object.keys(source).forEach(function (key) { return destination[key] = source[key]; }); });
- return destination;
-}
-function request(options) {
- var req;
- return new Promise(function (c, e) {
- var endpoint = url_1.parse(options.url);
- var opts = {
- hostname: endpoint.hostname,
- port: endpoint.port ? parseInt(endpoint.port) : (endpoint.protocol === 'https:' ? 443 : 80),
- path: endpoint.path,
- method: options.type || 'GET',
- headers: options.headers,
- agent: options.agent,
- rejectUnauthorized: (typeof options.strictSSL === 'boolean') ? options.strictSSL : true
- };
- if (options.user && options.password) {
- opts.auth = options.user + ':' + options.password;
- }
- var handler = function (res) {
- if (res.statusCode >= 300 && res.statusCode < 400 && options.followRedirects && options.followRedirects > 0 && res.headers['location']) {
- c(request(assign({}, options, {
- url: res.headers['location'],
- followRedirects: options.followRedirects - 1
- })));
- }
- else {
- c({ req: req, res: res });
- }
- };
- if (endpoint.protocol === 'https:') {
- req = https.request(opts, handler);
- }
- else {
- req = http.request(opts, handler);
- }
- req.on('error', e);
- if (options.timeout) {
- req.setTimeout(options.timeout);
- }
- if (options.data) {
- req.write(options.data);
- }
- req.end();
- });
-}
-function getErrorStatusDescription(status) {
- if (status < 400) {
- return void 0;
- }
- switch (status) {
- case 400: return localize('status.400', 'Bad request. The request cannot be fulfilled due to bad syntax.');
- case 401: return localize('status.401', 'Unauthorized. The server is refusing to respond.');
- case 403: return localize('status.403', 'Forbidden. The server is refusing to respond.');
- case 404: return localize('status.404', 'Not Found. The requested location could not be found.');
- case 405: return localize('status.405', 'Method not allowed. A request was made using a request method not supported by that location.');
- case 406: return localize('status.406', 'Not Acceptable. The server can only generate a response that is not accepted by the client.');
- case 407: return localize('status.407', 'Proxy Authentication Required. The client must first authenticate itself with the proxy.');
- case 408: return localize('status.408', 'Request Timeout. The server timed out waiting for the request.');
- case 409: return localize('status.409', 'Conflict. The request could not be completed because of a conflict in the request.');
- case 410: return localize('status.410', 'Gone. The requested page is no longer available.');
- case 411: return localize('status.411', 'Length Required. The "Content-Length" is not defined.');
- case 412: return localize('status.412', 'Precondition Failed. The precondition given in the request evaluated to false by the server.');
- case 413: return localize('status.413', 'Request Entity Too Large. The server will not accept the request, because the request entity is too large.');
- case 414: return localize('status.414', 'Request-URI Too Long. The server will not accept the request, because the URL is too long.');
- case 415: return localize('status.415', 'Unsupported Media Type. The server will not accept the request, because the media type is not supported.');
- case 500: return localize('status.500', 'Internal Server Error.');
- case 501: return localize('status.501', 'Not Implemented. The server either does not recognize the request method, or it lacks the ability to fulfill the request.');
- case 503: return localize('status.503', 'Service Unavailable. The server is currently unavailable (overloaded or down).');
- default: return localize('status.416', 'HTTP status code {0}', status);
- }
-}
-exports.getErrorStatusDescription = getErrorStatusDescription;
-// proxy handling
-function getSystemProxyURI(requestURL) {
- if (requestURL.protocol === 'http:') {
- return process.env.HTTP_PROXY || process.env.http_proxy || null;
- }
- else if (requestURL.protocol === 'https:') {
- return process.env.HTTPS_PROXY || process.env.https_proxy || process.env.HTTP_PROXY || process.env.http_proxy || null;
- }
- return null;
-}
-function getProxyAgent(rawRequestURL, options) {
- if (options === void 0) { options = {}; }
- var requestURL = url_1.parse(rawRequestURL);
- var proxyURL = options.proxyUrl || getSystemProxyURI(requestURL);
- if (!proxyURL) {
- return null;
- }
- var proxyEndpoint = url_1.parse(proxyURL);
- if (!/^https?:$/.test(proxyEndpoint.protocol)) {
- return null;
- }
- var opts = {
- host: proxyEndpoint.hostname,
- port: Number(proxyEndpoint.port),
- auth: proxyEndpoint.auth,
- rejectUnauthorized: (typeof options.strictSSL === 'boolean') ? options.strictSSL : true
- };
- return requestURL.protocol === 'http:' ? new HttpProxyAgent(opts) : new HttpsProxyAgent(opts);
-}
-//# sourceMappingURL=main.js.map
-
-/***/ }),
-/* 50 */
-/***/ (function(module, exports) {
-
-module.exports = require("https");
-
-/***/ }),
-/* 51 */
-/***/ (function(module, exports) {
-
-module.exports = require("http");
-
-/***/ }),
-/* 52 */
-/***/ (function(module, exports, __webpack_require__) {
-
-
-/**
- * Module dependencies.
- */
-
-var net = __webpack_require__(15);
-var tls = __webpack_require__(53);
-var url = __webpack_require__(40);
-var Agent = __webpack_require__(54);
-var inherits = __webpack_require__(56).inherits;
-var debug = __webpack_require__(61)('http-proxy-agent');
-
-/**
- * Module exports.
- */
-
-module.exports = HttpProxyAgent;
-
-/**
- * The `HttpProxyAgent` implements an HTTP Agent subclass that connects to the
- * specified "HTTP proxy server" in order to proxy HTTP requests.
- *
- * @api public
- */
-
-function HttpProxyAgent (opts) {
- if (!(this instanceof HttpProxyAgent)) return new HttpProxyAgent(opts);
- if ('string' == typeof opts) opts = url.parse(opts);
- if (!opts) throw new Error('an HTTP(S) proxy server `host` and `port` must be specified!');
- debug('creating new HttpProxyAgent instance: %o', opts);
- Agent.call(this, opts);
-
- var proxy = Object.assign({}, opts);
-
- // if `true`, then connect to the proxy server over TLS. defaults to `false`.
- this.secureProxy = proxy.protocol ? /^https:?$/i.test(proxy.protocol) : false;
-
- // prefer `hostname` over `host`, and set the `port` if needed
- proxy.host = proxy.hostname || proxy.host;
- proxy.port = +proxy.port || (this.secureProxy ? 443 : 80);
-
- if (proxy.host && proxy.path) {
- // if both a `host` and `path` are specified then it's most likely the
- // result of a `url.parse()` call... we need to remove the `path` portion so
- // that `net.connect()` doesn't attempt to open that as a unix socket file.
- delete proxy.path;
- delete proxy.pathname;
- }
-
- this.proxy = proxy;
-}
-inherits(HttpProxyAgent, Agent);
-
-/**
- * Called when the node-core HTTP client library is creating a new HTTP request.
- *
- * @api public
- */
-
-HttpProxyAgent.prototype.callback = function connect (req, opts, fn) {
- var proxy = this.proxy;
-
- // change the `http.ClientRequest` instance's "path" field
- // to the absolute path of the URL that will be requested
- var parsed = url.parse(req.path);
- if (null == parsed.protocol) parsed.protocol = 'http:';
- if (null == parsed.hostname) parsed.hostname = opts.hostname || opts.host;
- if (null == parsed.port) parsed.port = opts.port;
- if (parsed.port == 80) {
- // if port is 80, then we can remove the port so that the
- // ":80" portion is not on the produced URL
- delete parsed.port;
- }
- var absolute = url.format(parsed);
- req.path = absolute;
-
- // inject the `Proxy-Authorization` header if necessary
- if (proxy.auth) {
- req.setHeader(
- 'Proxy-Authorization',
- 'Basic ' + Buffer.from(proxy.auth).toString('base64')
- );
- }
-
- // create a socket connection to the proxy server
- var socket;
- if (this.secureProxy) {
- socket = tls.connect(proxy);
- } else {
- socket = net.connect(proxy);
- }
-
- // at this point, the http ClientRequest's internal `_header` field might have
- // already been set. If this is the case then we'll need to re-generate the
- // string since we just changed the `req.path`
- if (req._header) {
- debug('regenerating stored HTTP header string for request');
- req._header = null;
- req._implicitHeader();
- if (req.output && req.output.length > 0) {
- debug('patching connection write() output buffer with updated header');
- // the _header has already been queued to be written to the socket
- var first = req.output[0];
- var endOfHeaders = first.indexOf('\r\n\r\n') + 4;
- req.output[0] = req._header + first.substring(endOfHeaders);
- debug('output buffer: %o', req.output);
- }
- }
-
- fn(null, socket);
-};
-
-
-/***/ }),
-/* 53 */
-/***/ (function(module, exports) {
-
-module.exports = require("tls");
-
-/***/ }),
-/* 54 */
-/***/ (function(module, exports, __webpack_require__) {
-
-"use strict";
-
-__webpack_require__(55);
-const inherits = __webpack_require__(56).inherits;
-const promisify = __webpack_require__(57);
-const EventEmitter = __webpack_require__(60).EventEmitter;
-
-module.exports = Agent;
-
-function isAgent(v) {
- return v && typeof v.addRequest === 'function';
-}
-
-/**
- * Base `http.Agent` implementation.
- * No pooling/keep-alive is implemented by default.
- *
- * @param {Function} callback
- * @api public
- */
-function Agent(callback, _opts) {
- if (!(this instanceof Agent)) {
- return new Agent(callback, _opts);
- }
-
- EventEmitter.call(this);
-
- // The callback gets promisified if it has 3 parameters
- // (i.e. it has a callback function) lazily
- this._promisifiedCallback = false;
-
- let opts = _opts;
- if ('function' === typeof callback) {
- this.callback = callback;
- } else if (callback) {
- opts = callback;
- }
-
- // timeout for the socket to be returned from the callback
- this.timeout = (opts && opts.timeout) || null;
-
- this.options = opts;
-}
-inherits(Agent, EventEmitter);
-
-/**
- * Override this function in your subclass!
- */
-Agent.prototype.callback = function callback(req, opts) {
- throw new Error(
- '"agent-base" has no default implementation, you must subclass and override `callback()`'
- );
-};
-
-/**
- * Called by node-core's "_http_client.js" module when creating
- * a new HTTP request with this Agent instance.
- *
- * @api public
- */
-Agent.prototype.addRequest = function addRequest(req, _opts) {
- const ownOpts = Object.assign({}, _opts);
-
- // Set default `host` for HTTP to localhost
- if (null == ownOpts.host) {
- ownOpts.host = 'localhost';
- }
-
- // Set default `port` for HTTP if none was explicitly specified
- if (null == ownOpts.port) {
- ownOpts.port = ownOpts.secureEndpoint ? 443 : 80;
- }
-
- const opts = Object.assign({}, this.options, ownOpts);
-
- if (opts.host && opts.path) {
- // If both a `host` and `path` are specified then it's most likely the
- // result of a `url.parse()` call... we need to remove the `path` portion so
- // that `net.connect()` doesn't attempt to open that as a unix socket file.
- delete opts.path;
- }
-
- delete opts.agent;
- delete opts.hostname;
- delete opts._defaultAgent;
- delete opts.defaultPort;
- delete opts.createConnection;
-
- // Hint to use "Connection: close"
- // XXX: non-documented `http` module API :(
- req._last = true;
- req.shouldKeepAlive = false;
-
- // Create the `stream.Duplex` instance
- let timeout;
- let timedOut = false;
- const timeoutMs = this.timeout;
- const freeSocket = this.freeSocket;
-
- function onerror(err) {
- if (req._hadError) return;
- req.emit('error', err);
- // For Safety. Some additional errors might fire later on
- // and we need to make sure we don't double-fire the error event.
- req._hadError = true;
- }
-
- function ontimeout() {
- timeout = null;
- timedOut = true;
- const err = new Error(
- 'A "socket" was not created for HTTP request before ' + timeoutMs + 'ms'
- );
- err.code = 'ETIMEOUT';
- onerror(err);
- }
-
- function callbackError(err) {
- if (timedOut) return;
- if (timeout != null) {
- clearTimeout(timeout);
- timeout = null;
- }
- onerror(err);
- }
-
- function onsocket(socket) {
- if (timedOut) return;
- if (timeout != null) {
- clearTimeout(timeout);
- timeout = null;
- }
- if (isAgent(socket)) {
- // `socket` is actually an http.Agent instance, so relinquish
- // responsibility for this `req` to the Agent from here on
- socket.addRequest(req, opts);
- } else if (socket) {
- function onfree() {
- freeSocket(socket, opts);
- }
- socket.on('free', onfree);
- req.onSocket(socket);
- } else {
- const err = new Error(
- 'no Duplex stream was returned to agent-base for `' + req.method + ' ' + req.path + '`'
- );
- onerror(err);
- }
- }
-
- if (!this._promisifiedCallback && this.callback.length >= 3) {
- // Legacy callback function - convert to a Promise
- this.callback = promisify(this.callback, this);
- this._promisifiedCallback = true;
- }
-
- if (timeoutMs > 0) {
- timeout = setTimeout(ontimeout, timeoutMs);
- }
-
- try {
- Promise.resolve(this.callback(req, opts)).then(onsocket, callbackError);
- } catch (err) {
- Promise.reject(err).catch(callbackError);
- }
-};
-
-Agent.prototype.freeSocket = function freeSocket(socket, opts) {
- // TODO reuse sockets
- socket.destroy();
-};
-
-
-/***/ }),
-/* 55 */
-/***/ (function(module, exports, __webpack_require__) {
-
-"use strict";
-
-const url = __webpack_require__(40);
-const https = __webpack_require__(50);
-
-/**
- * This currently needs to be applied to all Node.js versions
- * in order to determine if the `req` is an HTTP or HTTPS request.
- *
- * There is currently no PR attempting to move this property upstream.
- */
-const patchMarker = "__agent_base_https_request_patched__";
-if (!https.request[patchMarker]) {
- https.request = (function(request) {
- return function(_options, cb) {
- let options;
- if (typeof _options === 'string') {
- options = url.parse(_options);
- } else {
- options = Object.assign({}, _options);
- }
- if (null == options.port) {
- options.port = 443;
- }
- options.secureEndpoint = true;
- return request.call(https, options, cb);
- };
- })(https.request);
- https.request[patchMarker] = true;
-}
-
-/**
- * This is needed for Node.js >= 9.0.0 to make sure `https.get()` uses the
- * patched `https.request()`.
- *
- * Ref: https://github.com/nodejs/node/commit/5118f31
- */
-https.get = function (_url, _options, cb) {
- let options;
- if (typeof _url === 'string' && _options && typeof _options !== 'function') {
- options = Object.assign({}, url.parse(_url), _options);
- } else if (!_options && !cb) {
- options = _url;
- } else if (!cb) {
- options = _url;
- cb = _options;
- }
-
- const req = https.request(options, cb);
- req.end();
- return req;
-};
-
-
-/***/ }),
-/* 56 */
-/***/ (function(module, exports) {
-
-module.exports = require("util");
-
-/***/ }),
-/* 57 */
-/***/ (function(module, exports, __webpack_require__) {
-
-"use strict";
-
-
-/* global module, require */
-module.exports = function () {
-
- "use strict";
-
- // Get a promise object. This may be native, or it may be polyfilled
-
- var ES6Promise = __webpack_require__(58);
-
- /**
- * thatLooksLikeAPromiseToMe()
- *
- * Duck-types a promise.
- *
- * @param {object} o
- * @return {bool} True if this resembles a promise
- */
- function thatLooksLikeAPromiseToMe(o) {
- return o && typeof o.then === "function" && typeof o.catch === "function";
- }
-
- /**
- * promisify()
- *
- * Transforms callback-based function -- func(arg1, arg2 .. argN, callback) -- into
- * an ES6-compatible Promise. Promisify provides a default callback of the form (error, result)
- * and rejects when `error` is truthy. You can also supply settings object as the second argument.
- *
- * @param {function} original - The function to promisify
- * @param {object} settings - Settings object
- * @param {object} settings.thisArg - A `this` context to use. If not set, assume `settings` _is_ `thisArg`
- * @param {bool} settings.multiArgs - Should multiple arguments be returned as an array?
- * @return {function} A promisified version of `original`
- */
- return function promisify(original, settings) {
-
- return function () {
- for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
- args[_key] = arguments[_key];
- }
-
- var returnMultipleArguments = settings && settings.multiArgs;
-
- var target = void 0;
- if (settings && settings.thisArg) {
- target = settings.thisArg;
- } else if (settings) {
- target = settings;
- }
-
- // Return the promisified function
- return new ES6Promise(function (resolve, reject) {
-
- // Append the callback bound to the context
- args.push(function callback(err) {
-
- if (err) {
- return reject(err);
- }
-
- for (var _len2 = arguments.length, values = Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
- values[_key2 - 1] = arguments[_key2];
- }
-
- if (false === !!returnMultipleArguments) {
- return resolve(values[0]);
- }
-
- resolve(values);
- });
-
- // Call the function
- var response = original.apply(target, args);
-
- // If it looks like original already returns a promise,
- // then just resolve with that promise. Hopefully, the callback function we added will just be ignored.
- if (thatLooksLikeAPromiseToMe(response)) {
- resolve(response);
- }
- });
- };
- };
-}();
-
-/***/ }),
-/* 58 */
-/***/ (function(module, exports, __webpack_require__) {
-
-"use strict";
-
-
-/* global self, window, module, global, require */
-module.exports = function () {
-
- "use strict";
-
- var globalObject = void 0;
-
- function isFunction(x) {
- return typeof x === "function";
- }
-
- // Seek the global object
- if (global !== undefined) {
- globalObject = global;
- } else if (window !== undefined && window.document) {
- globalObject = window;
- } else {
- globalObject = self;
- }
-
- // Test for any native promise implementation, and if that
- // implementation appears to conform to the specificaton.
- // This code mostly nicked from the es6-promise module polyfill
- // and then fooled with.
- var hasPromiseSupport = function () {
-
- // No promise object at all, and it's a non-starter
- if (!globalObject.hasOwnProperty("Promise")) {
- return false;
- }
-
- // There is a Promise object. Does it conform to the spec?
- var P = globalObject.Promise;
-
- // Some of these methods are missing from
- // Firefox/Chrome experimental implementations
- if (!P.hasOwnProperty("resolve") || !P.hasOwnProperty("reject")) {
- return false;
- }
-
- if (!P.hasOwnProperty("all") || !P.hasOwnProperty("race")) {
- return false;
- }
-
- // Older version of the spec had a resolver object
- // as the arg rather than a function
- return function () {
-
- var resolve = void 0;
-
- var p = new globalObject.Promise(function (r) {
- resolve = r;
- });
-
- if (p) {
- return isFunction(resolve);
- }
-
- return false;
- }();
- }();
-
- // Export the native Promise implementation if it
- // looks like it matches the spec
- if (hasPromiseSupport) {
- return globalObject.Promise;
- }
-
- // Otherwise, return the es6-promise polyfill by @jaffathecake.
- return __webpack_require__(59).Promise;
-}();
-
-/***/ }),
-/* 59 */
-/***/ (function(module, exports, __webpack_require__) {
-
-/*!
- * @overview es6-promise - a tiny implementation of Promises/A+.
- * @copyright Copyright (c) 2014 Yehuda Katz, Tom Dale, Stefan Penner and contributors (Conversion to ES6 API by Jake Archibald)
- * @license Licensed under MIT license
- * See https://raw.githubusercontent.com/stefanpenner/es6-promise/master/LICENSE
- * @version v4.2.8+1e68dce6
- */
-
-(function (global, factory) {
- true ? module.exports = factory() :
- undefined;
-}(this, (function () { 'use strict';
-
-function objectOrFunction(x) {
- var type = typeof x;
- return x !== null && (type === 'object' || type === 'function');
-}
-
-function isFunction(x) {
- return typeof x === 'function';
-}
-
-
-
-var _isArray = void 0;
-if (Array.isArray) {
- _isArray = Array.isArray;
-} else {
- _isArray = function (x) {
- return Object.prototype.toString.call(x) === '[object Array]';
- };
-}
-
-var isArray = _isArray;
-
-var len = 0;
-var vertxNext = void 0;
-var customSchedulerFn = void 0;
-
-var asap = function asap(callback, arg) {
- queue[len] = callback;
- queue[len + 1] = arg;
- len += 2;
- if (len === 2) {
- // If len is 2, that means that we need to schedule an async flush.
- // If additional callbacks are queued before the queue is flushed, they
- // will be processed by this flush that we are scheduling.
- if (customSchedulerFn) {
- customSchedulerFn(flush);
- } else {
- scheduleFlush();
- }
- }
-};
-
-function setScheduler(scheduleFn) {
- customSchedulerFn = scheduleFn;
-}
-
-function setAsap(asapFn) {
- asap = asapFn;
-}
-
-var browserWindow = typeof window !== 'undefined' ? window : undefined;
-var browserGlobal = browserWindow || {};
-var BrowserMutationObserver = browserGlobal.MutationObserver || browserGlobal.WebKitMutationObserver;
-var isNode = typeof self === 'undefined' && typeof process !== 'undefined' && {}.toString.call(process) === '[object process]';
-
-// test for web worker but not in IE10
-var isWorker = typeof Uint8ClampedArray !== 'undefined' && typeof importScripts !== 'undefined' && typeof MessageChannel !== 'undefined';
-
-// node
-function useNextTick() {
- // node version 0.10.x displays a deprecation warning when nextTick is used recursively
- // see https://github.com/cujojs/when/issues/410 for details
- return function () {
- return process.nextTick(flush);
- };
-}
-
-// vertx
-function useVertxTimer() {
- if (typeof vertxNext !== 'undefined') {
- return function () {
- vertxNext(flush);
- };
- }
-
- return useSetTimeout();
-}
-
-function useMutationObserver() {
- var iterations = 0;
- var observer = new BrowserMutationObserver(flush);
- var node = document.createTextNode('');
- observer.observe(node, { characterData: true });
-
- return function () {
- node.data = iterations = ++iterations % 2;
- };
-}
-
-// web worker
-function useMessageChannel() {
- var channel = new MessageChannel();
- channel.port1.onmessage = flush;
- return function () {
- return channel.port2.postMessage(0);
- };
-}
-
-function useSetTimeout() {
- // Store setTimeout reference so es6-promise will be unaffected by
- // other code modifying setTimeout (like sinon.useFakeTimers())
- var globalSetTimeout = setTimeout;
- return function () {
- return globalSetTimeout(flush, 1);
- };
-}
-
-var queue = new Array(1000);
-function flush() {
- for (var i = 0; i < len; i += 2) {
- var callback = queue[i];
- var arg = queue[i + 1];
-
- callback(arg);
-
- queue[i] = undefined;
- queue[i + 1] = undefined;
- }
-
- len = 0;
-}
-
-function attemptVertx() {
- try {
- var vertx = Function('return this')().require('vertx');
- vertxNext = vertx.runOnLoop || vertx.runOnContext;
- return useVertxTimer();
- } catch (e) {
- return useSetTimeout();
- }
-}
-
-var scheduleFlush = void 0;
-// Decide what async method to use to triggering processing of queued callbacks:
-if (isNode) {
- scheduleFlush = useNextTick();
-} else if (BrowserMutationObserver) {
- scheduleFlush = useMutationObserver();
-} else if (isWorker) {
- scheduleFlush = useMessageChannel();
-} else if (browserWindow === undefined && "function" === 'function') {
- scheduleFlush = attemptVertx();
-} else {
- scheduleFlush = useSetTimeout();
-}
-
-function then(onFulfillment, onRejection) {
- var parent = this;
-
- var child = new this.constructor(noop);
-
- if (child[PROMISE_ID] === undefined) {
- makePromise(child);
- }
-
- var _state = parent._state;
-
-
- if (_state) {
- var callback = arguments[_state - 1];
- asap(function () {
- return invokeCallback(_state, child, callback, parent._result);
- });
- } else {
- subscribe(parent, child, onFulfillment, onRejection);
- }
-
- return child;
-}
-
-/**
- `Promise.resolve` returns a promise that will become resolved with the
- passed `value`. It is shorthand for the following:
-
- ```javascript
- let promise = new Promise(function(resolve, reject){
- resolve(1);
- });
-
- promise.then(function(value){
- // value === 1
- });
- ```
-
- Instead of writing the above, your code now simply becomes the following:
-
- ```javascript
- let promise = Promise.resolve(1);
-
- promise.then(function(value){
- // value === 1
- });
- ```
-
- @method resolve
- @static
- @param {Any} value value that the returned promise will be resolved with
- Useful for tooling.
- @return {Promise} a promise that will become fulfilled with the given
- `value`
-*/
-function resolve$1(object) {
- /*jshint validthis:true */
- var Constructor = this;
-
- if (object && typeof object === 'object' && object.constructor === Constructor) {
- return object;
- }
-
- var promise = new Constructor(noop);
- resolve(promise, object);
- return promise;
-}
-
-var PROMISE_ID = Math.random().toString(36).substring(2);
-
-function noop() {}
-
-var PENDING = void 0;
-var FULFILLED = 1;
-var REJECTED = 2;
-
-function selfFulfillment() {
- return new TypeError("You cannot resolve a promise with itself");
-}
-
-function cannotReturnOwn() {
- return new TypeError('A promises callback cannot return that same promise.');
-}
-
-function tryThen(then$$1, value, fulfillmentHandler, rejectionHandler) {
- try {
- then$$1.call(value, fulfillmentHandler, rejectionHandler);
- } catch (e) {
- return e;
- }
-}
-
-function handleForeignThenable(promise, thenable, then$$1) {
- asap(function (promise) {
- var sealed = false;
- var error = tryThen(then$$1, thenable, function (value) {
- if (sealed) {
- return;
- }
- sealed = true;
- if (thenable !== value) {
- resolve(promise, value);
- } else {
- fulfill(promise, value);
- }
- }, function (reason) {
- if (sealed) {
- return;
- }
- sealed = true;
-
- reject(promise, reason);
- }, 'Settle: ' + (promise._label || ' unknown promise'));
-
- if (!sealed && error) {
- sealed = true;
- reject(promise, error);
- }
- }, promise);
-}
-
-function handleOwnThenable(promise, thenable) {
- if (thenable._state === FULFILLED) {
- fulfill(promise, thenable._result);
- } else if (thenable._state === REJECTED) {
- reject(promise, thenable._result);
- } else {
- subscribe(thenable, undefined, function (value) {
- return resolve(promise, value);
- }, function (reason) {
- return reject(promise, reason);
- });
- }
-}
-
-function handleMaybeThenable(promise, maybeThenable, then$$1) {
- if (maybeThenable.constructor === promise.constructor && then$$1 === then && maybeThenable.constructor.resolve === resolve$1) {
- handleOwnThenable(promise, maybeThenable);
- } else {
- if (then$$1 === undefined) {
- fulfill(promise, maybeThenable);
- } else if (isFunction(then$$1)) {
- handleForeignThenable(promise, maybeThenable, then$$1);
- } else {
- fulfill(promise, maybeThenable);
- }
- }
-}
-
-function resolve(promise, value) {
- if (promise === value) {
- reject(promise, selfFulfillment());
- } else if (objectOrFunction(value)) {
- var then$$1 = void 0;
- try {
- then$$1 = value.then;
- } catch (error) {
- reject(promise, error);
- return;
- }
- handleMaybeThenable(promise, value, then$$1);
- } else {
- fulfill(promise, value);
- }
-}
-
-function publishRejection(promise) {
- if (promise._onerror) {
- promise._onerror(promise._result);
- }
-
- publish(promise);
-}
-
-function fulfill(promise, value) {
- if (promise._state !== PENDING) {
- return;
- }
-
- promise._result = value;
- promise._state = FULFILLED;
-
- if (promise._subscribers.length !== 0) {
- asap(publish, promise);
- }
-}
-
-function reject(promise, reason) {
- if (promise._state !== PENDING) {
- return;
- }
- promise._state = REJECTED;
- promise._result = reason;
-
- asap(publishRejection, promise);
-}
-
-function subscribe(parent, child, onFulfillment, onRejection) {
- var _subscribers = parent._subscribers;
- var length = _subscribers.length;
-
-
- parent._onerror = null;
-
- _subscribers[length] = child;
- _subscribers[length + FULFILLED] = onFulfillment;
- _subscribers[length + REJECTED] = onRejection;
-
- if (length === 0 && parent._state) {
- asap(publish, parent);
- }
-}
-
-function publish(promise) {
- var subscribers = promise._subscribers;
- var settled = promise._state;
-
- if (subscribers.length === 0) {
- return;
- }
-
- var child = void 0,
- callback = void 0,
- detail = promise._result;
-
- for (var i = 0; i < subscribers.length; i += 3) {
- child = subscribers[i];
- callback = subscribers[i + settled];
-
- if (child) {
- invokeCallback(settled, child, callback, detail);
- } else {
- callback(detail);
- }
- }
-
- promise._subscribers.length = 0;
-}
-
-function invokeCallback(settled, promise, callback, detail) {
- var hasCallback = isFunction(callback),
- value = void 0,
- error = void 0,
- succeeded = true;
-
- if (hasCallback) {
- try {
- value = callback(detail);
- } catch (e) {
- succeeded = false;
- error = e;
- }
-
- if (promise === value) {
- reject(promise, cannotReturnOwn());
- return;
- }
- } else {
- value = detail;
- }
-
- if (promise._state !== PENDING) {
- // noop
- } else if (hasCallback && succeeded) {
- resolve(promise, value);
- } else if (succeeded === false) {
- reject(promise, error);
- } else if (settled === FULFILLED) {
- fulfill(promise, value);
- } else if (settled === REJECTED) {
- reject(promise, value);
- }
-}
-
-function initializePromise(promise, resolver) {
- try {
- resolver(function resolvePromise(value) {
- resolve(promise, value);
- }, function rejectPromise(reason) {
- reject(promise, reason);
- });
- } catch (e) {
- reject(promise, e);
- }
-}
-
-var id = 0;
-function nextId() {
- return id++;
-}
-
-function makePromise(promise) {
- promise[PROMISE_ID] = id++;
- promise._state = undefined;
- promise._result = undefined;
- promise._subscribers = [];
-}
-
-function validationError() {
- return new Error('Array Methods must be provided an Array');
-}
-
-var Enumerator = function () {
- function Enumerator(Constructor, input) {
- this._instanceConstructor = Constructor;
- this.promise = new Constructor(noop);
-
- if (!this.promise[PROMISE_ID]) {
- makePromise(this.promise);
- }
-
- if (isArray(input)) {
- this.length = input.length;
- this._remaining = input.length;
-
- this._result = new Array(this.length);
-
- if (this.length === 0) {
- fulfill(this.promise, this._result);
- } else {
- this.length = this.length || 0;
- this._enumerate(input);
- if (this._remaining === 0) {
- fulfill(this.promise, this._result);
- }
- }
- } else {
- reject(this.promise, validationError());
- }
- }
-
- Enumerator.prototype._enumerate = function _enumerate(input) {
- for (var i = 0; this._state === PENDING && i < input.length; i++) {
- this._eachEntry(input[i], i);
- }
- };
-
- Enumerator.prototype._eachEntry = function _eachEntry(entry, i) {
- var c = this._instanceConstructor;
- var resolve$$1 = c.resolve;
-
-
- if (resolve$$1 === resolve$1) {
- var _then = void 0;
- var error = void 0;
- var didError = false;
- try {
- _then = entry.then;
- } catch (e) {
- didError = true;
- error = e;
- }
-
- if (_then === then && entry._state !== PENDING) {
- this._settledAt(entry._state, i, entry._result);
- } else if (typeof _then !== 'function') {
- this._remaining--;
- this._result[i] = entry;
- } else if (c === Promise$1) {
- var promise = new c(noop);
- if (didError) {
- reject(promise, error);
- } else {
- handleMaybeThenable(promise, entry, _then);
- }
- this._willSettleAt(promise, i);
- } else {
- this._willSettleAt(new c(function (resolve$$1) {
- return resolve$$1(entry);
- }), i);
- }
- } else {
- this._willSettleAt(resolve$$1(entry), i);
- }
- };
-
- Enumerator.prototype._settledAt = function _settledAt(state, i, value) {
- var promise = this.promise;
-
-
- if (promise._state === PENDING) {
- this._remaining--;
-
- if (state === REJECTED) {
- reject(promise, value);
- } else {
- this._result[i] = value;
- }
- }
-
- if (this._remaining === 0) {
- fulfill(promise, this._result);
- }
- };
-
- Enumerator.prototype._willSettleAt = function _willSettleAt(promise, i) {
- var enumerator = this;
-
- subscribe(promise, undefined, function (value) {
- return enumerator._settledAt(FULFILLED, i, value);
- }, function (reason) {
- return enumerator._settledAt(REJECTED, i, reason);
- });
- };
-
- return Enumerator;
-}();
-
-/**
- `Promise.all` accepts an array of promises, and returns a new promise which
- is fulfilled with an array of fulfillment values for the passed promises, or
- rejected with the reason of the first passed promise to be rejected. It casts all
- elements of the passed iterable to promises as it runs this algorithm.
-
- Example:
-
- ```javascript
- let promise1 = resolve(1);
- let promise2 = resolve(2);
- let promise3 = resolve(3);
- let promises = [ promise1, promise2, promise3 ];
-
- Promise.all(promises).then(function(array){
- // The array here would be [ 1, 2, 3 ];
- });
- ```
-
- If any of the `promises` given to `all` are rejected, the first promise
- that is rejected will be given as an argument to the returned promises's
- rejection handler. For example:
-
- Example:
-
- ```javascript
- let promise1 = resolve(1);
- let promise2 = reject(new Error("2"));
- let promise3 = reject(new Error("3"));
- let promises = [ promise1, promise2, promise3 ];
-
- Promise.all(promises).then(function(array){
- // Code here never runs because there are rejected promises!
- }, function(error) {
- // error.message === "2"
- });
- ```
-
- @method all
- @static
- @param {Array} entries array of promises
- @param {String} label optional string for labeling the promise.
- Useful for tooling.
- @return {Promise} promise that is fulfilled when all `promises` have been
- fulfilled, or rejected if any of them become rejected.
- @static
-*/
-function all(entries) {
- return new Enumerator(this, entries).promise;
-}
-
-/**
- `Promise.race` returns a new promise which is settled in the same way as the
- first passed promise to settle.
-
- Example:
-
- ```javascript
- let promise1 = new Promise(function(resolve, reject){
- setTimeout(function(){
- resolve('promise 1');
- }, 200);
- });
-
- let promise2 = new Promise(function(resolve, reject){
- setTimeout(function(){
- resolve('promise 2');
- }, 100);
- });
-
- Promise.race([promise1, promise2]).then(function(result){
- // result === 'promise 2' because it was resolved before promise1
- // was resolved.
- });
- ```
-
- `Promise.race` is deterministic in that only the state of the first
- settled promise matters. For example, even if other promises given to the
- `promises` array argument are resolved, but the first settled promise has
- become rejected before the other promises became fulfilled, the returned
- promise will become rejected:
-
- ```javascript
- let promise1 = new Promise(function(resolve, reject){
- setTimeout(function(){
- resolve('promise 1');
- }, 200);
- });
-
- let promise2 = new Promise(function(resolve, reject){
- setTimeout(function(){
- reject(new Error('promise 2'));
- }, 100);
- });
-
- Promise.race([promise1, promise2]).then(function(result){
- // Code here never runs
- }, function(reason){
- // reason.message === 'promise 2' because promise 2 became rejected before
- // promise 1 became fulfilled
- });
- ```
-
- An example real-world use case is implementing timeouts:
-
- ```javascript
- Promise.race([ajax('foo.json'), timeout(5000)])
- ```
-
- @method race
- @static
- @param {Array} promises array of promises to observe
- Useful for tooling.
- @return {Promise} a promise which settles in the same way as the first passed
- promise to settle.
-*/
-function race(entries) {
- /*jshint validthis:true */
- var Constructor = this;
-
- if (!isArray(entries)) {
- return new Constructor(function (_, reject) {
- return reject(new TypeError('You must pass an array to race.'));
- });
- } else {
- return new Constructor(function (resolve, reject) {
- var length = entries.length;
- for (var i = 0; i < length; i++) {
- Constructor.resolve(entries[i]).then(resolve, reject);
- }
- });
- }
-}
-
-/**
- `Promise.reject` returns a promise rejected with the passed `reason`.
- It is shorthand for the following:
-
- ```javascript
- let promise = new Promise(function(resolve, reject){
- reject(new Error('WHOOPS'));
- });
-
- promise.then(function(value){
- // Code here doesn't run because the promise is rejected!
- }, function(reason){
- // reason.message === 'WHOOPS'
- });
- ```
-
- Instead of writing the above, your code now simply becomes the following:
-
- ```javascript
- let promise = Promise.reject(new Error('WHOOPS'));
-
- promise.then(function(value){
- // Code here doesn't run because the promise is rejected!
- }, function(reason){
- // reason.message === 'WHOOPS'
- });
- ```
-
- @method reject
- @static
- @param {Any} reason value that the returned promise will be rejected with.
- Useful for tooling.
- @return {Promise} a promise rejected with the given `reason`.
-*/
-function reject$1(reason) {
- /*jshint validthis:true */
- var Constructor = this;
- var promise = new Constructor(noop);
- reject(promise, reason);
- return promise;
-}
-
-function needsResolver() {
- throw new TypeError('You must pass a resolver function as the first argument to the promise constructor');
-}
-
-function needsNew() {
- throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.");
-}
-
-/**
- Promise objects represent the eventual result of an asynchronous operation. The
- primary way of interacting with a promise is through its `then` method, which
- registers callbacks to receive either a promise's eventual value or the reason
- why the promise cannot be fulfilled.
-
- Terminology
- -----------
-
- - `promise` is an object or function with a `then` method whose behavior conforms to this specification.
- - `thenable` is an object or function that defines a `then` method.
- - `value` is any legal JavaScript value (including undefined, a thenable, or a promise).
- - `exception` is a value that is thrown using the throw statement.
- - `reason` is a value that indicates why a promise was rejected.
- - `settled` the final resting state of a promise, fulfilled or rejected.
-
- A promise can be in one of three states: pending, fulfilled, or rejected.
-
- Promises that are fulfilled have a fulfillment value and are in the fulfilled
- state. Promises that are rejected have a rejection reason and are in the
- rejected state. A fulfillment value is never a thenable.
-
- Promises can also be said to *resolve* a value. If this value is also a
- promise, then the original promise's settled state will match the value's
- settled state. So a promise that *resolves* a promise that rejects will
- itself reject, and a promise that *resolves* a promise that fulfills will
- itself fulfill.
-
-
- Basic Usage:
- ------------
-
- ```js
- let promise = new Promise(function(resolve, reject) {
- // on success
- resolve(value);
-
- // on failure
- reject(reason);
- });
-
- promise.then(function(value) {
- // on fulfillment
- }, function(reason) {
- // on rejection
- });
- ```
-
- Advanced Usage:
- ---------------
-
- Promises shine when abstracting away asynchronous interactions such as
- `XMLHttpRequest`s.
-
- ```js
- function getJSON(url) {
- return new Promise(function(resolve, reject){
- let xhr = new XMLHttpRequest();
-
- xhr.open('GET', url);
- xhr.onreadystatechange = handler;
- xhr.responseType = 'json';
- xhr.setRequestHeader('Accept', 'application/json');
- xhr.send();
-
- function handler() {
- if (this.readyState === this.DONE) {
- if (this.status === 200) {
- resolve(this.response);
- } else {
- reject(new Error('getJSON: `' + url + '` failed with status: [' + this.status + ']'));
- }
- }
- };
- });
- }
-
- getJSON('/posts.json').then(function(json) {
- // on fulfillment
- }, function(reason) {
- // on rejection
- });
- ```
-
- Unlike callbacks, promises are great composable primitives.
-
- ```js
- Promise.all([
- getJSON('/posts'),
- getJSON('/comments')
- ]).then(function(values){
- values[0] // => postsJSON
- values[1] // => commentsJSON
-
- return values;
- });
- ```
-
- @class Promise
- @param {Function} resolver
- Useful for tooling.
- @constructor
-*/
-
-var Promise$1 = function () {
- function Promise(resolver) {
- this[PROMISE_ID] = nextId();
- this._result = this._state = undefined;
- this._subscribers = [];
-
- if (noop !== resolver) {
- typeof resolver !== 'function' && needsResolver();
- this instanceof Promise ? initializePromise(this, resolver) : needsNew();
- }
- }
-
- /**
- The primary way of interacting with a promise is through its `then` method,
- which registers callbacks to receive either a promise's eventual value or the
- reason why the promise cannot be fulfilled.
- ```js
- findUser().then(function(user){
- // user is available
- }, function(reason){
- // user is unavailable, and you are given the reason why
- });
- ```
- Chaining
- --------
- The return value of `then` is itself a promise. This second, 'downstream'
- promise is resolved with the return value of the first promise's fulfillment
- or rejection handler, or rejected if the handler throws an exception.
- ```js
- findUser().then(function (user) {
- return user.name;
- }, function (reason) {
- return 'default name';
- }).then(function (userName) {
- // If `findUser` fulfilled, `userName` will be the user's name, otherwise it
- // will be `'default name'`
- });
- findUser().then(function (user) {
- throw new Error('Found user, but still unhappy');
- }, function (reason) {
- throw new Error('`findUser` rejected and we're unhappy');
- }).then(function (value) {
- // never reached
- }, function (reason) {
- // if `findUser` fulfilled, `reason` will be 'Found user, but still unhappy'.
- // If `findUser` rejected, `reason` will be '`findUser` rejected and we're unhappy'.
- });
- ```
- If the downstream promise does not specify a rejection handler, rejection reasons will be propagated further downstream.
- ```js
- findUser().then(function (user) {
- throw new PedagogicalException('Upstream error');
- }).then(function (value) {
- // never reached
- }).then(function (value) {
- // never reached
- }, function (reason) {
- // The `PedgagocialException` is propagated all the way down to here
- });
- ```
- Assimilation
- ------------
- Sometimes the value you want to propagate to a downstream promise can only be
- retrieved asynchronously. This can be achieved by returning a promise in the
- fulfillment or rejection handler. The downstream promise will then be pending
- until the returned promise is settled. This is called *assimilation*.
- ```js
- findUser().then(function (user) {
- return findCommentsByAuthor(user);
- }).then(function (comments) {
- // The user's comments are now available
- });
- ```
- If the assimliated promise rejects, then the downstream promise will also reject.
- ```js
- findUser().then(function (user) {
- return findCommentsByAuthor(user);
- }).then(function (comments) {
- // If `findCommentsByAuthor` fulfills, we'll have the value here
- }, function (reason) {
- // If `findCommentsByAuthor` rejects, we'll have the reason here
- });
- ```
- Simple Example
- --------------
- Synchronous Example
- ```javascript
- let result;
- try {
- result = findResult();
- // success
- } catch(reason) {
- // failure
- }
- ```
- Errback Example
- ```js
- findResult(function(result, err){
- if (err) {
- // failure
- } else {
- // success
- }
- });
- ```
- Promise Example;
- ```javascript
- findResult().then(function(result){
- // success
- }, function(reason){
- // failure
- });
- ```
- Advanced Example
- --------------
- Synchronous Example
- ```javascript
- let author, books;
- try {
- author = findAuthor();
- books = findBooksByAuthor(author);
- // success
- } catch(reason) {
- // failure
- }
- ```
- Errback Example
- ```js
- function foundBooks(books) {
- }
- function failure(reason) {
- }
- findAuthor(function(author, err){
- if (err) {
- failure(err);
- // failure
- } else {
- try {
- findBoooksByAuthor(author, function(books, err) {
- if (err) {
- failure(err);
- } else {
- try {
- foundBooks(books);
- } catch(reason) {
- failure(reason);
- }
- }
- });
- } catch(error) {
- failure(err);
- }
- // success
- }
- });
- ```
- Promise Example;
- ```javascript
- findAuthor().
- then(findBooksByAuthor).
- then(function(books){
- // found books
- }).catch(function(reason){
- // something went wrong
- });
- ```
- @method then
- @param {Function} onFulfilled
- @param {Function} onRejected
- Useful for tooling.
- @return {Promise}
- */
-
- /**
- `catch` is simply sugar for `then(undefined, onRejection)` which makes it the same
- as the catch block of a try/catch statement.
- ```js
- function findAuthor(){
- throw new Error('couldn't find that author');
- }
- // synchronous
- try {
- findAuthor();
- } catch(reason) {
- // something went wrong
- }
- // async with promises
- findAuthor().catch(function(reason){
- // something went wrong
- });
- ```
- @method catch
- @param {Function} onRejection
- Useful for tooling.
- @return {Promise}
- */
-
-
- Promise.prototype.catch = function _catch(onRejection) {
- return this.then(null, onRejection);
- };
-
- /**
- `finally` will be invoked regardless of the promise's fate just as native
- try/catch/finally behaves
-
- Synchronous example:
-
- ```js
- findAuthor() {
- if (Math.random() > 0.5) {
- throw new Error();
- }
- return new Author();
- }
-
- try {
- return findAuthor(); // succeed or fail
- } catch(error) {
- return findOtherAuther();
- } finally {
- // always runs
- // doesn't affect the return value
- }
- ```
-
- Asynchronous example:
-
- ```js
- findAuthor().catch(function(reason){
- return findOtherAuther();
- }).finally(function(){
- // author was either found, or not
- });
- ```
-
- @method finally
- @param {Function} callback
- @return {Promise}
- */
-
-
- Promise.prototype.finally = function _finally(callback) {
- var promise = this;
- var constructor = promise.constructor;
-
- if (isFunction(callback)) {
- return promise.then(function (value) {
- return constructor.resolve(callback()).then(function () {
- return value;
- });
- }, function (reason) {
- return constructor.resolve(callback()).then(function () {
- throw reason;
- });
- });
- }
-
- return promise.then(callback, callback);
- };
-
- return Promise;
-}();
-
-Promise$1.prototype.then = then;
-Promise$1.all = all;
-Promise$1.race = race;
-Promise$1.resolve = resolve$1;
-Promise$1.reject = reject$1;
-Promise$1._setScheduler = setScheduler;
-Promise$1._setAsap = setAsap;
-Promise$1._asap = asap;
-
-/*global self*/
-function polyfill() {
- var local = void 0;
-
- if (typeof global !== 'undefined') {
- local = global;
- } else if (typeof self !== 'undefined') {
- local = self;
- } else {
- try {
- local = Function('return this')();
- } catch (e) {
- throw new Error('polyfill failed because global object is unavailable in this environment');
- }
- }
-
- var P = local.Promise;
-
- if (P) {
- var promiseToString = null;
- try {
- promiseToString = Object.prototype.toString.call(P.resolve());
- } catch (e) {
- // silently ignored
- }
-
- if (promiseToString === '[object Promise]' && !P.cast) {
- return;
- }
- }
-
- local.Promise = Promise$1;
-}
-
-// Strange compat..
-Promise$1.polyfill = polyfill;
-Promise$1.Promise = Promise$1;
-
-return Promise$1;
-
-})));
-
-
-
-//# sourceMappingURL=es6-promise.map
-
-
-/***/ }),
-/* 60 */
-/***/ (function(module, exports) {
-
-module.exports = require("events");
-
-/***/ }),
-/* 61 */
-/***/ (function(module, exports, __webpack_require__) {
-
-/**
- * Detect Electron renderer process, which is node, but we should
- * treat as a browser.
- */
-
-if (typeof process === 'undefined' || process.type === 'renderer') {
- module.exports = __webpack_require__(62);
-} else {
- module.exports = __webpack_require__(65);
-}
-
-
-/***/ }),
-/* 62 */
-/***/ (function(module, exports, __webpack_require__) {
-
-/**
- * This is the web browser implementation of `debug()`.
- *
- * Expose `debug()` as the module.
- */
-
-exports = module.exports = __webpack_require__(63);
-exports.log = log;
-exports.formatArgs = formatArgs;
-exports.save = save;
-exports.load = load;
-exports.useColors = useColors;
-exports.storage = 'undefined' != typeof chrome
- && 'undefined' != typeof chrome.storage
- ? chrome.storage.local
- : localstorage();
-
-/**
- * Colors.
- */
-
-exports.colors = [
- '#0000CC', '#0000FF', '#0033CC', '#0033FF', '#0066CC', '#0066FF', '#0099CC',
- '#0099FF', '#00CC00', '#00CC33', '#00CC66', '#00CC99', '#00CCCC', '#00CCFF',
- '#3300CC', '#3300FF', '#3333CC', '#3333FF', '#3366CC', '#3366FF', '#3399CC',
- '#3399FF', '#33CC00', '#33CC33', '#33CC66', '#33CC99', '#33CCCC', '#33CCFF',
- '#6600CC', '#6600FF', '#6633CC', '#6633FF', '#66CC00', '#66CC33', '#9900CC',
- '#9900FF', '#9933CC', '#9933FF', '#99CC00', '#99CC33', '#CC0000', '#CC0033',
- '#CC0066', '#CC0099', '#CC00CC', '#CC00FF', '#CC3300', '#CC3333', '#CC3366',
- '#CC3399', '#CC33CC', '#CC33FF', '#CC6600', '#CC6633', '#CC9900', '#CC9933',
- '#CCCC00', '#CCCC33', '#FF0000', '#FF0033', '#FF0066', '#FF0099', '#FF00CC',
- '#FF00FF', '#FF3300', '#FF3333', '#FF3366', '#FF3399', '#FF33CC', '#FF33FF',
- '#FF6600', '#FF6633', '#FF9900', '#FF9933', '#FFCC00', '#FFCC33'
-];
-
-/**
- * Currently only WebKit-based Web Inspectors, Firefox >= v31,
- * and the Firebug extension (any Firefox version) are known
- * to support "%c" CSS customizations.
- *
- * TODO: add a `localStorage` variable to explicitly enable/disable colors
- */
-
-function useColors() {
- // NB: In an Electron preload script, document will be defined but not fully
- // initialized. Since we know we're in Chrome, we'll just detect this case
- // explicitly
- if (typeof window !== 'undefined' && window.process && window.process.type === 'renderer') {
- return true;
- }
-
- // Internet Explorer and Edge do not support colors.
- if (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) {
- return false;
- }
-
- // is webkit? http://stackoverflow.com/a/16459606/376773
- // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632
- return (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) ||
- // is firebug? http://stackoverflow.com/a/398120/376773
- (typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) ||
- // is firefox >= v31?
- // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
- (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31) ||
- // double check webkit in userAgent just in case we are in a worker
- (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/));
-}
-
-/**
- * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.
- */
-
-exports.formatters.j = function(v) {
- try {
- return JSON.stringify(v);
- } catch (err) {
- return '[UnexpectedJSONParseError]: ' + err.message;
- }
-};
-
-
-/**
- * Colorize log arguments if enabled.
- *
- * @api public
- */
-
-function formatArgs(args) {
- var useColors = this.useColors;
-
- args[0] = (useColors ? '%c' : '')
- + this.namespace
- + (useColors ? ' %c' : ' ')
- + args[0]
- + (useColors ? '%c ' : ' ')
- + '+' + exports.humanize(this.diff);
-
- if (!useColors) return;
-
- var c = 'color: ' + this.color;
- args.splice(1, 0, c, 'color: inherit')
-
- // the final "%c" is somewhat tricky, because there could be other
- // arguments passed either before or after the %c, so we need to
- // figure out the correct index to insert the CSS into
- var index = 0;
- var lastC = 0;
- args[0].replace(/%[a-zA-Z%]/g, function(match) {
- if ('%%' === match) return;
- index++;
- if ('%c' === match) {
- // we only are interested in the *last* %c
- // (the user may have provided their own)
- lastC = index;
- }
- });
-
- args.splice(lastC, 0, c);
-}
-
-/**
- * Invokes `console.log()` when available.
- * No-op when `console.log` is not a "function".
- *
- * @api public
- */
-
-function log() {
- // this hackery is required for IE8/9, where
- // the `console.log` function doesn't have 'apply'
- return 'object' === typeof console
- && console.log
- && Function.prototype.apply.call(console.log, console, arguments);
-}
-
-/**
- * Save `namespaces`.
- *
- * @param {String} namespaces
- * @api private
- */
-
-function save(namespaces) {
- try {
- if (null == namespaces) {
- exports.storage.removeItem('debug');
- } else {
- exports.storage.debug = namespaces;
- }
- } catch(e) {}
-}
-
-/**
- * Load `namespaces`.
- *
- * @return {String} returns the previously persisted debug modes
- * @api private
- */
-
-function load() {
- var r;
- try {
- r = exports.storage.debug;
- } catch(e) {}
-
- // If debug isn't set in LS, and we're in Electron, try to load $DEBUG
- if (!r && typeof process !== 'undefined' && 'env' in process) {
- r = process.env.DEBUG;
- }
-
- return r;
-}
-
-/**
- * Enable namespaces listed in `localStorage.debug` initially.
- */
-
-exports.enable(load());
-
-/**
- * Localstorage attempts to return the localstorage.
- *
- * This is necessary because safari throws
- * when a user disables cookies/localstorage
- * and you attempt to access it.
- *
- * @return {LocalStorage}
- * @api private
- */
-
-function localstorage() {
- try {
- return window.localStorage;
- } catch (e) {}
-}
-
-
-/***/ }),
-/* 63 */
-/***/ (function(module, exports, __webpack_require__) {
-
-
-/**
- * This is the common logic for both the Node.js and web browser
- * implementations of `debug()`.
- *
- * Expose `debug()` as the module.
- */
-
-exports = module.exports = createDebug.debug = createDebug['default'] = createDebug;
-exports.coerce = coerce;
-exports.disable = disable;
-exports.enable = enable;
-exports.enabled = enabled;
-exports.humanize = __webpack_require__(64);
-
-/**
- * Active `debug` instances.
- */
-exports.instances = [];
-
-/**
- * The currently active debug mode names, and names to skip.
- */
-
-exports.names = [];
-exports.skips = [];
-
-/**
- * Map of special "%n" handling functions, for the debug "format" argument.
- *
- * Valid key names are a single, lower or upper-case letter, i.e. "n" and "N".
- */
-
-exports.formatters = {};
-
-/**
- * Select a color.
- * @param {String} namespace
- * @return {Number}
- * @api private
- */
-
-function selectColor(namespace) {
- var hash = 0, i;
-
- for (i in namespace) {
- hash = ((hash << 5) - hash) + namespace.charCodeAt(i);
- hash |= 0; // Convert to 32bit integer
- }
-
- return exports.colors[Math.abs(hash) % exports.colors.length];
-}
-
-/**
- * Create a debugger with the given `namespace`.
- *
- * @param {String} namespace
- * @return {Function}
- * @api public
- */
-
-function createDebug(namespace) {
-
- var prevTime;
-
- function debug() {
- // disabled?
- if (!debug.enabled) return;
-
- var self = debug;
-
- // set `diff` timestamp
- var curr = +new Date();
- var ms = curr - (prevTime || curr);
- self.diff = ms;
- self.prev = prevTime;
- self.curr = curr;
- prevTime = curr;
-
- // turn the `arguments` into a proper Array
- var args = new Array(arguments.length);
- for (var i = 0; i < args.length; i++) {
- args[i] = arguments[i];
- }
-
- args[0] = exports.coerce(args[0]);
-
- if ('string' !== typeof args[0]) {
- // anything else let's inspect with %O
- args.unshift('%O');
- }
-
- // apply any `formatters` transformations
- var index = 0;
- args[0] = args[0].replace(/%([a-zA-Z%])/g, function(match, format) {
- // if we encounter an escaped % then don't increase the array index
- if (match === '%%') return match;
- index++;
- var formatter = exports.formatters[format];
- if ('function' === typeof formatter) {
- var val = args[index];
- match = formatter.call(self, val);
-
- // now we need to remove `args[index]` since it's inlined in the `format`
- args.splice(index, 1);
- index--;
- }
- return match;
- });
-
- // apply env-specific formatting (colors, etc.)
- exports.formatArgs.call(self, args);
-
- var logFn = debug.log || exports.log || console.log.bind(console);
- logFn.apply(self, args);
- }
-
- debug.namespace = namespace;
- debug.enabled = exports.enabled(namespace);
- debug.useColors = exports.useColors();
- debug.color = selectColor(namespace);
- debug.destroy = destroy;
-
- // env-specific initialization logic for debug instances
- if ('function' === typeof exports.init) {
- exports.init(debug);
- }
-
- exports.instances.push(debug);
-
- return debug;
-}
-
-function destroy () {
- var index = exports.instances.indexOf(this);
- if (index !== -1) {
- exports.instances.splice(index, 1);
- return true;
- } else {
- return false;
- }
-}
-
-/**
- * Enables a debug mode by namespaces. This can include modes
- * separated by a colon and wildcards.
- *
- * @param {String} namespaces
- * @api public
- */
-
-function enable(namespaces) {
- exports.save(namespaces);
-
- exports.names = [];
- exports.skips = [];
-
- var i;
- var split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/);
- var len = split.length;
-
- for (i = 0; i < len; i++) {
- if (!split[i]) continue; // ignore empty strings
- namespaces = split[i].replace(/\*/g, '.*?');
- if (namespaces[0] === '-') {
- exports.skips.push(new RegExp('^' + namespaces.substr(1) + '$'));
- } else {
- exports.names.push(new RegExp('^' + namespaces + '$'));
- }
- }
-
- for (i = 0; i < exports.instances.length; i++) {
- var instance = exports.instances[i];
- instance.enabled = exports.enabled(instance.namespace);
- }
-}
-
-/**
- * Disable debug output.
- *
- * @api public
- */
-
-function disable() {
- exports.enable('');
-}
-
-/**
- * Returns true if the given mode name is enabled, false otherwise.
- *
- * @param {String} name
- * @return {Boolean}
- * @api public
- */
-
-function enabled(name) {
- if (name[name.length - 1] === '*') {
- return true;
- }
- var i, len;
- for (i = 0, len = exports.skips.length; i < len; i++) {
- if (exports.skips[i].test(name)) {
- return false;
- }
- }
- for (i = 0, len = exports.names.length; i < len; i++) {
- if (exports.names[i].test(name)) {
- return true;
- }
- }
- return false;
-}
-
-/**
- * Coerce `val`.
- *
- * @param {Mixed} val
- * @return {Mixed}
- * @api private
- */
-
-function coerce(val) {
- if (val instanceof Error) return val.stack || val.message;
- return val;
-}
-
-
-/***/ }),
-/* 64 */
-/***/ (function(module, exports) {
-
-/**
- * Helpers.
- */
-
-var s = 1000;
-var m = s * 60;
-var h = m * 60;
-var d = h * 24;
-var y = d * 365.25;
-
-/**
- * Parse or format the given `val`.
- *
- * Options:
- *
- * - `long` verbose formatting [false]
- *
- * @param {String|Number} val
- * @param {Object} [options]
- * @throws {Error} throw an error if val is not a non-empty string or a number
- * @return {String|Number}
- * @api public
- */
-
-module.exports = function(val, options) {
- options = options || {};
- var type = typeof val;
- if (type === 'string' && val.length > 0) {
- return parse(val);
- } else if (type === 'number' && isNaN(val) === false) {
- return options.long ? fmtLong(val) : fmtShort(val);
- }
- throw new Error(
- 'val is not a non-empty string or a valid number. val=' +
- JSON.stringify(val)
- );
-};
-
-/**
- * Parse the given `str` and return milliseconds.
- *
- * @param {String} str
- * @return {Number}
- * @api private
- */
-
-function parse(str) {
- str = String(str);
- if (str.length > 100) {
- return;
- }
- var match = /^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(
- str
- );
- if (!match) {
- return;
- }
- var n = parseFloat(match[1]);
- var type = (match[2] || 'ms').toLowerCase();
- switch (type) {
- case 'years':
- case 'year':
- case 'yrs':
- case 'yr':
- case 'y':
- return n * y;
- case 'days':
- case 'day':
- case 'd':
- return n * d;
- case 'hours':
- case 'hour':
- case 'hrs':
- case 'hr':
- case 'h':
- return n * h;
- case 'minutes':
- case 'minute':
- case 'mins':
- case 'min':
- case 'm':
- return n * m;
- case 'seconds':
- case 'second':
- case 'secs':
- case 'sec':
- case 's':
- return n * s;
- case 'milliseconds':
- case 'millisecond':
- case 'msecs':
- case 'msec':
- case 'ms':
- return n;
- default:
- return undefined;
- }
-}
-
-/**
- * Short format for `ms`.
- *
- * @param {Number} ms
- * @return {String}
- * @api private
- */
-
-function fmtShort(ms) {
- if (ms >= d) {
- return Math.round(ms / d) + 'd';
- }
- if (ms >= h) {
- return Math.round(ms / h) + 'h';
- }
- if (ms >= m) {
- return Math.round(ms / m) + 'm';
- }
- if (ms >= s) {
- return Math.round(ms / s) + 's';
- }
- return ms + 'ms';
-}
-
-/**
- * Long format for `ms`.
- *
- * @param {Number} ms
- * @return {String}
- * @api private
- */
-
-function fmtLong(ms) {
- return plural(ms, d, 'day') ||
- plural(ms, h, 'hour') ||
- plural(ms, m, 'minute') ||
- plural(ms, s, 'second') ||
- ms + ' ms';
-}
-
-/**
- * Pluralization helper.
- */
-
-function plural(ms, n, name) {
- if (ms < n) {
- return;
- }
- if (ms < n * 1.5) {
- return Math.floor(ms / n) + ' ' + name;
- }
- return Math.ceil(ms / n) + ' ' + name + 's';
-}
-
-
-/***/ }),
-/* 65 */
-/***/ (function(module, exports, __webpack_require__) {
-
-/**
- * Module dependencies.
- */
-
-var tty = __webpack_require__(66);
-var util = __webpack_require__(56);
-
-/**
- * This is the Node.js implementation of `debug()`.
- *
- * Expose `debug()` as the module.
- */
-
-exports = module.exports = __webpack_require__(63);
-exports.init = init;
-exports.log = log;
-exports.formatArgs = formatArgs;
-exports.save = save;
-exports.load = load;
-exports.useColors = useColors;
-
-/**
- * Colors.
- */
-
-exports.colors = [ 6, 2, 3, 4, 5, 1 ];
-
-try {
- var supportsColor = __webpack_require__(67);
- if (supportsColor && supportsColor.level >= 2) {
- exports.colors = [
- 20, 21, 26, 27, 32, 33, 38, 39, 40, 41, 42, 43, 44, 45, 56, 57, 62, 63, 68,
- 69, 74, 75, 76, 77, 78, 79, 80, 81, 92, 93, 98, 99, 112, 113, 128, 129, 134,
- 135, 148, 149, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171,
- 172, 173, 178, 179, 184, 185, 196, 197, 198, 199, 200, 201, 202, 203, 204,
- 205, 206, 207, 208, 209, 214, 215, 220, 221
- ];
- }
-} catch (err) {
- // swallow - we only care if `supports-color` is available; it doesn't have to be.
-}
-
-/**
- * Build up the default `inspectOpts` object from the environment variables.
- *
- * $ DEBUG_COLORS=no DEBUG_DEPTH=10 DEBUG_SHOW_HIDDEN=enabled node script.js
- */
-
-exports.inspectOpts = Object.keys(process.env).filter(function (key) {
- return /^debug_/i.test(key);
-}).reduce(function (obj, key) {
- // camel-case
- var prop = key
- .substring(6)
- .toLowerCase()
- .replace(/_([a-z])/g, function (_, k) { return k.toUpperCase() });
-
- // coerce string value into JS value
- var val = process.env[key];
- if (/^(yes|on|true|enabled)$/i.test(val)) val = true;
- else if (/^(no|off|false|disabled)$/i.test(val)) val = false;
- else if (val === 'null') val = null;
- else val = Number(val);
-
- obj[prop] = val;
- return obj;
-}, {});
-
-/**
- * Is stdout a TTY? Colored output is enabled when `true`.
- */
-
-function useColors() {
- return 'colors' in exports.inspectOpts
- ? Boolean(exports.inspectOpts.colors)
- : tty.isatty(process.stderr.fd);
-}
-
-/**
- * Map %o to `util.inspect()`, all on a single line.
- */
-
-exports.formatters.o = function(v) {
- this.inspectOpts.colors = this.useColors;
- return util.inspect(v, this.inspectOpts)
- .split('\n').map(function(str) {
- return str.trim()
- }).join(' ');
-};
-
-/**
- * Map %o to `util.inspect()`, allowing multiple lines if needed.
- */
-
-exports.formatters.O = function(v) {
- this.inspectOpts.colors = this.useColors;
- return util.inspect(v, this.inspectOpts);
-};
-
-/**
- * Adds ANSI color escape codes if enabled.
- *
- * @api public
- */
-
-function formatArgs(args) {
- var name = this.namespace;
- var useColors = this.useColors;
-
- if (useColors) {
- var c = this.color;
- var colorCode = '\u001b[3' + (c < 8 ? c : '8;5;' + c);
- var prefix = ' ' + colorCode + ';1m' + name + ' ' + '\u001b[0m';
-
- args[0] = prefix + args[0].split('\n').join('\n' + prefix);
- args.push(colorCode + 'm+' + exports.humanize(this.diff) + '\u001b[0m');
- } else {
- args[0] = getDate() + name + ' ' + args[0];
- }
-}
-
-function getDate() {
- if (exports.inspectOpts.hideDate) {
- return '';
- } else {
- return new Date().toISOString() + ' ';
- }
-}
-
-/**
- * Invokes `util.format()` with the specified arguments and writes to stderr.
- */
-
-function log() {
- return process.stderr.write(util.format.apply(util, arguments) + '\n');
-}
-
-/**
- * Save `namespaces`.
- *
- * @param {String} namespaces
- * @api private
- */
-
-function save(namespaces) {
- if (null == namespaces) {
- // If you set a process.env field to null or undefined, it gets cast to the
- // string 'null' or 'undefined'. Just delete instead.
- delete process.env.DEBUG;
- } else {
- process.env.DEBUG = namespaces;
- }
-}
-
-/**
- * Load `namespaces`.
- *
- * @return {String} returns the previously persisted debug modes
- * @api private
- */
-
-function load() {
- return process.env.DEBUG;
-}
-
-/**
- * Init logic for `debug` instances.
- *
- * Create a new `inspectOpts` object in case `useColors` is set
- * differently for a particular `debug` instance.
- */
-
-function init (debug) {
- debug.inspectOpts = {};
-
- var keys = Object.keys(exports.inspectOpts);
- for (var i = 0; i < keys.length; i++) {
- debug.inspectOpts[keys[i]] = exports.inspectOpts[keys[i]];
- }
-}
-
-/**
- * Enable namespaces listed in `process.env.DEBUG` initially.
- */
-
-exports.enable(load());
-
-
-/***/ }),
-/* 66 */
-/***/ (function(module, exports) {
-
-module.exports = require("tty");
-
-/***/ }),
-/* 67 */
-/***/ (function(module, exports, __webpack_require__) {
-
-"use strict";
-
-const os = __webpack_require__(13);
-const hasFlag = __webpack_require__(68);
-
-const env = process.env;
-
-let forceColor;
-if (hasFlag('no-color') ||
- hasFlag('no-colors') ||
- hasFlag('color=false')) {
- forceColor = false;
-} else if (hasFlag('color') ||
- hasFlag('colors') ||
- hasFlag('color=true') ||
- hasFlag('color=always')) {
- forceColor = true;
-}
-if ('FORCE_COLOR' in env) {
- forceColor = env.FORCE_COLOR.length === 0 || parseInt(env.FORCE_COLOR, 10) !== 0;
-}
-
-function translateLevel(level) {
- if (level === 0) {
- return false;
- }
-
- return {
- level,
- hasBasic: true,
- has256: level >= 2,
- has16m: level >= 3
- };
-}
-
-function supportsColor(stream) {
- if (forceColor === false) {
- return 0;
- }
-
- if (hasFlag('color=16m') ||
- hasFlag('color=full') ||
- hasFlag('color=truecolor')) {
- return 3;
- }
-
- if (hasFlag('color=256')) {
- return 2;
- }
-
- if (stream && !stream.isTTY && forceColor !== true) {
- return 0;
- }
-
- const min = forceColor ? 1 : 0;
-
- if (process.platform === 'win32') {
- // Node.js 7.5.0 is the first version of Node.js to include a patch to
- // libuv that enables 256 color output on Windows. Anything earlier and it
- // won't work. However, here we target Node.js 8 at minimum as it is an LTS
- // release, and Node.js 7 is not. Windows 10 build 10586 is the first Windows
- // release that supports 256 colors. Windows 10 build 14931 is the first release
- // that supports 16m/TrueColor.
- const osRelease = os.release().split('.');
- if (
- Number(process.versions.node.split('.')[0]) >= 8 &&
- Number(osRelease[0]) >= 10 &&
- Number(osRelease[2]) >= 10586
- ) {
- return Number(osRelease[2]) >= 14931 ? 3 : 2;
- }
-
- return 1;
- }
-
- if ('CI' in env) {
- if (['TRAVIS', 'CIRCLECI', 'APPVEYOR', 'GITLAB_CI'].some(sign => sign in env) || env.CI_NAME === 'codeship') {
- return 1;
- }
-
- return min;
- }
-
- if ('TEAMCITY_VERSION' in env) {
- return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
- }
-
- if (env.COLORTERM === 'truecolor') {
- return 3;
- }
-
- if ('TERM_PROGRAM' in env) {
- const version = parseInt((env.TERM_PROGRAM_VERSION || '').split('.')[0], 10);
-
- switch (env.TERM_PROGRAM) {
- case 'iTerm.app':
- return version >= 3 ? 3 : 2;
- case 'Apple_Terminal':
- return 2;
- // No default
- }
- }
-
- if (/-256(color)?$/i.test(env.TERM)) {
- return 2;
- }
-
- if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
- return 1;
- }
-
- if ('COLORTERM' in env) {
- return 1;
- }
-
- if (env.TERM === 'dumb') {
- return min;
- }
-
- return min;
-}
-
-function getSupportLevel(stream) {
- const level = supportsColor(stream);
- return translateLevel(level);
-}
-
-module.exports = {
- supportsColor: getSupportLevel,
- stdout: getSupportLevel(process.stdout),
- stderr: getSupportLevel(process.stderr)
-};
-
-
-/***/ }),
-/* 68 */
-/***/ (function(module, exports, __webpack_require__) {
-
-"use strict";
-
-module.exports = (flag, argv) => {
- argv = argv || process.argv;
- const prefix = flag.startsWith('-') ? '' : (flag.length === 1 ? '-' : '--');
- const pos = argv.indexOf(prefix + flag);
- const terminatorPos = argv.indexOf('--');
- return pos !== -1 && (terminatorPos === -1 ? true : pos < terminatorPos);
-};
-
-
-/***/ }),
-/* 69 */
-/***/ (function(module, exports, __webpack_require__) {
-
-/**
- * Module dependencies.
- */
-
-var net = __webpack_require__(15);
-var tls = __webpack_require__(53);
-var url = __webpack_require__(40);
-var Agent = __webpack_require__(54);
-var inherits = __webpack_require__(56).inherits;
-var debug = __webpack_require__(70)('https-proxy-agent');
-
-/**
- * Module exports.
- */
-
-module.exports = HttpsProxyAgent;
-
-/**
- * The `HttpsProxyAgent` implements an HTTP Agent subclass that connects to the
- * specified "HTTP(s) proxy server" in order to proxy HTTPS requests.
- *
- * @api public
- */
-
-function HttpsProxyAgent(opts) {
- if (!(this instanceof HttpsProxyAgent)) return new HttpsProxyAgent(opts);
- if ('string' == typeof opts) opts = url.parse(opts);
- if (!opts)
- throw new Error(
- 'an HTTP(S) proxy server `host` and `port` must be specified!'
- );
- debug('creating new HttpsProxyAgent instance: %o', opts);
- Agent.call(this, opts);
-
- var proxy = Object.assign({}, opts);
-
- // if `true`, then connect to the proxy server over TLS. defaults to `false`.
- this.secureProxy = proxy.protocol ? /^https:?$/i.test(proxy.protocol) : false;
-
- // prefer `hostname` over `host`, and set the `port` if needed
- proxy.host = proxy.hostname || proxy.host;
- proxy.port = +proxy.port || (this.secureProxy ? 443 : 80);
-
- // ALPN is supported by Node.js >= v5.
- // attempt to negotiate http/1.1 for proxy servers that support http/2
- if (this.secureProxy && !('ALPNProtocols' in proxy)) {
- proxy.ALPNProtocols = ['http 1.1']
- }
-
- if (proxy.host && proxy.path) {
- // if both a `host` and `path` are specified then it's most likely the
- // result of a `url.parse()` call... we need to remove the `path` portion so
- // that `net.connect()` doesn't attempt to open that as a unix socket file.
- delete proxy.path;
- delete proxy.pathname;
- }
-
- this.proxy = proxy;
- this.defaultPort = 443;
-}
-inherits(HttpsProxyAgent, Agent);
-
-/**
- * Called when the node-core HTTP client library is creating a new HTTP request.
- *
- * @api public
- */
-
-HttpsProxyAgent.prototype.callback = function connect(req, opts, fn) {
- var proxy = this.proxy;
-
- // create a socket connection to the proxy server
- var socket;
- if (this.secureProxy) {
- socket = tls.connect(proxy);
- } else {
- socket = net.connect(proxy);
- }
-
- // we need to buffer any HTTP traffic that happens with the proxy before we get
- // the CONNECT response, so that if the response is anything other than an "200"
- // response code, then we can re-play the "data" events on the socket once the
- // HTTP parser is hooked up...
- var buffers = [];
- var buffersLength = 0;
-
- function read() {
- var b = socket.read();
- if (b) ondata(b);
- else socket.once('readable', read);
- }
-
- function cleanup() {
- socket.removeListener('data', ondata);
- socket.removeListener('end', onend);
- socket.removeListener('error', onerror);
- socket.removeListener('close', onclose);
- socket.removeListener('readable', read);
- }
-
- function onclose(err) {
- debug('onclose had error %o', err);
- }
-
- function onend() {
- debug('onend');
- }
-
- function onerror(err) {
- cleanup();
- fn(err);
- }
-
- function ondata(b) {
- buffers.push(b);
- buffersLength += b.length;
- var buffered = Buffer.concat(buffers, buffersLength);
- var str = buffered.toString('ascii');
-
- if (!~str.indexOf('\r\n\r\n')) {
- // keep buffering
- debug('have not received end of HTTP headers yet...');
- if (socket.read) {
- read();
- } else {
- socket.once('data', ondata);
- }
- return;
- }
-
- var firstLine = str.substring(0, str.indexOf('\r\n'));
- var statusCode = +firstLine.split(' ')[1];
- debug('got proxy server response: %o', firstLine);
-
- if (200 == statusCode) {
- // 200 Connected status code!
- var sock = socket;
-
- // nullify the buffered data since we won't be needing it
- buffers = buffered = null;
-
- if (opts.secureEndpoint) {
- // since the proxy is connecting to an SSL server, we have
- // to upgrade this socket connection to an SSL connection
- debug(
- 'upgrading proxy-connected socket to TLS connection: %o',
- opts.host
- );
- opts.socket = socket;
- opts.servername = opts.servername || opts.host;
- opts.host = null;
- opts.hostname = null;
- opts.port = null;
- sock = tls.connect(opts);
- }
-
- cleanup();
- fn(null, sock);
- } else {
- // some other status code that's not 200... need to re-play the HTTP header
- // "data" events onto the socket once the HTTP machinery is attached so that
- // the user can parse and handle the error status code
- cleanup();
-
- // save a reference to the concat'd Buffer for the `onsocket` callback
- buffers = buffered;
-
- // need to wait for the "socket" event to re-play the "data" events
- req.once('socket', onsocket);
- fn(null, socket);
- }
- }
-
- function onsocket(socket) {
- // replay the "buffers" Buffer onto the `socket`, since at this point
- // the HTTP module machinery has been hooked up for the user
- if ('function' == typeof socket.ondata) {
- // node <= v0.11.3, the `ondata` function is set on the socket
- socket.ondata(buffers, 0, buffers.length);
- } else if (socket.listeners('data').length > 0) {
- // node > v0.11.3, the "data" event is listened for directly
- socket.emit('data', buffers);
- } else {
- // never?
- throw new Error('should not happen...');
- }
-
- // nullify the cached Buffer instance
- buffers = null;
- }
-
- socket.on('error', onerror);
- socket.on('close', onclose);
- socket.on('end', onend);
-
- if (socket.read) {
- read();
- } else {
- socket.once('data', ondata);
- }
-
- var hostname = opts.host + ':' + opts.port;
- var msg = 'CONNECT ' + hostname + ' HTTP/1.1\r\n';
-
- var headers = Object.assign({}, proxy.headers);
- if (proxy.auth) {
- headers['Proxy-Authorization'] =
- 'Basic ' + Buffer.from(proxy.auth).toString('base64');
- }
-
- // the Host header should only include the port
- // number when it is a non-standard port
- var host = opts.host;
- if (!isDefaultPort(opts.port, opts.secureEndpoint)) {
- host += ':' + opts.port;
- }
- headers['Host'] = host;
-
- headers['Connection'] = 'close';
- Object.keys(headers).forEach(function(name) {
- msg += name + ': ' + headers[name] + '\r\n';
- });
-
- socket.write(msg + '\r\n');
-};
-
-function isDefaultPort(port, secure) {
- return Boolean((!secure && port === 80) || (secure && port === 443));
-}
-
-
-/***/ }),
-/* 70 */
-/***/ (function(module, exports, __webpack_require__) {
-
-"use strict";
-
-
-/**
- * Detect Electron renderer / nwjs process, which is node, but we should
- * treat as a browser.
- */
-if (typeof process === 'undefined' || process.type === 'renderer' || process.browser === true || process.__nwjs) {
- module.exports = __webpack_require__(71);
-} else {
- module.exports = __webpack_require__(74);
-}
-
-
-
-/***/ }),
-/* 71 */
-/***/ (function(module, exports, __webpack_require__) {
-
-"use strict";
-
-
-function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
-
-/* eslint-env browser */
-
-/**
- * This is the web browser implementation of `debug()`.
- */
-exports.log = log;
-exports.formatArgs = formatArgs;
-exports.save = save;
-exports.load = load;
-exports.useColors = useColors;
-exports.storage = localstorage();
-/**
- * Colors.
- */
-
-exports.colors = ['#0000CC', '#0000FF', '#0033CC', '#0033FF', '#0066CC', '#0066FF', '#0099CC', '#0099FF', '#00CC00', '#00CC33', '#00CC66', '#00CC99', '#00CCCC', '#00CCFF', '#3300CC', '#3300FF', '#3333CC', '#3333FF', '#3366CC', '#3366FF', '#3399CC', '#3399FF', '#33CC00', '#33CC33', '#33CC66', '#33CC99', '#33CCCC', '#33CCFF', '#6600CC', '#6600FF', '#6633CC', '#6633FF', '#66CC00', '#66CC33', '#9900CC', '#9900FF', '#9933CC', '#9933FF', '#99CC00', '#99CC33', '#CC0000', '#CC0033', '#CC0066', '#CC0099', '#CC00CC', '#CC00FF', '#CC3300', '#CC3333', '#CC3366', '#CC3399', '#CC33CC', '#CC33FF', '#CC6600', '#CC6633', '#CC9900', '#CC9933', '#CCCC00', '#CCCC33', '#FF0000', '#FF0033', '#FF0066', '#FF0099', '#FF00CC', '#FF00FF', '#FF3300', '#FF3333', '#FF3366', '#FF3399', '#FF33CC', '#FF33FF', '#FF6600', '#FF6633', '#FF9900', '#FF9933', '#FFCC00', '#FFCC33'];
-/**
- * Currently only WebKit-based Web Inspectors, Firefox >= v31,
- * and the Firebug extension (any Firefox version) are known
- * to support "%c" CSS customizations.
- *
- * TODO: add a `localStorage` variable to explicitly enable/disable colors
- */
-// eslint-disable-next-line complexity
-
-function useColors() {
- // NB: In an Electron preload script, document will be defined but not fully
- // initialized. Since we know we're in Chrome, we'll just detect this case
- // explicitly
- if (typeof window !== 'undefined' && window.process && (window.process.type === 'renderer' || window.process.__nwjs)) {
- return true;
- } // Internet Explorer and Edge do not support colors.
-
-
- if (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) {
- return false;
- } // Is webkit? http://stackoverflow.com/a/16459606/376773
- // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632
-
-
- return typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance || // Is firebug? http://stackoverflow.com/a/398120/376773
- typeof window !== 'undefined' && window.console && (window.console.firebug || window.console.exception && window.console.table) || // Is firefox >= v31?
- // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
- typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31 || // Double check webkit in userAgent just in case we are in a worker
- typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/);
-}
-/**
- * Colorize log arguments if enabled.
- *
- * @api public
- */
-
-
-function formatArgs(args) {
- args[0] = (this.useColors ? '%c' : '') + this.namespace + (this.useColors ? ' %c' : ' ') + args[0] + (this.useColors ? '%c ' : ' ') + '+' + module.exports.humanize(this.diff);
-
- if (!this.useColors) {
- return;
- }
-
- var c = 'color: ' + this.color;
- args.splice(1, 0, c, 'color: inherit'); // The final "%c" is somewhat tricky, because there could be other
- // arguments passed either before or after the %c, so we need to
- // figure out the correct index to insert the CSS into
-
- var index = 0;
- var lastC = 0;
- args[0].replace(/%[a-zA-Z%]/g, function (match) {
- if (match === '%%') {
- return;
- }
-
- index++;
-
- if (match === '%c') {
- // We only are interested in the *last* %c
- // (the user may have provided their own)
- lastC = index;
- }
- });
- args.splice(lastC, 0, c);
-}
-/**
- * Invokes `console.log()` when available.
- * No-op when `console.log` is not a "function".
- *
- * @api public
- */
-
-
-function log() {
- var _console;
-
- // This hackery is required for IE8/9, where
- // the `console.log` function doesn't have 'apply'
- return (typeof console === "undefined" ? "undefined" : _typeof(console)) === 'object' && console.log && (_console = console).log.apply(_console, arguments);
-}
-/**
- * Save `namespaces`.
- *
- * @param {String} namespaces
- * @api private
- */
-
-
-function save(namespaces) {
- try {
- if (namespaces) {
- exports.storage.setItem('debug', namespaces);
- } else {
- exports.storage.removeItem('debug');
- }
- } catch (error) {// Swallow
- // XXX (@Qix-) should we be logging these?
- }
-}
-/**
- * Load `namespaces`.
- *
- * @return {String} returns the previously persisted debug modes
- * @api private
- */
-
-
-function load() {
- var r;
-
- try {
- r = exports.storage.getItem('debug');
- } catch (error) {} // Swallow
- // XXX (@Qix-) should we be logging these?
- // If debug isn't set in LS, and we're in Electron, try to load $DEBUG
-
-
- if (!r && typeof process !== 'undefined' && 'env' in process) {
- r = process.env.DEBUG;
- }
-
- return r;
-}
-/**
- * Localstorage attempts to return the localstorage.
- *
- * This is necessary because safari throws
- * when a user disables cookies/localstorage
- * and you attempt to access it.
- *
- * @return {LocalStorage}
- * @api private
- */
-
-
-function localstorage() {
- try {
- // TVMLKit (Apple TV JS Runtime) does not have a window object, just localStorage in the global context
- // The Browser also has localStorage in the global context.
- return localStorage;
- } catch (error) {// Swallow
- // XXX (@Qix-) should we be logging these?
- }
-}
-
-module.exports = __webpack_require__(72)(exports);
-var formatters = module.exports.formatters;
-/**
- * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.
- */
-
-formatters.j = function (v) {
- try {
- return JSON.stringify(v);
- } catch (error) {
- return '[UnexpectedJSONParseError]: ' + error.message;
- }
-};
-
-
-
-/***/ }),
-/* 72 */
-/***/ (function(module, exports, __webpack_require__) {
-
-"use strict";
-
-
-/**
- * This is the common logic for both the Node.js and web browser
- * implementations of `debug()`.
- */
-function setup(env) {
- createDebug.debug = createDebug;
- createDebug.default = createDebug;
- createDebug.coerce = coerce;
- createDebug.disable = disable;
- createDebug.enable = enable;
- createDebug.enabled = enabled;
- createDebug.humanize = __webpack_require__(73);
- Object.keys(env).forEach(function (key) {
- createDebug[key] = env[key];
- });
- /**
- * Active `debug` instances.
- */
-
- createDebug.instances = [];
- /**
- * The currently active debug mode names, and names to skip.
- */
-
- createDebug.names = [];
- createDebug.skips = [];
- /**
- * Map of special "%n" handling functions, for the debug "format" argument.
- *
- * Valid key names are a single, lower or upper-case letter, i.e. "n" and "N".
- */
-
- createDebug.formatters = {};
- /**
- * Selects a color for a debug namespace
- * @param {String} namespace The namespace string for the for the debug instance to be colored
- * @return {Number|String} An ANSI color code for the given namespace
- * @api private
- */
-
- function selectColor(namespace) {
- var hash = 0;
-
- for (var i = 0; i < namespace.length; i++) {
- hash = (hash << 5) - hash + namespace.charCodeAt(i);
- hash |= 0; // Convert to 32bit integer
- }
-
- return createDebug.colors[Math.abs(hash) % createDebug.colors.length];
- }
-
- createDebug.selectColor = selectColor;
- /**
- * Create a debugger with the given `namespace`.
- *
- * @param {String} namespace
- * @return {Function}
- * @api public
- */
-
- function createDebug(namespace) {
- var prevTime;
-
- function debug() {
- // Disabled?
- if (!debug.enabled) {
- return;
- }
-
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
- args[_key] = arguments[_key];
- }
-
- var self = debug; // Set `diff` timestamp
-
- var curr = Number(new Date());
- var ms = curr - (prevTime || curr);
- self.diff = ms;
- self.prev = prevTime;
- self.curr = curr;
- prevTime = curr;
- args[0] = createDebug.coerce(args[0]);
-
- if (typeof args[0] !== 'string') {
- // Anything else let's inspect with %O
- args.unshift('%O');
- } // Apply any `formatters` transformations
-
-
- var index = 0;
- args[0] = args[0].replace(/%([a-zA-Z%])/g, function (match, format) {
- // If we encounter an escaped % then don't increase the array index
- if (match === '%%') {
- return match;
- }
-
- index++;
- var formatter = createDebug.formatters[format];
-
- if (typeof formatter === 'function') {
- var val = args[index];
- match = formatter.call(self, val); // Now we need to remove `args[index]` since it's inlined in the `format`
-
- args.splice(index, 1);
- index--;
- }
-
- return match;
- }); // Apply env-specific formatting (colors, etc.)
-
- createDebug.formatArgs.call(self, args);
- var logFn = self.log || createDebug.log;
- logFn.apply(self, args);
- }
-
- debug.namespace = namespace;
- debug.enabled = createDebug.enabled(namespace);
- debug.useColors = createDebug.useColors();
- debug.color = selectColor(namespace);
- debug.destroy = destroy;
- debug.extend = extend; // Debug.formatArgs = formatArgs;
- // debug.rawLog = rawLog;
- // env-specific initialization logic for debug instances
-
- if (typeof createDebug.init === 'function') {
- createDebug.init(debug);
- }
-
- createDebug.instances.push(debug);
- return debug;
- }
-
- function destroy() {
- var index = createDebug.instances.indexOf(this);
-
- if (index !== -1) {
- createDebug.instances.splice(index, 1);
- return true;
- }
-
- return false;
- }
-
- function extend(namespace, delimiter) {
- return createDebug(this.namespace + (typeof delimiter === 'undefined' ? ':' : delimiter) + namespace);
- }
- /**
- * Enables a debug mode by namespaces. This can include modes
- * separated by a colon and wildcards.
- *
- * @param {String} namespaces
- * @api public
- */
-
-
- function enable(namespaces) {
- createDebug.save(namespaces);
- createDebug.names = [];
- createDebug.skips = [];
- var i;
- var split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/);
- var len = split.length;
-
- for (i = 0; i < len; i++) {
- if (!split[i]) {
- // ignore empty strings
- continue;
- }
-
- namespaces = split[i].replace(/\*/g, '.*?');
-
- if (namespaces[0] === '-') {
- createDebug.skips.push(new RegExp('^' + namespaces.substr(1) + '$'));
- } else {
- createDebug.names.push(new RegExp('^' + namespaces + '$'));
- }
- }
-
- for (i = 0; i < createDebug.instances.length; i++) {
- var instance = createDebug.instances[i];
- instance.enabled = createDebug.enabled(instance.namespace);
- }
- }
- /**
- * Disable debug output.
- *
- * @api public
- */
-
-
- function disable() {
- createDebug.enable('');
- }
- /**
- * Returns true if the given mode name is enabled, false otherwise.
- *
- * @param {String} name
- * @return {Boolean}
- * @api public
- */
-
-
- function enabled(name) {
- if (name[name.length - 1] === '*') {
- return true;
- }
-
- var i;
- var len;
-
- for (i = 0, len = createDebug.skips.length; i < len; i++) {
- if (createDebug.skips[i].test(name)) {
- return false;
- }
- }
-
- for (i = 0, len = createDebug.names.length; i < len; i++) {
- if (createDebug.names[i].test(name)) {
- return true;
- }
- }
-
- return false;
- }
- /**
- * Coerce `val`.
- *
- * @param {Mixed} val
- * @return {Mixed}
- * @api private
- */
-
-
- function coerce(val) {
- if (val instanceof Error) {
- return val.stack || val.message;
- }
-
- return val;
- }
-
- createDebug.enable(createDebug.load());
- return createDebug;
-}
-
-module.exports = setup;
-
-
-
-/***/ }),
-/* 73 */
-/***/ (function(module, exports) {
-
-/**
- * Helpers.
- */
-
-var s = 1000;
-var m = s * 60;
-var h = m * 60;
-var d = h * 24;
-var w = d * 7;
-var y = d * 365.25;
-
-/**
- * Parse or format the given `val`.
- *
- * Options:
- *
- * - `long` verbose formatting [false]
- *
- * @param {String|Number} val
- * @param {Object} [options]
- * @throws {Error} throw an error if val is not a non-empty string or a number
- * @return {String|Number}
- * @api public
- */
-
-module.exports = function(val, options) {
- options = options || {};
- var type = typeof val;
- if (type === 'string' && val.length > 0) {
- return parse(val);
- } else if (type === 'number' && isFinite(val)) {
- return options.long ? fmtLong(val) : fmtShort(val);
- }
- throw new Error(
- 'val is not a non-empty string or a valid number. val=' +
- JSON.stringify(val)
- );
-};
-
-/**
- * Parse the given `str` and return milliseconds.
- *
- * @param {String} str
- * @return {Number}
- * @api private
- */
-
-function parse(str) {
- str = String(str);
- if (str.length > 100) {
- return;
- }
- var match = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(
- str
- );
- if (!match) {
- return;
- }
- var n = parseFloat(match[1]);
- var type = (match[2] || 'ms').toLowerCase();
- switch (type) {
- case 'years':
- case 'year':
- case 'yrs':
- case 'yr':
- case 'y':
- return n * y;
- case 'weeks':
- case 'week':
- case 'w':
- return n * w;
- case 'days':
- case 'day':
- case 'd':
- return n * d;
- case 'hours':
- case 'hour':
- case 'hrs':
- case 'hr':
- case 'h':
- return n * h;
- case 'minutes':
- case 'minute':
- case 'mins':
- case 'min':
- case 'm':
- return n * m;
- case 'seconds':
- case 'second':
- case 'secs':
- case 'sec':
- case 's':
- return n * s;
- case 'milliseconds':
- case 'millisecond':
- case 'msecs':
- case 'msec':
- case 'ms':
- return n;
- default:
- return undefined;
- }
-}
-
-/**
- * Short format for `ms`.
- *
- * @param {Number} ms
- * @return {String}
- * @api private
- */
-
-function fmtShort(ms) {
- var msAbs = Math.abs(ms);
- if (msAbs >= d) {
- return Math.round(ms / d) + 'd';
- }
- if (msAbs >= h) {
- return Math.round(ms / h) + 'h';
- }
- if (msAbs >= m) {
- return Math.round(ms / m) + 'm';
- }
- if (msAbs >= s) {
- return Math.round(ms / s) + 's';
- }
- return ms + 'ms';
-}
-
-/**
- * Long format for `ms`.
- *
- * @param {Number} ms
- * @return {String}
- * @api private
- */
-
-function fmtLong(ms) {
- var msAbs = Math.abs(ms);
- if (msAbs >= d) {
- return plural(ms, msAbs, d, 'day');
- }
- if (msAbs >= h) {
- return plural(ms, msAbs, h, 'hour');
- }
- if (msAbs >= m) {
- return plural(ms, msAbs, m, 'minute');
- }
- if (msAbs >= s) {
- return plural(ms, msAbs, s, 'second');
- }
- return ms + ' ms';
-}
-
-/**
- * Pluralization helper.
- */
-
-function plural(ms, msAbs, n, name) {
- var isPlural = msAbs >= n * 1.5;
- return Math.round(ms / n) + ' ' + name + (isPlural ? 's' : '');
-}
-
-
-/***/ }),
-/* 74 */
-/***/ (function(module, exports, __webpack_require__) {
-
-"use strict";
-
-
-/**
- * Module dependencies.
- */
-var tty = __webpack_require__(66);
-
-var util = __webpack_require__(56);
-/**
- * This is the Node.js implementation of `debug()`.
- */
-
-
-exports.init = init;
-exports.log = log;
-exports.formatArgs = formatArgs;
-exports.save = save;
-exports.load = load;
-exports.useColors = useColors;
-/**
- * Colors.
- */
-
-exports.colors = [6, 2, 3, 4, 5, 1];
-
-try {
- // Optional dependency (as in, doesn't need to be installed, NOT like optionalDependencies in package.json)
- // eslint-disable-next-line import/no-extraneous-dependencies
- var supportsColor = __webpack_require__(67);
-
- if (supportsColor && (supportsColor.stderr || supportsColor).level >= 2) {
- exports.colors = [20, 21, 26, 27, 32, 33, 38, 39, 40, 41, 42, 43, 44, 45, 56, 57, 62, 63, 68, 69, 74, 75, 76, 77, 78, 79, 80, 81, 92, 93, 98, 99, 112, 113, 128, 129, 134, 135, 148, 149, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 178, 179, 184, 185, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 214, 215, 220, 221];
- }
-} catch (error) {} // Swallow - we only care if `supports-color` is available; it doesn't have to be.
-
-/**
- * Build up the default `inspectOpts` object from the environment variables.
- *
- * $ DEBUG_COLORS=no DEBUG_DEPTH=10 DEBUG_SHOW_HIDDEN=enabled node script.js
- */
-
-
-exports.inspectOpts = Object.keys(process.env).filter(function (key) {
- return /^debug_/i.test(key);
-}).reduce(function (obj, key) {
- // Camel-case
- var prop = key.substring(6).toLowerCase().replace(/_([a-z])/g, function (_, k) {
- return k.toUpperCase();
- }); // Coerce string value into JS value
-
- var val = process.env[key];
-
- if (/^(yes|on|true|enabled)$/i.test(val)) {
- val = true;
- } else if (/^(no|off|false|disabled)$/i.test(val)) {
- val = false;
- } else if (val === 'null') {
- val = null;
- } else {
- val = Number(val);
- }
-
- obj[prop] = val;
- return obj;
-}, {});
-/**
- * Is stdout a TTY? Colored output is enabled when `true`.
- */
-
-function useColors() {
- return 'colors' in exports.inspectOpts ? Boolean(exports.inspectOpts.colors) : tty.isatty(process.stderr.fd);
-}
-/**
- * Adds ANSI color escape codes if enabled.
- *
- * @api public
- */
-
-
-function formatArgs(args) {
- var name = this.namespace,
- useColors = this.useColors;
-
- if (useColors) {
- var c = this.color;
- var colorCode = "\x1B[3" + (c < 8 ? c : '8;5;' + c);
- var prefix = " ".concat(colorCode, ";1m").concat(name, " \x1B[0m");
- args[0] = prefix + args[0].split('\n').join('\n' + prefix);
- args.push(colorCode + 'm+' + module.exports.humanize(this.diff) + "\x1B[0m");
- } else {
- args[0] = getDate() + name + ' ' + args[0];
- }
-}
-
-function getDate() {
- if (exports.inspectOpts.hideDate) {
- return '';
- }
-
- return new Date().toISOString() + ' ';
-}
-/**
- * Invokes `util.format()` with the specified arguments and writes to stderr.
- */
-
-
-function log() {
- return process.stderr.write(util.format.apply(util, arguments) + '\n');
-}
-/**
- * Save `namespaces`.
- *
- * @param {String} namespaces
- * @api private
- */
-
-
-function save(namespaces) {
- if (namespaces) {
- process.env.DEBUG = namespaces;
- } else {
- // If you set a process.env field to null or undefined, it gets cast to the
- // string 'null' or 'undefined'. Just delete instead.
- delete process.env.DEBUG;
- }
-}
-/**
- * Load `namespaces`.
- *
- * @return {String} returns the previously persisted debug modes
- * @api private
- */
-
-
-function load() {
- return process.env.DEBUG;
-}
-/**
- * Init logic for `debug` instances.
- *
- * Create a new `inspectOpts` object in case `useColors` is set
- * differently for a particular `debug` instance.
- */
-
-
-function init(debug) {
- debug.inspectOpts = {};
- var keys = Object.keys(exports.inspectOpts);
-
- for (var i = 0; i < keys.length; i++) {
- debug.inspectOpts[keys[i]] = exports.inspectOpts[keys[i]];
- }
-}
-
-module.exports = __webpack_require__(72)(exports);
-var formatters = module.exports.formatters;
-/**
- * Map %o to `util.inspect()`, all on a single line.
- */
-
-formatters.o = function (v) {
- this.inspectOpts.colors = this.useColors;
- return util.inspect(v, this.inspectOpts).replace(/\s*\n\s*/g, ' ');
-};
-/**
- * Map %O to `util.inspect()`, allowing multiple lines if needed.
- */
-
-
-formatters.O = function (v) {
- this.inspectOpts.colors = this.useColors;
- return util.inspect(v, this.inspectOpts);
-};
-
-
-
-/***/ }),
-/* 75 */
-/***/ (function(module, exports) {
-
-module.exports = require("zlib");
-
-/***/ }),
-/* 76 */
-/***/ (function(module, exports, __webpack_require__) {
-
-"use strict";
-/* --------------------------------------------------------------------------------------------\r
- * Copyright (c) Microsoft Corporation. All rights reserved.\r
- * Licensed under the MIT License. See License.txt in the project root for license information.\r
- * ------------------------------------------------------------------------------------------ */\r
-\r
-Object.defineProperty(exports, "__esModule", { value: true });\r
-var path = __webpack_require__(1);\r
-var fs = __webpack_require__(2);\r
-var toString = Object.prototype.toString;\r
-function isDefined(value) {\r
- return typeof value !== 'undefined';\r
-}\r
-function isNumber(value) {\r
- return toString.call(value) === '[object Number]';\r
-}\r
-function isString(value) {\r
- return toString.call(value) === '[object String]';\r
-}\r
-function isBoolean(value) {\r
- return value === true || value === false;\r
-}\r
-function readJsonFileSync(filename) {\r
- return JSON.parse(fs.readFileSync(filename, 'utf8'));\r
-}\r
-var MessageFormat;\r
-(function (MessageFormat) {\r
- MessageFormat["file"] = "file";\r
- MessageFormat["bundle"] = "bundle";\r
- MessageFormat["both"] = "both";\r
-})(MessageFormat = exports.MessageFormat || (exports.MessageFormat = {}));\r
-var BundleFormat;\r
-(function (BundleFormat) {\r
- // the nls.bundle format\r
- BundleFormat["standalone"] = "standalone";\r
- BundleFormat["languagePack"] = "languagePack";\r
-})(BundleFormat = exports.BundleFormat || (exports.BundleFormat = {}));\r
-var LocalizeInfo;\r
-(function (LocalizeInfo) {\r
- function is(value) {\r
- var candidate = value;\r
- return candidate && isDefined(candidate.key) && isDefined(candidate.comment);\r
- }\r
- LocalizeInfo.is = is;\r
-})(LocalizeInfo || (LocalizeInfo = {}));\r
-var resolvedLanguage;\r
-var resolvedBundles;\r
-var options;\r
-var isPseudo;\r
-function initializeSettings() {\r
- options = { locale: undefined, language: undefined, languagePackSupport: false, cacheLanguageResolution: true, messageFormat: MessageFormat.bundle };\r
- if (isString(process.env.VSCODE_NLS_CONFIG)) {\r
- try {\r
- var vscodeOptions = JSON.parse(process.env.VSCODE_NLS_CONFIG);\r
- var language = void 0;\r
- var locale = void 0;\r
- if (vscodeOptions.availableLanguages) {\r
- var value = vscodeOptions.availableLanguages['*'];\r
- if (isString(value)) {\r
- language = value;\r
- }\r
- }\r
- if (isString(vscodeOptions.locale)) {\r
- options.locale = vscodeOptions.locale.toLowerCase();\r
- }\r
- if (language === undefined) {\r
- options.language = options.locale;\r
- }\r
- else if (language !== 'en') {\r
- options.language = language;\r
- }\r
- if (isBoolean(vscodeOptions._languagePackSupport)) {\r
- options.languagePackSupport = vscodeOptions._languagePackSupport;\r
- }\r
- if (isString(vscodeOptions._cacheRoot)) {\r
- options.cacheRoot = vscodeOptions._cacheRoot;\r
- }\r
- if (isString(vscodeOptions._languagePackId)) {\r
- options.languagePackId = vscodeOptions._languagePackId;\r
- }\r
- if (isString(vscodeOptions._translationsConfigFile)) {\r
- options.translationsConfigFile = vscodeOptions._translationsConfigFile;\r
- try {\r
- options.translationsConfig = readJsonFileSync(options.translationsConfigFile);\r
- }\r
- catch (error) {\r
- // We can't read the translation config file. Mark the cache as corrupted.\r
- if (vscodeOptions._corruptedFile) {\r
- fs.writeFile(vscodeOptions._corruptedFile, 'corrupted', 'utf8', function (err) {\r
- console.error(err);\r
- });\r
- }\r
- }\r
- }\r
- }\r
- catch (_a) {\r
- // Do nothing.\r
- }\r
- }\r
- isPseudo = options.locale === 'pseudo';\r
- resolvedLanguage = undefined;\r
- resolvedBundles = Object.create(null);\r
-}\r
-initializeSettings();\r
-function supportsLanguagePack() {\r
- return options.languagePackSupport === true && options.cacheRoot !== undefined && options.languagePackId !== undefined && options.translationsConfigFile !== undefined\r
- && options.translationsConfig !== undefined;\r
-}\r
-function format(message, args) {\r
- var result;\r
- if (isPseudo) {\r
- // FF3B and FF3D is the Unicode zenkaku representation for [ and ]\r
- message = '\uFF3B' + message.replace(/[aouei]/g, '$&$&') + '\uFF3D';\r
- }\r
- if (args.length === 0) {\r
- result = message;\r
- }\r
- else {\r
- result = message.replace(/\{(\d+)\}/g, function (match, rest) {\r
- var index = rest[0];\r
- var arg = args[index];\r
- var replacement = match;\r
- if (typeof arg === 'string') {\r
- replacement = arg;\r
- }\r
- else if (typeof arg === 'number' || typeof arg === 'boolean' || arg === void 0 || arg === null) {\r
- replacement = String(arg);\r
- }\r
- return replacement;\r
- });\r
- }\r
- return result;\r
-}\r
-function createScopedLocalizeFunction(messages) {\r
- return function (key, message) {\r
- var args = [];\r
- for (var _i = 2; _i < arguments.length; _i++) {\r
- args[_i - 2] = arguments[_i];\r
- }\r
- if (isNumber(key)) {\r
- if (key >= messages.length) {\r
- console.error("Broken localize call found. Index out of bounds. Stacktrace is\n: " + new Error('').stack);\r
- return;\r
- }\r
- return format(messages[key], args);\r
- }\r
- else {\r
- if (isString(message)) {\r
- console.warn("Message " + message + " didn't get externalized correctly.");\r
- return format(message, args);\r
- }\r
- else {\r
- console.error("Broken localize call found. Stacktrace is\n: " + new Error('').stack);\r
- }\r
- }\r
- };\r
-}\r
-function localize(key, message) {\r
- var args = [];\r
- for (var _i = 2; _i < arguments.length; _i++) {\r
- args[_i - 2] = arguments[_i];\r
- }\r
- return format(message, args);\r
-}\r
-function resolveLanguage(file) {\r
- var resolvedLanguage;\r
- if (options.cacheLanguageResolution && resolvedLanguage) {\r
- resolvedLanguage = resolvedLanguage;\r
- }\r
- else {\r
- if (isPseudo || !options.language) {\r
- resolvedLanguage = '.nls.json';\r
- }\r
- else {\r
- var locale = options.language;\r
- while (locale) {\r
- var candidate = '.nls.' + locale + '.json';\r
- if (fs.existsSync(file + candidate)) {\r
- resolvedLanguage = candidate;\r
- break;\r
- }\r
- else {\r
- var index = locale.lastIndexOf('-');\r
- if (index > 0) {\r
- locale = locale.substring(0, index);\r
- }\r
- else {\r
- resolvedLanguage = '.nls.json';\r
- locale = null;\r
- }\r
- }\r
- }\r
- }\r
- if (options.cacheLanguageResolution) {\r
- resolvedLanguage = resolvedLanguage;\r
- }\r
- }\r
- return file + resolvedLanguage;\r
-}\r
-function findInTheBoxBundle(root) {\r
- var language = options.language;\r
- while (language) {\r
- var candidate = path.join(root, "nls.bundle." + language + ".json");\r
- if (fs.existsSync(candidate)) {\r
- return candidate;\r
- }\r
- else {\r
- var index = language.lastIndexOf('-');\r
- if (index > 0) {\r
- language = language.substring(0, index);\r
- }\r
- else {\r
- language = undefined;\r
- }\r
- }\r
- }\r
- // Test if we can reslove the default bundle.\r
- if (language === undefined) {\r
- var candidate = path.join(root, 'nls.bundle.json');\r
- if (fs.existsSync(candidate)) {\r
- return candidate;\r
- }\r
- }\r
- return undefined;\r
-}\r
-function mkdir(directory) {\r
- try {\r
- fs.mkdirSync(directory);\r
- }\r
- catch (err) {\r
- if (err.code === 'EEXIST') {\r
- return;\r
- }\r
- else if (err.code === 'ENOENT') {\r
- var parent = path.dirname(directory);\r
- if (parent !== directory) {\r
- mkdir(parent);\r
- fs.mkdirSync(directory);\r
- }\r
- }\r
- else {\r
- throw err;\r
- }\r
- }\r
-}\r
-function createDefaultNlsBundle(folder) {\r
- var metaData = readJsonFileSync(path.join(folder, 'nls.metadata.json'));\r
- var result = Object.create(null);\r
- for (var module_1 in metaData) {\r
- var entry = metaData[module_1];\r
- result[module_1] = entry.messages;\r
- }\r
- return result;\r
-}\r
-function createNLSBundle(header, metaDataPath) {\r
- var languagePackLocation = options.translationsConfig[header.id];\r
- if (!languagePackLocation) {\r
- return undefined;\r
- }\r
- var languagePack = readJsonFileSync(languagePackLocation).contents;\r
- var metaData = readJsonFileSync(path.join(metaDataPath, 'nls.metadata.json'));\r
- var result = Object.create(null);\r
- for (var module_2 in metaData) {\r
- var entry = metaData[module_2];\r
- var translations = languagePack[header.outDir + "/" + module_2];\r
- if (translations) {\r
- var resultMessages = [];\r
- for (var i = 0; i < entry.keys.length; i++) {\r
- var messageKey = entry.keys[i];\r
- var key = isString(messageKey) ? messageKey : messageKey.key;\r
- var translatedMessage = translations[key];\r
- if (translatedMessage === undefined) {\r
- translatedMessage = entry.messages[i];\r
- }\r
- resultMessages.push(translatedMessage);\r
- }\r
- result[module_2] = resultMessages;\r
- }\r
- else {\r
- result[module_2] = entry.messages;\r
- }\r
- }\r
- return result;\r
-}\r
-function touch(file) {\r
- var d = new Date();\r
- fs.utimes(file, d, d, function () {\r
- // Do nothing. Ignore\r
- });\r
-}\r
-function cacheBundle(key, bundle) {\r
- resolvedBundles[key] = bundle;\r
- return bundle;\r
-}\r
-function loadNlsBundleOrCreateFromI18n(header, bundlePath) {\r
- var result;\r
- var bundle = path.join(options.cacheRoot, header.id + "-" + header.hash + ".json");\r
- var useMemoryOnly = false;\r
- var writeBundle = false;\r
- try {\r
- result = JSON.parse(fs.readFileSync(bundle, { encoding: 'utf8', flag: 'r' }));\r
- touch(bundle);\r
- return result;\r
- }\r
- catch (err) {\r
- if (err.code === 'ENOENT') {\r
- writeBundle = true;\r
- }\r
- else if (err instanceof SyntaxError) {\r
- // We have a syntax error. So no valid JSON. Use\r
- console.log("Syntax error parsing message bundle: " + err.message + ".");\r
- fs.unlink(bundle, function (err) {\r
- if (err) {\r
- console.error("Deleting corrupted bundle " + bundle + " failed.");\r
- }\r
- });\r
- useMemoryOnly = true;\r
- }\r
- else {\r
- throw err;\r
- }\r
- }\r
- result = createNLSBundle(header, bundlePath);\r
- if (!result || useMemoryOnly) {\r
- return result;\r
- }\r
- if (writeBundle) {\r
- try {\r
- fs.writeFileSync(bundle, JSON.stringify(result), { encoding: 'utf8', flag: 'wx' });\r
- }\r
- catch (err) {\r
- if (err.code === 'EEXIST') {\r
- return result;\r
- }\r
- throw err;\r
- }\r
- }\r
- return result;\r
-}\r
-function loadDefaultNlsBundle(bundlePath) {\r
- try {\r
- return createDefaultNlsBundle(bundlePath);\r
- }\r
- catch (err) {\r
- console.log("Generating default bundle from meta data failed.", err);\r
- return undefined;\r
- }\r
-}\r
-function loadNlsBundle(header, bundlePath) {\r
- var result;\r
- // Core decided to use a language pack. Do the same in the extension\r
- if (supportsLanguagePack()) {\r
- try {\r
- result = loadNlsBundleOrCreateFromI18n(header, bundlePath);\r
- }\r
- catch (err) {\r
- console.log("Load or create bundle failed ", err);\r
- }\r
- }\r
- if (!result) {\r
- // No language pack found, but core is running in language pack mode\r
- // Don't try to use old in the box bundles since the might be stale\r
- // Fall right back to the default bundle.\r
- if (options.languagePackSupport) {\r
- return loadDefaultNlsBundle(bundlePath);\r
- }\r
- var candidate = findInTheBoxBundle(bundlePath);\r
- if (candidate) {\r
- try {\r
- return readJsonFileSync(candidate);\r
- }\r
- catch (err) {\r
- console.log("Loading in the box message bundle failed.", err);\r
- }\r
- }\r
- result = loadDefaultNlsBundle(bundlePath);\r
- }\r
- return result;\r
-}\r
-function tryFindMetaDataHeaderFile(file) {\r
- var result;\r
- var dirname = path.dirname(file);\r
- while (true) {\r
- result = path.join(dirname, 'nls.metadata.header.json');\r
- if (fs.existsSync(result)) {\r
- break;\r
- }\r
- var parent = path.dirname(dirname);\r
- if (parent === dirname) {\r
- result = undefined;\r
- break;\r
- }\r
- else {\r
- dirname = parent;\r
- }\r
- }\r
- return result;\r
-}\r
-function loadMessageBundle(file) {\r
- if (!file) {\r
- // No file. We are in dev mode. Return the default\r
- // localize function.\r
- return localize;\r
- }\r
- // Remove extension since we load json files.\r
- var ext = path.extname(file);\r
- if (ext) {\r
- file = file.substr(0, file.length - ext.length);\r
- }\r
- if (options.messageFormat === MessageFormat.both || options.messageFormat === MessageFormat.bundle) {\r
- var headerFile = tryFindMetaDataHeaderFile(file);\r
- if (headerFile) {\r
- var bundlePath = path.dirname(headerFile);\r
- var bundle = resolvedBundles[bundlePath];\r
- if (bundle === undefined) {\r
- try {\r
- var header = JSON.parse(fs.readFileSync(headerFile, 'utf8'));\r
- try {\r
- var nlsBundle = loadNlsBundle(header, bundlePath);\r
- bundle = cacheBundle(bundlePath, nlsBundle ? { header: header, nlsBundle: nlsBundle } : null);\r
- }\r
- catch (err) {\r
- console.error('Failed to load nls bundle', err);\r
- bundle = cacheBundle(bundlePath, null);\r
- }\r
- }\r
- catch (err) {\r
- console.error('Failed to read header file', err);\r
- bundle = cacheBundle(bundlePath, null);\r
- }\r
- }\r
- if (bundle) {\r
- var module_3 = file.substr(bundlePath.length + 1).replace(/\\/g, '/');\r
- var messages = bundle.nlsBundle[module_3];\r
- if (messages === undefined) {\r
- console.error("Messages for file " + file + " not found. See console for details.");\r
- return function () {\r
- return 'Messages not found.';\r
- };\r
- }\r
- return createScopedLocalizeFunction(messages);\r
- }\r
- }\r
- }\r
- if (options.messageFormat === MessageFormat.both || options.messageFormat === MessageFormat.file) {\r
- // Try to load a single file bundle\r
- try {\r
- var json = readJsonFileSync(resolveLanguage(file));\r
- if (Array.isArray(json)) {\r
- return createScopedLocalizeFunction(json);\r
- }\r
- else {\r
- if (isDefined(json.messages) && isDefined(json.keys)) {\r
- return createScopedLocalizeFunction(json.messages);\r
- }\r
- else {\r
- console.error("String bundle '" + file + "' uses an unsupported format.");\r
- return function () {\r
- return 'File bundle has unsupported format. See console for details';\r
- };\r
- }\r
- }\r
- }\r
- catch (err) {\r
- if (err.code !== 'ENOENT') {\r
- console.error('Failed to load single file bundle', err);\r
- }\r
- }\r
- }\r
- console.error("Failed to load message bundle for file " + file);\r
- return function () {\r
- return 'Failed to load message bundle. See console for details.';\r
- };\r
-}\r
-exports.loadMessageBundle = loadMessageBundle;\r
-function config(opts) {\r
- if (opts) {\r
- if (isString(opts.locale)) {\r
- options.locale = opts.locale.toLowerCase();\r
- options.language = options.locale;\r
- resolvedLanguage = undefined;\r
- resolvedBundles = Object.create(null);\r
- }\r
- if (opts.messageFormat !== undefined) {\r
- options.messageFormat = opts.messageFormat;\r
- }\r
- if (opts.bundleFormat === BundleFormat.standalone && options.languagePackSupport === true) {\r
- options.languagePackSupport = false;\r
- }\r
- }\r
- isPseudo = options.locale === 'pseudo';\r
- return loadMessageBundle;\r
-}\r
-exports.config = config;\r
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "URI", function() { return URI; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "uriToFsPath", function() { return uriToFsPath; });
+/*---------------------------------------------------------------------------------------------
+ * Copyright (c) Microsoft Corporation. All rights reserved.
+ * Licensed under the MIT License. See License.txt in the project root for license information.
+ *--------------------------------------------------------------------------------------------*/
+
+var __extends = (undefined && undefined.__extends) || (function () {
+ var extendStatics = function (d, b) {
+ extendStatics = Object.setPrototypeOf ||
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
+ function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
+ return extendStatics(d, b);
+ };
+ return function (d, b) {
+ extendStatics(d, b);
+ function __() { this.constructor = d; }
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
+ };
+})();
+var _a;
+var isWindows;
+if (typeof process === 'object') {
+ isWindows = process.platform === 'win32';
+}
+else if (typeof navigator === 'object') {
+ var userAgent = navigator.userAgent;
+ isWindows = userAgent.indexOf('Windows') >= 0;
+}
+function isHighSurrogate(charCode) {
+ return (0xD800 <= charCode && charCode <= 0xDBFF);
+}
+function isLowSurrogate(charCode) {
+ return (0xDC00 <= charCode && charCode <= 0xDFFF);
+}
+function isLowerAsciiHex(code) {
+ return code >= 97 /* a */ && code <= 102 /* f */;
+}
+function isLowerAsciiLetter(code) {
+ return code >= 97 /* a */ && code <= 122 /* z */;
+}
+function isUpperAsciiLetter(code) {
+ return code >= 65 /* A */ && code <= 90 /* Z */;
+}
+function isAsciiLetter(code) {
+ return isLowerAsciiLetter(code) || isUpperAsciiLetter(code);
+}
+//#endregion
+var _schemePattern = /^\w[\w\d+.-]*$/;
+var _singleSlashStart = /^\//;
+var _doubleSlashStart = /^\/\//;
+function _validateUri(ret, _strict) {
+ // scheme, must be set
+ if (!ret.scheme && _strict) {
+ throw new Error("[UriError]: Scheme is missing: {scheme: \"\", authority: \"" + ret.authority + "\", path: \"" + ret.path + "\", query: \"" + ret.query + "\", fragment: \"" + ret.fragment + "\"}");
+ }
+ // scheme, https://tools.ietf.org/html/rfc3986#section-3.1
+ // ALPHA *( ALPHA / DIGIT / "+" / "-" / "." )
+ if (ret.scheme && !_schemePattern.test(ret.scheme)) {
+ throw new Error('[UriError]: Scheme contains illegal characters.');
+ }
+ // path, http://tools.ietf.org/html/rfc3986#section-3.3
+ // If a URI contains an authority component, then the path component
+ // must either be empty or begin with a slash ("/") character. If a URI
+ // does not contain an authority component, then the path cannot begin
+ // with two slash characters ("//").
+ if (ret.path) {
+ if (ret.authority) {
+ if (!_singleSlashStart.test(ret.path)) {
+ throw new Error('[UriError]: If a URI contains an authority component, then the path component must either be empty or begin with a slash ("/") character');
+ }
+ }
+ else {
+ if (_doubleSlashStart.test(ret.path)) {
+ throw new Error('[UriError]: If a URI does not contain an authority component, then the path cannot begin with two slash characters ("//")');
+ }
+ }
+ }
+}
+// for a while we allowed uris *without* schemes and this is the migration
+// for them, e.g. an uri without scheme and without strict-mode warns and falls
+// back to the file-scheme. that should cause the least carnage and still be a
+// clear warning
+function _schemeFix(scheme, _strict) {
+ if (!scheme && !_strict) {
+ return 'file';
+ }
+ return scheme;
+}
+// implements a bit of https://tools.ietf.org/html/rfc3986#section-5
+function _referenceResolution(scheme, path) {
+ // the slash-character is our 'default base' as we don't
+ // support constructing URIs relative to other URIs. This
+ // also means that we alter and potentially break paths.
+ // see https://tools.ietf.org/html/rfc3986#section-5.1.4
+ switch (scheme) {
+ case 'https':
+ case 'http':
+ case 'file':
+ if (!path) {
+ path = _slash;
+ }
+ else if (path[0] !== _slash) {
+ path = _slash + path;
+ }
+ break;
+ }
+ return path;
+}
+var _empty = '';
+var _slash = '/';
+var _regexp = /^(([^:/?#]+?):)?(\/\/([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/;
+/**
+ * Uniform Resource Identifier (URI) http://tools.ietf.org/html/rfc3986.
+ * This class is a simple parser which creates the basic component parts
+ * (http://tools.ietf.org/html/rfc3986#section-3) with minimal validation
+ * and encoding.
+ *
+ * ```txt
+ * foo://example.com:8042/over/there?name=ferret#nose
+ * \_/ \______________/\_________/ \_________/ \__/
+ * | | | | |
+ * scheme authority path query fragment
+ * | _____________________|__
+ * / \ / \
+ * urn:example:animal:ferret:nose
+ * ```
+ */
+var URI = /** @class */ (function () {
+ /**
+ * @internal
+ */
+ function URI(schemeOrData, authority, path, query, fragment, _strict) {
+ if (_strict === void 0) { _strict = false; }
+ if (typeof schemeOrData === 'object') {
+ this.scheme = schemeOrData.scheme || _empty;
+ this.authority = schemeOrData.authority || _empty;
+ this.path = schemeOrData.path || _empty;
+ this.query = schemeOrData.query || _empty;
+ this.fragment = schemeOrData.fragment || _empty;
+ // no validation because it's this URI
+ // that creates uri components.
+ // _validateUri(this);
+ }
+ else {
+ this.scheme = _schemeFix(schemeOrData, _strict);
+ this.authority = authority || _empty;
+ this.path = _referenceResolution(this.scheme, path || _empty);
+ this.query = query || _empty;
+ this.fragment = fragment || _empty;
+ _validateUri(this, _strict);
+ }
+ }
+ URI.isUri = function (thing) {
+ if (thing instanceof URI) {
+ return true;
+ }
+ if (!thing) {
+ return false;
+ }
+ return typeof thing.authority === 'string'
+ && typeof thing.fragment === 'string'
+ && typeof thing.path === 'string'
+ && typeof thing.query === 'string'
+ && typeof thing.scheme === 'string'
+ && typeof thing.fsPath === 'function'
+ && typeof thing.with === 'function'
+ && typeof thing.toString === 'function';
+ };
+ Object.defineProperty(URI.prototype, "fsPath", {
+ // ---- filesystem path -----------------------
+ /**
+ * Returns a string representing the corresponding file system path of this URI.
+ * Will handle UNC paths, normalizes windows drive letters to lower-case, and uses the
+ * platform specific path separator.
+ *
+ * * Will *not* validate the path for invalid characters and semantics.
+ * * Will *not* look at the scheme of this URI.
+ * * The result shall *not* be used for display purposes but for accessing a file on disk.
+ *
+ *
+ * The *difference* to `URI#path` is the use of the platform specific separator and the handling
+ * of UNC paths. See the below sample of a file-uri with an authority (UNC path).
+ *
+ * ```ts
+ const u = URI.parse('file://server/c$/folder/file.txt')
+ u.authority === 'server'
+ u.path === '/shares/c$/file.txt'
+ u.fsPath === '\\server\c$\folder\file.txt'
+ ```
+ *
+ * Using `URI#path` to read a file (using fs-apis) would not be enough because parts of the path,
+ * namely the server name, would be missing. Therefore `URI#fsPath` exists - it's sugar to ease working
+ * with URIs that represent files on disk (`file` scheme).
+ */
+ get: function () {
+ // if (this.scheme !== 'file') {
+ // console.warn(`[UriError] calling fsPath with scheme ${this.scheme}`);
+ // }
+ return uriToFsPath(this, false);
+ },
+ enumerable: true,
+ configurable: true
+ });
+ // ---- modify to new -------------------------
+ URI.prototype.with = function (change) {
+ if (!change) {
+ return this;
+ }
+ var scheme = change.scheme, authority = change.authority, path = change.path, query = change.query, fragment = change.fragment;
+ if (scheme === undefined) {
+ scheme = this.scheme;
+ }
+ else if (scheme === null) {
+ scheme = _empty;
+ }
+ if (authority === undefined) {
+ authority = this.authority;
+ }
+ else if (authority === null) {
+ authority = _empty;
+ }
+ if (path === undefined) {
+ path = this.path;
+ }
+ else if (path === null) {
+ path = _empty;
+ }
+ if (query === undefined) {
+ query = this.query;
+ }
+ else if (query === null) {
+ query = _empty;
+ }
+ if (fragment === undefined) {
+ fragment = this.fragment;
+ }
+ else if (fragment === null) {
+ fragment = _empty;
+ }
+ if (scheme === this.scheme
+ && authority === this.authority
+ && path === this.path
+ && query === this.query
+ && fragment === this.fragment) {
+ return this;
+ }
+ return new _URI(scheme, authority, path, query, fragment);
+ };
+ // ---- parse & validate ------------------------
+ /**
+ * Creates a new URI from a string, e.g. `http://www.msft.com/some/path`,
+ * `file:///usr/home`, or `scheme:with/path`.
+ *
+ * @param value A string which represents an URI (see `URI#toString`).
+ */
+ URI.parse = function (value, _strict) {
+ if (_strict === void 0) { _strict = false; }
+ var match = _regexp.exec(value);
+ if (!match) {
+ return new _URI(_empty, _empty, _empty, _empty, _empty);
+ }
+ return new _URI(match[2] || _empty, percentDecode(match[4] || _empty), percentDecode(match[5] || _empty), percentDecode(match[7] || _empty), percentDecode(match[9] || _empty), _strict);
+ };
+ /**
+ * Creates a new URI from a file system path, e.g. `c:\my\files`,
+ * `/usr/home`, or `\\server\share\some\path`.
+ *
+ * The *difference* between `URI#parse` and `URI#file` is that the latter treats the argument
+ * as path, not as stringified-uri. E.g. `URI.file(path)` is **not the same as**
+ * `URI.parse('file://' + path)` because the path might contain characters that are
+ * interpreted (# and ?). See the following sample:
+ * ```ts
+ const good = URI.file('/coding/c#/project1');
+ good.scheme === 'file';
+ good.path === '/coding/c#/project1';
+ good.fragment === '';
+ const bad = URI.parse('file://' + '/coding/c#/project1');
+ bad.scheme === 'file';
+ bad.path === '/coding/c'; // path is now broken
+ bad.fragment === '/project1';
+ ```
+ *
+ * @param path A file system path (see `URI#fsPath`)
+ */
+ URI.file = function (path) {
+ var authority = _empty;
+ // normalize to fwd-slashes on windows,
+ // on other systems bwd-slashes are valid
+ // filename character, eg /f\oo/ba\r.txt
+ if (isWindows) {
+ path = path.replace(/\\/g, _slash);
+ }
+ // check for authority as used in UNC shares
+ // or use the path as given
+ if (path[0] === _slash && path[1] === _slash) {
+ var idx = path.indexOf(_slash, 2);
+ if (idx === -1) {
+ authority = path.substring(2);
+ path = _slash;
+ }
+ else {
+ authority = path.substring(2, idx);
+ path = path.substring(idx) || _slash;
+ }
+ }
+ return new _URI('file', authority, path, _empty, _empty);
+ };
+ URI.from = function (components) {
+ return new _URI(components.scheme, components.authority, components.path, components.query, components.fragment);
+ };
+ // /**
+ // * Join a URI path with path fragments and normalizes the resulting path.
+ // *
+ // * @param uri The input URI.
+ // * @param pathFragment The path fragment to add to the URI path.
+ // * @returns The resulting URI.
+ // */
+ // static joinPath(uri: URI, ...pathFragment: string[]): URI {
+ // if (!uri.path) {
+ // throw new Error(`[UriError]: cannot call joinPaths on URI without path`);
+ // }
+ // let newPath: string;
+ // if (isWindows && uri.scheme === 'file') {
+ // newPath = URI.file(paths.win32.join(uriToFsPath(uri, true), ...pathFragment)).path;
+ // } else {
+ // newPath = paths.posix.join(uri.path, ...pathFragment);
+ // }
+ // return uri.with({ path: newPath });
+ // }
+ // ---- printing/externalize ---------------------------
+ /**
+ * Creates a string representation for this URI. It's guaranteed that calling
+ * `URI.parse` with the result of this function creates an URI which is equal
+ * to this URI.
+ *
+ * * The result shall *not* be used for display purposes but for externalization or transport.
+ * * The result will be encoded using the percentage encoding and encoding happens mostly
+ * ignore the scheme-specific encoding rules.
+ *
+ * @param skipEncoding Do not encode the result, default is `false`
+ */
+ URI.prototype.toString = function (skipEncoding) {
+ if (skipEncoding === void 0) { skipEncoding = false; }
+ return _asFormatted(this, skipEncoding);
+ };
+ URI.prototype.toJSON = function () {
+ return this;
+ };
+ URI.revive = function (data) {
+ if (!data) {
+ return data;
+ }
+ else if (data instanceof URI) {
+ return data;
+ }
+ else {
+ var result = new _URI(data);
+ result._formatted = data.external;
+ result._fsPath = data._sep === _pathSepMarker ? data.fsPath : null;
+ return result;
+ }
+ };
+ return URI;
+}());
+
+var _pathSepMarker = isWindows ? 1 : undefined;
+// eslint-disable-next-line @typescript-eslint/class-name-casing
+var _URI = /** @class */ (function (_super) {
+ __extends(_URI, _super);
+ function _URI() {
+ var _this = _super !== null && _super.apply(this, arguments) || this;
+ _this._formatted = null;
+ _this._fsPath = null;
+ return _this;
+ }
+ Object.defineProperty(_URI.prototype, "fsPath", {
+ get: function () {
+ if (!this._fsPath) {
+ this._fsPath = uriToFsPath(this, false);
+ }
+ return this._fsPath;
+ },
+ enumerable: true,
+ configurable: true
+ });
+ _URI.prototype.toString = function (skipEncoding) {
+ if (skipEncoding === void 0) { skipEncoding = false; }
+ if (!skipEncoding) {
+ if (!this._formatted) {
+ this._formatted = _asFormatted(this, false);
+ }
+ return this._formatted;
+ }
+ else {
+ // we don't cache that
+ return _asFormatted(this, true);
+ }
+ };
+ _URI.prototype.toJSON = function () {
+ var res = {
+ $mid: 1
+ };
+ // cached state
+ if (this._fsPath) {
+ res.fsPath = this._fsPath;
+ res._sep = _pathSepMarker;
+ }
+ if (this._formatted) {
+ res.external = this._formatted;
+ }
+ // uri components
+ if (this.path) {
+ res.path = this.path;
+ }
+ if (this.scheme) {
+ res.scheme = this.scheme;
+ }
+ if (this.authority) {
+ res.authority = this.authority;
+ }
+ if (this.query) {
+ res.query = this.query;
+ }
+ if (this.fragment) {
+ res.fragment = this.fragment;
+ }
+ return res;
+ };
+ return _URI;
+}(URI));
+// reserved characters: https://tools.ietf.org/html/rfc3986#section-2.2
+var encodeTable = (_a = {},
+ _a[58 /* Colon */] = '%3A',
+ _a[47 /* Slash */] = '%2F',
+ _a[63 /* QuestionMark */] = '%3F',
+ _a[35 /* Hash */] = '%23',
+ _a[91 /* OpenSquareBracket */] = '%5B',
+ _a[93 /* CloseSquareBracket */] = '%5D',
+ _a[64 /* AtSign */] = '%40',
+ _a[33 /* ExclamationMark */] = '%21',
+ _a[36 /* DollarSign */] = '%24',
+ _a[38 /* Ampersand */] = '%26',
+ _a[39 /* SingleQuote */] = '%27',
+ _a[40 /* OpenParen */] = '%28',
+ _a[41 /* CloseParen */] = '%29',
+ _a[42 /* Asterisk */] = '%2A',
+ _a[43 /* Plus */] = '%2B',
+ _a[44 /* Comma */] = '%2C',
+ _a[59 /* Semicolon */] = '%3B',
+ _a[61 /* Equals */] = '%3D',
+ _a[32 /* Space */] = '%20',
+ _a);
+function encodeURIComponentFast(uriComponent, allowSlash) {
+ var res = undefined;
+ var nativeEncodePos = -1;
+ for (var pos = 0; pos < uriComponent.length; pos++) {
+ var code = uriComponent.charCodeAt(pos);
+ // unreserved characters: https://tools.ietf.org/html/rfc3986#section-2.3
+ if ((code >= 97 /* a */ && code <= 122 /* z */)
+ || (code >= 65 /* A */ && code <= 90 /* Z */)
+ || (code >= 48 /* Digit0 */ && code <= 57 /* Digit9 */)
+ || code === 45 /* Dash */
+ || code === 46 /* Period */
+ || code === 95 /* Underline */
+ || code === 126 /* Tilde */
+ || (allowSlash && code === 47 /* Slash */)) {
+ // check if we are delaying native encode
+ if (nativeEncodePos !== -1) {
+ res += encodeURIComponent(uriComponent.substring(nativeEncodePos, pos));
+ nativeEncodePos = -1;
+ }
+ // check if we write into a new string (by default we try to return the param)
+ if (res !== undefined) {
+ res += uriComponent.charAt(pos);
+ }
+ }
+ else {
+ // encoding needed, we need to allocate a new string
+ if (res === undefined) {
+ res = uriComponent.substr(0, pos);
+ }
+ // check with default table first
+ var escaped = encodeTable[code];
+ if (escaped !== undefined) {
+ // check if we are delaying native encode
+ if (nativeEncodePos !== -1) {
+ res += encodeURIComponent(uriComponent.substring(nativeEncodePos, pos));
+ nativeEncodePos = -1;
+ }
+ // append escaped variant to result
+ res += escaped;
+ }
+ else if (nativeEncodePos === -1) {
+ // use native encode only when needed
+ nativeEncodePos = pos;
+ }
+ }
+ }
+ if (nativeEncodePos !== -1) {
+ res += encodeURIComponent(uriComponent.substring(nativeEncodePos));
+ }
+ return res !== undefined ? res : uriComponent;
+}
+function encodeURIComponentMinimal(path) {
+ var res = undefined;
+ for (var pos = 0; pos < path.length; pos++) {
+ var code = path.charCodeAt(pos);
+ if (code === 35 /* Hash */ || code === 63 /* QuestionMark */) {
+ if (res === undefined) {
+ res = path.substr(0, pos);
+ }
+ res += encodeTable[code];
+ }
+ else {
+ if (res !== undefined) {
+ res += path[pos];
+ }
+ }
+ }
+ return res !== undefined ? res : path;
+}
+/**
+ * Compute `fsPath` for the given uri
+ */
+function uriToFsPath(uri, keepDriveLetterCasing) {
+ var value;
+ if (uri.authority && uri.path.length > 1 && uri.scheme === 'file') {
+ // unc path: file://shares/c$/far/boo
+ value = "//" + uri.authority + uri.path;
+ }
+ else if (uri.path.charCodeAt(0) === 47 /* Slash */
+ && (uri.path.charCodeAt(1) >= 65 /* A */ && uri.path.charCodeAt(1) <= 90 /* Z */ || uri.path.charCodeAt(1) >= 97 /* a */ && uri.path.charCodeAt(1) <= 122 /* z */)
+ && uri.path.charCodeAt(2) === 58 /* Colon */) {
+ if (!keepDriveLetterCasing) {
+ // windows drive letter: file:///c:/far/boo
+ value = uri.path[1].toLowerCase() + uri.path.substr(2);
+ }
+ else {
+ value = uri.path.substr(1);
+ }
+ }
+ else {
+ // other path
+ value = uri.path;
+ }
+ if (isWindows) {
+ value = value.replace(/\//g, '\\');
+ }
+ return value;
+}
+/**
+ * Create the external version of a uri
+ */
+function _asFormatted(uri, skipEncoding) {
+ var encoder = !skipEncoding
+ ? encodeURIComponentFast
+ : encodeURIComponentMinimal;
+ var res = '';
+ var scheme = uri.scheme, authority = uri.authority, path = uri.path, query = uri.query, fragment = uri.fragment;
+ if (scheme) {
+ res += scheme;
+ res += ':';
+ }
+ if (authority || scheme === 'file') {
+ res += _slash;
+ res += _slash;
+ }
+ if (authority) {
+ var idx = authority.indexOf('@');
+ if (idx !== -1) {
+ // <user>@<auth>
+ var userinfo = authority.substr(0, idx);
+ authority = authority.substr(idx + 1);
+ idx = userinfo.indexOf(':');
+ if (idx === -1) {
+ res += encoder(userinfo, false);
+ }
+ else {
+ // <user>:<pass>@<auth>
+ res += encoder(userinfo.substr(0, idx), false);
+ res += ':';
+ res += encoder(userinfo.substr(idx + 1), false);
+ }
+ res += '@';
+ }
+ authority = authority.toLowerCase();
+ idx = authority.indexOf(':');
+ if (idx === -1) {
+ res += encoder(authority, false);
+ }
+ else {
+ // <auth>:<port>
+ res += encoder(authority.substr(0, idx), false);
+ res += authority.substr(idx);
+ }
+ }
+ if (path) {
+ // lower-case windows drive letters in /C:/fff or C:/fff
+ if (path.length >= 3 && path.charCodeAt(0) === 47 /* Slash */ && path.charCodeAt(2) === 58 /* Colon */) {
+ var code = path.charCodeAt(1);
+ if (code >= 65 /* A */ && code <= 90 /* Z */) {
+ path = "/" + String.fromCharCode(code + 32) + ":" + path.substr(3); // "/c:".length === 3
+ }
+ }
+ else if (path.length >= 2 && path.charCodeAt(1) === 58 /* Colon */) {
+ var code = path.charCodeAt(0);
+ if (code >= 65 /* A */ && code <= 90 /* Z */) {
+ path = String.fromCharCode(code + 32) + ":" + path.substr(2); // "/c:".length === 3
+ }
+ }
+ // encode the rest of the path
+ res += encoder(path, true);
+ }
+ if (query) {
+ res += '?';
+ res += encoder(query, false);
+ }
+ if (fragment) {
+ res += '#';
+ res += !skipEncoding ? encodeURIComponentFast(fragment, false) : fragment;
+ }
+ return res;
+}
+// --- decode
+function decodeURIComponentGraceful(str) {
+ try {
+ return decodeURIComponent(str);
+ }
+ catch (_a) {
+ if (str.length > 3) {
+ return str.substr(0, 3) + decodeURIComponentGraceful(str.substr(3));
+ }
+ else {
+ return str;
+ }
+ }
+}
+var _rEncodedAsHex = /(%[0-9A-Za-z][0-9A-Za-z])+/g;
+function percentDecode(str) {
+ if (!str.match(_rEncodedAsHex)) {
+ return str;
+ }
+ return str.replace(_rEncodedAsHex, function (match) { return decodeURIComponentGraceful(match); });
+}
+
+
+/***/ }),
+/* 36 */,
+/* 37 */,
+/* 38 */,
+/* 39 */
+/***/ (function(module, exports, __webpack_require__) {
+
+"use strict";
+
+/*---------------------------------------------------------------------------------------------
+ * Copyright (c) Microsoft Corporation. All rights reserved.
+ * Licensed under the MIT License. See License.txt in the project root for license information.
+ *--------------------------------------------------------------------------------------------*/
+var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
+ if (k2 === undefined) k2 = k;
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
+}) : (function(o, m, k, k2) {
+ if (k2 === undefined) k2 = k;
+ o[k2] = m[k];
+}));
+var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
+}) : function(o, v) {
+ o["default"] = v;
+});
+var __importStar = (this && this.__importStar) || function (mod) {
+ if (mod && mod.__esModule) return mod;
+ var result = {};
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
+ __setModuleDefault(result, mod);
+ return result;
+};
+Object.defineProperty(exports, "__esModule", { value: true });
+const node_1 = __webpack_require__(40);
+const runner_1 = __webpack_require__(88);
+const jsonServer_1 = __webpack_require__(89);
+const request_light_1 = __webpack_require__(115);
+const vscode_uri_1 = __webpack_require__(35);
+const fs = __importStar(__webpack_require__(2));
+// Create a connection for the server.
+const connection = node_1.createConnection();
+console.log = connection.console.log.bind(connection.console);
+console.error = connection.console.error.bind(connection.console);
+process.on('unhandledRejection', (e) => {
+ connection.console.error(runner_1.formatError(`Unhandled exception`, e));
+});
+function getHTTPRequestService() {
+ return {
+ getContent(uri, _encoding) {
+ const headers = { 'Accept-Encoding': 'gzip, deflate' };
+ return request_light_1.xhr({ url: uri, followRedirects: 5, headers }).then(response => {
+ return response.responseText;
+ }, (error) => {
+ return Promise.reject(error.responseText || request_light_1.getErrorStatusDescription(error.status) || error.toString());
+ });
+ }
+ };
+}
+function getFileRequestService() {
+ return {
+ getContent(location, encoding) {
+ return new Promise((c, e) => {
+ const uri = vscode_uri_1.URI.parse(location);
+ fs.readFile(uri.fsPath, encoding, (err, buf) => {
+ if (err) {
+ return e(err);
+ }
+ c(buf.toString());
+ });
+ });
+ }
+ };
+}
+jsonServer_1.startServer(connection, { file: getFileRequestService(), http: getHTTPRequestService(), configureHttpRequests: request_light_1.configure });
+
+
+/***/ }),
+/* 40 */
+/***/ (function(module, exports, __webpack_require__) {
+
+"use strict";
+/* --------------------------------------------------------------------------------------------
+ * Copyright (c) Microsoft Corporation. All rights reserved.
+ * Licensed under the MIT License. See License.txt in the project root for license information.
+ * ----------------------------------------------------------------------------------------- */
+
+
+module.exports = __webpack_require__(41);
+
+/***/ }),
+/* 41 */
+/***/ (function(module, exports, __webpack_require__) {
+
+"use strict";
+
+/* --------------------------------------------------------------------------------------------
+ * Copyright (c) Microsoft Corporation. All rights reserved.
+ * Licensed under the MIT License. See License.txt in the project root for license information.
+ * ------------------------------------------------------------------------------------------ */
+/// <reference path="../../typings/thenable.d.ts" />
+function __export(m) {
+ for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
+}
+Object.defineProperty(exports, "__esModule", { value: true });
+const Is = __webpack_require__(42);
+const server_1 = __webpack_require__(43);
+const fm = __webpack_require__(82);
+const node_1 = __webpack_require__(85);
+__export(__webpack_require__(86));
+var Files;
+(function (Files) {
+ Files.uriToFilePath = fm.uriToFilePath;
+ Files.resolveGlobalNodePath = fm.resolveGlobalNodePath;
+ Files.resolveGlobalYarnPath = fm.resolveGlobalYarnPath;
+ Files.resolve = fm.resolve;
+ Files.resolveModulePath = fm.resolveModulePath;
+})(Files = exports.Files || (exports.Files = {}));
+let _shutdownReceived = false;
+let exitTimer = undefined;
+function setupExitTimer() {
+ const argName = '--clientProcessId';
+ function runTimer(value) {
+ try {
+ let processId = parseInt(value);
+ if (!isNaN(processId)) {
+ exitTimer = setInterval(() => {
+ try {
+ process.kill(processId, 0);
+ }
+ catch (ex) {
+ // Parent process doesn't exist anymore. Exit the server.
+ process.exit(_shutdownReceived ? 0 : 1);
+ }
+ }, 3000);
+ }
+ }
+ catch (e) {
+ // Ignore errors;
+ }
+ }
+ for (let i = 2; i < process.argv.length; i++) {
+ let arg = process.argv[i];
+ if (arg === argName && i + 1 < process.argv.length) {
+ runTimer(process.argv[i + 1]);
+ return;
+ }
+ else {
+ let args = arg.split('=');
+ if (args[0] === argName) {
+ runTimer(args[1]);
+ }
+ }
+ }
+}
+setupExitTimer();
+const watchDog = {
+ initialize: (params) => {
+ const processId = params.processId;
+ if (Is.number(processId) && exitTimer === undefined) {
+ // We received a parent process id. Set up a timer to periodically check
+ // if the parent is still alive.
+ setInterval(() => {
+ try {
+ process.kill(processId, 0);
+ }
+ catch (ex) {
+ // Parent process doesn't exist anymore. Exit the server.
+ process.exit(_shutdownReceived ? 0 : 1);
+ }
+ }, 3000);
+ }
+ },
+ get shutdownReceived() {
+ return _shutdownReceived;
+ },
+ set shutdownReceived(value) {
+ _shutdownReceived = value;
+ },
+ exit: (code) => {
+ process.exit(code);
+ }
+};
+function createConnection(arg1, arg2, arg3, arg4) {
+ let factories;
+ let input;
+ let output;
+ let options;
+ if (arg1 !== void 0 && arg1.__brand === 'features') {
+ factories = arg1;
+ arg1 = arg2;
+ arg2 = arg3;
+ arg3 = arg4;
+ }
+ if (node_1.ConnectionStrategy.is(arg1) || node_1.ConnectionOptions.is(arg1)) {
+ options = arg1;
+ }
+ else {
+ input = arg1;
+ output = arg2;
+ options = arg3;
+ }
+ return _createConnection(input, output, options, factories);
+}
+exports.createConnection = createConnection;
+function _createConnection(input, output, options, factories) {
+ if (!input && !output && process.argv.length > 2) {
+ let port = void 0;
+ let pipeName = void 0;
+ let argv = process.argv.slice(2);
+ for (let i = 0; i < argv.length; i++) {
+ let arg = argv[i];
+ if (arg === '--node-ipc') {
+ input = new node_1.IPCMessageReader(process);
+ output = new node_1.IPCMessageWriter(process);
+ break;
+ }
+ else if (arg === '--stdio') {
+ input = process.stdin;
+ output = process.stdout;
+ break;
+ }
+ else if (arg === '--socket') {
+ port = parseInt(argv[i + 1]);
+ break;
+ }
+ else if (arg === '--pipe') {
+ pipeName = argv[i + 1];
+ break;
+ }
+ else {
+ var args = arg.split('=');
+ if (args[0] === '--socket') {
+ port = parseInt(args[1]);
+ break;
+ }
+ else if (args[0] === '--pipe') {
+ pipeName = args[1];
+ break;
+ }
+ }
+ }
+ if (port) {
+ let transport = node_1.createServerSocketTransport(port);
+ input = transport[0];
+ output = transport[1];
+ }
+ else if (pipeName) {
+ let transport = node_1.createServerPipeTransport(pipeName);
+ input = transport[0];
+ output = transport[1];
+ }
+ }
+ var commandLineMessage = 'Use arguments of createConnection or set command line parameters: \'--node-ipc\', \'--stdio\' or \'--socket={number}\'';
+ if (!input) {
+ throw new Error('Connection input stream is not set. ' + commandLineMessage);
+ }
+ if (!output) {
+ throw new Error('Connection output stream is not set. ' + commandLineMessage);
+ }
+ // Backwards compatibility
+ if (Is.func(input.read) && Is.func(input.on)) {
+ let inputStream = input;
+ inputStream.on('end', () => {
+ process.exit(_shutdownReceived ? 0 : 1);
+ });
+ inputStream.on('close', () => {
+ process.exit(_shutdownReceived ? 0 : 1);
+ });
+ }
+ const connectionFactory = (logger) => {
+ return node_1.createProtocolConnection(input, output, logger, options);
+ };
+ return server_1.createConnection(connectionFactory, watchDog, factories);
+}
+//# sourceMappingURL=main.js.map
+
+/***/ }),
+/* 42 */
+/***/ (function(module, exports, __webpack_require__) {
+
+"use strict";
+
+/* --------------------------------------------------------------------------------------------
+ * Copyright (c) Microsoft Corporation. All rights reserved.
+ * Licensed under the MIT License. See License.txt in the project root for license information.
+ * ------------------------------------------------------------------------------------------ */
+Object.defineProperty(exports, "__esModule", { value: true });
+function boolean(value) {
+ return value === true || value === false;
+}
+exports.boolean = boolean;
+function string(value) {
+ return typeof value === 'string' || value instanceof String;
+}
+exports.string = string;
+function number(value) {
+ return typeof value === 'number' || value instanceof Number;
+}
+exports.number = number;
+function error(value) {
+ return value instanceof Error;
+}
+exports.error = error;
+function func(value) {
+ return typeof value === 'function';
+}
+exports.func = func;
+function array(value) {
+ return Array.isArray(value);
+}
+exports.array = array;
+function stringArray(value) {
+ return array(value) && value.every(elem => string(elem));
+}
+exports.stringArray = stringArray;
+function typedArray(value, check) {
+ return Array.isArray(value) && value.every(check);
+}
+exports.typedArray = typedArray;
+function thenable(value) {
+ return value && func(value.then);
+}
+exports.thenable = thenable;
+//# sourceMappingURL=is.js.map
+
+/***/ }),
+/* 43 */
+/***/ (function(module, exports, __webpack_require__) {
+
+"use strict";
+
+/* --------------------------------------------------------------------------------------------
+ * Copyright (c) Microsoft Corporation. All rights reserved.
+ * Licensed under the MIT License. See License.txt in the project root for license information.
+ * ------------------------------------------------------------------------------------------ */
+Object.defineProperty(exports, "__esModule", { value: true });
+const vscode_languageserver_protocol_1 = __webpack_require__(44);
+const Is = __webpack_require__(42);
+const UUID = __webpack_require__(77);
+const progress_1 = __webpack_require__(78);
+const configuration_1 = __webpack_require__(79);
+const workspaceFolders_1 = __webpack_require__(80);
+const callHierarchy_1 = __webpack_require__(81);
+function null2Undefined(value) {
+ if (value === null) {
+ return undefined;
+ }
+ return value;
+}
+/**
+ * A manager for simple text documents
+ */
+class TextDocuments {
+ /**
+ * Create a new text document manager.
+ */
+ constructor(configuration) {
+ this._documents = Object.create(null);
+ this._configuration = configuration;
+ this._onDidChangeContent = new vscode_languageserver_protocol_1.Emitter();
+ this._onDidOpen = new vscode_languageserver_protocol_1.Emitter();
+ this._onDidClose = new vscode_languageserver_protocol_1.Emitter();
+ this._onDidSave = new vscode_languageserver_protocol_1.Emitter();
+ this._onWillSave = new vscode_languageserver_protocol_1.Emitter();
+ }
+ /**
+ * An event that fires when a text document managed by this manager
+ * has been opened or the content changes.
+ */
+ get onDidChangeContent() {
+ return this._onDidChangeContent.event;
+ }
+ /**
+ * An event that fires when a text document managed by this manager
+ * has been opened.
+ */
+ get onDidOpen() {
+ return this._onDidOpen.event;
+ }
+ /**
+ * An event that fires when a text document managed by this manager
+ * will be saved.
+ */
+ get onWillSave() {
+ return this._onWillSave.event;
+ }
+ /**
+ * Sets a handler that will be called if a participant wants to provide
+ * edits during a text document save.
+ */
+ onWillSaveWaitUntil(handler) {
+ this._willSaveWaitUntil = handler;
+ }
+ /**
+ * An event that fires when a text document managed by this manager
+ * has been saved.
+ */
+ get onDidSave() {
+ return this._onDidSave.event;
+ }
+ /**
+ * An event that fires when a text document managed by this manager
+ * has been closed.
+ */
+ get onDidClose() {
+ return this._onDidClose.event;
+ }
+ /**
+ * Returns the document for the given URI. Returns undefined if
+ * the document is not mananged by this instance.
+ *
+ * @param uri The text document's URI to retrieve.
+ * @return the text document or `undefined`.
+ */
+ get(uri) {
+ return this._documents[uri];
+ }
+ /**
+ * Returns all text documents managed by this instance.
+ *
+ * @return all text documents.
+ */
+ all() {
+ return Object.keys(this._documents).map(key => this._documents[key]);
+ }
+ /**
+ * Returns the URIs of all text documents managed by this instance.
+ *
+ * @return the URI's of all text documents.
+ */
+ keys() {
+ return Object.keys(this._documents);
+ }
+ /**
+ * Listens for `low level` notification on the given connection to
+ * update the text documents managed by this instance.
+ *
+ * Please note that the connection only provides handlers not an event model. Therefore
+ * listening on a connection will overwrite the following handlers on a connection:
+ * `onDidOpenTextDocument`, `onDidChangeTextDocument`, `onDidCloseTextDocument`,
+ * `onWillSaveTextDocument`, `onWillSaveTextDocumentWaitUntil` and `onDidSaveTextDocument`.
+ *
+ * Use the correspnding events on the TextDocuments instance instead.
+ *
+ * @param connection The connection to listen on.
+ */
+ listen(connection) {
+ connection.__textDocumentSync = vscode_languageserver_protocol_1.TextDocumentSyncKind.Full;
+ connection.onDidOpenTextDocument((event) => {
+ let td = event.textDocument;
+ let document = this._configuration.create(td.uri, td.languageId, td.version, td.text);
+ this._documents[td.uri] = document;
+ let toFire = Object.freeze({ document });
+ this._onDidOpen.fire(toFire);
+ this._onDidChangeContent.fire(toFire);
+ });
+ connection.onDidChangeTextDocument((event) => {
+ let td = event.textDocument;
+ let changes = event.contentChanges;
+ if (changes.length === 0) {
+ return;
+ }
+ let document = this._documents[td.uri];
+ const { version } = td;
+ if (version === null || version === undefined) {
+ throw new Error(`Received document change event for ${td.uri} without valid version identifier`);
+ }
+ document = this._configuration.update(document, changes, version);
+ this._documents[td.uri] = document;
+ this._onDidChangeContent.fire(Object.freeze({ document }));
+ });
+ connection.onDidCloseTextDocument((event) => {
+ let document = this._documents[event.textDocument.uri];
+ if (document) {
+ delete this._documents[event.textDocument.uri];
+ this._onDidClose.fire(Object.freeze({ document }));
+ }
+ });
+ connection.onWillSaveTextDocument((event) => {
+ let document = this._documents[event.textDocument.uri];
+ if (document) {
+ this._onWillSave.fire(Object.freeze({ document, reason: event.reason }));
+ }
+ });
+ connection.onWillSaveTextDocumentWaitUntil((event, token) => {
+ let document = this._documents[event.textDocument.uri];
+ if (document && this._willSaveWaitUntil) {
+ return this._willSaveWaitUntil(Object.freeze({ document, reason: event.reason }), token);
+ }
+ else {
+ return [];
+ }
+ });
+ connection.onDidSaveTextDocument((event) => {
+ let document = this._documents[event.textDocument.uri];
+ if (document) {
+ this._onDidSave.fire(Object.freeze({ document }));
+ }
+ });
+ }
+}
+exports.TextDocuments = TextDocuments;
+/**
+ * Helps tracking error message. Equal occurences of the same
+ * message are only stored once. This class is for example
+ * useful if text documents are validated in a loop and equal
+ * error message should be folded into one.
+ */
+class ErrorMessageTracker {
+ constructor() {
+ this._messages = Object.create(null);
+ }
+ /**
+ * Add a message to the tracker.
+ *
+ * @param message The message to add.
+ */
+ add(message) {
+ let count = this._messages[message];
+ if (!count) {
+ count = 0;
+ }
+ count++;
+ this._messages[message] = count;
+ }
+ /**
+ * Send all tracked messages to the connection's window.
+ *
+ * @param connection The connection established between client and server.
+ */
+ sendErrors(connection) {
+ Object.keys(this._messages).forEach(message => {
+ connection.window.showErrorMessage(message);
+ });
+ }
+}
+exports.ErrorMessageTracker = ErrorMessageTracker;
+class RemoteConsoleImpl {
+ constructor() {
+ }
+ rawAttach(connection) {
+ this._rawConnection = connection;
+ }
+ attach(connection) {
+ this._connection = connection;
+ }
+ get connection() {
+ if (!this._connection) {
+ throw new Error('Remote is not attached to a connection yet.');
+ }
+ return this._connection;
+ }
+ fillServerCapabilities(_capabilities) {
+ }
+ initialize(_capabilities) {
+ }
+ error(message) {
+ this.send(vscode_languageserver_protocol_1.MessageType.Error, message);
+ }
+ warn(message) {
+ this.send(vscode_languageserver_protocol_1.MessageType.Warning, message);
+ }
+ info(message) {
+ this.send(vscode_languageserver_protocol_1.MessageType.Info, message);
+ }
+ log(message) {
+ this.send(vscode_languageserver_protocol_1.MessageType.Log, message);
+ }
+ send(type, message) {
+ if (this._rawConnection) {
+ this._rawConnection.sendNotification(vscode_languageserver_protocol_1.LogMessageNotification.type, { type, message });
+ }
+ }
+}
+class _RemoteWindowImpl {
+ constructor() {
+ }
+ attach(connection) {
+ this._connection = connection;
+ }
+ get connection() {
+ if (!this._connection) {
+ throw new Error('Remote is not attached to a connection yet.');
+ }
+ return this._connection;
+ }
+ initialize(_capabilities) {
+ }
+ fillServerCapabilities(_capabilities) {
+ }
+ showErrorMessage(message, ...actions) {
+ let params = { type: vscode_languageserver_protocol_1.MessageType.Error, message, actions };
+ return this.connection.sendRequest(vscode_languageserver_protocol_1.ShowMessageRequest.type, params).then(null2Undefined);
+ }
+ showWarningMessage(message, ...actions) {
+ let params = { type: vscode_languageserver_protocol_1.MessageType.Warning, message, actions };
+ return this.connection.sendRequest(vscode_languageserver_protocol_1.ShowMessageRequest.type, params).then(null2Undefined);
+ }
+ showInformationMessage(message, ...actions) {
+ let params = { type: vscode_languageserver_protocol_1.MessageType.Info, message, actions };
+ return this.connection.sendRequest(vscode_languageserver_protocol_1.ShowMessageRequest.type, params).then(null2Undefined);
+ }
+}
+const RemoteWindowImpl = progress_1.ProgressFeature(_RemoteWindowImpl);
+var BulkRegistration;
+(function (BulkRegistration) {
+ /**
+ * Creates a new bulk registration.
+ * @return an empty bulk registration.
+ */
+ function create() {
+ return new BulkRegistrationImpl();
+ }
+ BulkRegistration.create = create;
+})(BulkRegistration = exports.BulkRegistration || (exports.BulkRegistration = {}));
+class BulkRegistrationImpl {
+ constructor() {
+ this._registrations = [];
+ this._registered = new Set();
+ }
+ add(type, registerOptions) {
+ const method = Is.string(type) ? type : type.method;
+ if (this._registered.has(method)) {
+ throw new Error(`${method} is already added to this registration`);
+ }
+ const id = UUID.generateUuid();
+ this._registrations.push({
+ id: id,
+ method: method,
+ registerOptions: registerOptions || {}
+ });
+ this._registered.add(method);
+ }
+ asRegistrationParams() {
+ return {
+ registrations: this._registrations
+ };
+ }
+}
+var BulkUnregistration;
+(function (BulkUnregistration) {
+ function create() {
+ return new BulkUnregistrationImpl(undefined, []);
+ }
+ BulkUnregistration.create = create;
+})(BulkUnregistration = exports.BulkUnregistration || (exports.BulkUnregistration = {}));
+class BulkUnregistrationImpl {
+ constructor(_connection, unregistrations) {
+ this._connection = _connection;
+ this._unregistrations = new Map();
+ unregistrations.forEach(unregistration => {
+ this._unregistrations.set(unregistration.method, unregistration);
+ });
+ }
+ get isAttached() {
+ return !!this._connection;
+ }
+ attach(connection) {
+ this._connection = connection;
+ }
+ add(unregistration) {
+ this._unregistrations.set(unregistration.method, unregistration);
+ }
+ dispose() {
+ let unregistrations = [];
+ for (let unregistration of this._unregistrations.values()) {
+ unregistrations.push(unregistration);
+ }
+ let params = {
+ unregisterations: unregistrations
+ };
+ this._connection.sendRequest(vscode_languageserver_protocol_1.UnregistrationRequest.type, params).then(undefined, (_error) => {
+ this._connection.console.info(`Bulk unregistration failed.`);
+ });
+ }
+ disposeSingle(arg) {
+ const method = Is.string(arg) ? arg : arg.method;
+ const unregistration = this._unregistrations.get(method);
+ if (!unregistration) {
+ return false;
+ }
+ let params = {
+ unregisterations: [unregistration]
+ };
+ this._connection.sendRequest(vscode_languageserver_protocol_1.UnregistrationRequest.type, params).then(() => {
+ this._unregistrations.delete(method);
+ }, (_error) => {
+ this._connection.console.info(`Unregistering request handler for ${unregistration.id} failed.`);
+ });
+ return true;
+ }
+}
+class RemoteClientImpl {
+ attach(connection) {
+ this._connection = connection;
+ }
+ get connection() {
+ if (!this._connection) {
+ throw new Error('Remote is not attached to a connection yet.');
+ }
+ return this._connection;
+ }
+ initialize(_capabilities) {
+ }
+ fillServerCapabilities(_capabilities) {
+ }
+ register(typeOrRegistrations, registerOptionsOrType, registerOptions) {
+ if (typeOrRegistrations instanceof BulkRegistrationImpl) {
+ return this.registerMany(typeOrRegistrations);
+ }
+ else if (typeOrRegistrations instanceof BulkUnregistrationImpl) {
+ return this.registerSingle1(typeOrRegistrations, registerOptionsOrType, registerOptions);
+ }
+ else {
+ return this.registerSingle2(typeOrRegistrations, registerOptionsOrType);
+ }
+ }
+ registerSingle1(unregistration, type, registerOptions) {
+ const method = Is.string(type) ? type : type.method;
+ const id = UUID.generateUuid();
+ let params = {
+ registrations: [{ id, method, registerOptions: registerOptions || {} }]
+ };
+ if (!unregistration.isAttached) {
+ unregistration.attach(this.connection);
+ }
+ return this.connection.sendRequest(vscode_languageserver_protocol_1.RegistrationRequest.type, params).then((_result) => {
+ unregistration.add({ id: id, method: method });
+ return unregistration;
+ }, (_error) => {
+ this.connection.console.info(`Registering request handler for ${method} failed.`);
+ return Promise.reject(_error);
+ });
+ }
+ registerSingle2(type, registerOptions) {
+ const method = Is.string(type) ? type : type.method;
+ const id = UUID.generateUuid();
+ let params = {
+ registrations: [{ id, method, registerOptions: registerOptions || {} }]
+ };
+ return this.connection.sendRequest(vscode_languageserver_protocol_1.RegistrationRequest.type, params).then((_result) => {
+ return vscode_languageserver_protocol_1.Disposable.create(() => {
+ this.unregisterSingle(id, method);
+ });
+ }, (_error) => {
+ this.connection.console.info(`Registering request handler for ${method} failed.`);
+ return Promise.reject(_error);
+ });
+ }
+ unregisterSingle(id, method) {
+ let params = {
+ unregisterations: [{ id, method }]
+ };
+ return this.connection.sendRequest(vscode_languageserver_protocol_1.UnregistrationRequest.type, params).then(undefined, (_error) => {
+ this.connection.console.info(`Unregistering request handler for ${id} failed.`);
+ });
+ }
+ registerMany(registrations) {
+ let params = registrations.asRegistrationParams();
+ return this.connection.sendRequest(vscode_languageserver_protocol_1.RegistrationRequest.type, params).then(() => {
+ return new BulkUnregistrationImpl(this._connection, params.registrations.map(registration => { return { id: registration.id, method: registration.method }; }));
+ }, (_error) => {
+ this.connection.console.info(`Bulk registration failed.`);
+ return Promise.reject(_error);
+ });
+ }
+}
+class _RemoteWorkspaceImpl {
+ constructor() {
+ }
+ attach(connection) {
+ this._connection = connection;
+ }
+ get connection() {
+ if (!this._connection) {
+ throw new Error('Remote is not attached to a connection yet.');
+ }
+ return this._connection;
+ }
+ initialize(_capabilities) {
+ }
+ fillServerCapabilities(_capabilities) {
+ }
+ applyEdit(paramOrEdit) {
+ function isApplyWorkspaceEditParams(value) {
+ return value && !!value.edit;
+ }
+ let params = isApplyWorkspaceEditParams(paramOrEdit) ? paramOrEdit : { edit: paramOrEdit };
+ return this.connection.sendRequest(vscode_languageserver_protocol_1.ApplyWorkspaceEditRequest.type, params);
+ }
+}
+const RemoteWorkspaceImpl = workspaceFolders_1.WorkspaceFoldersFeature(configuration_1.ConfigurationFeature(_RemoteWorkspaceImpl));
+class TracerImpl {
+ constructor() {
+ this._trace = vscode_languageserver_protocol_1.Trace.Off;
+ }
+ attach(connection) {
+ this._connection = connection;
+ }
+ get connection() {
+ if (!this._connection) {
+ throw new Error('Remote is not attached to a connection yet.');
+ }
+ return this._connection;
+ }
+ initialize(_capabilities) {
+ }
+ fillServerCapabilities(_capabilities) {
+ }
+ set trace(value) {
+ this._trace = value;
+ }
+ log(message, verbose) {
+ if (this._trace === vscode_languageserver_protocol_1.Trace.Off) {
+ return;
+ }
+ this.connection.sendNotification(vscode_languageserver_protocol_1.LogTraceNotification.type, {
+ message: message,
+ verbose: this._trace === vscode_languageserver_protocol_1.Trace.Verbose ? verbose : undefined
+ });
+ }
+}
+class TelemetryImpl {
+ constructor() {
+ }
+ attach(connection) {
+ this._connection = connection;
+ }
+ get connection() {
+ if (!this._connection) {
+ throw new Error('Remote is not attached to a connection yet.');
+ }
+ return this._connection;
+ }
+ initialize(_capabilities) {
+ }
+ fillServerCapabilities(_capabilities) {
+ }
+ logEvent(data) {
+ this.connection.sendNotification(vscode_languageserver_protocol_1.TelemetryEventNotification.type, data);
+ }
+}
+class _LanguagesImpl {
+ constructor() {
+ }
+ attach(connection) {
+ this._connection = connection;
+ }
+ get connection() {
+ if (!this._connection) {
+ throw new Error('Remote is not attached to a connection yet.');
+ }
+ return this._connection;
+ }
+ initialize(_capabilities) {
+ }
+ fillServerCapabilities(_capabilities) {
+ }
+ attachWorkDoneProgress(params) {
+ return progress_1.attachWorkDone(this.connection, params);
+ }
+ attachPartialResultProgress(_type, params) {
+ return progress_1.attachPartialResult(this.connection, params);
+ }
+}
+exports._LanguagesImpl = _LanguagesImpl;
+const LanguagesImpl = callHierarchy_1.CallHierarchyFeature(_LanguagesImpl);
+function combineConsoleFeatures(one, two) {
+ return function (Base) {
+ return two(one(Base));
+ };
+}
+exports.combineConsoleFeatures = combineConsoleFeatures;
+function combineTelemetryFeatures(one, two) {
+ return function (Base) {
+ return two(one(Base));
+ };
+}
+exports.combineTelemetryFeatures = combineTelemetryFeatures;
+function combineTracerFeatures(one, two) {
+ return function (Base) {
+ return two(one(Base));
+ };
+}
+exports.combineTracerFeatures = combineTracerFeatures;
+function combineClientFeatures(one, two) {
+ return function (Base) {
+ return two(one(Base));
+ };
+}
+exports.combineClientFeatures = combineClientFeatures;
+function combineWindowFeatures(one, two) {
+ return function (Base) {
+ return two(one(Base));
+ };
+}
+exports.combineWindowFeatures = combineWindowFeatures;
+function combineWorkspaceFeatures(one, two) {
+ return function (Base) {
+ return two(one(Base));
+ };
+}
+exports.combineWorkspaceFeatures = combineWorkspaceFeatures;
+function combineLanguagesFeatures(one, two) {
+ return function (Base) {
+ return two(one(Base));
+ };
+}
+exports.combineLanguagesFeatures = combineLanguagesFeatures;
+function combineFeatures(one, two) {
+ function combine(one, two, func) {
+ if (one && two) {
+ return func(one, two);
+ }
+ else if (one) {
+ return one;
+ }
+ else {
+ return two;
+ }
+ }
+ let result = {
+ __brand: 'features',
+ console: combine(one.console, two.console, combineConsoleFeatures),
+ tracer: combine(one.tracer, two.tracer, combineTracerFeatures),
+ telemetry: combine(one.telemetry, two.telemetry, combineTelemetryFeatures),
+ client: combine(one.client, two.client, combineClientFeatures),
+ window: combine(one.window, two.window, combineWindowFeatures),
+ workspace: combine(one.workspace, two.workspace, combineWorkspaceFeatures)
+ };
+ return result;
+}
+exports.combineFeatures = combineFeatures;
+function createConnection(connectionFactory, watchDog, factories) {
+ const logger = (factories && factories.console ? new (factories.console(RemoteConsoleImpl))() : new RemoteConsoleImpl());
+ const connection = connectionFactory(logger);
+ logger.rawAttach(connection);
+ const tracer = (factories && factories.tracer ? new (factories.tracer(TracerImpl))() : new TracerImpl());
+ const telemetry = (factories && factories.telemetry ? new (factories.telemetry(TelemetryImpl))() : new TelemetryImpl());
+ const client = (factories && factories.client ? new (factories.client(RemoteClientImpl))() : new RemoteClientImpl());
+ const remoteWindow = (factories && factories.window ? new (factories.window(RemoteWindowImpl))() : new RemoteWindowImpl());
+ const workspace = (factories && factories.workspace ? new (factories.workspace(RemoteWorkspaceImpl))() : new RemoteWorkspaceImpl());
+ const languages = (factories && factories.languages ? new (factories.languages(LanguagesImpl))() : new LanguagesImpl());
+ const allRemotes = [logger, tracer, telemetry, client, remoteWindow, workspace, languages];
+ function asPromise(value) {
+ if (value instanceof Promise) {
+ return value;
+ }
+ else if (Is.thenable(value)) {
+ return new Promise((resolve, reject) => {
+ value.then((resolved) => resolve(resolved), (error) => reject(error));
+ });
+ }
+ else {
+ return Promise.resolve(value);
+ }
+ }
+ let shutdownHandler = undefined;
+ let initializeHandler = undefined;
+ let exitHandler = undefined;
+ let protocolConnection = {
+ listen: () => connection.listen(),
+ sendRequest: (type, ...params) => connection.sendRequest(Is.string(type) ? type : type.method, ...params),
+ onRequest: (type, handler) => connection.onRequest(type, handler),
+ sendNotification: (type, param) => {
+ const method = Is.string(type) ? type : type.method;
+ if (arguments.length === 1) {
+ connection.sendNotification(method);
+ }
+ else {
+ connection.sendNotification(method, param);
+ }
+ },
+ onNotification: (type, handler) => connection.onNotification(type, handler),
+ onProgress: connection.onProgress,
+ sendProgress: connection.sendProgress,
+ onInitialize: (handler) => initializeHandler = handler,
+ onInitialized: (handler) => connection.onNotification(vscode_languageserver_protocol_1.InitializedNotification.type, handler),
+ onShutdown: (handler) => shutdownHandler = handler,
+ onExit: (handler) => exitHandler = handler,
+ get console() { return logger; },
+ get telemetry() { return telemetry; },
+ get tracer() { return tracer; },
+ get client() { return client; },
+ get window() { return remoteWindow; },
+ get workspace() { return workspace; },
+ get languages() { return languages; },
+ onDidChangeConfiguration: (handler) => connection.onNotification(vscode_languageserver_protocol_1.DidChangeConfigurationNotification.type, handler),
+ onDidChangeWatchedFiles: (handler) => connection.onNotification(vscode_languageserver_protocol_1.DidChangeWatchedFilesNotification.type, handler),
+ __textDocumentSync: undefined,
+ onDidOpenTextDocument: (handler) => connection.onNotification(vscode_languageserver_protocol_1.DidOpenTextDocumentNotification.type, handler),
+ onDidChangeTextDocument: (handler) => connection.onNotification(vscode_languageserver_protocol_1.DidChangeTextDocumentNotification.type, handler),
+ onDidCloseTextDocument: (handler) => connection.onNotification(vscode_languageserver_protocol_1.DidCloseTextDocumentNotification.type, handler),
+ onWillSaveTextDocument: (handler) => connection.onNotification(vscode_languageserver_protocol_1.WillSaveTextDocumentNotification.type, handler),
+ onWillSaveTextDocumentWaitUntil: (handler) => connection.onRequest(vscode_languageserver_protocol_1.WillSaveTextDocumentWaitUntilRequest.type, handler),
+ onDidSaveTextDocument: (handler) => connection.onNotification(vscode_languageserver_protocol_1.DidSaveTextDocumentNotification.type, handler),
+ sendDiagnostics: (params) => connection.sendNotification(vscode_languageserver_protocol_1.PublishDiagnosticsNotification.type, params),
+ onHover: (handler) => connection.onRequest(vscode_languageserver_protocol_1.HoverRequest.type, (params, cancel) => {
+ return handler(params, cancel, progress_1.attachWorkDone(connection, params), undefined);
+ }),
+ onCompletion: (handler) => connection.onRequest(vscode_languageserver_protocol_1.CompletionRequest.type, (params, cancel) => {
+ return handler(params, cancel, progress_1.attachWorkDone(connection, params), progress_1.attachPartialResult(connection, params));
+ }),
+ onCompletionResolve: (handler) => connection.onRequest(vscode_languageserver_protocol_1.CompletionResolveRequest.type, handler),
+ onSignatureHelp: (handler) => connection.onRequest(vscode_languageserver_protocol_1.SignatureHelpRequest.type, (params, cancel) => {
+ return handler(params, cancel, progress_1.attachWorkDone(connection, params), undefined);
+ }),
+ onDeclaration: (handler) => connection.onRequest(vscode_languageserver_protocol_1.DeclarationRequest.type, (params, cancel) => {
+ return handler(params, cancel, progress_1.attachWorkDone(connection, params), progress_1.attachPartialResult(connection, params));
+ }),
+ onDefinition: (handler) => connection.onRequest(vscode_languageserver_protocol_1.DefinitionRequest.type, (params, cancel) => {
+ return handler(params, cancel, progress_1.attachWorkDone(connection, params), progress_1.attachPartialResult(connection, params));
+ }),
+ onTypeDefinition: (handler) => connection.onRequest(vscode_languageserver_protocol_1.TypeDefinitionRequest.type, (params, cancel) => {
+ return handler(params, cancel, progress_1.attachWorkDone(connection, params), progress_1.attachPartialResult(connection, params));
+ }),
+ onImplementation: (handler) => connection.onRequest(vscode_languageserver_protocol_1.ImplementationRequest.type, (params, cancel) => {
+ return handler(params, cancel, progress_1.attachWorkDone(connection, params), progress_1.attachPartialResult(connection, params));
+ }),
+ onReferences: (handler) => connection.onRequest(vscode_languageserver_protocol_1.ReferencesRequest.type, (params, cancel) => {
+ return handler(params, cancel, progress_1.attachWorkDone(connection, params), progress_1.attachPartialResult(connection, params));
+ }),
+ onDocumentHighlight: (handler) => connection.onRequest(vscode_languageserver_protocol_1.DocumentHighlightRequest.type, (params, cancel) => {
+ return handler(params, cancel, progress_1.attachWorkDone(connection, params), progress_1.attachPartialResult(connection, params));
+ }),
+ onDocumentSymbol: (handler) => connection.onRequest(vscode_languageserver_protocol_1.DocumentSymbolRequest.type, (params, cancel) => {
+ return handler(params, cancel, progress_1.attachWorkDone(connection, params), progress_1.attachPartialResult(connection, params));
+ }),
+ onWorkspaceSymbol: (handler) => connection.onRequest(vscode_languageserver_protocol_1.WorkspaceSymbolRequest.type, (params, cancel) => {
+ return handler(params, cancel, progress_1.attachWorkDone(connection, params), progress_1.attachPartialResult(connection, params));
+ }),
+ onCodeAction: (handler) => connection.onRequest(vscode_languageserver_protocol_1.CodeActionRequest.type, (params, cancel) => {
+ return handler(params, cancel, progress_1.attachWorkDone(connection, params), progress_1.attachPartialResult(connection, params));
+ }),
+ onCodeLens: (handler) => connection.onRequest(vscode_languageserver_protocol_1.CodeLensRequest.type, (params, cancel) => {
+ return handler(params, cancel, progress_1.attachWorkDone(connection, params), progress_1.attachPartialResult(connection, params));
+ }),
+ onCodeLensResolve: (handler) => connection.onRequest(vscode_languageserver_protocol_1.CodeLensResolveRequest.type, (params, cancel) => {
+ return handler(params, cancel);
+ }),
+ onDocumentFormatting: (handler) => connection.onRequest(vscode_languageserver_protocol_1.DocumentFormattingRequest.type, (params, cancel) => {
+ return handler(params, cancel, progress_1.attachWorkDone(connection, params), undefined);
+ }),
+ onDocumentRangeFormatting: (handler) => connection.onRequest(vscode_languageserver_protocol_1.DocumentRangeFormattingRequest.type, (params, cancel) => {
+ return handler(params, cancel, progress_1.attachWorkDone(connection, params), undefined);
+ }),
+ onDocumentOnTypeFormatting: (handler) => connection.onRequest(vscode_languageserver_protocol_1.DocumentOnTypeFormattingRequest.type, (params, cancel) => {
+ return handler(params, cancel);
+ }),
+ onRenameRequest: (handler) => connection.onRequest(vscode_languageserver_protocol_1.RenameRequest.type, (params, cancel) => {
+ return handler(params, cancel, progress_1.attachWorkDone(connection, params), undefined);
+ }),
+ onPrepareRename: (handler) => connection.onRequest(vscode_languageserver_protocol_1.PrepareRenameRequest.type, (params, cancel) => {
+ return handler(params, cancel);
+ }),
+ onDocumentLinks: (handler) => connection.onRequest(vscode_languageserver_protocol_1.DocumentLinkRequest.type, (params, cancel) => {
+ return handler(params, cancel, progress_1.attachWorkDone(connection, params), progress_1.attachPartialResult(connection, params));
+ }),
+ onDocumentLinkResolve: (handler) => connection.onRequest(vscode_languageserver_protocol_1.DocumentLinkResolveRequest.type, (params, cancel) => {
+ return handler(params, cancel);
+ }),
+ onDocumentColor: (handler) => connection.onRequest(vscode_languageserver_protocol_1.DocumentColorRequest.type, (params, cancel) => {
+ return handler(params, cancel, progress_1.attachWorkDone(connection, params), progress_1.attachPartialResult(connection, params));
+ }),
+ onColorPresentation: (handler) => connection.onRequest(vscode_languageserver_protocol_1.ColorPresentationRequest.type, (params, cancel) => {
+ return handler(params, cancel, progress_1.attachWorkDone(connection, params), progress_1.attachPartialResult(connection, params));
+ }),
+ onFoldingRanges: (handler) => connection.onRequest(vscode_languageserver_protocol_1.FoldingRangeRequest.type, (params, cancel) => {
+ return handler(params, cancel, progress_1.attachWorkDone(connection, params), progress_1.attachPartialResult(connection, params));
+ }),
+ onSelectionRanges: (handler) => connection.onRequest(vscode_languageserver_protocol_1.SelectionRangeRequest.type, (params, cancel) => {
+ return handler(params, cancel, progress_1.attachWorkDone(connection, params), progress_1.attachPartialResult(connection, params));
+ }),
+ onExecuteCommand: (handler) => connection.onRequest(vscode_languageserver_protocol_1.ExecuteCommandRequest.type, (params, cancel) => {
+ return handler(params, cancel, progress_1.attachWorkDone(connection, params), undefined);
+ }),
+ dispose: () => connection.dispose()
+ };
+ for (let remote of allRemotes) {
+ remote.attach(protocolConnection);
+ }
+ connection.onRequest(vscode_languageserver_protocol_1.InitializeRequest.type, (params) => {
+ watchDog.initialize(params);
+ if (Is.string(params.trace)) {
+ tracer.trace = vscode_languageserver_protocol_1.Trace.fromString(params.trace);
+ }
+ for (let remote of allRemotes) {
+ remote.initialize(params.capabilities);
+ }
+ if (initializeHandler) {
+ let result = initializeHandler(params, new vscode_languageserver_protocol_1.CancellationTokenSource().token, progress_1.attachWorkDone(connection, params), undefined);
+ return asPromise(result).then((value) => {
+ if (value instanceof vscode_languageserver_protocol_1.ResponseError) {
+ return value;
+ }
+ let result = value;
+ if (!result) {
+ result = { capabilities: {} };
+ }
+ let capabilities = result.capabilities;
+ if (!capabilities) {
+ capabilities = {};
+ result.capabilities = capabilities;
+ }
+ if (capabilities.textDocumentSync === undefined || capabilities.textDocumentSync === null) {
+ capabilities.textDocumentSync = Is.number(protocolConnection.__textDocumentSync) ? protocolConnection.__textDocumentSync : vscode_languageserver_protocol_1.TextDocumentSyncKind.None;
+ }
+ else if (!Is.number(capabilities.textDocumentSync) && !Is.number(capabilities.textDocumentSync.change)) {
+ capabilities.textDocumentSync.change = Is.number(protocolConnection.__textDocumentSync) ? protocolConnection.__textDocumentSync : vscode_languageserver_protocol_1.TextDocumentSyncKind.None;
+ }
+ for (let remote of allRemotes) {
+ remote.fillServerCapabilities(capabilities);
+ }
+ return result;
+ });
+ }
+ else {
+ let result = { capabilities: { textDocumentSync: vscode_languageserver_protocol_1.TextDocumentSyncKind.None } };
+ for (let remote of allRemotes) {
+ remote.fillServerCapabilities(result.capabilities);
+ }
+ return result;
+ }
+ });
+ connection.onRequest(vscode_languageserver_protocol_1.ShutdownRequest.type, () => {
+ watchDog.shutdownReceived = true;
+ if (shutdownHandler) {
+ return shutdownHandler(new vscode_languageserver_protocol_1.CancellationTokenSource().token);
+ }
+ else {
+ return undefined;
+ }
+ });
+ connection.onNotification(vscode_languageserver_protocol_1.ExitNotification.type, () => {
+ try {
+ if (exitHandler) {
+ exitHandler();
+ }
+ }
+ finally {
+ if (watchDog.shutdownReceived) {
+ watchDog.exit(0);
+ }
+ else {
+ watchDog.exit(1);
+ }
+ }
+ });
+ connection.onNotification(vscode_languageserver_protocol_1.SetTraceNotification.type, (params) => {
+ tracer.trace = vscode_languageserver_protocol_1.Trace.fromString(params.value);
+ });
+ return protocolConnection;
+}
+exports.createConnection = createConnection;
+//# sourceMappingURL=server.js.map
+
+/***/ }),
+/* 44 */
+/***/ (function(module, exports, __webpack_require__) {
+
+"use strict";
+
+/* --------------------------------------------------------------------------------------------
+ * Copyright (c) Microsoft Corporation. All rights reserved.
+ * Licensed under the MIT License. See License.txt in the project root for license information.
+ * ------------------------------------------------------------------------------------------ */
+function __export(m) {
+ for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
+}
+Object.defineProperty(exports, "__esModule", { value: true });
+const node_1 = __webpack_require__(45);
+__export(__webpack_require__(45));
+__export(__webpack_require__(60));
+function createProtocolConnection(input, output, logger, options) {
+ return node_1.createMessageConnection(input, output, logger, options);
+}
+exports.createProtocolConnection = createProtocolConnection;
+//# sourceMappingURL=main.js.map
+
+/***/ }),
+/* 45 */
+/***/ (function(module, exports, __webpack_require__) {
+
+"use strict";
+/* --------------------------------------------------------------------------------------------
+ * Copyright (c) Microsoft Corporation. All rights reserved.
+ * Licensed under the MIT License. See License.txt in the project root for license information.
+ * ----------------------------------------------------------------------------------------- */
+
+
+module.exports = __webpack_require__(46);
+
+/***/ }),
+/* 46 */
+/***/ (function(module, exports, __webpack_require__) {
+
+"use strict";
+
+function __export(m) {
+ for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
+}
+Object.defineProperty(exports, "__esModule", { value: true });
+/* --------------------------------------------------------------------------------------------
+ * Copyright (c) Microsoft Corporation. All rights reserved.
+ * Licensed under the MIT License. See License.txt in the project root for license information.
+ * ----------------------------------------------------------------------------------------- */
+const ril_1 = __webpack_require__(47);
+// Install the node runtime abstract.
+ril_1.default.install();
+const api_1 = __webpack_require__(50);
+const path = __webpack_require__(1);
+const os = __webpack_require__(14);
+const crypto_1 = __webpack_require__(15);
+const net_1 = __webpack_require__(16);
+__export(__webpack_require__(50));
+class IPCMessageReader extends api_1.AbstractMessageReader {
+ constructor(process) {
+ super();
+ this.process = process;
+ let eventEmitter = this.process;
+ eventEmitter.on('error', (error) => this.fireError(error));
+ eventEmitter.on('close', () => this.fireClose());
+ }
+ listen(callback) {
+ this.process.on('message', callback);
+ return api_1.Disposable.create(() => this.process.off('message', callback));
+ }
+}
+exports.IPCMessageReader = IPCMessageReader;
+class IPCMessageWriter extends api_1.AbstractMessageWriter {
+ constructor(process) {
+ super();
+ this.process = process;
+ this.errorCount = 0;
+ let eventEmitter = this.process;
+ eventEmitter.on('error', (error) => this.fireError(error));
+ eventEmitter.on('close', () => this.fireClose);
+ }
+ write(msg) {
+ try {
+ if (typeof this.process.send === 'function') {
+ this.process.send(msg, undefined, undefined, (error) => {
+ if (error) {
+ this.errorCount++;
+ this.handleError(error, msg);
+ }
+ else {
+ this.errorCount = 0;
+ }
+ });
+ }
+ return Promise.resolve();
+ }
+ catch (error) {
+ this.handleError(error, msg);
+ return Promise.reject(error);
+ }
+ }
+ handleError(error, msg) {
+ this.errorCount++;
+ this.fireError(error, msg, this.errorCount);
+ }
+}
+exports.IPCMessageWriter = IPCMessageWriter;
+class SocketMessageReader extends api_1.ReadableStreamMessageReader {
+ constructor(socket, encoding = 'utf-8') {
+ super(ril_1.default().stream.asReadableStream(socket), encoding);
+ }
+}
+exports.SocketMessageReader = SocketMessageReader;
+class SocketMessageWriter extends api_1.WriteableStreamMessageWriter {
+ constructor(socket, options) {
+ super(ril_1.default().stream.asWritableStream(socket), options);
+ this.socket = socket;
+ }
+ dispose() {
+ super.dispose();
+ this.socket.destroy();
+ }
+}
+exports.SocketMessageWriter = SocketMessageWriter;
+class StreamMessageReader extends api_1.ReadableStreamMessageReader {
+ constructor(readble, encoding) {
+ super(ril_1.default().stream.asReadableStream(readble), encoding);
+ }
+}
+exports.StreamMessageReader = StreamMessageReader;
+class StreamMessageWriter extends api_1.WriteableStreamMessageWriter {
+ constructor(writable, options) {
+ super(ril_1.default().stream.asWritableStream(writable), options);
+ }
+}
+exports.StreamMessageWriter = StreamMessageWriter;
+function generateRandomPipeName() {
+ const randomSuffix = crypto_1.randomBytes(21).toString('hex');
+ if (process.platform === 'win32') {
+ return `\\\\.\\pipe\\vscode-jsonrpc-${randomSuffix}-sock`;
+ }
+ else {
+ // Mac/Unix: use socket file
+ return path.join(os.tmpdir(), `vscode-${randomSuffix}.sock`);
+ }
+}
+exports.generateRandomPipeName = generateRandomPipeName;
+function createClientPipeTransport(pipeName, encoding = 'utf-8') {
+ let connectResolve;
+ const connected = new Promise((resolve, _reject) => {
+ connectResolve = resolve;
+ });
+ return new Promise((resolve, reject) => {
+ let server = net_1.createServer((socket) => {
+ server.close();
+ connectResolve([
+ new SocketMessageReader(socket, encoding),
+ new SocketMessageWriter(socket, encoding)
+ ]);
+ });
+ server.on('error', reject);
+ server.listen(pipeName, () => {
+ server.removeListener('error', reject);
+ resolve({
+ onConnected: () => { return connected; }
+ });
+ });
+ });
+}
+exports.createClientPipeTransport = createClientPipeTransport;
+function createServerPipeTransport(pipeName, encoding = 'utf-8') {
+ const socket = net_1.createConnection(pipeName);
+ return [
+ new SocketMessageReader(socket, encoding),
+ new SocketMessageWriter(socket, encoding)
+ ];
+}
+exports.createServerPipeTransport = createServerPipeTransport;
+function createClientSocketTransport(port, encoding = 'utf-8') {
+ let connectResolve;
+ const connected = new Promise((resolve, _reject) => {
+ connectResolve = resolve;
+ });
+ return new Promise((resolve, reject) => {
+ const server = net_1.createServer((socket) => {
+ server.close();
+ connectResolve([
+ new SocketMessageReader(socket, encoding),
+ new SocketMessageWriter(socket, encoding)
+ ]);
+ });
+ server.on('error', reject);
+ server.listen(port, '127.0.0.1', () => {
+ server.removeListener('error', reject);
+ resolve({
+ onConnected: () => { return connected; }
+ });
+ });
+ });
+}
+exports.createClientSocketTransport = createClientSocketTransport;
+function createServerSocketTransport(port, encoding = 'utf-8') {
+ const socket = net_1.createConnection(port, '127.0.0.1');
+ return [
+ new SocketMessageReader(socket, encoding),
+ new SocketMessageWriter(socket, encoding)
+ ];
+}
+exports.createServerSocketTransport = createServerSocketTransport;
+function isMessageReader(value) {
+ return value.listen !== undefined && value.read === undefined;
+}
+function isMessageWriter(value) {
+ return value.write !== undefined && value.end === undefined;
+}
+function createMessageConnection(input, output, logger, options) {
+ if (!logger) {
+ logger = api_1.NullLogger;
+ }
+ const reader = isMessageReader(input) ? input : new StreamMessageReader(input);
+ const writer = isMessageWriter(output) ? output : new StreamMessageWriter(output);
+ if (api_1.ConnectionStrategy.is(options)) {
+ options = { connectionStrategy: options };
+ }
+ return api_1.createMessageConnection(reader, writer, logger, options);
+}
+exports.createMessageConnection = createMessageConnection;