vscode-languageserver-types
Advanced tools
Comparing version 3.0.1-alpha.3 to 3.0.1-alpha.4
@@ -288,3 +288,3 @@ /** | ||
private _textEditChanges; | ||
constructor(); | ||
constructor(workspaceEdit?: WorkspaceEdit); | ||
/** | ||
@@ -300,2 +300,3 @@ * Returns the underlying [WorkspaceEdit](#WorkspaceEdit) literal | ||
getTextEditChange(textDocument: VersionedTextDocumentIdentifier): TextEditChange; | ||
getTextEditChange(uri: string): TextEditChange; | ||
} | ||
@@ -302,0 +303,0 @@ /** |
@@ -189,2 +189,23 @@ (function (factory) { | ||
})(TextEdit = exports.TextEdit || (exports.TextEdit = {})); | ||
var TextEditChangeImpl = (function () { | ||
function TextEditChangeImpl(edits) { | ||
this.edits = edits; | ||
} | ||
TextEditChangeImpl.prototype.insert = function (position, newText) { | ||
this.edits.push(TextEdit.insert(position, newText)); | ||
}; | ||
TextEditChangeImpl.prototype.replace = function (range, newText) { | ||
this.edits.push(TextEdit.replace(range, newText)); | ||
}; | ||
TextEditChangeImpl.prototype.delete = function (range) { | ||
this.edits.push(TextEdit.del(range)); | ||
}; | ||
TextEditChangeImpl.prototype.all = function () { | ||
return this.edits; | ||
}; | ||
TextEditChangeImpl.prototype.clear = function () { | ||
this.edits.splice(0, this.edits.length); | ||
}; | ||
return TextEditChangeImpl; | ||
}()); | ||
/** | ||
@@ -194,7 +215,17 @@ * A workspace change helps constructing changes to a workspace. | ||
var WorkspaceChange = (function () { | ||
function WorkspaceChange() { | ||
this._workspaceEdit = { | ||
changes: [] | ||
}; | ||
function WorkspaceChange(workspaceEdit) { | ||
var _this = this; | ||
this._textEditChanges = Object.create(null); | ||
if (workspaceEdit) { | ||
this._workspaceEdit = workspaceEdit; | ||
workspaceEdit.changes.forEach(function (textDocumentEdit) { | ||
var textEditChange = new TextEditChangeImpl(textDocumentEdit.edits); | ||
_this._textEditChanges[textDocumentEdit.textDocument.uri] = textEditChange; | ||
}); | ||
} | ||
else { | ||
this._workspaceEdit = { | ||
changes: [] | ||
}; | ||
} | ||
} | ||
@@ -212,40 +243,21 @@ Object.defineProperty(WorkspaceChange.prototype, "edit", { | ||
}); | ||
/** | ||
* Returns the [TextEditChange](#TextEditChange) to manage text edits | ||
* for resources. | ||
*/ | ||
WorkspaceChange.prototype.getTextEditChange = function (textDocument) { | ||
var TextEditChangeImpl = (function () { | ||
function TextEditChangeImpl(edits) { | ||
this.edits = edits; | ||
WorkspaceChange.prototype.getTextEditChange = function (key) { | ||
if (VersionedTextDocumentIdentifier.is(key)) { | ||
var textDocument = key; | ||
var result = this._textEditChanges[textDocument.uri]; | ||
if (!result) { | ||
var edits = []; | ||
var textDocumentEdit = { | ||
textDocument: textDocument, | ||
edits: edits | ||
}; | ||
this._workspaceEdit.changes.push(textDocumentEdit); | ||
result = new TextEditChangeImpl(edits); | ||
this._textEditChanges[textDocument.uri] = result; | ||
} | ||
TextEditChangeImpl.prototype.insert = function (position, newText) { | ||
this.edits.push(TextEdit.insert(position, newText)); | ||
}; | ||
TextEditChangeImpl.prototype.replace = function (range, newText) { | ||
this.edits.push(TextEdit.replace(range, newText)); | ||
}; | ||
TextEditChangeImpl.prototype.delete = function (range) { | ||
this.edits.push(TextEdit.del(range)); | ||
}; | ||
TextEditChangeImpl.prototype.all = function () { | ||
return this.edits; | ||
}; | ||
TextEditChangeImpl.prototype.clear = function () { | ||
this.edits.splice(0, this.edits.length); | ||
}; | ||
return TextEditChangeImpl; | ||
}()); | ||
var result = this._textEditChanges[textDocument.uri]; | ||
if (!result) { | ||
var edits = []; | ||
var textDocumentEdit = { | ||
textDocument: textDocument, | ||
edits: edits | ||
}; | ||
this._workspaceEdit.changes.push(textDocumentEdit); | ||
result = new TextEditChangeImpl(edits); | ||
this._textEditChanges[textDocument.uri] = result; | ||
return result; | ||
} | ||
return result; | ||
else { | ||
return this._textEditChanges[key]; | ||
} | ||
}; | ||
@@ -252,0 +264,0 @@ return WorkspaceChange; |
{ | ||
"name": "vscode-languageserver-types", | ||
"description": "Types used by the Language server for node", | ||
"version": "3.0.1-alpha.3", | ||
"version": "3.0.1-alpha.4", | ||
"author": "Microsoft Corporation", | ||
@@ -6,0 +6,0 @@ "license": "MIT", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
63988
1810