Add quickfix for missing properties in concourse editor
This commit is contained in:
@@ -28,11 +28,11 @@ export interface ActivatorOptions {
|
||||
jvmHeap?: string;
|
||||
}
|
||||
|
||||
export function activate(options: ActivatorOptions, context: VSCode.ExtensionContext) {
|
||||
export function activate(options: ActivatorOptions, context: VSCode.ExtensionContext): Promise<LanguageClient> {
|
||||
let DEBUG = options.DEBUG;
|
||||
let jvmHeap = options.jvmHeap;
|
||||
if (options.CONNECT_TO_LS) {
|
||||
connectToLS(context, options);
|
||||
return connectToLS(context, options);
|
||||
} else {
|
||||
let clientOptions = options.clientOptions;
|
||||
let fatJarFile = Path.resolve(context.extensionPath, options.fatJarFile);
|
||||
@@ -61,7 +61,7 @@ export function activate(options: ActivatorOptions, context: VSCode.ExtensionCon
|
||||
log("Found java exe: " + javaExecutablePath);
|
||||
|
||||
|
||||
isJava8(javaExecutablePath).then(eight => {
|
||||
return isJava8(javaExecutablePath).then(eight => {
|
||||
if (!eight) {
|
||||
VSCode.window.showErrorMessage('Java-based Language Server requires Java 8 (using ' + javaExecutablePath + ')');
|
||||
return;
|
||||
@@ -109,12 +109,12 @@ export function activate(options: ActivatorOptions, context: VSCode.ExtensionCon
|
||||
});
|
||||
}
|
||||
|
||||
setupLanguageClient(context, createServer, options);
|
||||
return Promise.resolve(setupLanguageClient(context, createServer, options));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function connectToLS(context: VSCode.ExtensionContext, options: ActivatorOptions) {
|
||||
function connectToLS(context: VSCode.ExtensionContext, options: ActivatorOptions): Promise<LanguageClient> {
|
||||
let connectionInfo = {
|
||||
port: 5007
|
||||
};
|
||||
@@ -128,10 +128,10 @@ function connectToLS(context: VSCode.ExtensionContext, options: ActivatorOptions
|
||||
return Promise.resolve(result);
|
||||
};
|
||||
|
||||
setupLanguageClient(context, serverOptions, options);
|
||||
return Promise.resolve(setupLanguageClient(context, serverOptions, options));
|
||||
}
|
||||
|
||||
function setupLanguageClient(context: VSCode.ExtensionContext, createServer: ServerOptions, options: ActivatorOptions) {
|
||||
function setupLanguageClient(context: VSCode.ExtensionContext, createServer: ServerOptions, options: ActivatorOptions): LanguageClient {
|
||||
// Create the language client and start the client.
|
||||
let client = new LanguageClient(options.extensionId, options.extensionId,
|
||||
createServer, options.clientOptions
|
||||
@@ -150,6 +150,7 @@ function setupLanguageClient(context: VSCode.ExtensionContext, createServer: Ser
|
||||
// client can be deactivated on extension deactivation
|
||||
context.subscriptions.push(disposable);
|
||||
context.subscriptions.push(progressService);
|
||||
return client
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -2,13 +2,14 @@
|
||||
{
|
||||
"version": "0.1.0",
|
||||
"configurations": [
|
||||
|
||||
{
|
||||
"name": "Launch Extension",
|
||||
"type": "extensionHost",
|
||||
"request": "launch",
|
||||
"runtimeExecutable": "${execPath}",
|
||||
"args": ["--extensionDevelopmentPath=${workspaceRoot}" ],
|
||||
"stopOnEntry": false,
|
||||
"stopOnEntry": true,
|
||||
"sourceMaps": true,
|
||||
"outDir": "${workspaceRoot}/out/lib",
|
||||
"preLaunchTask": "npm"
|
||||
|
||||
@@ -8,8 +8,10 @@ import * as Path from 'path';
|
||||
import * as FS from 'fs';
|
||||
import * as Net from 'net';
|
||||
import * as ChildProcess from 'child_process';
|
||||
import {LanguageClient, LanguageClientOptions, SettingMonitor, ServerOptions, StreamInfo} from 'vscode-languageclient';
|
||||
import {LanguageClient, RequestType, 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;
|
||||
|
||||
@@ -28,8 +30,14 @@ 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,
|
||||
@@ -47,6 +55,21 @@ export function activate(context: VSCode.ExtensionContext) {
|
||||
}
|
||||
}
|
||||
};
|
||||
commons.activate(options, context);
|
||||
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)
|
||||
}
|
||||
);
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -28,6 +28,12 @@
|
||||
"onLanguage:concourse-task-yaml"
|
||||
],
|
||||
"contributes": {
|
||||
"commands": [
|
||||
{
|
||||
"command": "mycommand.sayHello",
|
||||
"title": "Say Hello"
|
||||
}
|
||||
],
|
||||
"languages": [
|
||||
{
|
||||
"id": "concourse-pipeline-yaml",
|
||||
@@ -84,7 +90,7 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"vsce": "^1.17.0",
|
||||
"typescript": "^2.0.x",
|
||||
"typescript": "^2.2.x",
|
||||
"@types/node": "^6.0.40",
|
||||
"vscode": "^1.0.0"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user