Initial commit for atom-spring-boot

This commit is contained in:
BoykoAlex
2018-02-21 14:47:09 -05:00
parent 6745fb4925
commit 898fc3ebd6
9 changed files with 349 additions and 1 deletions

View File

@@ -0,0 +1,3 @@
.idea/
server/
node_modules/

View File

@@ -0,0 +1,3 @@
.idea/
server/
node_modules/

View File

@@ -0,0 +1,140 @@
const path = require('path');
const { JavaProcessLanguageClient, StsAdapter } = require('pivotal-atom-languageclient-commons');
const { Convert } = require('atom-languageclient');
const PROPERTIES = require('../properties.json');
const BOOT_DATA_MARKER_TYPE = 'BootApp-Hint';
const BOOT_HINT_GUTTER_NAME = 'boot-hint-gutter';
class SpringBootLanguageClient extends JavaProcessLanguageClient {
constructor() {
//noinspection JSAnnotator
super(
PROPERTIES.jarUrl,
path.join(__dirname, '..', 'server'),
'spring-boot-language-server.jar'
);
// this.DEBUG = true;
}
postInitialization(server) {
this.sendConfig(server);
this._disposable.add(atom.config.observe('boot-java', () => this.sendConfig(server)));
}
sendConfig(server) {
server.connection.didChangeConfiguration({ settings: {'boot-java': atom.config.get('boot-java') }});
}
getGrammarScopes() {
return ['source.java'];
}
getLanguageName() {
return 'spring-boot';
}
getServerName() {
return 'Spring Boot';
}
activate() {
require('atom-package-deps')
.install('boot-java')
.then(() => console.debug('All dependencies installed, good to go'));
super.activate();
}
getOrInstallLauncher() {
return Promise.resolve('org.springframework.boot.loader.JarLauncher');
}
launchVmArgs(version) {
return super.getOrInstallLauncher().then(lsJar => {
const toolsJar = this.findJavaFile('lib', 'tools.jar');
if (version < 9 && !toolsJar) {
// Notify the user that tool.jar is not found
const notification = atom.notifications.addWarning(`"Boot-Java" Package Functionality Limited`, {
dismissable: true,
detail: 'No tools.jar found',
description: 'JAVA_HOME environment variable points either to JRE or JDK missing "lib/tools.jar" hence Boot Hints are unavailable',
buttons: [{
text: 'OK',
onDidClick: () => {
notification.dismiss()
},
}],
});
}
return [
// '-Xdebug',
// '-agentlib:jdwp=transport=dt_socket,server=y,address=7999,suspend=n',
'-Dorg.slf4j.simpleLogger.logFile=boot-java.log',
'-Dorg.slf4j.simpleLogger.defaultLogLevel=debug',
'-cp',
`${toolsJar ? `${toolsJar}${path.delimiter}` : ''}${lsJar}`
];
});
}
createStsAdapter() {
return new BootStsAdapter();
}
filterChangeWatchedFiles(filePath) {
return filePath.endsWith('.gradle') || filePath.endsWith(path.join('', 'pom.xml'));
}
}
class BootStsAdapter extends StsAdapter {
constructor() {
super();
}
onHighlight(params) {
this.findEditors(params.doc.uri).forEach(editor => this.markHintsForEditor(editor, params.ranges));
}
markHintsForEditor(editor, ranges) {
editor.findMarkers(BOOT_DATA_MARKER_TYPE).forEach(m => m.destroy());
if (Array.isArray(ranges)) {
ranges.forEach(range => this.createHintMarker(editor, range));
}
const gutter = editor.gutterWithName(BOOT_HINT_GUTTER_NAME);
if (gutter) {
if (!ranges || !ranges.length) {
gutter.hide();
} else if (!gutter.isVisible()) {
gutter.show();
}
}
}
createHintMarker(editor, range) {
// Create marker model
const marker = editor.markBufferRange(Convert.lsRangeToAtomRange(range), BOOT_DATA_MARKER_TYPE);
// Marker around the text in the editor
editor.decorateMarker(marker, {
type: 'highlight',
class: 'boot-hint'
});
// Marker in the diagnostic gutter
let gutter = editor.gutterWithName(BOOT_HINT_GUTTER_NAME);
if (!gutter) {
gutter = editor.addGutter({
name: BOOT_HINT_GUTTER_NAME,
visible: false,
});
}
const iconElement = document.createElement('span');
iconElement.setAttribute('class', 'gutter-boot-hint');
gutter.decorateMarker(marker, {item: iconElement});
}
}
module.exports = new SpringBootLanguageClient();

