New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

vscode-languageserver

Package Overview
Dependencies
Maintainers
11
Versions
268
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vscode-languageserver - npm Package Compare versions

Comparing version 8.0.0-next.6 to 8.0.0-next.7

lib/common/textDocuments.d.ts

5

lib/common/api.d.ts

@@ -7,2 +7,4 @@ import { _, Features, _Connection } from './server';

export { SemanticTokensBuilder };
import { TextDocuments, TextDocumentsConfiguration, TextDocumentChangeEvent, TextDocumentWillSaveEvent } from './textDocuments';
export { TextDocuments, TextDocumentsConfiguration, TextDocumentChangeEvent, TextDocumentWillSaveEvent };
export * from './server';

@@ -12,6 +14,7 @@ import { DiagnosticsFeatureShape } from './proposed.diagnostic';

import { InlineValuesFeatureShape } from './proposed.inlineValues';
import { NotebooksFeatureShape } from './proposed.notebooks';
import { NotebooksFeatureShape, Notebooks as _Notebooks } from './proposed.notebooks';
export declare namespace ProposedFeatures {
const all: Features<_, _, _, _, _, _, DiagnosticsFeatureShape & TypeHierarchyFeatureShape & InlineValuesFeatureShape, NotebooksFeatureShape>;
type Connection = _Connection<_, _, _, _, _, _, DiagnosticsFeatureShape & TypeHierarchyFeatureShape & InlineValuesFeatureShape, NotebooksFeatureShape>;
const Notebooks: typeof _Notebooks;
}

@@ -17,3 +17,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.ProposedFeatures = exports.SemanticTokensBuilder = void 0;
exports.ProposedFeatures = exports.TextDocuments = exports.SemanticTokensBuilder = void 0;
const server_1 = require("./server");

@@ -23,2 +23,4 @@ const semanticTokens_1 = require("./semanticTokens");

__exportStar(require("vscode-languageserver-protocol/"), exports);
const textDocuments_1 = require("./textDocuments");
Object.defineProperty(exports, "TextDocuments", { enumerable: true, get: function () { return textDocuments_1.TextDocuments; } });
__exportStar(require("./server"), exports);

@@ -36,3 +38,4 @@ const proposed_diagnostic_1 = require("./proposed.diagnostic");

};
ProposedFeatures.Notebooks = proposed_notebooks_1.Notebooks;
})(ProposedFeatures = exports.ProposedFeatures || (exports.ProposedFeatures = {}));
//# sourceMappingURL=api.js.map

67

lib/common/proposed.notebooks.d.ts

@@ -1,5 +0,6 @@

import { Proposed, NotificationHandler1 } from 'vscode-languageserver-protocol';
import type { Feature, _Notebooks } from './server';
import { Proposed, NotificationHandler1, Event, LSPObject, DocumentUri } from 'vscode-languageserver-protocol';
import type { Feature, _Notebooks, _Connection, _ } from './server';
import { TextDocuments, TextDocumentsConfiguration } from './textDocuments';
/**
* Shape of the type hierarchy feature
* Shape of the notebooks feature
*

@@ -12,2 +13,3 @@ * @since 3.17.0 - proposed state

onDidChangeNotebookDocument(handler: NotificationHandler1<Proposed.DidChangeNotebookDocumentParams>): void;
onDidSaveNotebookDocument(handler: NotificationHandler1<Proposed.DidSaveNotebookDocumentParams>): void;
onDidCloseNotebookDocument(handler: NotificationHandler1<Proposed.DidCloseNotebookDocumentParams>): void;

@@ -17,1 +19,60 @@ };

export declare const NotebooksFeature: Feature<_Notebooks, NotebooksFeatureShape>;
export declare type NotebookDocumentChangeEvent = {
/**
* The notebook document that changed.
*/
notebookDocument: Proposed.NotebookDocument;
/**
* The meta data change if any.
*/
metadata?: {
old: LSPObject | undefined;
new: LSPObject | undefined;
};
/**
* The cell changes if any.
*/
cells?: {
added: Proposed.NotebookCell[];
removed: Proposed.NotebookCell[];
changed: {
old: Proposed.NotebookCell;
new: Proposed.NotebookCell;
}[];
contentChanged: Proposed.NotebookCell[];
};
};
export declare class Notebooks<T extends {
uri: DocumentUri;
}> {
private readonly notebookDocuments;
private readonly notebookCellMap;
private readonly _onDidOpen;
private readonly _onDidSave;
private readonly _onDidChange;
private readonly _onDidClose;
private _cellTextDocuments;
constructor(configuration: TextDocumentsConfiguration<T>);
get cellTextDocuments(): TextDocuments<T>;
getCellTextDocument(cell: Proposed.NotebookCell): T | undefined;
getNotebookDocument(uri: DocumentUri): Proposed.NotebookDocument | undefined;
getNotebookCell(uri: DocumentUri): Proposed.NotebookCell | undefined;
findNotebookDocumentForCell(cell: DocumentUri | Proposed.NotebookCell): Proposed.NotebookDocument | undefined;
get onDidOpen(): Event<Proposed.NotebookDocument>;
get onDidSave(): Event<Proposed.NotebookDocument>;
get onDidChange(): Event<NotebookDocumentChangeEvent>;
get onDidClose(): Event<Proposed.NotebookDocument>;
/**
* Listens for `low level` notification on the given connection to
* update the notebook 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:
* `onDidOpenNotebookDocument`, `onDidChangeNotebookDocument`, `onDidSaveNotebookDocument`,
* and `onDidCloseNotebookDocument`.
*
* @param connection The connection to listen on.
*/
listen(connection: _Connection<_, _, _, _, _, _, _, NotebooksFeatureShape>): void;
private updateCellMap;
}

