Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5,088 changes: 1,107 additions & 3,981 deletions package-lock.json

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -653,16 +653,16 @@
"glob": "^7.1.4",
"mocha": "^9.2.2",
"prettier": "^2.0.5",
"typescript": "^3.5.2",
"vsce": "^2.15.0",
"@vscode/test-electron": "2.x"
"typescript": "^5.0",
"@vscode/vsce": "^2.15.0",
"@vscode/test-electron": "^2.0"
},
"dependencies": {
"axios": "0.21.2",
"axios": "^1.0.0",
"jsonc-parser": "~2.1.0",
"vscode-debugadapter": "^1.19.0",
"vscode-debugprotocol": "^1.19.0",
"vscode-extension-telemetry": "0.1.2",
"vscode-languageclient": "^5.2.1"
"vscode-languageclient": "^9.0.0"
}
}
29 changes: 19 additions & 10 deletions src/handler.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
import * as vscode from 'vscode';
import { LanguageClient, ServerOptions, LanguageClientOptions, RevealOutputChannelOn } from 'vscode-languageclient';
import {
LanguageClient,
LanguageClientOptions,
RevealOutputChannelOn,
ServerOptions,
} from 'vscode-languageclient/node';

import { ConnectionStatus } from './interfaces';
import { ConnectionType, ProtocolType } from './settings';
import { IAggregateConfiguration } from './configuration';
import { puppetFileLangID, puppetLangID } from './extension';
import { IPuppetStatusBar } from './feature/PuppetStatusBarFeature';
import { ConnectionStatus } from './interfaces';
import { OutputChannelLogger } from './logging/outputchannel';
import { PuppetVersionDetails, PuppetVersionRequest, PuppetCommandStrings } from './messages';
import { PuppetCommandStrings, PuppetVersionDetails, PuppetVersionRequest } from './messages';
import { ConnectionType, ProtocolType } from './settings';
import { reporter } from './telemetry';
import { puppetFileLangID, puppetLangID } from './extension';
import { IAggregateConfiguration } from './configuration';

export abstract class ConnectionHandler {
private timeSpent: number;
Expand Down Expand Up @@ -56,7 +61,7 @@ export abstract class ConnectionHandler {
this.logger.debug('Creating language client');
this._languageClient = new LanguageClient('PuppetVSCode', serverOptions, clientOptions);
this._languageClient
.onReady()
.start()
.then(
() => {
this.languageClient.onTelemetry((event) => {
Expand Down Expand Up @@ -90,7 +95,11 @@ export abstract class ConnectionHandler {

start(): void {
this.setConnectionStatus('Starting languageserver', ConnectionStatus.Starting, '');
this.context.subscriptions.push(this.languageClient.start());
this.languageClient.start().then(() => {
this.context.subscriptions.push({
dispose: () => this.languageClient.stop(),
});
});
}

stop(): void {
Expand Down Expand Up @@ -129,7 +138,7 @@ export abstract class ConnectionHandler {
if (count >= 30 || this._languageClient === undefined) {
clearInterval(handle);
this.setConnectionStatus(lastVersionResponse.puppetVersion, ConnectionStatus.RunningLoaded, '');
resolve();
resolve(undefined);
return;
}

Expand All @@ -143,7 +152,7 @@ export abstract class ConnectionHandler {
) {
clearInterval(handle);
this.setConnectionStatus(lastVersionResponse.puppetVersion, ConnectionStatus.RunningLoaded, '');
resolve();
resolve(undefined);
} else {
let toolTip = '';

Expand Down
2 changes: 1 addition & 1 deletion src/handlers/stdio.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as vscode from 'vscode';
import { Executable, ServerOptions } from 'vscode-languageclient';
import { Executable, ServerOptions } from 'vscode-languageclient/node';
import { IAggregateConfiguration } from '../configuration';
import { IPuppetStatusBar } from '../feature/PuppetStatusBarFeature';
import { ConnectionHandler } from '../handler';
Expand Down
2 changes: 1 addition & 1 deletion src/handlers/tcp.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as cp from 'child_process';
import * as net from 'net';
import * as vscode from 'vscode';
import { Executable, ServerOptions, StreamInfo } from 'vscode-languageclient';
import { Executable, ServerOptions, StreamInfo } from 'vscode-languageclient/node';
import { IAggregateConfiguration } from '../configuration';
import { IPuppetStatusBar } from '../feature/PuppetStatusBarFeature';
import { ConnectionHandler } from '../handler';
Expand Down
3 changes: 1 addition & 2 deletions src/helpers/commandHelper.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as path from 'path';
import * as vscode from 'vscode';
import { Executable } from 'vscode-languageclient';
import { Executable } from 'vscode-languageclient/node';
import { IAggregateConfiguration } from '../configuration';
import { PathResolver } from '../configuration/pathResolver';
import { ProtocolType, PuppetInstallType } from '../settings';
Expand Down Expand Up @@ -35,7 +35,6 @@ export class CommandEnvironmentHelper {
private static applyRubyEnvFromConfiguration(exe: Executable, config: IAggregateConfiguration): Executable {
// setup defaults
exe.options.env = this.shallowCloneObject(process.env);
exe.options.stdio = 'pipe';

switch (process.platform) {
case 'win32':
Expand Down
12 changes: 6 additions & 6 deletions src/messages.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/* eslint-disable @typescript-eslint/no-namespace */
import { RequestType, RequestType0 } from 'vscode-languageclient';
import { RequestType, RequestType0 } from 'vscode-languageclient/node';

export namespace PuppetVersionRequest {
export const type = new RequestType0<PuppetVersionDetails, void, void>('puppet/getVersion');
export const type = new RequestType0<PuppetVersionDetails, void>('puppet/getVersion');
}

export interface PuppetVersionDetails {
Expand All @@ -21,7 +21,7 @@ export interface PuppetResourceRequestParams {
}

export namespace PuppetResourceRequest {
export const type = new RequestType<PuppetResourceRequestParams, PuppetResourceResponse, void, void>(
export const type = new RequestType<PuppetResourceRequestParams, PuppetResourceResponse, void>(
'puppet/getResource',
);
}
Expand All @@ -37,7 +37,7 @@ export interface PuppetFixDiagnosticErrorsRequestParams {
}

export namespace PuppetFixDiagnosticErrorsRequest {
export const type = new RequestType<PuppetFixDiagnosticErrorsRequestParams, any, void, void>(
export const type = new RequestType<PuppetFixDiagnosticErrorsRequestParams, any, void>(
'puppet/fixDiagnosticErrors',
);
}
Expand All @@ -49,7 +49,7 @@ export interface PuppetFixDiagnosticErrorsResponse {
}

export namespace PuppetNodeGraphRequest {
export const type = new RequestType<any, PuppetNodeGraphResponse, void, void>('puppet/compileNodeGraph');
export const type = new RequestType<any, PuppetNodeGraphResponse, void>('puppet/compileNodeGraph');
}

export interface PuppetNodeGraphResponse {
Expand All @@ -59,7 +59,7 @@ export interface PuppetNodeGraphResponse {
}

export namespace CompileNodeGraphRequest {
export const type = new RequestType<any, any, void, void>('puppet/compileNodeGraph');
export const type = new RequestType<any, any, void>('puppet/compileNodeGraph');
}

export interface CompileNodeGraphResponse {
Expand Down
26 changes: 10 additions & 16 deletions src/views/facts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
TreeItem,
TreeItemCollapsibleState,
} from 'vscode';
import { RequestType0 } from 'vscode-languageclient';
import { RequestType0 } from 'vscode-languageclient/node';
import { ConnectionHandler } from '../handler';
import { PuppetVersionDetails } from '../messages';
import { reporter } from '../telemetry';
Expand All @@ -21,20 +21,14 @@ class PuppetFact extends TreeItem {
public readonly children?: Array<[string, PuppetFact]>,
) {
super(label, collapsibleState);
this.tooltip = `${this.label}-${this.value}`;
this.description = this.value;
if (children) {
this.iconPath = ThemeIcon.Folder;
} else {
this.iconPath = ThemeIcon.File;
}
}

get tooltip(): string {
return `${this.label}-${this.value}`;
}

get description(): string {
return this.value;
}
}

interface PuppetFactResponse {
Expand All @@ -53,7 +47,7 @@ export class PuppetFactsProvider implements TreeDataProvider<PuppetFact> {
}

refresh(): void {
this._onDidChangeTreeData.fire();
this._onDidChangeTreeData.fire(undefined);
}

getTreeItem(element: PuppetFact): TreeItem | Thenable<PuppetFact> {
Expand All @@ -75,10 +69,10 @@ export class PuppetFactsProvider implements TreeDataProvider<PuppetFact> {
if we didn't cache, we would have to call out for each expand and getting
facts is slow.
*/
await this.handler.languageClient.onReady();
await this.handler.languageClient.start();

const details = await this.handler.languageClient.sendRequest(
new RequestType0<PuppetVersionDetails, void, void>('puppet/getVersion'),
new RequestType0<PuppetVersionDetails, void>('puppet/getVersion'),
);
if (!details.factsLoaded) {
// language server is ready, but hasn't loaded facts yet
Expand All @@ -90,7 +84,7 @@ export class PuppetFactsProvider implements TreeDataProvider<PuppetFact> {
clearInterval(handle);

const results = await this.handler.languageClient.sendRequest(
new RequestType0<PuppetFactResponse, void, void>('puppet/getFacts'),
new RequestType0<PuppetFactResponse, void>('puppet/getFacts'),
);
this.elements = this.toList(results.facts);

Expand All @@ -102,13 +96,13 @@ export class PuppetFactsProvider implements TreeDataProvider<PuppetFact> {
}

const details = await this.handler.languageClient.sendRequest(
new RequestType0<PuppetVersionDetails, void, void>('puppet/getVersion'),
new RequestType0<PuppetVersionDetails, void>('puppet/getVersion'),
);
if (details.factsLoaded) {
clearInterval(handle);

const results = await this.handler.languageClient.sendRequest(
new RequestType0<PuppetFactResponse, void, void>('puppet/getFacts'),
new RequestType0<PuppetFactResponse, void>('puppet/getFacts'),
);
this.elements = this.toList(results.facts);

Expand All @@ -125,7 +119,7 @@ export class PuppetFactsProvider implements TreeDataProvider<PuppetFact> {
}

const results = await this.handler.languageClient.sendRequest(
new RequestType0<PuppetFactResponse, void, void>('puppet/getFacts'),
new RequestType0<PuppetFactResponse, void>('puppet/getFacts'),
);
this.elements = this.toList(results.facts);

Expand Down
14 changes: 4 additions & 10 deletions src/views/puppetfile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,14 @@ class PuppetfileDependencyItem extends TreeItem {
public readonly children?: Array<[string, PuppetfileDependencyItem]>,
) {
super(name, collapsibleState);
this.tooltip = `${name}-${version}`;
this.description = version;
if (children) {
this.iconPath = ThemeIcon.Folder;
} else {
this.iconPath = new ThemeIcon('package');
}
}

get tooltip(): string {
return `${this.name}-${this.version}`;
}

get description(): string {
return this.version;
}
}

class PuppetfileDependency {
Expand Down Expand Up @@ -105,7 +99,7 @@ export class PuppetfileProvider implements TreeDataProvider<PuppetfileDependency
}

private async getPuppetfileDependenciesFromLanguageServer(): Promise<PuppetfileDependencyItem[]> {
await this.handler.languageClient.onReady();
await this.handler.languageClient.start();

const fileUri = Uri.file(path.join(workspace.workspaceFolders[0].uri.fsPath, 'Puppetfile'));
/*
Expand All @@ -115,7 +109,7 @@ export class PuppetfileProvider implements TreeDataProvider<PuppetfileDependency
*/
return workspace.openTextDocument(fileUri).then(async () => {
const results = await this.handler.languageClient.sendRequest(
new RequestType<never, PuppetfileDependencyResponse, void, void>('puppetfile/getDependencies'),
new RequestType<never, PuppetfileDependencyResponse, void>('puppetfile/getDependencies'),
{
uri: fileUri.toString(),
},
Expand Down