vscode-languageclient
Advanced tools
Comparing version 10.0.0-next.1 to 10.0.0-next.2
@@ -6,3 +6,3 @@ import { TextDocument, Disposable, OutputChannel, DiagnosticCollection, Diagnostic as VDiagnostic, Uri, CancellationToken, WorkspaceFolder as VWorkspaceFolder, FileCreateEvent, FileRenameEvent, FileDeleteEvent, FileWillCreateEvent, FileWillRenameEvent, FileWillDeleteEvent, CompletionItemProvider, HoverProvider, SignatureHelpProvider, DefinitionProvider, ReferenceProvider, DocumentHighlightProvider, CodeActionProvider, DocumentFormattingEditProvider, DocumentRangeFormattingEditProvider, OnTypeFormattingEditProvider, RenameProvider, DocumentSymbolProvider, DocumentLinkProvider, DeclarationProvider, ImplementationProvider, DocumentColorProvider, SelectionRangeProvider, TypeDefinitionProvider, CallHierarchyProvider, LinkedEditingRangeProvider, TypeHierarchyProvider, WorkspaceSymbolProvider, ProviderResult, TextEdit as VTextEdit, InlineCompletionItemProvider } from 'vscode'; | ||
import { DynamicFeature, FeatureClient, TextDocumentSendFeature, StaticFeature, TextDocumentProviderFeature, WorkspaceProviderFeature } from './features'; | ||
import { DiagnosticProviderMiddleware, DiagnosticProviderShape, $DiagnosticPullOptions } from './diagnostic'; | ||
import { DiagnosticProviderMiddleware, DiagnosticProviderShape, $DiagnosticPullOptions, DiagnosticFeatureShape } from './diagnostic'; | ||
import { NotebookDocumentMiddleware, $NotebookDocumentOptions, NotebookDocumentProviderShape } from './notebook'; | ||
@@ -455,5 +455,5 @@ import { ConfigurationMiddleware, $ConfigurationOptions, DidChangeConfigurationMiddleware } from './configuration'; | ||
getFeature(request: typeof WorkspaceSymbolRequest.method): DynamicFeature<TextDocumentRegistrationOptions> & WorkspaceProviderFeature<WorkspaceSymbolProvider>; | ||
getFeature(request: typeof DocumentDiagnosticRequest.method): DynamicFeature<TextDocumentRegistrationOptions> & TextDocumentProviderFeature<DiagnosticProviderShape> | undefined; | ||
getFeature(request: typeof NotebookDocumentSyncRegistrationType.method): DynamicFeature<NotebookDocumentSyncRegistrationOptions> & NotebookDocumentProviderShape | undefined; | ||
getFeature(request: typeof InlineCompletionRequest.method): DynamicFeature<InlineCompletionRegistrationOptions> & TextDocumentProviderFeature<InlineCompletionItemProvider>; | ||
getFeature(request: typeof DocumentDiagnosticRequest.method): DynamicFeature<TextDocumentRegistrationOptions> & TextDocumentProviderFeature<DiagnosticProviderShape> & DiagnosticFeatureShape; | ||
getFeature(request: typeof NotebookDocumentSyncRegistrationType.method): DynamicFeature<NotebookDocumentSyncRegistrationOptions> & NotebookDocumentProviderShape; | ||
getFeature(request: typeof InlineCompletionRequest.method): (DynamicFeature<InlineCompletionRegistrationOptions> & TextDocumentProviderFeature<InlineCompletionItemProvider>) | undefined; | ||
getFeature(request: typeof ExecuteCommandRequest.method): DynamicFeature<ExecuteCommandOptions>; | ||
@@ -460,0 +460,0 @@ hasDedicatedTextSynchronizationFeature(textDocument: TextDocument): boolean; |
@@ -118,6 +118,22 @@ import { Disposable, CancellationToken, ProviderResult, Diagnostic as VDiagnostic, TextDocument, Event as VEvent, EventEmitter, Uri } from 'vscode'; | ||
export type DiagnosticProviderShape = { | ||
/** | ||
* An event that signals that the diagnostics should be refreshed for | ||
* all documents. | ||
*/ | ||
onDidChangeDiagnosticsEmitter: EventEmitter<void>; | ||
/** | ||
* The provider of diagnostics. | ||
*/ | ||
diagnostics: vsdiag.DiagnosticProvider; | ||
/** | ||
* Forget the given document and remove all diagnostics. | ||
* | ||
* @param document The document to forget. | ||
*/ | ||
forget(document: TextDocument): void; | ||
}; | ||
export declare class DiagnosticFeature extends TextDocumentLanguageFeature<DiagnosticOptions, DiagnosticRegistrationOptions, DiagnosticProviderShape, DiagnosticProviderMiddleware, $DiagnosticPullOptions> { | ||
export interface DiagnosticFeatureShape { | ||
refresh(): void; | ||
} | ||
export declare class DiagnosticFeature extends TextDocumentLanguageFeature<DiagnosticOptions, DiagnosticRegistrationOptions, DiagnosticProviderShape, DiagnosticProviderMiddleware, $DiagnosticPullOptions> implements DiagnosticFeatureShape { | ||
private tabs; | ||
@@ -128,3 +144,4 @@ constructor(client: FeatureClient<DiagnosticProviderMiddleware, $DiagnosticPullOptions>); | ||
clear(): void; | ||
refresh(): void; | ||
protected registerLanguageProvider(options: DiagnosticRegistrationOptions): [Disposable, DiagnosticProviderShape]; | ||
} |
@@ -523,3 +523,4 @@ "use strict"; | ||
class BackgroundScheduler { | ||
constructor(diagnosticRequestor) { | ||
constructor(client, diagnosticRequestor) { | ||
this.client = client; | ||
this.diagnosticRequestor = diagnosticRequestor; | ||
@@ -538,3 +539,7 @@ this.documents = new vscode_languageserver_protocol_1.LinkedMap(); | ||
this.documents.set(key, document, vscode_languageserver_protocol_1.Touch.Last); | ||
this.trigger(); | ||
// Make sure we run up to that document. We could | ||
// consider inserting it after the current last | ||
// document for performance reasons but it might not catch | ||
// all interfile dependencies. | ||
this.lastDocumentToPull = document; | ||
} | ||
@@ -547,30 +552,55 @@ remove(document) { | ||
this.stop(); | ||
return; | ||
} | ||
else if (key === this.endDocumentKey()) { | ||
// Make sure we have a correct last document. It could have | ||
this.endDocument = this.documents.last; | ||
else if (key === this.lastDocumentToPullKey()) { | ||
// The remove document was the one we would run up to. So | ||
// take the one before it. | ||
const before = this.documents.before(key); | ||
if (before === undefined) { | ||
this.stop(); | ||
} | ||
else { | ||
this.lastDocumentToPull = before; | ||
} | ||
} | ||
} | ||
trigger() { | ||
this.lastDocumentToPull = this.documents.last; | ||
this.runLoop(); | ||
} | ||
runLoop() { | ||
if (this.isDisposed === true) { | ||
return; | ||
} | ||
// 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; | ||
// We have an empty background list. Make sure we stop | ||
// background activity. | ||
if (this.documents.size === 0) { | ||
this.stop(); | ||
return; | ||
} | ||
this.endDocument = this.documents.last; | ||
this.intervalHandle = (0, vscode_languageserver_protocol_1.RAL)().timer.setInterval(() => { | ||
// We have no last document anymore so stop the loop | ||
if (this.lastDocumentToPull === undefined) { | ||
return; | ||
} | ||
// We have a timeout in the loop. So we should not schedule | ||
// another run. | ||
if (this.timeoutHandle !== undefined) { | ||
return; | ||
} | ||
this.timeoutHandle = (0, vscode_languageserver_protocol_1.RAL)().timer.setTimeout(() => { | ||
const document = this.documents.first; | ||
if (document !== undefined) { | ||
const key = DocumentOrUri.asKey(document); | ||
this.diagnosticRequestor.pull(document); | ||
if (document === undefined) { | ||
return; | ||
} | ||
const key = DocumentOrUri.asKey(document); | ||
this.diagnosticRequestor.pullAsync(document).catch((error) => { | ||
this.client.error(`Document pull failed for text document ${key}`, error, false); | ||
}).finally(() => { | ||
this.timeoutHandle = undefined; | ||
this.documents.set(key, document, vscode_languageserver_protocol_1.Touch.Last); | ||
if (key === this.endDocumentKey()) { | ||
this.stop(); | ||
if (key !== this.lastDocumentToPullKey()) { | ||
this.runLoop(); | ||
} | ||
} | ||
}, 200); | ||
}); | ||
}, 500); | ||
} | ||
@@ -581,10 +611,11 @@ dispose() { | ||
this.documents.clear(); | ||
this.lastDocumentToPull = undefined; | ||
} | ||
stop() { | ||
this.intervalHandle?.dispose(); | ||
this.intervalHandle = undefined; | ||
this.endDocument = undefined; | ||
this.timeoutHandle?.dispose(); | ||
this.timeoutHandle = undefined; | ||
this.lastDocumentToPull = undefined; | ||
} | ||
endDocumentKey() { | ||
return this.endDocument !== undefined ? DocumentOrUri.asKey(this.endDocument) : undefined; | ||
lastDocumentToPullKey() { | ||
return this.lastDocumentToPull !== undefined ? DocumentOrUri.asKey(this.lastDocumentToPull) : undefined; | ||
} | ||
@@ -594,3 +625,3 @@ } | ||
constructor(client, tabs, options) { | ||
const diagnosticPullOptions = client.clientOptions.diagnosticPullOptions ?? { onChange: true, onSave: false, onFocus: false }; | ||
const diagnosticPullOptions = Object.assign({ onChange: false, onSave: false, onFocus: false }, client.clientOptions.diagnosticPullOptions); | ||
const documentSelector = client.protocol2CodeConverter.asDocumentSelector(options.documentSelector); | ||
@@ -641,5 +672,5 @@ const disposables = []; | ||
this.diagnosticRequestor = new DiagnosticRequestor(client, tabs, options); | ||
this.backgroundScheduler = new BackgroundScheduler(this.diagnosticRequestor); | ||
this.backgroundScheduler = new BackgroundScheduler(client, this.diagnosticRequestor); | ||
const addToBackgroundIfNeeded = (document) => { | ||
if (!matches(document) || !options.interFileDependencies || isActiveDocument(document)) { | ||
if (!matches(document) || !options.interFileDependencies || isActiveDocument(document) || diagnosticPullOptions.onChange === false) { | ||
return; | ||
@@ -662,3 +693,3 @@ } | ||
if (diagnosticPullOptions.onFocus === true && matches(this.activeTextDocument) && considerDocument(this.activeTextDocument, DiagnosticPullMode.onFocus)) { | ||
this.diagnosticRequestor.pull(this.activeTextDocument, () => { this.backgroundScheduler.trigger(); }); | ||
this.diagnosticRequestor.pull(this.activeTextDocument); | ||
} | ||
@@ -745,3 +776,3 @@ } | ||
if (considerDocument(textDocument, DiagnosticPullMode.onSave)) { | ||
this.diagnosticRequestor.pull(event.textDocument, () => { this.backgroundScheduler.trigger(); }); | ||
this.diagnosticRequestor.pull(event.textDocument); | ||
} | ||
@@ -781,6 +812,9 @@ })); | ||
} | ||
forget(document) { | ||
this.cleanUpDocument(document); | ||
} | ||
cleanUpDocument(document) { | ||
this.backgroundScheduler.remove(document); | ||
if (this.diagnosticRequestor.knows(PullState.document, document)) { | ||
this.diagnosticRequestor.forgetDocument(document); | ||
this.backgroundScheduler.remove(document); | ||
} | ||
@@ -826,2 +860,7 @@ } | ||
} | ||
refresh() { | ||
for (const provider of this.getAllProviders()) { | ||
provider.onDidChangeDiagnosticsEmitter.fire(); | ||
} | ||
} | ||
registerLanguageProvider(options) { | ||
@@ -828,0 +867,0 @@ if (this.tabs === undefined) { |
@@ -323,3 +323,3 @@ import { TextDocument, Event as VEvent, DocumentSelector as VDocumentSelector, Event, Disposable, CancellationToken, ProviderResult, TextEdit as VTextEdit, ReferenceProvider, DefinitionProvider, SignatureHelpProvider, HoverProvider, CompletionItemProvider, WorkspaceSymbolProvider, DocumentHighlightProvider, CodeActionProvider, DocumentFormattingEditProvider, DocumentRangeFormattingEditProvider, OnTypeFormattingEditProvider, RenameProvider, DocumentSymbolProvider, DocumentLinkProvider, DocumentColorProvider, DeclarationProvider, ImplementationProvider, SelectionRangeProvider, TypeDefinitionProvider, CallHierarchyProvider, LinkedEditingRangeProvider, TypeHierarchyProvider, FileCreateEvent, FileRenameEvent, FileDeleteEvent, FileWillCreateEvent, FileWillRenameEvent, FileWillDeleteEvent, CancellationError, InlineCompletionItemProvider } from 'vscode'; | ||
import type { InlayHintsProviderShape } from './inlayHint'; | ||
import type { DiagnosticProviderShape } from './diagnostic'; | ||
import type { DiagnosticFeatureShape, DiagnosticProviderShape } from './diagnostic'; | ||
import type { NotebookDocumentProviderShape } from './notebook'; | ||
@@ -414,7 +414,7 @@ import { FoldingRangeProviderShape } from './foldingRange'; | ||
getFeature(request: typeof WorkspaceSymbolRequest.method): DynamicFeature<TextDocumentRegistrationOptions> & WorkspaceProviderFeature<WorkspaceSymbolProvider>; | ||
getFeature(request: typeof DocumentDiagnosticRequest.method): DynamicFeature<TextDocumentRegistrationOptions> & TextDocumentProviderFeature<DiagnosticProviderShape> | undefined; | ||
getFeature(request: typeof NotebookDocumentSyncRegistrationType.method): DynamicFeature<NotebookDocumentSyncRegistrationOptions> & NotebookDocumentProviderShape | undefined; | ||
getFeature(request: typeof InlineCompletionRequest.method): DynamicFeature<InlineCompletionRegistrationOptions> & TextDocumentProviderFeature<InlineCompletionItemProvider>; | ||
getFeature(request: typeof DocumentDiagnosticRequest.method): DynamicFeature<TextDocumentRegistrationOptions> & TextDocumentProviderFeature<DiagnosticProviderShape> & DiagnosticFeatureShape; | ||
getFeature(request: typeof NotebookDocumentSyncRegistrationType.method): DynamicFeature<NotebookDocumentSyncRegistrationOptions> & NotebookDocumentProviderShape; | ||
getFeature(request: typeof InlineCompletionRequest.method): (DynamicFeature<InlineCompletionRegistrationOptions> & TextDocumentProviderFeature<InlineCompletionItemProvider>) | undefined; | ||
getFeature(request: typeof ExecuteCommandRequest.method): DynamicFeature<ExecuteCommandOptions>; | ||
} | ||
export {}; |
{ | ||
"name": "vscode-languageclient", | ||
"description": "VSCode Language client implementation", | ||
"version": "10.0.0-next.1", | ||
"version": "10.0.0-next.2", | ||
"author": "Microsoft Corporation", | ||
@@ -33,3 +33,3 @@ "license": "MIT", | ||
"semver": "^7.6.0", | ||
"vscode-languageserver-protocol": "3.17.6-next.2" | ||
"vscode-languageserver-protocol": "3.17.6-next.3" | ||
}, | ||
@@ -44,3 +44,3 @@ "scripts": { | ||
"test": "cd ../client-node-tests && npm test && cd ../client", | ||
"clean": "node ../node_modules/.bin/rimraf lib", | ||
"clean": "node ../node_modules/rimraf/dist/esm/bin.mjs lib", | ||
"all": "npm run clean && npm run compile && npm run lint && npm test", | ||
@@ -47,0 +47,0 @@ "compile:publish": "node ../build/bin/tsc -b ./tsconfig.publish.json && shx cp src/node/terminateProcess.sh lib/node/terminateProcess.sh", |
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
660456
13168
+ Addedvscode-jsonrpc@9.0.0-next.2(transitive)
+ Addedvscode-languageserver-protocol@3.17.6-next.3(transitive)
+ Addedvscode-languageserver-types@3.17.6-next.3(transitive)
- Removedvscode-jsonrpc@9.0.0-next.1(transitive)
- Removedvscode-languageserver-protocol@3.17.6-next.2(transitive)
- Removedvscode-languageserver-types@3.17.6-next.2(transitive)