View File

@@ -0,0 +1,90 @@
{
"name": "spring-boot",
"main": "./lib/main",
"version": "0.1.4",
"description": "Spring Boot support for Atom",
"repository": "https://github.com/spring-projects/atom-spring-boot",
"icon": "icon.png",
"license": "MIT",
"engines": {
"atom": ">=1.21.0"
},
"files": [
"lib/",
"server/",
"styles/",
"properties.json"
],
"configSchema": {
"boot-hints.on": {
"type": "boolean",
"default": true,
"description": "Enable/Disable Spring running Boot application live hints decorators in the source code"
}
},
"dependencies": {
"atom-package-deps": "^4.6.0",
"download": "^6.2.5",
"pivotal-atom-languageclient-commons": "0.0.19"
},
"devDependencies": {
"coffeelint": "^1.10.1"
},
"scripts": {
"clean": "rm -fr node_modules",
"postinstall": "node script.js"
},
"package-deps": [
"atom-ide-ui",
"ide-java"
],
"consumedServices": {
"linter-indie": {
"versions": {
"2.0.0": "consumeLinterV2"
}
},
"datatip": {
"versions": {
"0.1.0": "consumeDatatip"
}
}
},
"providedServices": {
"autocomplete.provider": {
"versions": {
"2.0.0": "provideAutocomplete"
}
},
"code-actions": {
"versions": {
"0.1.0": "provideCodeActions"
}
},
"code-format.range": {
"versions": {
"0.1.0": "provideCodeFormat"
}
},
"code-highlight": {
"versions": {
"0.1.0": "provideCodeHighlight"
}
},
"definitions": {
"versions": {
"0.1.0": "provideDefinitions"
}
},
"find-references": {
"versions": {
"0.1.0": "provideFindReferences"
}
},
"outline-view": {
"versions": {
"0.1.0": "provideOutlines"
}
}
}
}

View File

@@ -0,0 +1,3 @@
{
"jarUrl": "https://s3-us-west-1.amazonaws.com/s3-test.spring.io/sts4/fatjars/snapshots/boot-java-language-server-0.0.10-201711061741.jar"
}

View File

@@ -0,0 +1,34 @@
const fs = require('fs');
const path = require('path');
const download = require('download');
const PROPERTIES = require('./properties.json');
let fileExists = function(path) {
return new Promise((resolve, reject) => {
fs.access(path, fs.R_OK, error => {
resolve(!error || error.code !== 'ENOENT');
})
});
};
const serverDownloadUrl = PROPERTIES.jarUrl;
const serverHome = path.join(__dirname, 'server');
const localFileName = path.join(serverHome, 'spring-boot-language-server.jar');
fileExists(localFileName).then(exists => {
if (!exists) {
console.log(`Downloading ${serverDownloadUrl} to ${localFileName}`);
fileExists(serverHome)
.then(doesExist => { if (!doesExist) fs.mkdir(serverHome) })
.then(() => download(serverDownloadUrl))
.then(data => fs.writeFileSync(localFileName, data))
.then(() => fileExists(localFileName))
.then(doesExist => { if (!doesExist) throw Error(`Failed to install the ${this.getServerName()} language server`) })
.then(() => console.log(`Successfully downloaded ${serverDownloadUrl}`));
}
});

Binary file not shown.

After

Width:  |  Height:  |  Size: 617 B

View File

