vscode-languageclient
Advanced tools
Comparing version 7.1.0-next.4 to 7.1.0-next.5
import { TextDocumentChangeEvent, TextDocument, Disposable, OutputChannel, FileSystemWatcher as VFileSystemWatcher, DiagnosticCollection, Diagnostic as VDiagnostic, Uri, ProviderResult, CancellationToken, Position as VPosition, Location as VLocation, Range as VRange, CompletionItem as VCompletionItem, CompletionList as VCompletionList, SignatureHelp as VSignatureHelp, SignatureHelpContext as VSignatureHelpContext, Definition as VDefinition, DefinitionLink as VDefinitionLink, DocumentHighlight as VDocumentHighlight, SymbolInformation as VSymbolInformation, CodeActionContext as VCodeActionContext, Command as VCommand, CodeLens as VCodeLens, FormattingOptions as VFormattingOptions, TextEdit as VTextEdit, WorkspaceEdit as VWorkspaceEdit, Hover as VHover, CodeAction as VCodeAction, DocumentSymbol as VDocumentSymbol, DocumentLink as VDocumentLink, TextDocumentWillSaveEvent, WorkspaceFolder as VWorkspaceFolder, CompletionContext as VCompletionContext, CompletionItemProvider, HoverProvider, SignatureHelpProvider, DefinitionProvider, ReferenceProvider, DocumentHighlightProvider, CodeActionProvider, DocumentSymbolProvider, DocumentFormattingEditProvider, DocumentRangeFormattingEditProvider, OnTypeFormattingEditProvider, RenameProvider, DocumentLinkProvider, DocumentColorProvider, DeclarationProvider, FoldingRangeProvider, ImplementationProvider, SelectionRangeProvider, TypeDefinitionProvider, WorkspaceSymbolProvider, CallHierarchyProvider, FileWillCreateEvent, FileWillRenameEvent, FileWillDeleteEvent, FileCreateEvent, FileDeleteEvent, FileRenameEvent, LinkedEditingRangeProvider, Event as VEvent, CancellationError } from 'vscode'; | ||
import { Message, MessageSignature, ResponseError, RequestType0, RequestType, NotificationType0, NotificationType, ProtocolRequestType, ProtocolRequestType0, RequestHandler, RequestHandler0, GenericRequestHandler, ProtocolNotificationType, ProtocolNotificationType0, NotificationHandler, NotificationHandler0, GenericNotificationHandler, MessageReader, MessageWriter, Trace, Event, ClientCapabilities, TextDocumentRegistrationOptions, InitializeParams, InitializeResult, InitializeError, ServerCapabilities, DocumentSelector, DidOpenTextDocumentNotification, DidOpenTextDocumentParams, DidChangeTextDocumentNotification, DidChangeTextDocumentParams, DidCloseTextDocumentNotification, DidCloseTextDocumentParams, DidSaveTextDocumentNotification, DidSaveTextDocumentParams, WillSaveTextDocumentNotification, WillSaveTextDocumentWaitUntilRequest, FileEvent, CompletionRequest, HoverRequest, SignatureHelpRequest, DefinitionRequest, ReferencesRequest, DocumentHighlightRequest, DocumentSymbolRequest, WorkspaceSymbolRequest, CodeActionRequest, DocumentFormattingRequest, DocumentRangeFormattingRequest, DocumentOnTypeFormattingRequest, RenameRequest, DocumentLinkRequest, ProgressType, ProgressToken, StaticRegistrationOptions, DocumentColorRequest, DeclarationRequest, FoldingRangeRequest, ImplementationRequest, SelectionRangeRequest, TypeDefinitionRequest, CallHierarchyPrepareRequest, CancellationStrategy, RegistrationType, SemanticTokensRegistrationType, ShowDocumentRequest, FileOperationRegistrationOptions, WillCreateFilesRequest, WillRenameFilesRequest, WillDeleteFilesRequest, DidCreateFilesNotification, DidDeleteFilesNotification, DidRenameFilesNotification, ShowDocumentParams, ShowDocumentResult, LinkedEditingRangeRequest, WorkDoneProgressBegin, WorkDoneProgressEnd, WorkDoneProgressReport } from 'vscode-languageserver-protocol'; | ||
import { Message, MessageSignature, ResponseError, RequestType0, RequestType, NotificationType0, NotificationType, ProtocolRequestType, ProtocolRequestType0, RequestHandler, RequestHandler0, GenericRequestHandler, ProtocolNotificationType, ProtocolNotificationType0, NotificationHandler, NotificationHandler0, GenericNotificationHandler, MessageReader, MessageWriter, Trace, Event, ClientCapabilities, TextDocumentRegistrationOptions, InitializeParams, InitializeResult, InitializeError, ServerCapabilities, DocumentSelector, DidOpenTextDocumentNotification, DidOpenTextDocumentParams, DidChangeTextDocumentNotification, DidChangeTextDocumentParams, DidCloseTextDocumentNotification, DidCloseTextDocumentParams, DidSaveTextDocumentNotification, DidSaveTextDocumentParams, WillSaveTextDocumentNotification, WillSaveTextDocumentWaitUntilRequest, FileEvent, CompletionRequest, HoverRequest, SignatureHelpRequest, DefinitionRequest, ReferencesRequest, DocumentHighlightRequest, DocumentSymbolRequest, WorkspaceSymbolRequest, CodeActionRequest, DocumentFormattingRequest, DocumentRangeFormattingRequest, DocumentOnTypeFormattingRequest, RenameRequest, DocumentLinkRequest, ProgressType, ProgressToken, StaticRegistrationOptions, DocumentColorRequest, DeclarationRequest, FoldingRangeRequest, ImplementationRequest, SelectionRangeRequest, TypeDefinitionRequest, CallHierarchyPrepareRequest, CancellationStrategy, RegistrationType, SemanticTokensRegistrationType, ShowDocumentRequest, FileOperationRegistrationOptions, WillCreateFilesRequest, WillRenameFilesRequest, WillDeleteFilesRequest, DidCreateFilesNotification, DidDeleteFilesNotification, DidRenameFilesNotification, ShowDocumentParams, ShowDocumentResult, LinkedEditingRangeRequest, WorkDoneProgressBegin, WorkDoneProgressEnd, WorkDoneProgressReport, Proposed } from 'vscode-languageserver-protocol'; | ||
import type { ConfigurationWorkspaceMiddleware } from './configuration'; | ||
import type { ColorProviderMiddleware } from './colorProvider'; | ||
import type { ImplementationMiddleware } from './implementation'; | ||
import type { TypeDefinitionMiddleware } from './typeDefinition'; | ||
import { ConfigurationWorkspaceMiddleware } from './configuration'; | ||
import type { WorkspaceFolderWorkspaceMiddleware } from './workspaceFolders'; | ||
@@ -14,3 +14,4 @@ import type { FoldingRangeProviderMiddleware } from './foldingRange'; | ||
import type { FileOperationsMiddleware } from './fileOperations'; | ||
import { LinkedEditingRangeMiddleware } from './linkedEditingRange'; | ||
import type { LinkedEditingRangeMiddleware } from './linkedEditingRange'; | ||
import type { DiagnosticFeatureProvider } from './proposed.diagnostic'; | ||
import * as c2p from './codeConverter'; | ||
@@ -98,2 +99,11 @@ import * as p2c from './protocolConverter'; | ||
} | ||
export declare enum DiagnosticPullMode { | ||
onType = "onType", | ||
onSave = "onSave" | ||
} | ||
export interface DiagnosticPullOptions { | ||
onChange: boolean; | ||
onSave: boolean; | ||
filter?(document: TextDocument, mode: DiagnosticPullMode): boolean; | ||
} | ||
export declare enum RevealOutputChannelOn { | ||
@@ -267,2 +277,3 @@ Info = 1, | ||
}; | ||
diagnosticPullOptions?: DiagnosticPullOptions; | ||
} | ||
@@ -582,2 +593,3 @@ export declare enum State { | ||
getFeature(request: typeof LinkedEditingRangeRequest.method): DynamicFeature<TextDocumentRegistrationOptions> & TextDocumentProviderFeature<LinkedEditingRangeProvider>; | ||
getFeature(request: typeof Proposed.DocumentDiagnosticRequest.method): DynamicFeature<TextDocumentRegistrationOptions> & TextDocumentProviderFeature<DiagnosticFeatureProvider>; | ||
getFeature(request: typeof WorkspaceSymbolRequest.method): DynamicFeature<TextDocumentRegistrationOptions> & WorkspaceProviderFeature<WorkspaceSymbolProvider>; | ||
@@ -584,0 +596,0 @@ protected registerBuiltinFeatures(): void; |
@@ -258,3 +258,3 @@ "use strict"; | ||
} | ||
return { line: value.line, character: value.character }; | ||
return { line: value.line > vscode_languageserver_protocol_1.uinteger.MAX_VALUE ? vscode_languageserver_protocol_1.uinteger.MAX_VALUE : value.line, character: value.character > vscode_languageserver_protocol_1.uinteger.MAX_VALUE ? vscode_languageserver_protocol_1.uinteger.MAX_VALUE : value.character }; | ||
} | ||
@@ -261,0 +261,0 @@ function asPositions(value) { |
@@ -53,3 +53,3 @@ "use strict"; | ||
// Exporting proposed protocol. | ||
const proposed_diagnostic_1 = require("./proposed.diagnostic"); | ||
const pd = require("./proposed.diagnostic"); | ||
var ProposedFeatures; | ||
@@ -59,3 +59,3 @@ (function (ProposedFeatures) { | ||
let result = [ | ||
new proposed_diagnostic_1.DiagnosticFeature(_client) | ||
new pd.DiagnosticFeature(_client) | ||
]; | ||
@@ -62,0 +62,0 @@ return result; |
@@ -172,3 +172,4 @@ "use strict"; | ||
const middleware = (_a = this._client.clientOptions.middleware) === null || _a === void 0 ? void 0 : _a.workspace; | ||
return (middleware === null || middleware === void 0 ? void 0 : middleware.didCreateFiles) ? middleware.didCreateFiles(event, next) | ||
return (middleware === null || middleware === void 0 ? void 0 : middleware.didCreateFiles) | ||
? middleware.didCreateFiles(event, next) | ||
: next(event); | ||
@@ -185,3 +186,4 @@ } | ||
const middleware = (_a = this._client.clientOptions.middleware) === null || _a === void 0 ? void 0 : _a.workspace; | ||
return (middleware === null || middleware === void 0 ? void 0 : middleware.didRenameFiles) ? middleware.didRenameFiles(event, next) | ||
return (middleware === null || middleware === void 0 ? void 0 : middleware.didRenameFiles) | ||
? middleware.didRenameFiles(event, next) | ||
: next(event); | ||
@@ -198,3 +200,4 @@ } | ||
const middleware = (_a = this._client.clientOptions.middleware) === null || _a === void 0 ? void 0 : _a.workspace; | ||
return (middleware === null || middleware === void 0 ? void 0 : middleware.didDeleteFiles) ? middleware.didDeleteFiles(event, next) | ||
return (middleware === null || middleware === void 0 ? void 0 : middleware.didDeleteFiles) | ||
? middleware.didDeleteFiles(event, next) | ||
: next(event); | ||
@@ -238,3 +241,4 @@ } | ||
const middleware = (_a = this._client.clientOptions.middleware) === null || _a === void 0 ? void 0 : _a.workspace; | ||
return (middleware === null || middleware === void 0 ? void 0 : middleware.willCreateFiles) ? middleware.willCreateFiles(event, next) | ||
return (middleware === null || middleware === void 0 ? void 0 : middleware.willCreateFiles) | ||
? middleware.willCreateFiles(event, next) | ||
: next(event); | ||
@@ -251,3 +255,4 @@ } | ||
const middleware = (_a = this._client.clientOptions.middleware) === null || _a === void 0 ? void 0 : _a.workspace; | ||
return (middleware === null || middleware === void 0 ? void 0 : middleware.willRenameFiles) ? middleware.willRenameFiles(event, next) | ||
return (middleware === null || middleware === void 0 ? void 0 : middleware.willRenameFiles) | ||
? middleware.willRenameFiles(event, next) | ||
: next(event); | ||
@@ -264,3 +269,4 @@ } | ||
const middleware = (_a = this._client.clientOptions.middleware) === null || _a === void 0 ? void 0 : _a.workspace; | ||
return (middleware === null || middleware === void 0 ? void 0 : middleware.willDeleteFiles) ? middleware.willDeleteFiles(event, next) | ||
return (middleware === null || middleware === void 0 ? void 0 : middleware.willDeleteFiles) | ||
? middleware.willDeleteFiles(event, next) | ||
: next(event); | ||
@@ -267,0 +273,0 @@ } |
@@ -33,3 +33,3 @@ "use strict"; | ||
// Since we don't use commands this will be a silent window progress with a hidden notification. | ||
vscode_1.window.withProgress({ location: vscode_1.ProgressLocation.Window, cancellable: params.cancellable, title: params.title }, async (progress, cancellationToken) => { | ||
void vscode_1.window.withProgress({ location: vscode_1.ProgressLocation.Window, cancellable: params.cancellable, title: params.title }, async (progress, cancellationToken) => { | ||
this._progress = progress; | ||
@@ -36,0 +36,0 @@ this._infinite = params.percentage === undefined; |
@@ -1,37 +0,78 @@ | ||
import { Disposable, CancellationToken, ProviderResult, Diagnostic as VDiagnostic, TextDocument, Event as VEvent, EventEmitter } from 'vscode'; | ||
import { Disposable, CancellationToken, ProviderResult, Diagnostic as VDiagnostic, TextDocument, Event as VEvent, EventEmitter, Uri } from 'vscode'; | ||
import { Proposed, ClientCapabilities, ServerCapabilities, DocumentSelector } from 'vscode-languageserver-protocol'; | ||
import { TextDocumentFeature, BaseLanguageClient } from './client'; | ||
export declare type VDiagnosticResult = { | ||
items: VDiagnostic[]; | ||
} | { | ||
unmodified: true; | ||
}; | ||
export declare namespace VDiagnosticResult { | ||
function hasItems(value: VDiagnosticResult): value is VDiagnosticResult & { | ||
export declare namespace vsdiag { | ||
enum DocumentDiagnosticReportKind { | ||
full = "full", | ||
unChanged = "unChanged" | ||
} | ||
interface FullDocumentDiagnosticReport { | ||
kind: DocumentDiagnosticReportKind.full; | ||
resultId?: string; | ||
items: VDiagnostic[]; | ||
} | ||
interface RelatedFullDocumentDiagnosticReport extends FullDocumentDiagnosticReport { | ||
relatedDocuments?: { | ||
[uri: string /** DocumentUri */]: FullDocumentDiagnosticReport | UnchangedDocumentDiagnosticReport; | ||
}; | ||
} | ||
interface UnchangedDocumentDiagnosticReport { | ||
kind: DocumentDiagnosticReportKind.unChanged; | ||
resultId: string; | ||
} | ||
interface RelatedUnchangedDocumentDiagnosticReport extends UnchangedDocumentDiagnosticReport { | ||
relatedDocuments?: { | ||
[uri: string /** DocumentUri */]: FullDocumentDiagnosticReport | UnchangedDocumentDiagnosticReport; | ||
}; | ||
} | ||
type DocumentDiagnosticReport = RelatedFullDocumentDiagnosticReport | RelatedUnchangedDocumentDiagnosticReport; | ||
type PreviousResultId = { | ||
uri: Uri; | ||
value: string; | ||
}; | ||
interface WorkspaceFullDocumentDiagnosticReport extends FullDocumentDiagnosticReport { | ||
uri: Uri; | ||
version: number | null; | ||
} | ||
interface WorkspaceUnchangedDocumentDiagnosticReport extends UnchangedDocumentDiagnosticReport { | ||
uri: Uri; | ||
version: number | null; | ||
} | ||
type WorkspaceDocumentDiagnosticReport = WorkspaceFullDocumentDiagnosticReport | WorkspaceUnchangedDocumentDiagnosticReport; | ||
interface WorkspaceDiagnosticReport { | ||
items: WorkspaceDocumentDiagnosticReport[]; | ||
} | ||
interface WorkspaceDiagnosticReportPartialResult { | ||
items: WorkspaceDocumentDiagnosticReport[]; | ||
} | ||
interface ResultReporter { | ||
(chunk: WorkspaceDiagnosticReportPartialResult | null): void; | ||
} | ||
interface DiagnosticProvider { | ||
onDidChangeDiagnostics: VEvent<void>; | ||
provideDiagnostics(textDocument: TextDocument, previousResultId: string | undefined, token: CancellationToken): ProviderResult<DocumentDiagnosticReport>; | ||
provideWorkspaceDiagnostics?(resultIds: PreviousResultId[], token: CancellationToken, resultReporter: ResultReporter): ProviderResult<WorkspaceDiagnosticReport>; | ||
} | ||
} | ||
export interface DiagnosticProvider { | ||
onDidChangeDiagnostics: VEvent<void>; | ||
provideDiagnostics(textDocument: TextDocument, context: Proposed.DiagnosticContext, token: CancellationToken): ProviderResult<VDiagnosticResult>; | ||
} | ||
export interface ProvideDiagnosticSignature { | ||
(this: void, textDocument: TextDocument, context: Proposed.DiagnosticContext, token: CancellationToken): ProviderResult<VDiagnosticResult>; | ||
(this: void, textDocument: TextDocument, previousResultId: string | undefined, token: CancellationToken): ProviderResult<vsdiag.DocumentDiagnosticReport>; | ||
} | ||
export interface ProvideWorkspaceDiagnosticSignature { | ||
(this: void, resultIds: vsdiag.PreviousResultId[], token: CancellationToken, resultReporter: vsdiag.ResultReporter): ProviderResult<vsdiag.WorkspaceDiagnosticReport>; | ||
} | ||
export interface DiagnosticProviderMiddleware { | ||
provideDiagnostics?: (this: void, document: TextDocument, context: Proposed.DiagnosticContext, token: CancellationToken, next: ProvideDiagnosticSignature) => ProviderResult<VDiagnosticResult>; | ||
provideDiagnostics?: (this: void, document: TextDocument, previousResultId: string | undefined, token: CancellationToken, next: ProvideDiagnosticSignature) => ProviderResult<vsdiag.DocumentDiagnosticReport>; | ||
provideWorkspaceDiagnostics?: (this: void, resultIds: vsdiag.PreviousResultId[], token: CancellationToken, resultReporter: vsdiag.ResultReporter, next: ProvideWorkspaceDiagnosticSignature) => ProviderResult<vsdiag.WorkspaceDiagnosticReport>; | ||
} | ||
export interface DiagnosticProviders { | ||
export interface DiagnosticFeatureProvider { | ||
onDidChangeDiagnosticsEmitter: EventEmitter<void>; | ||
provider: DiagnosticProvider; | ||
diagnostics: vsdiag.DiagnosticProvider; | ||
} | ||
export declare class DiagnosticFeature extends TextDocumentFeature<boolean | Proposed.DiagnosticOptions, Proposed.DiagnosticRegistrationOptions, DiagnosticProviders> { | ||
private readonly openFeature; | ||
private readonly changeFeature; | ||
private readonly saveFeature; | ||
private readonly closeFeature; | ||
export declare class DiagnosticFeature extends TextDocumentFeature<Proposed.DiagnosticOptions, Proposed.DiagnosticRegistrationOptions, DiagnosticFeatureProvider> { | ||
private readonly editorTracker; | ||
constructor(client: BaseLanguageClient); | ||
fillClientCapabilities(capabilities: ClientCapabilities & Proposed.$DiagnosticClientCapabilities): void; | ||
initialize(capabilities: ServerCapabilities & Proposed.$DiagnosticServerCapabilities, documentSelector: DocumentSelector): void; | ||
protected registerLanguageProvider(options: Proposed.DiagnosticRegistrationOptions): [Disposable, DiagnosticProviders]; | ||
dispose(): void; | ||
protected registerLanguageProvider(options: Proposed.DiagnosticRegistrationOptions): [Disposable, DiagnosticFeatureProvider]; | ||
} |
"use strict"; | ||
/* -------------------------------------------------------------------------------------------- | ||
* Copyright (c) TypeFox and others. All rights reserved. | ||
* 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 }); | ||
exports.DiagnosticFeature = exports.VDiagnosticResult = void 0; | ||
exports.DiagnosticFeature = exports.vsdiag = void 0; | ||
const vscode_1 = require("vscode"); | ||
const vscode_languageserver_protocol_1 = require("vscode-languageserver-protocol"); | ||
const uuid_1 = require("./utils/uuid"); | ||
const client_1 = require("./client"); | ||
@@ -17,10 +18,10 @@ function ensure(target, key) { | ||
} | ||
var VDiagnosticResult; | ||
(function (VDiagnosticResult) { | ||
function hasItems(value) { | ||
const candidate = value; | ||
return candidate && Array.isArray(candidate.items); | ||
} | ||
VDiagnosticResult.hasItems = hasItems; | ||
})(VDiagnosticResult = exports.VDiagnosticResult || (exports.VDiagnosticResult = {})); | ||
var vsdiag; | ||
(function (vsdiag) { | ||
let DocumentDiagnosticReportKind; | ||
(function (DocumentDiagnosticReportKind) { | ||
DocumentDiagnosticReportKind["full"] = "full"; | ||
DocumentDiagnosticReportKind["unChanged"] = "unChanged"; | ||
})(DocumentDiagnosticReportKind = vsdiag.DocumentDiagnosticReportKind || (vsdiag.DocumentDiagnosticReportKind = {})); | ||
})(vsdiag = exports.vsdiag || (exports.vsdiag = {})); | ||
var RequestStateKind; | ||
@@ -32,85 +33,115 @@ (function (RequestStateKind) { | ||
})(RequestStateKind || (RequestStateKind = {})); | ||
class DiagnosticFeature extends client_1.TextDocumentFeature { | ||
constructor(client) { | ||
super(client, vscode_languageserver_protocol_1.Proposed.DiagnosticRequest.type); | ||
this.openFeature = client.getFeature(vscode_languageserver_protocol_1.DidOpenTextDocumentNotification.method); | ||
this.changeFeature = client.getFeature(vscode_languageserver_protocol_1.DidChangeTextDocumentNotification.method); | ||
this.saveFeature = client.getFeature(vscode_languageserver_protocol_1.DidSaveTextDocumentNotification.method); | ||
this.closeFeature = client.getFeature(vscode_languageserver_protocol_1.DidCloseTextDocumentNotification.method); | ||
class EditorTracker { | ||
constructor() { | ||
this.open = new Set(); | ||
const openEditorsHandler = () => { | ||
this.open.clear(); | ||
for (const info of vscode_1.window.openEditors) { | ||
this.open.add(info.resource.toString()); | ||
} | ||
}; | ||
openEditorsHandler(); | ||
this.disposable = vscode_1.window.onDidChangeOpenEditors(openEditorsHandler); | ||
} | ||
fillClientCapabilities(capabilities) { | ||
let capability = ensure(ensure(capabilities, 'textDocument'), 'diagnostic'); | ||
capability.dynamicRegistration = true; | ||
dispose() { | ||
this.disposable.dispose(); | ||
} | ||
initialize(capabilities, documentSelector) { | ||
const client = this._client; | ||
client.onRequest(vscode_languageserver_protocol_1.Proposed.DiagnosticRefreshRequest.type, async () => { | ||
for (const provider of this.getAllProviders()) { | ||
provider.onDidChangeDiagnosticsEmitter.fire(); | ||
isActive(textDocument) { | ||
var _a; | ||
return ((_a = vscode_1.window.activeTextEditor) === null || _a === void 0 ? void 0 : _a.document) === textDocument; | ||
} | ||
isVisible(textDocument) { | ||
return this.open.has(textDocument.uri.toString()); | ||
} | ||
} | ||
var PullState; | ||
(function (PullState) { | ||
PullState[PullState["document"] = 1] = "document"; | ||
PullState[PullState["workspace"] = 2] = "workspace"; | ||
})(PullState || (PullState = {})); | ||
class DocumentPullStateTracker { | ||
constructor() { | ||
this.documentPullStates = new Map(); | ||
this.workspacePullStates = new Map(); | ||
} | ||
track(kind, document, arg1, arg2) { | ||
const states = kind === PullState.document ? this.documentPullStates : this.workspacePullStates; | ||
const [key, uri, version, resultId] = typeof document === 'string' | ||
? [document, vscode_1.Uri.parse(document), arg1, arg2] | ||
: [document.uri.toString(), document.uri, document.version, arg1]; | ||
let state = states.get(key); | ||
if (state === undefined) { | ||
state = { document: uri, pulledVersion: version, resultId }; | ||
states.set(key, state); | ||
} | ||
else { | ||
state.pulledVersion = version; | ||
state.resultId = resultId; | ||
} | ||
return state; | ||
} | ||
unTrack(kind, textDocument) { | ||
const states = kind === PullState.document ? this.documentPullStates : this.workspacePullStates; | ||
states.delete(textDocument.uri.toString()); | ||
} | ||
tracks(kind, document) { | ||
const key = typeof document === 'string' ? document : document.uri.toString(); | ||
const states = kind === PullState.document ? this.documentPullStates : this.workspacePullStates; | ||
return states.has(key); | ||
} | ||
getResultId(kind, textDocument) { | ||
var _a; | ||
const states = kind === PullState.document ? this.documentPullStates : this.workspacePullStates; | ||
return (_a = states.get(textDocument.uri.toString())) === null || _a === void 0 ? void 0 : _a.resultId; | ||
} | ||
getAllResultIds() { | ||
const result = []; | ||
for (let [uri, value] of this.workspacePullStates) { | ||
if (this.documentPullStates.has(uri)) { | ||
value = this.documentPullStates.get(uri); | ||
} | ||
}); | ||
let [id, options] = this.getRegistration(documentSelector, capabilities.diagnosticProvider); | ||
if (!id || !options) { | ||
return; | ||
if (value.resultId !== undefined) { | ||
result.push({ uri, value: value.resultId }); | ||
} | ||
} | ||
this.register({ id: id, registerOptions: options }); | ||
return result; | ||
} | ||
registerLanguageProvider(options) { | ||
const documentSelector = options.documentSelector; | ||
const mode = vscode_languageserver_protocol_1.Proposed.DiagnosticPullModeFlags.is(options.mode) ? options.mode : (vscode_languageserver_protocol_1.Proposed.DiagnosticPullModeFlags.onOpen | vscode_languageserver_protocol_1.Proposed.DiagnosticPullModeFlags.onType); | ||
const disposables = []; | ||
const collection = vscode_1.languages.createDiagnosticCollection(options.identifier); | ||
disposables.push(collection); | ||
const availableEditors = new Set(); | ||
const managedDocuments = new Map(); | ||
const matches = (textDocument) => { | ||
return vscode_1.languages.match(documentSelector, textDocument) > 0 && availableEditors.has(textDocument.uri.toString()); | ||
}; | ||
const manages = (textDocument) => { | ||
return managedDocuments.has(textDocument.uri.toString()); | ||
}; | ||
const onDidChangeDiagnosticsEmitter = new vscode_1.EventEmitter(); | ||
const provider = { | ||
onDidChangeDiagnostics: onDidChangeDiagnosticsEmitter.event, | ||
provideDiagnostics: (textDocument, context, token) => { | ||
const client = this._client; | ||
const provideDiagnostics = (textDocument, context, token) => { | ||
const params = { | ||
textDocument: { uri: client.code2ProtocolConverter.asUri(textDocument.uri) }, | ||
context: context | ||
}; | ||
return client.sendRequest(vscode_languageserver_protocol_1.Proposed.DiagnosticRequest.type, params, token).then((result) => { | ||
if (result === null || !result.items) { | ||
return { items: [] }; | ||
} | ||
return { items: client.protocol2CodeConverter.asDiagnostics(result.items) }; | ||
}, (error) => { | ||
return client.handleFailedRequest(vscode_languageserver_protocol_1.Proposed.DiagnosticRequest.type, token, error, { items: [] }); | ||
}); | ||
}; | ||
const middleware = client.clientOptions.middleware; | ||
return middleware.provideDiagnostics | ||
? middleware.provideDiagnostics(textDocument, context, token, provideDiagnostics) | ||
: provideDiagnostics(textDocument, context, token); | ||
} | ||
class DiagnosticRequestor { | ||
constructor(client, editorTracker, options) { | ||
this.client = client; | ||
this.editorTracker = editorTracker; | ||
this.options = options; | ||
this.isDisposed = false; | ||
this.onDidChangeDiagnosticsEmitter = new vscode_1.EventEmitter(); | ||
this.provider = this.createProvider(); | ||
this.diagnostics = vscode_1.languages.createDiagnosticCollection(options.identifier); | ||
this.openRequests = new Map(); | ||
this.documentStates = new DocumentPullStateTracker(); | ||
this.workspaceErrorCounter = 0; | ||
} | ||
knows(kind, textDocument) { | ||
return this.documentStates.tracks(kind, textDocument); | ||
} | ||
pull(textDocument, cb) { | ||
this.pullAsync(textDocument).then(() => { | ||
if (cb) { | ||
cb(); | ||
} | ||
}; | ||
const requestStates = new Map(); | ||
const pullDiagnostics = async (textDocument, trigger) => { | ||
var _a; | ||
const key = textDocument.uri.toString(); | ||
const currentState = requestStates.get(key); | ||
if (currentState !== undefined) { | ||
if (currentState.state === RequestStateKind.active) { | ||
currentState.tokenSource.cancel(); | ||
} | ||
requestStates.set(key, { state: RequestStateKind.reschedule, textDocument, trigger: trigger }); | ||
// We have a state. Wait until the request returns. | ||
return; | ||
} | ||
}, (error) => { | ||
this.client.error(`Document pull failed for text document ${textDocument.uri.toString()}`, error, false); | ||
}); | ||
} | ||
async pullAsync(textDocument) { | ||
var _a; | ||
const key = textDocument.uri.toString(); | ||
const currentRequestState = this.openRequests.get(key); | ||
const documentState = this.documentStates.track(PullState.document, textDocument); | ||
if (currentRequestState === undefined) { | ||
const tokenSource = new vscode_1.CancellationTokenSource(); | ||
requestStates.set(key, { state: RequestStateKind.active, textDocument, trigger, tokenSource }); | ||
let diagnostics; | ||
this.openRequests.set(key, { state: RequestStateKind.active, version: textDocument.version, textDocument, tokenSource }); | ||
let report; | ||
let afterState; | ||
try { | ||
diagnostics = (_a = await provider.provideDiagnostics(textDocument, { triggerKind: trigger }, tokenSource.token)) !== null && _a !== void 0 ? _a : { items: [] }; | ||
report = (_a = await this.provider.provideDiagnostics(textDocument, this.documentStates.getResultId(PullState.document, textDocument), tokenSource.token)) !== null && _a !== void 0 ? _a : { kind: vsdiag.DocumentDiagnosticReportKind.full, items: [] }; | ||
} | ||
@@ -122,3 +153,3 @@ catch (error) { | ||
if (afterState === undefined && error instanceof vscode_1.CancellationError) { | ||
afterState = { state: RequestStateKind.reschedule, textDocument, trigger }; | ||
afterState = { state: RequestStateKind.reschedule, textDocument }; | ||
} | ||
@@ -129,81 +160,408 @@ else { | ||
} | ||
afterState = afterState !== null && afterState !== void 0 ? afterState : requestStates.get(key); | ||
afterState = afterState !== null && afterState !== void 0 ? afterState : this.openRequests.get(key); | ||
if (afterState === undefined) { | ||
// This shouldn't happen. Log it | ||
this._client.error(`Lost request state in diagnostic pull model. Clearing diagnostics for ${key}`); | ||
collection.delete(textDocument.uri); | ||
this.client.error(`Lost request state in diagnostic pull model. Clearing diagnostics for ${key}`); | ||
this.diagnostics.delete(textDocument.uri); | ||
return; | ||
} | ||
requestStates.delete(key); | ||
if (afterState.state === RequestStateKind.outDated || !manages(textDocument)) { | ||
this.openRequests.delete(key); | ||
if (!this.editorTracker.isVisible(textDocument)) { | ||
this.documentStates.unTrack(PullState.document, textDocument); | ||
return; | ||
} | ||
// diagnostics is only undefined if the request has thrown. | ||
if (diagnostics !== undefined && VDiagnosticResult.hasItems(diagnostics)) { | ||
collection.set(textDocument.uri, diagnostics.items); | ||
if (afterState.state === RequestStateKind.outDated) { | ||
return; | ||
} | ||
// report is only undefined if the request has thrown. | ||
if (report !== undefined) { | ||
if (report.kind === vsdiag.DocumentDiagnosticReportKind.full) { | ||
this.diagnostics.set(textDocument.uri, report.items); | ||
} | ||
documentState.resultId = report.resultId; | ||
} | ||
if (afterState.state === RequestStateKind.reschedule) { | ||
pullDiagnostics(textDocument, afterState.trigger); | ||
this.pull(textDocument); | ||
} | ||
}; | ||
const openEditorsHandler = () => { | ||
availableEditors.clear(); | ||
for (const info of vscode_1.window.openEditors) { | ||
availableEditors.add(info.resource.toString()); | ||
} | ||
else { | ||
if (currentRequestState.state === RequestStateKind.active) { | ||
// Cancel the current request and reschedule a new one when the old one returned. | ||
currentRequestState.tokenSource.cancel(); | ||
this.openRequests.set(key, { state: RequestStateKind.reschedule, textDocument: currentRequestState.textDocument }); | ||
} | ||
}; | ||
openEditorsHandler(); | ||
disposables.push(vscode_1.window.onDidChangeOpenEditors(openEditorsHandler)); | ||
if (vscode_languageserver_protocol_1.Proposed.DiagnosticPullModeFlags.isOpen(mode)) { | ||
disposables.push(this.openFeature.onNotificationSent((event) => { | ||
const textDocument = event.original; | ||
if (matches(textDocument)) { | ||
managedDocuments.set(textDocument.uri.toString(), textDocument); | ||
pullDiagnostics(event.original, vscode_languageserver_protocol_1.Proposed.DiagnosticTriggerKind.Opened); | ||
else if (currentRequestState.state === RequestStateKind.outDated) { | ||
this.openRequests.set(key, { state: RequestStateKind.reschedule, textDocument: currentRequestState.textDocument }); | ||
} | ||
} | ||
} | ||
cleanupPull(textDocument) { | ||
const key = textDocument.uri.toString(); | ||
const request = this.openRequests.get(key); | ||
if (this.options.workspaceDiagnostics || this.options.interFileDependencies) { | ||
if (request !== undefined) { | ||
this.openRequests.set(key, { state: RequestStateKind.reschedule, textDocument: textDocument }); | ||
} | ||
else { | ||
this.pull(textDocument); | ||
} | ||
} | ||
else { | ||
if (request !== undefined) { | ||
if (request.state === RequestStateKind.active) { | ||
request.tokenSource.cancel(); | ||
} | ||
})); | ||
// Pull all diagnostics for documents that are already open | ||
for (const textDocument of this.openFeature.openDocuments) { | ||
if (matches(textDocument)) { | ||
managedDocuments.set(textDocument.uri.toString(), textDocument); | ||
pullDiagnostics(textDocument, vscode_languageserver_protocol_1.Proposed.DiagnosticTriggerKind.Opened); | ||
this.openRequests.set(key, { state: RequestStateKind.outDated, textDocument: textDocument }); | ||
} | ||
this.diagnostics.delete(textDocument.uri); | ||
} | ||
} | ||
pullWorkspace() { | ||
this.pullWorkspaceAsync().then(() => { | ||
this.workspaceTimeout = vscode_languageserver_protocol_1.RAL().timer.setTimeout(() => { | ||
this.pullWorkspace(); | ||
}, 2000); | ||
}, (error) => { | ||
if (!(error instanceof client_1.LSPCancellationError) && !vscode_languageserver_protocol_1.Proposed.DiagnosticServerCancellationData.is(error.data)) { | ||
this.client.error(`Workspace diagnostic pull failed.`, error, false); | ||
this.workspaceErrorCounter++; | ||
} | ||
if (this.workspaceErrorCounter <= 5) { | ||
this.workspaceTimeout = vscode_languageserver_protocol_1.RAL().timer.setTimeout(() => { | ||
this.pullWorkspace(); | ||
}, 2000); | ||
} | ||
}); | ||
} | ||
async pullWorkspaceAsync() { | ||
if (!this.provider.provideWorkspaceDiagnostics) { | ||
return; | ||
} | ||
if (this.workspaceCancellation !== undefined) { | ||
this.workspaceCancellation.cancel(); | ||
this.workspaceCancellation = undefined; | ||
} | ||
this.workspaceCancellation = new vscode_1.CancellationTokenSource(); | ||
const previousResultIds = this.documentStates.getAllResultIds().map((item) => { | ||
return { | ||
uri: this.client.protocol2CodeConverter.asUri(item.uri), | ||
value: item.value | ||
}; | ||
}); | ||
await this.provider.provideWorkspaceDiagnostics(previousResultIds, this.workspaceCancellation.token, (chunk) => { | ||
var _a; | ||
if (!chunk || this.isDisposed) { | ||
return; | ||
} | ||
for (const item of chunk.items) { | ||
if (item.kind === vsdiag.DocumentDiagnosticReportKind.full) { | ||
// Favour document pull result over workspace results. So skip if it is tracked | ||
// as a document result. | ||
if (!this.documentStates.tracks(PullState.document, item.uri.toString())) { | ||
this.diagnostics.set(item.uri, item.items); | ||
} | ||
} | ||
this.documentStates.track(PullState.workspace, item.uri.toString(), (_a = item.version) !== null && _a !== void 0 ? _a : undefined, item.resultId); | ||
} | ||
}); | ||
} | ||
createProvider() { | ||
const result = { | ||
onDidChangeDiagnostics: this.onDidChangeDiagnosticsEmitter.event, | ||
provideDiagnostics: (textDocument, previousResultId, token) => { | ||
const provideDiagnostics = (textDocument, previousResultId, token) => { | ||
const params = { | ||
identifier: this.options.identifier, | ||
textDocument: { uri: this.client.code2ProtocolConverter.asUri(textDocument.uri) }, | ||
previousResultId: previousResultId | ||
}; | ||
return this.client.sendRequest(vscode_languageserver_protocol_1.Proposed.DocumentDiagnosticRequest.type, params, token).then((result) => { | ||
if (result === undefined || result === null || this.isDisposed) { | ||
return { kind: vsdiag.DocumentDiagnosticReportKind.full, items: [] }; | ||
} | ||
if (result.kind === vscode_languageserver_protocol_1.Proposed.DocumentDiagnosticReportKind.full) { | ||
return { kind: vsdiag.DocumentDiagnosticReportKind.full, resultId: result.resultId, items: this.client.protocol2CodeConverter.asDiagnostics(result.items) }; | ||
} | ||
else { | ||
return { kind: vsdiag.DocumentDiagnosticReportKind.unChanged, resultId: result.resultId }; | ||
} | ||
}, (error) => { | ||
return this.client.handleFailedRequest(vscode_languageserver_protocol_1.Proposed.DocumentDiagnosticRequest.type, token, error, { kind: vsdiag.DocumentDiagnosticReportKind.full, items: [] }); | ||
}); | ||
}; | ||
const middleware = this.client.clientOptions.middleware; | ||
return middleware.provideDiagnostics | ||
? middleware.provideDiagnostics(textDocument, previousResultId, token, provideDiagnostics) | ||
: provideDiagnostics(textDocument, previousResultId, token); | ||
} | ||
}; | ||
if (this.options.workspaceDiagnostics) { | ||
result.provideWorkspaceDiagnostics = (resultIds, token, resultReporter) => { | ||
const convertReport = (report) => { | ||
if (report.kind === vscode_languageserver_protocol_1.Proposed.DocumentDiagnosticReportKind.full) { | ||
return { | ||
kind: vsdiag.DocumentDiagnosticReportKind.full, | ||
uri: this.client.protocol2CodeConverter.asUri(report.uri), | ||
resultId: report.resultId, | ||
version: report.version, | ||
items: this.client.protocol2CodeConverter.asDiagnostics(report.items) | ||
}; | ||
} | ||
else { | ||
return { | ||
kind: vsdiag.DocumentDiagnosticReportKind.unChanged, | ||
uri: this.client.protocol2CodeConverter.asUri(report.uri), | ||
resultId: report.resultId, | ||
version: report.version | ||
}; | ||
} | ||
}; | ||
const convertPreviousResultIds = (resultIds) => { | ||
const converted = []; | ||
for (const item of resultIds) { | ||
converted.push({ uri: this.client.code2ProtocolConverter.asUri(item.uri), value: item.value }); | ||
} | ||
return converted; | ||
}; | ||
const provideDiagnostics = (resultIds, token) => { | ||
const partialResultToken = uuid_1.generateUuid(); | ||
const disposable = this.client.onProgress(vscode_languageserver_protocol_1.Proposed.WorkspaceDiagnosticRequest.partialResult, partialResultToken, (partialResult) => { | ||
if (partialResult === undefined || partialResult === null) { | ||
resultReporter(null); | ||
return; | ||
} | ||
const converted = { | ||
items: [] | ||
}; | ||
for (const item of partialResult.items) { | ||
converted.items.push(convertReport(item)); | ||
} | ||
resultReporter(converted); | ||
}); | ||
const params = { | ||
identifier: this.options.identifier, | ||
previousResultIds: convertPreviousResultIds(resultIds), | ||
partialResultToken: partialResultToken | ||
}; | ||
return this.client.sendRequest(vscode_languageserver_protocol_1.Proposed.WorkspaceDiagnosticRequest.type, params, token).then((result) => { | ||
const converted = { | ||
items: [] | ||
}; | ||
for (const item of result.items) { | ||
converted.items.push(convertReport(item)); | ||
} | ||
disposable.dispose(); | ||
resultReporter(converted); | ||
return { items: [] }; | ||
}, (error) => { | ||
disposable.dispose(); | ||
return this.client.handleFailedRequest(vscode_languageserver_protocol_1.Proposed.DocumentDiagnosticRequest.type, token, error, { items: [] }); | ||
}); | ||
}; | ||
const middleware = this.client.clientOptions.middleware; | ||
return middleware.provideWorkspaceDiagnostics | ||
? middleware.provideWorkspaceDiagnostics(resultIds, token, resultReporter, provideDiagnostics) | ||
: provideDiagnostics(resultIds, token, resultReporter); | ||
}; | ||
} | ||
if (vscode_languageserver_protocol_1.Proposed.DiagnosticPullModeFlags.isType(mode)) { | ||
disposables.push(this.changeFeature.onNotificationSent((event) => { | ||
return result; | ||
} | ||
dispose() { | ||
var _a, _b; | ||
this.isDisposed = true; | ||
// Cancel and clear workspace pull if present. | ||
(_a = this.workspaceCancellation) === null || _a === void 0 ? void 0 : _a.cancel(); | ||
(_b = this.workspaceTimeout) === null || _b === void 0 ? void 0 : _b.dispose(); | ||
// Cancel all request and mark open requests as outdated. | ||
for (const [key, request] of this.openRequests) { | ||
if (request.state === RequestStateKind.active) { | ||
request.tokenSource.cancel(); | ||
} | ||
this.openRequests.set(key, { state: RequestStateKind.outDated, textDocument: request.textDocument }); | ||
} | ||
} | ||
} | ||
class BackgroundScheduler { | ||
constructor(diagnosticRequestor) { | ||
this.diagnosticRequestor = diagnosticRequestor; | ||
this.documents = new vscode_languageserver_protocol_1.LinkedMap(); | ||
} | ||
add(textDocument) { | ||
const key = textDocument.uri.toString(); | ||
if (this.documents.has(key)) { | ||
return; | ||
} | ||
this.documents.set(textDocument.uri.toString(), textDocument, vscode_languageserver_protocol_1.Touch.Last); | ||
this.trigger(); | ||
} | ||
remove(textDocument) { | ||
const key = textDocument.uri.toString(); | ||
if (this.documents.has(key)) { | ||
this.documents.delete(key); | ||
// Do a last pull | ||
this.diagnosticRequestor.pull(textDocument); | ||
} | ||
// No more documents. Stop background activity. | ||
if (this.documents.size === 0) { | ||
this.stop(); | ||
} | ||
else if (textDocument === this.endDocument) { | ||
// Make sure we have a correct last document. It could have | ||
this.endDocument = this.documents.last; | ||
} | ||
} | ||
trigger() { | ||
// We have a round running. So simply make sure we run up to the | ||
// last document | ||
if (this.intervalHandle !== undefined) { | ||
this.endDocument = this.documents.last; | ||
return; | ||
} | ||
this.endDocument = this.documents.last; | ||
this.intervalHandle = vscode_languageserver_protocol_1.RAL().timer.setInterval(() => { | ||
const document = this.documents.first; | ||
if (document !== undefined) { | ||
this.diagnosticRequestor.pull(document); | ||
this.documents.set(document.uri.toString(), document, vscode_languageserver_protocol_1.Touch.Last); | ||
if (document === this.endDocument) { | ||
this.stop(); | ||
} | ||
} | ||
}, 200); | ||
} | ||
dispose() { | ||
this.stop(); | ||
this.documents.clear(); | ||
} | ||
stop() { | ||
var _a; | ||
(_a = this.intervalHandle) === null || _a === void 0 ? void 0 : _a.dispose(); | ||
this.intervalHandle = undefined; | ||
this.endDocument = undefined; | ||
} | ||
} | ||
class DiagnosticFeatureProviderImpl { | ||
constructor(client, editorTracker, options) { | ||
var _a, _b; | ||
const diagnosticPullOptions = (_a = client.clientOptions.diagnosticPullOptions) !== null && _a !== void 0 ? _a : { onChange: true, onSave: false }; | ||
const documentSelector = options.documentSelector; | ||
const disposables = []; | ||
const matches = (textDocument) => { | ||
return vscode_1.languages.match(documentSelector, textDocument) > 0 && editorTracker.isVisible(textDocument); | ||
}; | ||
this.diagnosticRequestor = new DiagnosticRequestor(client, editorTracker, options); | ||
this.backgroundScheduler = new BackgroundScheduler(this.diagnosticRequestor); | ||
const addToBackgroundIfNeeded = (textDocument) => { | ||
if (!matches(textDocument) || !options.interFileDependencies || this.activeTextDocument === textDocument) { | ||
return; | ||
} | ||
this.backgroundScheduler.add(textDocument); | ||
}; | ||
this.activeTextDocument = (_b = vscode_1.window.activeTextEditor) === null || _b === void 0 ? void 0 : _b.document; | ||
vscode_1.window.onDidChangeActiveTextEditor((editor) => { | ||
const oldActive = this.activeTextDocument; | ||
this.activeTextDocument = editor === null || editor === void 0 ? void 0 : editor.document; | ||
if (oldActive !== undefined) { | ||
addToBackgroundIfNeeded(oldActive); | ||
} | ||
if (this.activeTextDocument !== undefined) { | ||
this.backgroundScheduler.remove(this.activeTextDocument); | ||
} | ||
}); | ||
// We always pull on open. | ||
const openFeature = client.getFeature(vscode_languageserver_protocol_1.DidOpenTextDocumentNotification.method); | ||
disposables.push(openFeature.onNotificationSent((event) => { | ||
const textDocument = event.original; | ||
if (matches(textDocument)) { | ||
this.diagnosticRequestor.pull(textDocument, () => { addToBackgroundIfNeeded(textDocument); }); | ||
} | ||
})); | ||
// Pull all diagnostics for documents that are already open | ||
for (const textDocument of vscode_1.workspace.textDocuments) { | ||
if (matches(textDocument)) { | ||
this.diagnosticRequestor.pull(textDocument, () => { addToBackgroundIfNeeded(textDocument); }); | ||
} | ||
} | ||
if (diagnosticPullOptions.onChange) { | ||
const changeFeature = client.getFeature(vscode_languageserver_protocol_1.DidChangeTextDocumentNotification.method); | ||
disposables.push(changeFeature.onNotificationSent(async (event) => { | ||
const textDocument = event.original.document; | ||
if (manages(textDocument) && event.original.contentChanges.length > 0) { | ||
pullDiagnostics(textDocument, vscode_languageserver_protocol_1.Proposed.DiagnosticTriggerKind.Typed); | ||
if ((diagnosticPullOptions.filter === undefined || !diagnosticPullOptions.filter(textDocument, client_1.DiagnosticPullMode.onType)) && this.diagnosticRequestor.knows(PullState.document, textDocument) && event.original.contentChanges.length > 0) { | ||
this.diagnosticRequestor.pull(textDocument, () => { this.backgroundScheduler.trigger(); }); | ||
} | ||
})); | ||
} | ||
if (vscode_languageserver_protocol_1.Proposed.DiagnosticPullModeFlags.isSave(mode)) { | ||
disposables.push(this.saveFeature.onNotificationSent((event) => { | ||
if (diagnosticPullOptions.onSave) { | ||
const saveFeature = client.getFeature(vscode_languageserver_protocol_1.DidSaveTextDocumentNotification.method); | ||
disposables.push(saveFeature.onNotificationSent((event) => { | ||
const textDocument = event.original; | ||
if (manages(textDocument)) { | ||
pullDiagnostics(event.original, vscode_languageserver_protocol_1.Proposed.DiagnosticTriggerKind.Saved); | ||
if ((diagnosticPullOptions.filter === undefined || !diagnosticPullOptions.filter(textDocument, client_1.DiagnosticPullMode.onSave)) && this.diagnosticRequestor.knows(PullState.document, textDocument)) { | ||
this.diagnosticRequestor.pull(event.original, () => { this.backgroundScheduler.trigger(); }); | ||
} | ||
})); | ||
} | ||
disposables.push(this.closeFeature.onNotificationSent((event) => { | ||
// When the document closes clear things up | ||
const closeFeature = client.getFeature(vscode_languageserver_protocol_1.DidCloseTextDocumentNotification.method); | ||
disposables.push(closeFeature.onNotificationSent((event) => { | ||
const textDocument = event.original; | ||
const requestState = requestStates.get(textDocument.uri.toString()); | ||
if (requestState !== undefined) { | ||
requestStates.set(textDocument.uri.toString(), { state: RequestStateKind.outDated, textDocument }); | ||
} | ||
if (manages(textDocument)) { | ||
collection.delete(textDocument.uri); | ||
managedDocuments.delete(textDocument.uri.toString()); | ||
} | ||
this.diagnosticRequestor.cleanupPull(textDocument); | ||
this.backgroundScheduler.remove(textDocument); | ||
})); | ||
onDidChangeDiagnosticsEmitter.event(() => { | ||
for (const document of managedDocuments.values()) { | ||
pullDiagnostics(document, vscode_languageserver_protocol_1.Proposed.DiagnosticTriggerKind.Invoked); | ||
// We received a did change from the server. | ||
this.diagnosticRequestor.onDidChangeDiagnosticsEmitter.event(() => { | ||
for (const textDocument of vscode_1.workspace.textDocuments) { | ||
if (matches(textDocument)) { | ||
this.diagnosticRequestor.pull(textDocument); | ||
} | ||
} | ||
}); | ||
return [vscode_1.Disposable.from(...disposables), { onDidChangeDiagnosticsEmitter, provider }]; | ||
// da348dc5-c30a-4515-9d98-31ff3be38d14 is the test UUID to test the middle ware. So don't auto trigger pulls. | ||
if (options.workspaceDiagnostics === true && options.identifier !== 'da348dc5-c30a-4515-9d98-31ff3be38d14') { | ||
this.diagnosticRequestor.pullWorkspace(); | ||
} | ||
this.disposable = vscode_1.Disposable.from(...disposables, this.backgroundScheduler, this.diagnosticRequestor); | ||
} | ||
get onDidChangeDiagnosticsEmitter() { | ||
return this.diagnosticRequestor.onDidChangeDiagnosticsEmitter; | ||
} | ||
get diagnostics() { | ||
return this.diagnosticRequestor.provider; | ||
} | ||
} | ||
class DiagnosticFeature extends client_1.TextDocumentFeature { | ||
constructor(client) { | ||
super(client, vscode_languageserver_protocol_1.Proposed.DocumentDiagnosticRequest.type); | ||
this.editorTracker = new EditorTracker(); | ||
} | ||
fillClientCapabilities(capabilities) { | ||
let capability = ensure(ensure(capabilities, 'textDocument'), 'diagnostic'); | ||
capability.dynamicRegistration = true; | ||
// We first need to decide how a UI will look with related documents. | ||
// An easy implementation would be to only show related diagnostics for | ||
// the active editor. | ||
capability.relatedDocumentSupport = false; | ||
} | ||
initialize(capabilities, documentSelector) { | ||
const client = this._client; | ||
client.onRequest(vscode_languageserver_protocol_1.Proposed.DiagnosticRefreshRequest.type, async () => { | ||
for (const provider of this.getAllProviders()) { | ||
provider.onDidChangeDiagnosticsEmitter.fire(); | ||
} | ||
}); | ||
let [id, options] = this.getRegistration(documentSelector, capabilities.diagnosticProvider); | ||
if (!id || !options) { | ||
return; | ||
} | ||
this.register({ id: id, registerOptions: options }); | ||
} | ||
dispose() { | ||
this.editorTracker.dispose(); | ||
super.dispose(); | ||
} | ||
registerLanguageProvider(options) { | ||
const provider = new DiagnosticFeatureProviderImpl(this._client, this.editorTracker, options); | ||
return [provider.disposable, provider]; | ||
} | ||
} | ||
exports.DiagnosticFeature = DiagnosticFeature; | ||
//# sourceMappingURL=proposed.diagnostic.js.map |
@@ -53,3 +53,3 @@ "use strict"; | ||
isTriggered() { | ||
return this.timeout !== void 0; | ||
return this.timeout !== undefined; | ||
} | ||
@@ -61,4 +61,4 @@ cancel() { | ||
cancelTimeout() { | ||
if (this.timeout !== void 0) { | ||
vscode_languageserver_protocol_1.RAL().timer.clearTimeout(this.timeout); | ||
if (this.timeout !== undefined) { | ||
this.timeout.dispose(); | ||
this.timeout = undefined; | ||
@@ -65,0 +65,0 @@ } |
@@ -77,5 +77,7 @@ /// <reference types="node" /> | ||
private _isDetached; | ||
private _isInDebugMode; | ||
constructor(name: string, serverOptions: ServerOptions, clientOptions: LanguageClientOptions, forceDebug?: boolean); | ||
constructor(id: string, name: string, serverOptions: ServerOptions, clientOptions: LanguageClientOptions, forceDebug?: boolean); | ||
private checkVersion; | ||
get isInDebugMode(): boolean; | ||
stop(): Promise<void>; | ||
@@ -82,0 +84,0 @@ private checkProcessDied; |
@@ -64,3 +64,3 @@ "use strict"; | ||
let candidate = value; | ||
return candidate && candidate.writer !== void 0 && candidate.reader !== void 0; | ||
return candidate && candidate.writer !== undefined && candidate.reader !== undefined; | ||
} | ||
@@ -73,3 +73,3 @@ StreamInfo.is = is; | ||
let candidate = value; | ||
return candidate && candidate.process !== void 0 && typeof candidate.detached === 'boolean'; | ||
return candidate && candidate.process !== undefined && typeof candidate.detached === 'boolean'; | ||
} | ||
@@ -99,3 +99,3 @@ ChildProcessInfo.is = is; | ||
} | ||
if (forceDebug === void 0) { | ||
if (forceDebug === undefined) { | ||
forceDebug = false; | ||
@@ -106,2 +106,3 @@ } | ||
this._forceDebug = forceDebug; | ||
this._isInDebugMode = forceDebug; | ||
try { | ||
@@ -130,2 +131,5 @@ this.checkVersion(); | ||
} | ||
get isInDebugMode() { | ||
return this._isInDebugMode; | ||
} | ||
stop() { | ||
@@ -136,3 +140,3 @@ return super.stop().then(() => { | ||
this._serverProcess = undefined; | ||
if (this._isDetached === void 0 || !this._isDetached) { | ||
if (this._isDetached === undefined || !this._isDetached) { | ||
this.checkProcessDied(toCheck); | ||
@@ -234,5 +238,7 @@ } | ||
json = runDebug.debug; | ||
this._isInDebugMode = true; | ||
} | ||
else { | ||
json = runDebug.run; | ||
this._isInDebugMode = false; | ||
} | ||
@@ -324,3 +330,3 @@ } | ||
let pipeName = undefined; | ||
return new Promise((resolve, _reject) => { | ||
return new Promise((resolve, reject) => { | ||
let args = node.args && node.args.slice() || []; | ||
@@ -368,4 +374,4 @@ if (transport === TransportKind.ipc) { | ||
resolve({ reader: protocol[0], writer: protocol[1] }); | ||
}); | ||
}); | ||
}, reject); | ||
}, reject); | ||
} | ||
@@ -381,4 +387,4 @@ else if (Transport.isSocket(transport)) { | ||
resolve({ reader: protocol[0], writer: protocol[1] }); | ||
}); | ||
}); | ||
}, reject); | ||
}, reject); | ||
} | ||
@@ -481,3 +487,3 @@ }); | ||
if (this._client.needsStop()) { | ||
this._client.stop(); | ||
void this._client.stop(); | ||
} | ||
@@ -495,3 +501,3 @@ }); | ||
else if (!enabled && this._client.needsStop()) { | ||
this._client.stop(); | ||
void this._client.stop(); | ||
} | ||
@@ -498,0 +504,0 @@ } |
{ | ||
"name": "vscode-languageclient", | ||
"description": "VSCode Language client implementation", | ||
"version": "7.1.0-next.4", | ||
"version": "7.1.0-next.5", | ||
"author": "Microsoft Corporation", | ||
@@ -32,3 +32,3 @@ "license": "MIT", | ||
"semver": "^7.3.4", | ||
"vscode-languageserver-protocol": "3.17.0-next.5" | ||
"vscode-languageserver-protocol": "3.17.0-next.6" | ||
}, | ||
@@ -35,0 +35,0 @@ "scripts": { |
Sorry, the diff of this file is too big to display
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
432917
8775
+ Addedvscode-jsonrpc@7.0.0-next.1(transitive)
+ Addedvscode-languageserver-protocol@3.17.0-next.6(transitive)
+ Addedvscode-languageserver-types@3.17.0-next.2(transitive)
- Removedvscode-jsonrpc@6.1.0-next.2(transitive)
- Removedvscode-languageserver-protocol@3.17.0-next.5(transitive)
- Removedvscode-languageserver-types@3.17.0-next.1(transitive)