Skip to content
This repository has been archived by the owner on Apr 5, 2019. It is now read-only.

Commit

Permalink
SLATOM-6 Minor improvements, and debugging help (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
Janos Gyerik committed Jul 6, 2017
1 parent b456c62 commit 6cc4e07
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 13 deletions.
69 changes: 69 additions & 0 deletions develop.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
Development notes
=================

Working on this package
-----------------------

### General tips

- Install dependencies with `npm install`
- Remove the installed package from `~/.atom/packages` if exists
- Create a symlink to this Git clone in `~/.atom/packages`
- Have two windows open, one for dev and one for reloading
- To try the changes, reload the dev window with `window:reload` command (`control shift F5` in Linux)
- See also: http://flight-manual.atom.io/hacking-atom/sections/debugging/

Hacking atom-languageclient
---------------------------

Replace `node_modules/atom-languageclient` with your Git clone.

To try the changes in Atom, run `npm install`, and reload the dev window.

Run the tests with `npm run test`.

The upstream GitHub project (to contribute changes) is at `atom/atom-languageclient`.

You can enable debug logs with:

atom.config.set('core.debugLSP', true)

Packaging, publishing
---------------------

### Build

npm install

### Execute tests

atom --test spec

### Test installation from personal repo

apm install gh-user/repo

### Publish

Verify `package.json` content, especially version.

apm publish minor

See also: http://flight-manual.atom.io/hacking-atom/sections/publishing/

Misc
----

### Lifecycle of a package

This document explains nicely the steps performed during the startup of a package:

http://flight-manual.atom.io/hacking-atom/sections/package-word-count/

### Generate clean new package

It can be helpful sometimes to start clean.

- Generate package using command (`control shift p`)
- Creates a folder with basic files
- Registers the folder in ~/.atom/packages
2 changes: 1 addition & 1 deletion lib/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const path = require('path');

const languageServerInfo = {
basedir: 'files/server',
url: "https://repox.sonarsource.com/sonarsource-public-releases/org/sonarsource/sonarlint/core/sonarlint-language-server/2.15.0.797/sonarlint-language-server-2.15.0.797.jar",
url: "https://repox.sonarsource.com/sonarsource-public-builds/org/sonarsource/sonarlint/core/sonarlint-language-server/2.15.0.814/sonarlint-language-server-2.15.0.814.jar",
filename: "sonarlint-ls.jar"
}
const analyzerBasedir = 'files/analyzers'
Expand Down
15 changes: 6 additions & 9 deletions lib/requirements.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const expandHomeDir = require('expand-home-dir');
const findJavaHome = require('find-java-home');

const JAVA_BINARY = 'java' + ((process.platform.indexOf('win') === 0) ? '.exe' : '');
const javaHomeSettingName = 'sonarlint.javaHome'

exports.java = JAVA_BINARY;

Expand All @@ -27,7 +28,7 @@ function checkJavaRuntime() {
let source;
let javaHome = readJavaConfig();
if (javaHome) {
source = "The 'sonarlint.ls.javaHome' variable defined in settings";
source = `The '${javaHomeSettingName}' configuration defined in settings`;
} else {
javaHome = process.env['JDK_HOME'];
if (javaHome) {
Expand All @@ -40,17 +41,17 @@ function checkJavaRuntime() {
if (javaHome) {
javaHome = expandHomeDir(javaHome);
if (!pathExists.sync(javaHome)) {
openJREDownload(reject, source + ' points to a missing folder');
openJREDownload(reject, `${source} points to a non-existent folder: ${javaHome}`);
}
if (!pathExists.sync(path.resolve(javaHome, 'bin', JAVA_BINARY))){
openJREDownload(reject, source + ' does not point to a JRE.');
openJREDownload(reject, `${source} does not point to a JRE.`);
}
return resolve(javaHome);
}
//No settings, let's try to detect as last resort.
findJavaHome(function (err, home) {
if (err) {
openJREDownload(reject, "Java runtime could not be located. Install it and set its location using 'sonarlint.ls.javaHome' variable in settings.");
openJREDownload(reject, `Java runtime could not be located. Install it and set its location using '${javaHomeSettingName}' in settings.`);
} else {
resolve(home);
}
Expand All @@ -59,16 +60,12 @@ function checkJavaRuntime() {
}

function readJavaConfig() {
return atom.config.get('sonarlint.ls.javaHome');
return atom.config.get(javaHomeSettingName);
}

function checkJavaVersion(javaHome) {
return new Promise((resolve, reject) => {
const prog = path.resolve(javaHome, 'bin', JAVA_BINARY);
if ((fs.statSync(prog).mode & 1) == 0) {
openJREDownload(reject, "Java binary not an executable file: " + prog);
return;
}

cp.execFile(prog, ['-version'], {}, (error, stdout, stderr) => {
if (stderr.indexOf('version "9') > -1) {
Expand Down
15 changes: 12 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,17 @@
"files"
],
"dependencies": {
"atom-languageclient": "SonarSource/atom-languageclient#f1a0372e163191213edeefa13c8d3f8e7cf7a367",
"atom-languageclient": "SonarSource/atom-languageclient#43a843f5fa80b909b9a80d88409bfb92ad94350a",
"atom-linter": "^10.0.0",
"expand-home-dir": "0.0.3",
"find-java-home": "^0.1.4"
"find-java-home": "^0.1.4",
"path-exists": "^3.0.0"
},
"bundledDependencies": [
"atom-languageclient"
"atom-languageclient",
"expand-home-dir",
"find-java-home",
"path-exists"
],
"scripts": {
"prepublish": "node ./scripts/setup.js"
Expand All @@ -64,6 +68,11 @@
"gulp-zip": "^4.0.0"
},
"configSchema": {
"javaHome": {
"type": "string",
"default": "",
"order": 1
},
"testFilePattern": {
"type": "string",
"default": "{**/test/**,**/*test*,**/*Test*}",
Expand Down

0 comments on commit 6cc4e07

Please sign in to comment.