@@ -0,0 +1,16 @@
.boot-hint .region {
border-color: #32BA56;
border-style: dotted;
border-width: 1px;
}
atom-text-editor.editor {
.gutter-boot-hint:before {
content: url("atom://spring-boot/styles/boot-icon.png");
display: block;
width: 10px;
height: 1em;
margin: 0 2px 0 0;
float: left;
}
}

View File

@@ -54,6 +54,12 @@ resources:
branch: ((branch))
private_key: ((rsa_id))
uri: git@github.com:spring-projects/atom-bosh.git
- name: atom-spring-boot
type: git
source:
branch: ((branch))
private_key: ((rsa_id))
uri: git@github.com:spring-projects/atom-spring-boot.git
- name: atom-boot-java
type: git
source:
@@ -194,6 +200,14 @@ resources:
secret_access_key: ((s3_secretkey))
region_name: ((s3_region))
regexp: sts4/fatjars/snapshots/boot-properties-language-server-(.*).jar
- name: s3-spring-boot-fatjar-snapshot
type: s3
source:
bucket: ((s3_bucket))
access_key_id: ((s3_accesskey))
secret_access_key: ((s3_secretkey))
region_name: ((s3_region))
regexp: sts4/fatjars/snapshots/spring-boot-language-server-(.*).jar
- name: s3-boot-properties-fatjar--rc
type: s3
source:
@@ -226,6 +240,14 @@ resources:
secret_access_key: ((s3_secretkey))
region_name: ((s3_region))
regexp: sts4/atom/snapshots/bosh-yaml-(.*).tgz
- name: s3-spring-boot-atom-snapshot
type: s3
source:
bucket: ((s3_bucket))
access_key_id: ((s3_accesskey))
secret_access_key: ((s3_secretkey))
region_name: ((s3_region))
regexp: sts4/atom/snapshots/spring-boot-(.*).tgz
- name: s3-boot-java-atom-snapshot
type: s3
source:
@@ -321,7 +343,6 @@ jobs:
trigger: true
- get: maven-cache
- task: build-boot-properties-vsix-snapshot
attempts: 3 #Because its a bit flaky with the maven bits
file: sts4/concourse/tasks/build-vsix.yml
params:
extension_id: vscode-boot-properties
@@ -1000,6 +1021,10 @@ jobs:
params:
file: out/boot-properties-language-server-*.jar
acl: public-read
- put: s3-spring-boot-fatjar-snapshot
params:
file: out/spring-boot-language-server-*.jar
acl: public-read
- name: build-manifest-yaml-atom-package
serial: true
plan:
@@ -1132,6 +1157,39 @@ jobs:
params:
text: |
Concourse ${BUILD_PIPELINE_NAME}/${BUILD_JOB_NAME}/${BUILD_NAME} has failed!
- name: build-spring-boot-atom-package
serial: true
plan:
- aggregate:
- get: sts4
passed:
- atom-language-servers-test
- get: atom-spring-boot
- get: s3-spring-boot-fatjar-snapshot
trigger: true
passed:
- atom-language-servers-test
- task: build-spring-boot-atom-package
params:
package_name: atom-spring-boot
input_mapping:
fatjar: s3-spring-boot-fatjar-snapshot
release_repo: atom-spring-boot
file: sts4/concourse/tasks/build-atom-package.yml
- aggregate:
- put: s3-spring-boot-atom-snapshot
params:
file: out/spring-boot-*.tgz
acl: public-read
- put: atom-spring-boot
params:
repository: out/repo
rebase: true
on_failure:
put: slack-notification
params:
text: |
Concourse ${BUILD_PIPELINE_NAME}/${BUILD_JOB_NAME}/${BUILD_NAME} has failed!
- name: build-boot-properties-atom-package
serial: true
plan:
@@ -1203,6 +1261,7 @@ groups:
- build-manifest-yaml-atom-package
- build-boot-java-atom-package
- build-boot-properties-atom-package
- build-spring-boot-atom-package
- name: atom-rc
jobs:
- prepare-boot-java-atom-rc