@@ -7,4 +7,5 @@ /* --------------------------------------------------------------------------------------------

Object.defineProperty(exports, "__esModule", { value: true });
exports.NotebooksFeature = void 0;
exports.Notebooks = exports.NotebooksFeature = void 0;
const vscode_languageserver_protocol_1 = require("vscode-languageserver-protocol");
const textDocuments_1 = require("./textDocuments");
const NotebooksFeature = (Base) => {

@@ -24,2 +25,7 @@ return class extends Base {

},
onDidSaveNotebookDocument: (handler) => {
this.connection.onNotification(vscode_languageserver_protocol_1.Proposed.DidSaveNotebookDocumentNotification.type, (params) => {
handler(params);
});
},
onDidCloseNotebookDocument: (handler) => {

@@ -35,2 +41,199 @@ this.connection.onNotification(vscode_languageserver_protocol_1.Proposed.DidCloseNotebookDocumentNotification.type, (params) => {

exports.NotebooksFeature = NotebooksFeature;
class Connection {
onDidOpenTextDocument(handler) {
this.openHandler = handler;
}
openTextDocument(params) {
this.openHandler && this.openHandler(params);
}
onDidChangeTextDocument(handler) {
this.changeHandler = handler;
}
changeTextDocument(params) {
this.changeHandler && this.changeHandler(params);
}
onDidCloseTextDocument(handler) {
this.closeHandler = handler;
}
closeTextDocument(params) {
this.closeHandler && this.closeHandler(params);
}
onWillSaveTextDocument() {
}
onWillSaveTextDocumentWaitUntil() {
}
onDidSaveTextDocument() {
}
}
class Notebooks {
constructor(configuration) {
this._cellTextDocuments = new textDocuments_1.TextDocuments(configuration);
this.notebookDocuments = new Map();
this.notebookCellMap = new Map();
this._onDidOpen = new vscode_languageserver_protocol_1.Emitter();
this._onDidChange = new vscode_languageserver_protocol_1.Emitter();
this._onDidSave = new vscode_languageserver_protocol_1.Emitter();
this._onDidClose = new vscode_languageserver_protocol_1.Emitter();
}
get cellTextDocuments() {
return this._cellTextDocuments;
}
getCellTextDocument(cell) {
return this._cellTextDocuments.get(cell.document);
}
getNotebookDocument(uri) {
return this.notebookDocuments.get(uri);
}
getNotebookCell(uri) {
const value = this.notebookCellMap.get(uri);
return value && value[0];
}
findNotebookDocumentForCell(cell) {
const key = typeof cell === 'string' ? cell : cell.document;
const value = this.notebookCellMap.get(key);
return value && value[1];
}
get onDidOpen() {
return this._onDidOpen.event;
}
get onDidSave() {
return this._onDidSave.event;
}
get onDidChange() {
return this._onDidChange.event;
}
get onDidClose() {
return this._onDidClose.event;
}
/**
* Listens for `low level` notification on the given connection to
* update the notebook 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:
* `onDidOpenNotebookDocument`, `onDidChangeNotebookDocument`, `onDidSaveNotebookDocument`,
* and `onDidCloseNotebookDocument`.
*
* @param connection The connection to listen on.
*/
listen(connection) {
const cellTextDocumentConnection = new Connection();
this.cellTextDocuments.listen(cellTextDocumentConnection);
connection.notebooks.synchronization.onDidOpenNotebookDocument((params) => {
this.notebookDocuments.set(params.notebookDocument.uri, params.notebookDocument);
for (const cellTextDocument of params.cellTextDocuments) {
cellTextDocumentConnection.openTextDocument({ textDocument: cellTextDocument });
}
this.updateCellMap(params.notebookDocument);
this._onDidOpen.fire(params.notebookDocument);
});
connection.notebooks.synchronization.onDidChangeNotebookDocument((params) => {
const notebookDocument = this.notebookDocuments.get(params.notebookDocument.uri);
if (notebookDocument === undefined) {
return;
}
notebookDocument.version = params.notebookDocument.version;
const oldMetadata = notebookDocument.metadata;
let metadataChanged = false;
const change = params.change;
if (change.metadata !== undefined) {
metadataChanged = true;
notebookDocument.metadata = change.metadata;
}
const opened = [];
const closed = [];
if (change.cellStructure !== undefined) {
const array = change.cellStructure.array;
notebookDocument.cells.splice(array.start, array.deleteCount, ...(array.cells !== undefined ? array.cells : []));
// Additional open cell text documents.
if (change.cellStructure.didOpen !== undefined) {
for (const open of change.cellStructure.didOpen) {
cellTextDocumentConnection.openTextDocument({ textDocument: open });
opened.push(open.uri);
}
}
// Additional closed cell test documents.
if (change.cellStructure.didClose) {
for (const close of change.cellStructure.didClose) {
cellTextDocumentConnection.closeTextDocument({ textDocument: close });
closed.push(close.uri);
}
}
}
const changed = [];
if (change.cellData !== undefined) {
const cellUpdates = new Map(change.cellData.map(cell => [cell.document, cell]));
for (let i = 0; i <= notebookDocument.cells.length; i++) {
const change = cellUpdates.get(notebookDocument.cells[i].document);
if (change !== undefined) {
const old = notebookDocument.cells.splice(i, 1, change);
changed.push({ old: old[0], new: change });
cellUpdates.delete(change.document);
if (cellUpdates.size === 0) {
break;
}
}
}
}
const changedTextDocuments = [];
if (change.cellTextDocuments !== undefined) {
for (const cellTextDocument of change.cellTextDocuments) {
cellTextDocumentConnection.changeTextDocument({ textDocument: cellTextDocument.textDocument, contentChanges: cellTextDocument.contentChanges });
changedTextDocuments.push(cellTextDocument.textDocument.uri);
}
}
// Update internal data structure.
this.updateCellMap(notebookDocument);
const changeEvent = { notebookDocument };
if (metadataChanged) {
changeEvent.metadata = { old: oldMetadata, new: notebookDocument.metadata };
}
const added = [];
for (const open of opened) {
added.push(this.getNotebookCell(open));
}
const removed = [];
for (const close of closed) {
removed.push(this.getNotebookCell(close));
}
const contentChanged = [];
for (const change of changedTextDocuments) {
contentChanged.push(this.getNotebookCell(change));
}
if (added.length > 0 || removed.length > 0 || changed.length > 0 || contentChanged.length > 0) {
changeEvent.cells = { added, removed, changed, contentChanged };
}
if (changeEvent.metadata !== undefined || changeEvent.cells !== undefined) {
this._onDidChange.fire(changeEvent);
}
});
connection.notebooks.synchronization.onDidSaveNotebookDocument((params) => {
const notebookDocument = this.notebookDocuments.get(params.notebookDocument.uri);
if (notebookDocument === undefined) {
return;
}
this._onDidSave.fire(notebookDocument);
});
connection.notebooks.synchronization.onDidCloseNotebookDocument((params) => {
const notebookDocument = this.notebookDocuments.get(params.notebookDocument.uri);
if (notebookDocument === undefined) {
return;
}
this._onDidClose.fire(notebookDocument);
for (const cellTextDocument of params.cellTextDocuments) {
cellTextDocumentConnection.closeTextDocument({ textDocument: cellTextDocument });
}
this.notebookDocuments.delete(params.notebookDocument.uri);
for (const cell of notebookDocument.cells) {
this.notebookCellMap.delete(cell.document);
}
});
}
updateCellMap(notebookDocument) {
for (const cell of notebookDocument.cells) {
this.notebookCellMap.set(cell.document, [cell, notebookDocument]);
}
}
}
exports.Notebooks = Notebooks;
//# sourceMappingURL=proposed.notebooks.js.map

