rhamt-vscode-extension
Version:
RHAMT VSCode extension
143 lines (113 loc) • 5.09 kB
text/typescript
// 'use strict';
// import * as vscode from "vscode";
// import { window, ProgressLocation } from 'vscode';
// import { Utils } from "./Utils";
// import { RhamtClient } from 'rhamt-client';
// import { RuntimeConfiguration, RhamtConfiguration } from "rhamt-core";
// export class RhamtService {
// private rhamtClient?: RhamtClient;
// public async startServer() {
// Utils.createConfiguration()
// .then(config => {
// let runtime = new RuntimeConfiguration();
// runtime.javaHome = config.javaHome;
// runtime.rhamtCli = config.rhamtCli;
// runtime.port = Number(process.env.PORT) || 8080;
// this.rhamtClient = new RhamtClient();
// let options = {
// location: ProgressLocation.Window,
// cancellable: false
// };
// window.withProgress(options, async (progress, token) => {
// token.onCancellationRequested(() => {
// console.log('cancelled');
// });
// progress.report({message: 'Starting analysis engine'});
// this.initServerListeners(config);
// var p = new Promise(resolve => {
// this.rhamtClient!.start(runtime).then(() => {
// progress.report({message: 'Started'});
// setTimeout(() => {
// resolve();
// }, 1500);
// });
// });
// return p;
// });
// })
// .catch(() => {
// console.log('unable to create run configuration.');
// });
// }
// private initServerListeners(config: RhamtConfiguration): void {
// config.stoppedCallback = () => {
// vscode.window.showInformationMessage('analysis engine stopped');
// };
// config.timeoutCallback = () => {
// vscode.window.showErrorMessage('analysis engine start timeout');
// };
// }
// public stopServer() {
// console.log('attempting to stop the rhamt-client');
// if (this.rhamtClient && this.rhamtClient.isRunning()) {
// window.withProgress({
// location: ProgressLocation.Notification,
// title: "Stopping analysis engine",
// cancellable: true
// }, (progress, token) => {
// console.log('vscode rhamt-client server is running. attempting to terminate...');
// return new Promise((resolve, reject) => {
// this.rhamtClient!.stop()
// .then(() => {
// progress.report({ increment: 100, message: 'stopped' });
// resolve();
// })
// .catch(err => {
// reject();
// vscode.window.showErrorMessage(err);
// });
// });
// });
// }
// else {
// vscode.window.showInformationMessage('Analysis engine not running');
// }
// }
// public isRunning() : boolean {
// return this.rhamtClient!.isRunning();
// }
// public analyzeWorkspace() {
// if (vscode.workspace.workspaceFolders) {
// let locations = vscode.workspace.workspaceFolders.map(folder => folder.uri.fsPath);
// this.analyze(locations);
// }
// }
// public analyze(input: string[]) {
// console.log('attempting to start rhamt-client analysis');
// console.log('input: ' + input);
// let source = input[0];
// let out = source + '/../rhamt';
// const config = new RunConfiguration('mytester', source, out);
// this.rhamtClient!.analyze(config).then(() => {
// this.startProgress(config);
// })
// .catch(() => vscode.window.showInformationMessage('Unable to prepare analysis configuration'));
// }
// private startProgress(config: RunConfiguration): void {
// let options = {
// location: ProgressLocation.Window,
// cancellable: true
// };
// window.withProgress(options, (progress, token) => {
// token.onCancellationRequested(() => {
// console.log('cancelled');
// });
// progress.report({message: 'Preparing analysis configuration...'});
// var p = new Promise<any>(resolve => {
// let monitor = new ProgressMonitor(progress, () => resolve());
// config.handleMessage = monitor.handleMessage.bind(monitor);
// });
// return p;
// });
// }
// }