Adjust quick fix for Atom extensions

This commit is contained in:
BoykoAlex
2017-09-26 17:36:33 -04:00
parent 4173b22d9d
commit f3836c4770
8 changed files with 72 additions and 5 deletions

View File

@@ -17,7 +17,7 @@
"dependencies": {
"atom-package-deps": "^4.6.0",
"download": "^6.2.5",
"pivotal-atom-languageclient-commons": "0.0.10"
"pivotal-atom-languageclient-commons": "0.0.11"
},
"devDependencies": {
"coffeelint": "^1.10.1"

View File

@@ -19,7 +19,7 @@
"dependencies": {
"atom-package-deps": "^4.6.0",
"download": "^6.2.5",
"pivotal-atom-languageclient-commons": "0.0.10"
"pivotal-atom-languageclient-commons": "0.0.11"
},
"configSchema": {
"bosh": {

View File

@@ -19,7 +19,7 @@
"dependencies": {
"atom-package-deps": "^4.6.0",
"download": "^6.2.5",
"pivotal-atom-languageclient-commons": "0.0.10"
"pivotal-atom-languageclient-commons": "0.0.11"
},
"devDependencies": {
"coffeelint": "^1.10.1"

View File

@@ -8,6 +8,7 @@ const net = require('net');
const rpc = require('vscode-jsonrpc');
const {AutoLanguageClient, DownloadFile} = require('atom-languageclient');
const { Disposable } = require('atom');
import { StsAdapter } from './sts-adapter';
export class JarLanguageClient extends AutoLanguageClient {
@@ -53,6 +54,13 @@ export class JarLanguageClient extends AutoLanguageClient {
});
}
// Start adapters that are not shared between servers
startExclusiveAdapters(server) {
super.startExclusiveAdapters(server);
StsAdapter.attach(server.connection);
}
launchProcess(port) {
const command = this.findJavaExecutable('java');

View File

@@ -0,0 +1,21 @@
import {Convert} from 'atom-languageclient';
export class StsAdapter {
// Public: Attach to a {StsLanguageClientConnection} to receive messages.
static attach(connection) {
connection._onRequest({method: 'sts/moveCursor'}, params => StsAdapter.onMoveCursor(params));
connection._onNotification({method: 'sts/progress'}, params => StsAdapter.onProgress(params));
}
static onMoveCursor(params) {
atom.workspace.getTextEditors()
.filter(e => Convert.pathToUri(e.getPath()) === params.uri)
.forEach(e => e.setCursorScreenPosition(Convert.positionToPoint(params.position)));
return { applied: true};
}
static onProgress(params) {
console.log('PROGRESS: ' + JSON.stringify(params));
}
}

View File

@@ -1,6 +1,6 @@
{
"name": "pivotal-atom-languageclient-commons",
"version": "0.0.10",
"version": "0.0.11",
"description": "Atom language client commons for STS4 language servers",
"repository": "https://github.com/spring-projects/sts4",
"license": "MIT",

View File

@@ -19,7 +19,7 @@
"dependencies": {
"atom-package-deps": "^4.6.0",
"download": "^6.2.5",
"pivotal-atom-languageclient-commons": "0.0.10"
"pivotal-atom-languageclient-commons": "0.0.11"
},
"devDependencies": {
"coffeelint": "^1.10.1"

View File

@@ -106,6 +106,44 @@ public class ConcourseEditorTest {
);
}
@Test public void quickfixForOneOfMultipleMarkersOnSameRange() throws Exception {
Editor editor = harness.newEditor(
"jobs:\n" +
"- name: myjob\n" +
" plan:\n" +
" - task: foo\n" +
" config:\n" +
" inputs:\n" +
" - name: foo"
);
List<Diagnostic> problems = editor.assertProblems(
"config|[image_resource, rootfs_uri, image] is required",
"config|[platform, run] are required"
);
CodeAction quickfix = editor.assertCodeAction(problems.get(0));
//TODO: fix https://www.pivotaltracker.com/story/show/151460687 and uncomment code below
// assertEquals(null, quickfix);
quickfix = editor.assertCodeAction(problems.get(1));
assertEquals("Add properties: [platform, run]", quickfix.getLabel());
quickfix.perform();
editor.assertText(
"jobs:\n" +
"- name: myjob\n" +
" plan:\n" +
" - task: foo\n" +
" config:\n" +
" inputs:\n" +
" - name: foo\n" +
" platform: <*>\n" +
" run:\n" +
" path: "
);
}
@Test public void reconcileResourceTypeType() throws Exception {
Editor editor;
editor = harness.newEditor(