Make qucikfix infrastructure work across concourse and cf editors
This commit is contained in:
@@ -10,9 +10,11 @@ import * as FS from 'fs';
|
||||
import PortFinder = require('portfinder');
|
||||
import * as Net from 'net';
|
||||
import * as ChildProcess from 'child_process';
|
||||
import { LanguageClient, LanguageClientOptions, SettingMonitor, ServerOptions, StreamInfo } from 'vscode-languageclient';
|
||||
import { RequestType, LanguageClient, LanguageClientOptions, SettingMonitor, ServerOptions, StreamInfo } from 'vscode-languageclient';
|
||||
import { TextDocument, OutputChannel, Disposable, window } from 'vscode';
|
||||
import { Trace } from 'vscode-jsonrpc';
|
||||
import * as p2c from 'vscode-languageclient/lib/protocolConverter';
|
||||
import {WorkspaceEdit} from 'vscode-languageserver-types';
|
||||
|
||||
PortFinder.basePort = 45556;
|
||||
|
||||
@@ -28,7 +30,33 @@ export interface ActivatorOptions {
|
||||
jvmHeap?: string;
|
||||
}
|
||||
|
||||
interface QuickfixRequest {
|
||||
type: string;
|
||||
params: any;
|
||||
}
|
||||
|
||||
export function activate(options: ActivatorOptions, context: VSCode.ExtensionContext): Promise<LanguageClient> {
|
||||
let clientPromise = _activate(options, context);
|
||||
let commands = VSCode.commands
|
||||
commands.registerCommand("sts.quickfix", (fixType, fixParams) => {
|
||||
return clientPromise.then(client => {
|
||||
let type : RequestType<QuickfixRequest, WorkspaceEdit, void> = {method : "sts/quickfix"};
|
||||
let params : QuickfixRequest = {type: fixType, params: fixParams};
|
||||
return client.sendRequest(type, params)
|
||||
.then(
|
||||
(edit) => {
|
||||
return VSCode.workspace.applyEdit(p2c.asWorkspaceEdit(edit))
|
||||
},
|
||||
(error) => {
|
||||
return VSCode.window.showErrorMessage(""+error)
|
||||
}
|
||||
);
|
||||
})
|
||||
});
|
||||
return clientPromise;
|
||||
}
|
||||
|
||||
function _activate(options: ActivatorOptions, context: VSCode.ExtensionContext): Promise<LanguageClient> {
|
||||
let DEBUG = options.DEBUG;
|
||||
let jvmHeap = options.jvmHeap;
|
||||
if (options.CONNECT_TO_LS) {
|
||||
|
||||
@@ -8,10 +8,8 @@ import * as Path from 'path';
|
||||
import * as FS from 'fs';
|
||||
import * as Net from 'net';
|
||||
import * as ChildProcess from 'child_process';
|
||||
import {LanguageClient, RequestType, LanguageClientOptions, SettingMonitor, ServerOptions, StreamInfo} from 'vscode-languageclient';
|
||||
import {LanguageClient, LanguageClientOptions, SettingMonitor, ServerOptions, StreamInfo} from 'vscode-languageclient';
|
||||
import {TextDocument, OutputChannel} from 'vscode';
|
||||
import {WorkspaceEdit} from 'vscode-languageserver-types';
|
||||
import * as p2c from 'vscode-languageclient/lib/protocolConverter';
|
||||
|
||||
var log_output : OutputChannel = null;
|
||||
|
||||
@@ -30,14 +28,8 @@ function error(msg : string) {
|
||||
}
|
||||
}
|
||||
|
||||
interface QuickfixRequest {
|
||||
type: string;
|
||||
params: any;
|
||||
}
|
||||
|
||||
/** Called when extension is activated */
|
||||
export function activate(context: VSCode.ExtensionContext) {
|
||||
let commands = VSCode.commands
|
||||
let options : commons.ActivatorOptions = {
|
||||
DEBUG : false,
|
||||
CONNECT_TO_LS: false,
|
||||
@@ -56,20 +48,5 @@ export function activate(context: VSCode.ExtensionContext) {
|
||||
}
|
||||
};
|
||||
let clientPromise = commons.activate(options, context);
|
||||
commands.registerCommand("sts.quickfix", (fixType, fixParams) => {
|
||||
return clientPromise.then(client => {
|
||||
let type : RequestType<QuickfixRequest, WorkspaceEdit, void> = {method : "sts/quickfix"};
|
||||
let params : QuickfixRequest = {type: fixType, params: fixParams};
|
||||
return client.sendRequest(type, params)
|
||||
.then(
|
||||
(edit) => {
|
||||
return VSCode.workspace.applyEdit(p2c.asWorkspaceEdit(edit))
|
||||
},
|
||||
(error) => {
|
||||
return VSCode.window.showErrorMessage(""+error)
|
||||
}
|
||||
);
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user