Skip to content

Commit

Permalink
⬆️ Upgrade to vscode server 8.1.0
Browse files Browse the repository at this point in the history
This will give access to Diagnostic.CodeDescription
  • Loading branch information
jb.muscat authored and ouvreboite committed Nov 25, 2024
1 parent 9894481 commit 73dadc3
Show file tree
Hide file tree
Showing 9 changed files with 60 additions and 59 deletions.
4 changes: 2 additions & 2 deletions client/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"author": "Stoplight <[email protected]>",
"dependencies": {
"vscode-languageclient": "^6.1.3"
"vscode-languageclient": "^9.0.1"
},
"description": "JSON/YAML linter with OpenAPI and custom ruleset support.",
"displayName": "Spectral",
Expand All @@ -17,4 +17,4 @@
"url": "https://github.com/stoplightio/vscode-spectral"
},
"version": "0.0.1"
}
}
14 changes: 6 additions & 8 deletions client/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
TransportKind,
FileChangeType,
Disposable,
} from 'vscode-languageclient';
} from 'vscode-languageclient/node';
import { ExtensionSettings } from './configuration';
import { StartWatcherNotification, StartWatcherParams } from './notifications';

Expand Down Expand Up @@ -152,13 +152,13 @@ export function activate(context: ExtensionContext): void {
}
return result;
},
didChangeConfiguration: (event, next): void => {
didChangeConfiguration: async (sections, next): Promise<void> => {
environmentChange();
next(event);
await next(sections);
},
didChangeWorkspaceFolders: (event, next): void => {
didChangeWorkspaceFolders: async (sections, next): Promise<void> => {
environmentChange();
next(event);
await next(sections);
},
},
},
Expand All @@ -173,7 +173,7 @@ export function activate(context: ExtensionContext): void {
return;
}

client.onReady().then(() => {
client.start().then(() => {
client.onNotification(StartWatcherNotification.type, (params: StartWatcherParams) => {
// The language server lets us know which ruleset files to watch since
// it's configurable and depends on the file/location being validated. We
Expand All @@ -187,8 +187,6 @@ export function activate(context: ExtensionContext): void {
});
});

client.start();

commands = [Commands.registerCommand('spectral.showOutputChannel', () => {
client.outputChannel.show();
})];
Expand Down
2 changes: 1 addition & 1 deletion client/src/notifications.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export namespace StartWatcherNotification {
/**
* Notification type indicating a FileSystemWatcher should be started in the client.
*/
export const type = new NotificationType<StartWatcherParams, void>('spectral/startWatcher');
export const type = new NotificationType<StartWatcherParams>('spectral/startWatcher');
}

export interface StartWatcherParams {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -161,4 +161,4 @@
"server/**"
]
}
}
}
4 changes: 2 additions & 2 deletions server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"@stoplight/spectral-rulesets": "^1.21.3",
"minimatch": "^3.0.4",
"rollup": "~2.79.2",
"vscode-languageserver": "^6.1.1",
"vscode-languageserver": "^9.0.1",
"vscode-languageserver-textdocument": "^1.0.1",
"vscode-uri": "^3.0.7"
},
Expand All @@ -27,4 +27,4 @@
"url": "https://github.com/stoplightio/vscode-spectral"
},
"version": "0.0.1"
}
}
4 changes: 2 additions & 2 deletions server/src/notifications.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export namespace StartWatcherNotification {
/**
* Notification type indicating a FileSystemWatcher should be started in the client.
*/
export const type = new NotificationType<StartWatcherParams, void>('spectral/startWatcher');
export const type = new NotificationType<StartWatcherParams>('spectral/startWatcher');
}