@@ -1,2 +0,2 @@

import { CancellationToken, ProtocolRequestType0, RequestHandler0, ProtocolRequestType, RequestHandler, GenericRequestHandler, StarRequestHandler, HandlerResult, ProtocolNotificationType0, NotificationHandler0, ProtocolNotificationType, NotificationHandler, GenericNotificationHandler, StarNotificationHandler, ProgressType, Disposable, InitializeParams, InitializeResult, InitializeError, InitializedParams, DidChangeConfigurationParams, DidChangeWatchedFilesParams, DidOpenTextDocumentParams, DidChangeTextDocumentParams, DidCloseTextDocumentParams, WillSaveTextDocumentParams, TextEdit, DidSaveTextDocumentParams, PublishDiagnosticsParams, HoverParams, Hover, CompletionParams, CompletionItem, CompletionList, SignatureHelpParams, SignatureHelp, DeclarationParams, Declaration, DeclarationLink, Location, DefinitionParams, Definition, DefinitionLink, TypeDefinitionParams, ImplementationParams, ReferenceParams, DocumentHighlightParams, DocumentHighlight, DocumentSymbolParams, SymbolInformation, DocumentSymbol, WorkspaceSymbolParams, CodeActionParams, Command, CodeAction, CodeLensParams, CodeLens, DocumentFormattingParams, DocumentRangeFormattingParams, DocumentOnTypeFormattingParams, RenameParams, WorkspaceEdit, PrepareRenameParams, Range, DocumentLinkParams, DocumentLink, DocumentColorParams, ColorInformation, ColorPresentationParams, ColorPresentation, FoldingRangeParams, FoldingRange, SelectionRangeParams, SelectionRange, ExecuteCommandParams, MessageActionItem, ClientCapabilities, ServerCapabilities, Logger, ProtocolConnection, TextDocumentContentChangeEvent, TextDocumentSaveReason, Event, MessageSignature, ApplyWorkspaceEditParams, ApplyWorkspaceEditResponse, WorkDoneProgressParams, PartialResultParams, RegistrationType, RequestType0, RequestType, NotificationType0, NotificationType, WorkspaceSymbol } from 'vscode-languageserver-protocol';
import { CancellationToken, ProtocolRequestType0, RequestHandler0, ProtocolRequestType, RequestHandler, GenericRequestHandler, StarRequestHandler, HandlerResult, ProtocolNotificationType0, NotificationHandler0, ProtocolNotificationType, NotificationHandler, GenericNotificationHandler, StarNotificationHandler, ProgressType, Disposable, InitializeParams, InitializeResult, InitializeError, InitializedParams, DidChangeConfigurationParams, DidChangeWatchedFilesParams, DidOpenTextDocumentParams, DidChangeTextDocumentParams, DidCloseTextDocumentParams, WillSaveTextDocumentParams, TextEdit, DidSaveTextDocumentParams, PublishDiagnosticsParams, HoverParams, Hover, CompletionParams, CompletionItem, CompletionList, SignatureHelpParams, SignatureHelp, DeclarationParams, Declaration, DeclarationLink, Location, DefinitionParams, Definition, DefinitionLink, TypeDefinitionParams, ImplementationParams, ReferenceParams, DocumentHighlightParams, DocumentHighlight, DocumentSymbolParams, SymbolInformation, DocumentSymbol, WorkspaceSymbolParams, CodeActionParams, Command, CodeAction, CodeLensParams, CodeLens, DocumentFormattingParams, DocumentRangeFormattingParams, DocumentOnTypeFormattingParams, RenameParams, WorkspaceEdit, PrepareRenameParams, Range, DocumentLinkParams, DocumentLink, DocumentColorParams, ColorInformation, ColorPresentationParams, ColorPresentation, FoldingRangeParams, FoldingRange, SelectionRangeParams, SelectionRange, ExecuteCommandParams, MessageActionItem, ClientCapabilities, ServerCapabilities, Logger, ProtocolConnection, MessageSignature, ApplyWorkspaceEditParams, ApplyWorkspaceEditResponse, WorkDoneProgressParams, PartialResultParams, RegistrationType, RequestType0, RequestType, NotificationType0, NotificationType, WorkspaceSymbol } from 'vscode-languageserver-protocol';
import { WorkDoneProgressReporter, ResultProgressReporter, WindowProgress } from './progress';

