Skip to content

Commit

Permalink
[880] linting
Browse files Browse the repository at this point in the history
  • Loading branch information
bollwyvl committed Dec 10, 2022
1 parent 4e476a8 commit f65b5e9
Show file tree
Hide file tree
Showing 8 changed files with 1,352 additions and 2,780 deletions.
9 changes: 5 additions & 4 deletions packages/jupyterlab-lsp/src/connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ export class LSPConnection extends LspWsConnection {
method,
message: params
});
this.connection.sendNotification(method, params).catch(console.error);
this.connection.sendNotification(method, params);
});
}

Expand Down Expand Up @@ -618,9 +618,10 @@ export class LSPConnection extends LspWsConnection {
} as lsp.VersionedTextDocumentIdentifier,
contentChanges: changeEvents
};
this.connection
.sendNotification('textDocument/didChange', textDocumentChange)
.catch(console.error);
this.connection.sendNotification(
'textDocument/didChange',
textDocumentChange
);
documentInfo.version++;
}

Expand Down
3 changes: 1 addition & 2 deletions packages/jupyterlab-lsp/src/connection_manager.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { PageConfig, URLExt } from '@jupyterlab/coreutils';
import { ServerConnection } from '@jupyterlab/services';
import { Signal } from '@lumino/signaling';
import type * as protocol from 'vscode-languageserver-protocol';

Expand Down Expand Up @@ -392,7 +391,7 @@ export namespace DocumentConnectionManager {
virtual_document: VirtualDocument,
language: string
): IURIs {
const {settings} = Private.getLanguageServerManager();
const { settings } = Private.getLanguageServerManager();
const wsBase = settings.wsUrl;
const rootUri = PageConfig.getOption('rootUri');
const virtualDocumentsUri = PageConfig.getOption('virtualDocumentsUri');
Expand Down
2 changes: 1 addition & 1 deletion packages/jupyterlab-lsp/src/manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ export class LanguageServerManager implements ILanguageServerManager {
for (let key of Object.keys(sessions)) {
let id: TLanguageServerId = key as TLanguageServerId;
if (this._sessions.has(id)) {
Object.assign(this._sessions.get(id), sessions[key]);
Object.assign(this._sessions.get(id) || {}, sessions[key]);
} else {
this._sessions.set(id, sessions[key]);
}
Expand Down
4 changes: 3 additions & 1 deletion packages/lsp-ws-connection/src/test/connection.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,9 @@ describe('LspWsConnection', () => {

// Send the messages
expect(mockSocket.send.callCount).equal(1);
expect(JSON.parse(mockSocket.send.firstCall.args[0]).method).equal('initialize');
expect(JSON.parse(mockSocket.send.firstCall.args[0]).method).equal(
'initialize'
);
});

describe('register/unregister capability', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@ describe('ServerCapabilities client registration', () => {

if (typeof capabilityOptions === 'boolean') {
// eslint-disable-next-line jest/no-conditional-expect
expect((newServerCapabilities as any)[capability]).equal(capabilityOptions);
expect((newServerCapabilities as any)[capability]).equal(
capabilityOptions
);
} else {
// eslint-disable-next-line jest/no-conditional-expect
expect((newServerCapabilities as any)[capability]).to.deep.equal(
Expand Down
19 changes: 15 additions & 4 deletions packages/lsp-ws-connection/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ export type AnyLocation =
| undefined
| null;

export type AnyCompletion = lsProtocol.CompletionList | lsProtocol.CompletionItem[];
export type AnyCompletion =
| lsProtocol.CompletionList
| lsProtocol.CompletionItem[];

export enum CompletionTriggerKind {
Invoked = 1,
Expand All @@ -45,7 +47,10 @@ type ConnectionEvent =
| 'logging';

export interface ILspConnection {
on(event: 'completion', callback: (items: lsProtocol.CompletionItem[]) => void): void;
on(
event: 'completion',
callback: (items: lsProtocol.CompletionItem[]) => void
): void;
on(
event: 'completionResolved',
callback: (item: lsProtocol.CompletionItem) => void
Expand All @@ -60,7 +65,10 @@ export interface ILspConnection {
): void;
on(
event: 'highlight',
callback: (highlights: lsProtocol.DocumentHighlight[], documentUri: string) => void
callback: (
highlights: lsProtocol.DocumentHighlight[],
documentUri: string
) => void
): void;
on(
event: 'signature',
Expand All @@ -70,7 +78,10 @@ export interface ILspConnection {
event: 'goTo',
callback: (location: AnyLocation, documentUri: string) => void
): void;
on(event: 'rename', callback: (edit: lsProtocol.WorkspaceEdit | null) => void): void;
on(
event: 'rename',
callback: (edit: lsProtocol.WorkspaceEdit | null) => void
): void;
on(event: 'error', callback: (error: any) => void): void;
on(event: 'logging', callback: (log: any) => void): void;

Expand Down
79 changes: 51 additions & 28 deletions packages/lsp-ws-connection/src/ws-connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ import {
* - initializeParams() was extracted, and can be modified by subclasses
* - typescript 3.7 was adopted to clean up deep references
*/
export class LspWsConnection extends events.EventEmitter implements ILspConnection {
export class LspWsConnection
extends events.EventEmitter
implements ILspConnection
{
public isConnected = false;
public isInitialized = false;
public documentInfo: ILspOptions;
Expand Down Expand Up @@ -164,14 +167,16 @@ export class LspWsConnection extends events.EventEmitter implements ILspConnecti

const message: protocol.InitializeParams = this.initializeParams();

this.connection.sendRequest<protocol.InitializeResult>('initialize', message).then(
params => {
this.onServerInitialized(params);
},
e => {
console.warn('lsp-ws-connection initialization failure', e);
}
);
this.connection
.sendRequest<protocol.InitializeResult>('initialize', message)
.then(
params => {
this.onServerInitialized(params);
},
e => {
console.warn('lsp-ws-connection initialization failure', e);
}
);
}

sendOpen(documentInfo: IDocumentInfo) {
Expand All @@ -183,7 +188,10 @@ export class LspWsConnection extends events.EventEmitter implements ILspConnecti
version: documentInfo.version
} as protocol.TextDocumentItem
};
this.connection.sendNotification('textDocument/didOpen', textDocumentMessage);
this.connection.sendNotification(
'textDocument/didOpen',
textDocumentMessage
);
this.openedUris.set(documentInfo.uri, true);
this.sendChange(documentInfo);
}
Expand All @@ -203,7 +211,10 @@ export class LspWsConnection extends events.EventEmitter implements ILspConnecti
} as protocol.VersionedTextDocumentIdentifier,
contentChanges: [{ text: documentInfo.text }]
};
this.connection.sendNotification('textDocument/didChange', textDocumentChange);
this.connection.sendNotification(
'textDocument/didChange',
textDocumentChange
);
documentInfo.version++;
}

Expand All @@ -219,15 +230,23 @@ export class LspWsConnection extends events.EventEmitter implements ILspConnecti
} as protocol.VersionedTextDocumentIdentifier,
text: documentInfo.text
};
this.connection.sendNotification('textDocument/didSave', textDocumentChange);
this.connection.sendNotification(
'textDocument/didSave',
textDocumentChange
);
}

public sendConfigurationChange(settings: protocol.DidChangeConfigurationParams) {
public sendConfigurationChange(
settings: protocol.DidChangeConfigurationParams
) {
if (!this.isReady) {
return;
}

this.connection.sendNotification('workspace/didChangeConfiguration', settings);
this.connection.sendNotification(
'workspace/didChangeConfiguration',
settings
);
}

public async getHoverTooltip(
Expand Down Expand Up @@ -305,7 +324,10 @@ export class LspWsConnection extends events.EventEmitter implements ILspConnecti
return;
}
void this.connection
.sendRequest<protocol.CompletionItem>('completionItem/resolve', completionItem)
.sendRequest<protocol.CompletionItem>(
'completionItem/resolve',
completionItem
)
.then(result => {
this.emit('completionResolved', result);
});
Expand Down Expand Up @@ -368,18 +390,17 @@ export class LspWsConnection extends events.EventEmitter implements ILspConnecti
return;
}

const highlights = await this.connection.sendRequest<protocol.DocumentHighlight[]>(
'textDocument/documentHighlight',
{
textDocument: {
uri: documentInfo.uri
},
position: {
line: location.line,
character: location.ch
}
} as protocol.TextDocumentPositionParams
);
const highlights = await this.connection.sendRequest<
protocol.DocumentHighlight[]
>('textDocument/documentHighlight', {
textDocument: {
uri: documentInfo.uri
},
position: {
line: location.line,
character: location.ch
}
} as protocol.TextDocumentPositionParams);

if (emit) {
this.emit('highlight', highlights, documentInfo.uri);
Expand Down Expand Up @@ -534,7 +555,9 @@ export class LspWsConnection extends events.EventEmitter implements ILspConnecti
* The characters that trigger signature help automatically.
*/
public getLanguageSignatureCharacters(): string[] {
return this.serverCapabilities?.signatureHelpProvider?.triggerCharacters || [];
return (
this.serverCapabilities?.signatureHelpProvider?.triggerCharacters || []
);
}

/**
Expand Down
Loading

0 comments on commit f65b5e9

Please sign in to comment.