export interface StartWatcherParams {
Expand All @@ -31,5 +31,5 @@ export namespace ValidateNotification {
/**
* Notification type indicating a validation/linting operation should take place.
*/
export const type: NotificationType<TextDocument, void> = new NotificationType<TextDocument, void>('spectral/validate');
export const type: NotificationType<TextDocument> = new NotificationType<TextDocument>('spectral/validate');
}
16 changes: 8 additions & 8 deletions server/src/queue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// extension licensed under the MIT license.
// https://github.com/microsoft/vscode-eslint/blob/d40b96d4a2f0d085770b2bdce87b985bdd198bec/server/src/eslintServer.ts#L828
import {
IConnection,
Connection,
NotificationHandler,
NotificationType,
} from 'vscode-languageserver';
Expand Down Expand Up @@ -38,7 +38,7 @@ export class BufferedMessageQueue {
* Initializes a new queue.
* @param {IConnection} connection - The connection for communicating with clients.
*/
constructor(private connection: IConnection) {
constructor(private connection: Connection) {
this.queue = [];
this.notificationHandlers = new Map();
}
Expand All @@ -52,11 +52,11 @@ export class BufferedMessageQueue {

/**
* Registers a notification and handler at the same time.
* @param {NotificationType<P, RO>} type - The type of notification to process.
* @param {NotificationType<P>} type - The type of notification to process.
* @param {NotificationHandler<P>} handler - The handler for the notification.
* @param {queue~versionProvider} versionProvider - A provider that gives the document version.
*/
public registerNotification<P, RO>(type: NotificationType<P, RO>, handler: NotificationHandler<P>, versionProvider?: (params: P) => number): void {
public registerNotification<P>(type: NotificationType<P>, handler: NotificationHandler<P>, versionProvider?: (params: P) => number): void {
this.connection.onNotification(type, (params) => {
this.queue.push({
method: type.method,
Expand All @@ -70,11 +70,11 @@ export class BufferedMessageQueue {

/**
* Adds a message to the queue and kicks off processing.
* @param {NotificationType<P, RO>} type - The type of notification to add to the queue.
* @param {NotificationType<P>} type - The type of notification to add to the queue.
* @param {P} params - The subject of the notification.
* @param {number} version - The document version associated with the notification.
*/
public addNotificationMessage<P, RO>(type: NotificationType<P, RO>, params: P, version: number): void {
public addNotificationMessage<P>(type: NotificationType<P>, params: P, version: number): void {
this.queue.push({
method: type.method,
params,
Expand All @@ -85,11 +85,11 @@ export class BufferedMessageQueue {

/**
* Registers a handler for a notification.
* @param {NotificationType<P, RO>} type - The type of notification to process.
* @param {NotificationType<P>} type - The type of notification to process.
* @param {NotificationHandler<P>} handler - The handler for the notification.
* @param {queue~versionProvider} versionProvider - A provider that gives the document version.
*/
public onNotification<P, RO>(type: NotificationType<P, RO>, handler: NotificationHandler<P>, versionProvider?: (params: P) => number): void {
public onNotification<P>(type: NotificationType<P>, handler: NotificationHandler<P>, versionProvider?: (params: P) => number): void {
this.notificationHandlers.set(type.method, { handler, versionProvider });
}

Expand Down
8 changes: 4 additions & 4 deletions server/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import {
TextDocuments,
createConnection,
PublishDiagnosticsParams,
} from 'vscode-languageserver';
import { string as isString } from 'vscode-languageserver/lib/utils/is';
import { WorkDoneProgress } from 'vscode-languageserver/lib/progress';
} from 'vscode-languageserver/node';
import { string as isString } from 'vscode-languageserver/lib/common/utils/is';
import { WorkDoneProgressReporter } from 'vscode-languageserver/lib/common/progress';
import { TextDocument } from 'vscode-languageserver-textdocument';
import { URI } from 'vscode-uri';
import { Ruleset } from '@stoplight/spectral-core';
Expand Down Expand Up @@ -462,7 +462,7 @@ messageQueue.registerNotification(DidChangeWatchedFilesNotification.type, (_para
environmentChanged();
});

connection.onInitialize((_params: InitializeParams, _cancel, progress: WorkDoneProgress) => {
connection.onInitialize((_params: InitializeParams, _cancel, progress: WorkDoneProgressReporter) => {
progress.begin('Initializing Spectral Server');
documents = new TextDocuments(TextDocument);
linter = new Linter(documents, connection.console);
Expand Down
65 changes: 34 additions & 31 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3353,6 +3353,13 @@ minimatch@^5.0.1:
dependencies:
brace-expansion "^2.0.1"

minimatch@^5.1.0:
version "5.1.6"
resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-5.1.6.tgz#1cfcb8cf5522ea69952cd2af95ae09477f122a96"
integrity sha512-lKwV/1brpG6mBUFHtb7NUmtABCb2WZZmm2wNiOA5hAb8VdCS4B3dtMWyvcoViccwAW/COERjXLt0zP1zXUN26g==
dependencies:
brace-expansion "^2.0.1"

minimist@^1.2.0, minimist@^1.2.3, minimist@^1.2.5:
version "1.2.6"
resolved "https://registry.npmjs.org/minimist/-/minimist-1.2.6.tgz"
Expand Down Expand Up @@ -4146,19 +4153,14 @@ semver@^5.1.0:
resolved "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz"
integrity sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==

semver@^6.3.0:
version "6.3.0"
resolved "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz"
integrity sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==

semver@^7.2.1, semver@^7.3.4, semver@^7.3.5:
version "7.3.7"
resolved "https://registry.npmjs.org/semver/-/semver-7.3.7.tgz"
integrity sha512-QlYTucUYOews+WeEujDoEGziz4K6c47V/Bd+LjSSYcA94p+DmINdf7ncaUinThfvZyu13lN9OY1XDxt8C0Tw0g==
dependencies:
lru-cache "^6.0.0"

semver@^7.3.2:
semver@^7.3.2, semver@^7.3.7:
version "7.6.3"
resolved "https://registry.yarnpkg.com/semver/-/semver-7.6.3.tgz#980f7b5550bc175fb4dc09403085627f9eb33143"
integrity sha512-oVekP1cKtI+CTDvHWYFUcMtsK/00wmAEfyqKfNdARm8u1wNVhSgaX7A8d4UuIlUI5e84iEwOhs7ZPYRmzU9U6A==
Expand Down Expand Up @@ -4893,43 +4895,44 @@ vsce@^1.103.1:
yauzl "^2.3.1"
yazl "^2.2.2"

vscode-jsonrpc@^5.0.1:
version "5.0.1"
resolved "https://registry.npmjs.org/vscode-jsonrpc/-/vscode-jsonrpc-5.0.1.tgz"
integrity sha512-JvONPptw3GAQGXlVV2utDcHx0BiY34FupW/kI6mZ5x06ER5DdPG/tXWMVHjTNULF5uKPOUUD0SaXg5QaubJL0A==
vscode-jsonrpc@8.2.0:
version "8.2.0"
resolved "https://registry.yarnpkg.com/vscode-jsonrpc/-/vscode-jsonrpc-8.2.0.tgz#f43dfa35fb51e763d17cd94dcca0c9458f35abf9"
integrity sha512-C+r0eKJUIfiDIfwJhria30+TYWPtuHJXHtI7J0YlOmKAo7ogxP20T0zxB7HZQIFhIyvoBPwWskjxrvAtfjyZfA==

vscode-languageclient@^6.1.3:
version "6.1.3"
resolved "https://registry.npmjs.org/vscode-languageclient/-/vscode-languageclient-6.1.3.tgz"
integrity sha512-YciJxk08iU5LmWu7j5dUt9/1OLjokKET6rME3cI4BRpiF6HZlusm2ZwPt0MYJ0lV5y43sZsQHhyon2xBg4ZJVA==
vscode-languageclient@9.0.1:
version "9.0.1"
resolved "https://registry.yarnpkg.com/vscode-languageclient/-/vscode-languageclient-9.0.1.tgz#cdfe20267726c8d4db839dc1e9d1816e1296e854"
integrity sha512-JZiimVdvimEuHh5olxhxkht09m3JzUGwggb5eRUkzzJhZ2KjCN0nh55VfiED9oez9DyF8/fz1g1iBV3h+0Z2EA==
dependencies:
semver "^6.3.0"
vscode-languageserver-protocol "^3.15.3"
minimatch "^5.1.0"
semver "^7.3.7"
vscode-languageserver-protocol "3.17.5"

vscode-languageserver-protocol@^3.15.3:
version "3.15.3"
resolved "https://registry.npmjs.org/vscode-languageserver-protocol/-/vscode-languageserver-protocol-3.15.3.tgz"
integrity sha512-zrMuwHOAQRhjDSnflWdJG+O2ztMWss8GqUUB8dXLR/FPenwkiBNkMIJJYfSN6sgskvsF0rHAoBowNQfbyZnnvw==
vscode-languageserver-protocol@3.17.5:
version "3.17.5"
resolved "https://registry.yarnpkg.com/vscode-languageserver-protocol/-/vscode-languageserver-protocol-3.17.5.tgz#864a8b8f390835572f4e13bd9f8313d0e3ac4bea"
integrity sha512-mb1bvRJN8SVznADSGWM9u/b07H7Ecg0I3OgXDuLdn307rl/J3A9YD6/eYOssqhecL27hK1IPZAsaqh00i/Jljg==
dependencies:
vscode-jsonrpc "^5.0.1"
vscode-languageserver-types "3.15.1"
vscode-jsonrpc "8.2.0"
vscode-languageserver-types "3.17.5"

vscode-languageserver-textdocument@^1.0.1:
version "1.0.1"
resolved "https://registry.npmjs.org/vscode-languageserver-textdocument/-/vscode-languageserver-textdocument-1.0.1.tgz"
integrity sha512-UIcJDjX7IFkck7cSkNNyzIz5FyvpQfY7sdzVy+wkKN/BLaD4DQ0ppXQrKePomCxTS7RrolK1I0pey0bG9eh8dA==

vscode-languageserver-types@3.15.1:
version "3.15.1"
resolved "https://registry.npmjs.org/vscode-languageserver-types/-/vscode-languageserver-types-3.15.1.tgz"
integrity sha512-+a9MPUQrNGRrGU630OGbYVQ+11iOIovjCkqxajPa9w57Sd5ruK8WQNsslzpa0x/QJqC8kRc2DUxWjIFwoNm4ZQ==
vscode-languageserver-types@3.17.5:
version "3.17.5"
resolved "https://registry.yarnpkg.com/vscode-languageserver-types/-/vscode-languageserver-types-3.17.5.tgz#3273676f0cf2eab40b3f44d085acbb7f08a39d8a"
integrity sha512-Ld1VelNuX9pdF39h2Hgaeb5hEZM2Z3jUrrMgWQAu82jMtZp7p3vJT3BzToKtZI7NgQssZje5o0zryOrhQvzQAg==

vscode-languageserver@^6.1.1:
version "6.1.1"
resolved "https://registry.npmjs.org/vscode-languageserver/-/vscode-languageserver-6.1.1.tgz"
integrity sha512-DueEpkUAkD5XTR4MLYNr6bQIp/UFR0/IPApgXU3YfCBCB08u2sm9hRCs6DxYZELkk++STPjpcjksR2H8qI3cDQ==
vscode-languageserver@^9.0.1:
version "9.0.1"
resolved "https://registry.yarnpkg.com/vscode-languageserver/-/vscode-languageserver-9.0.1.tgz#500aef82097eb94df90d008678b0b6b5f474015b"
integrity sha512-woByF3PDpkHFUreUa7Hos7+pUWdeWMXRd26+ZX2A8cFx6v/JPTtd4/uN0/jB6XQHYaOlHbio03NTHCqrgG5n7g==
dependencies:
vscode-languageserver-protocol "^3.15.3"
vscode-languageserver-protocol "3.17.5"

vscode-test@^1.5.0:
version "1.5.0"
Expand Down

0 comments on commit 73dadc3

Please sign in to comment.