@@ -11,117 +11,3 @@ import { Configuration } from './configuration';

import { MonikerFeatureShape } from './moniker';
export interface TextDocumentsConfiguration<T> {
create(uri: string, languageId: string, version: number, content: string): T;
update(document: T, changes: TextDocumentContentChangeEvent[], version: number): T;
}
/**
* Event to signal changes to a text document.
*/
export interface TextDocumentChangeEvent<T> {
/**
* The document that has changed.
*/
document: T;
}
/**
* Event to signal that a document will be saved.
*/
export interface TextDocumentWillSaveEvent<T> {
/**
* The document that will be saved
*/
document: T;
/**
* The reason why save was triggered.
*/
reason: TextDocumentSaveReason;
}
/**
* A manager for simple text documents. The manager requires at a minimum that
* the server registered for the following text document sync events in the
* initialize handler or via dynamic registration:
*
* - open and close events.
* - change events.
*
* Registering for save and will save events is optional.
*/
export declare class TextDocuments<T> {
private _configuration;
private _documents;
private _onDidChangeContent;
private _onDidOpen;
private _onDidClose;
private _onDidSave;
private _onWillSave;
private _willSaveWaitUntil;
/**
* Create a new text document manager.
*/
constructor(configuration: TextDocumentsConfiguration<T>);
/**
* An event that fires when a text document managed by this manager
* has been opened or the content changes.
*/
get onDidChangeContent(): Event<TextDocumentChangeEvent<T>>;
/**
* An event that fires when a text document managed by this manager
* has been opened.
*/
get onDidOpen(): Event<TextDocumentChangeEvent<T>>;
/**
* An event that fires when a text document managed by this manager
* will be saved.
*/
get onWillSave(): Event<TextDocumentWillSaveEvent<T>>;
/**
* Sets a handler that will be called if a participant wants to provide
* edits during a text document save.
*/
onWillSaveWaitUntil(handler: RequestHandler<TextDocumentWillSaveEvent<T>, TextEdit[], void>): void;
/**
* An event that fires when a text document managed by this manager
* has been saved.
*/
get onDidSave(): Event<TextDocumentChangeEvent<T>>;
/**
* An event that fires when a text document managed by this manager
* has been closed.
*/
get onDidClose(): Event<TextDocumentChangeEvent<T>>;
/**
* Returns the document for the given URI. Returns undefined if
* the document is not managed by this instance.
*
* @param uri The text document's URI to retrieve.
* @return the text document or `undefined`.
*/
get(uri: string): T | undefined;
/**
* Returns all text documents managed by this instance.
*
* @return all text documents.
*/
all(): T[];
/**
* Returns the URIs of all text documents managed by this instance.
*
* @return the URI's of all text documents.
*/
keys(): string[];
/**
* 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 corresponding events on the TextDocuments instance instead.
*
* @param connection The connection to listen on.
*/
listen(connection: Connection): void;
}
/**
* Helps tracking error message. Equal occurrences of the same

@@ -533,6 +419,6 @@ * message are only stored once. This class is for example

*/
sendNotification<RO>(type: ProtocolNotificationType0<RO>): void;
sendNotification<P, RO>(type: ProtocolNotificationType<P, RO>, params: P): void;
sendNotification(type: NotificationType0): void;
sendNotification<P>(type: NotificationType<P>, params: P): void;
sendNotification<RO>(type: ProtocolNotificationType0<RO>): Promise<void>;
sendNotification<P, RO>(type: ProtocolNotificationType<P, RO>, params: P): Promise<void>;
sendNotification(type: NotificationType0): Promise<void>;
sendNotification<P>(type: NotificationType<P>, params: P): Promise<void>;
/**

@@ -544,3 +430,3 @@ * Send a notification to the client.

*/
sendNotification(method: string, params?: any): void;
sendNotification(method: string, params?: any): Promise<void>;
/**

@@ -559,3 +445,3 @@ * Installs a progress handler for a given token.

*/
sendProgress<P>(type: ProgressType<P>, token: string | number, value: P): void;
sendProgress<P>(type: ProgressType<P>, token: string | number, value: P): Promise<void>;
/**

@@ -681,3 +567,3 @@ * Installs a handler for the initialize request.

*/
sendDiagnostics(params: PublishDiagnosticsParams): void;
sendDiagnostics(params: PublishDiagnosticsParams): Promise<void>;
/**

@@ -684,0 +570,0 @@ * Installs a handler for the `Hover` request.

@@ -7,3 +7,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.createConnection = exports.combineFeatures = exports.combineNotebooksFeatures = exports.combineLanguagesFeatures = exports.combineWorkspaceFeatures = exports.combineWindowFeatures = exports.combineClientFeatures = exports.combineTracerFeatures = exports.combineTelemetryFeatures = exports.combineConsoleFeatures = exports._NotebooksImpl = exports._LanguagesImpl = exports.BulkUnregistration = exports.BulkRegistration = exports.ErrorMessageTracker = exports.TextDocuments = void 0;
exports.createConnection = exports.combineFeatures = exports.combineNotebooksFeatures = exports.combineLanguagesFeatures = exports.combineWorkspaceFeatures = exports.combineWindowFeatures = exports.combineClientFeatures = exports.combineTracerFeatures = exports.combineTelemetryFeatures = exports.combineConsoleFeatures = exports._NotebooksImpl = exports._LanguagesImpl = exports.BulkUnregistration = exports.BulkRegistration = exports.ErrorMessageTracker = void 0;
const vscode_languageserver_protocol_1 = require("vscode-languageserver-protocol");

@@ -28,162 +28,2 @@ const Is = require("./utils/is");

/**
* A manager for simple text documents. The manager requires at a minimum that
* the server registered for the following text document sync events in the
* initialize handler or via dynamic registration:
*
* - open and close events.
* - change events.
*
* Registering for save and will save events is optional.
*/
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 managed 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 corresponding 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 occurrences of the same

@@ -507,2 +347,5 @@ * message are only stored once. This class is for example

verbose: this._trace === vscode_languageserver_protocol_1.Trace.Verbose ? verbose : undefined
}).catch(() => {
// Very hard to decide what to do. We tried to send a log
// message which failed so we can't simply send another :-(.
});

@@ -528,3 +371,5 @@ }

logEvent(data) {
this.connection.sendNotification(vscode_languageserver_protocol_1.TelemetryEventNotification.type, data);
this.connection.sendNotification(vscode_languageserver_protocol_1.TelemetryEventNotification.type, data).catch(() => {
this.connection.console.log(`Sending TelemetryEventNotification failed`);
});
}

@@ -531,0 +376,0 @@ }

{
"name": "vscode-languageserver",
"description": "Language server implementation for node",
"version": "8.0.0-next.6",
"version": "8.0.0-next.7",
"author": "Microsoft Corporation",

@@ -24,3 +24,3 @@ "license": "MIT",

"dependencies": {
"vscode-languageserver-protocol": "3.17.0-next.12"
"vscode-languageserver-protocol": "3.17.0-next.13"
},

@@ -27,0 +27,0 @@ "scripts": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc