Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
broccolirob committed Mar 15, 2023
1 parent bfbfa7f commit f0aa397
Show file tree
Hide file tree
Showing 13 changed files with 6,638 additions and 926 deletions.
5,574 changes: 5,573 additions & 1 deletion resources/jquery-3.6.0.min.js

Large diffs are not rendered by default.

106 changes: 53 additions & 53 deletions src/slitherLanguageClient.ts
Original file line number Diff line number Diff line change
@@ -1,139 +1,139 @@
import {Socket} from 'net'
import { Socket } from "net";
import {
Emitter,
integer,
LanguageClient,
LanguageClientOptions,
ServerOptions,
StreamInfo,
} from 'vscode-languageclient/node'
import {Logger} from './utils/logger'
import {CompilationTarget, DetectorSettings} from './types/configTypes'
import * as vscode from 'vscode'
} from "vscode-languageclient/node";
import { Logger } from "./utils/logger";
import { CompilationTarget, DetectorSettings } from "./types/configTypes";
import * as vscode from "vscode";
import {
CommandLineArgumentGroup,
CreateAnalysisResult,
SlitherDetectorType,
VersionData,
} from './types/languageServerTypes'
} from "./types/languageServerTypes";
import {
AnalysisProgressParams,
SetCompilationTargetsParams,
} from './types/analysisTypes'
} from "./types/analysisTypes";

// The name of the language server executable
const lsp_executable_name = 'slither-lsp'
const lsp_executable_name = "slither-lsp";

export class SlitherLanguageClient {
public languageClient: LanguageClient
private socket: Socket | null = null
public languageClient: LanguageClient;
private socket: Socket | null = null;

private _analysisProgressEmitter: Emitter<AnalysisProgressParams> =
new Emitter<AnalysisProgressParams>()
new Emitter<AnalysisProgressParams>();
public onAnalysisProgress: vscode.Event<AnalysisProgressParams> =
this._analysisProgressEmitter.event
this._analysisProgressEmitter.event;

constructor(port: integer | null) {
// Define server options.
let serverOptions: ServerOptions
let serverOptions: ServerOptions;
if (port == null) {
// If we weren't given a port, we use stdio. We keep the process attached so when we exit, it exits.
serverOptions = {
run: {
command: lsp_executable_name,
args: [],
options: {detached: false},
options: { detached: false },
},
debug: {
command: lsp_executable_name,
args: [],
options: {detached: false},
options: { detached: false },
},
}
};
} else {
// If we were given a port, we establish a TCP socket connection to localhost.
let socket = new Socket()
this.socket = socket
let socket = new Socket();
this.socket = socket;

// Once we connect, our socket should be used for read/write handles in StreamInfo.
serverOptions = () => {
return new Promise((resolve, reject) => {
socket.connect(port, '127.0.0.1', () => {
resolve(<StreamInfo>{reader: this.socket, writer: this.socket})
})
})
}
socket.connect(port, "127.0.0.1", () => {
resolve(<StreamInfo>{ reader: this.socket, writer: this.socket });
});
});
};
}

// Define the language to register the server for.
let clientOptions: LanguageClientOptions = {
documentSelector: [{scheme: 'file', language: 'solidity'}],
}
documentSelector: [{ scheme: "file", language: "solidity" }],
};

// Define the language
this.languageClient = new LanguageClient(
'slither-lsp',
'Slither Language Server',
"slither-lsp",
"Slither Language Server",
serverOptions,
clientOptions,
)
clientOptions
);

// Define handlers for some requests/notifications.
this.languageClient.onNotification(
'$/analysis/reportAnalysisProgress',
"$/analysis/reportAnalysisProgress",
(params: AnalysisProgressParams) => {
this._analysisProgressEmitter.fire(params)
},
)
this._analysisProgressEmitter.fire(params);
}
);
}

public async start(callback: () => void) {
// When the language client is ready, execute the callback.
await this.languageClient.start().then(callback)
await this.languageClient.start().then(callback);
}

public async stop() {
if (this.languageClient) {
this.languageClient.stop()
this.languageClient.stop();
}
}

public async getVersionData(): Promise<VersionData> {
// Obtain version data.
return await this.languageClient.sendRequest('$/slither/getVersion', null)
return await this.languageClient.sendRequest("$/slither/getVersion", null);
}

//#region slither Methods

public async getDetectorTypeList(): Promise<SlitherDetectorType[]> {
// Obtain the list of all detectors our installation of slither has.
return await this.languageClient.sendRequest(
'$/slither/getDetectorList',
null,
)
"$/slither/getDetectorList",
null
);
}

public async setCompilationTargets(
compilationTargets: CompilationTarget[],
compilationTargets: CompilationTarget[]
): Promise<void> {
// Create our params to send.
let params: SetCompilationTargetsParams = {targets: compilationTargets}
let params: SetCompilationTargetsParams = { targets: compilationTargets };

// Send the command and return the result.
await this.languageClient.sendRequest(
'$/compilation/setCompilationTargets',
params,
)
"$/compilation/setCompilationTargets",
params
);
}

public async setDetectorSettings(
detectorSettings: DetectorSettings,
detectorSettings: DetectorSettings
): Promise<void> {
// Send the command and return the result.
await this.languageClient.sendRequest(
'$/slither/setDetectorSettings',
detectorSettings,
)
"$/slither/setDetectorSettings",
detectorSettings
);
}

//#endregion
Expand All @@ -144,15 +144,15 @@ export class SlitherLanguageClient {
CommandLineArgumentGroup[]
> {
// Create our params to send.
let params = {}
let params = {};

// Send the command and return the result.
let results: CommandLineArgumentGroup[] =
await this.languageClient.sendRequest(
'$/cryticCompile/getCommandLineArguments',
params,
)
return results
"$/cryticCompile/getCommandLineArguments",
params
);
return results;
}

//#endregion
Expand Down
Loading

0 comments on commit f0aa397

Please sign in to comment.