Skip to content
This repository was archived by the owner on Dec 15, 2022. It is now read-only.

Commit 437d5e1

Browse files
author
Winston Liu
authored
Merge pull request #110 from atom/wl-preferences
Enable sending configuration changes to the language server
2 parents d9460f7 + 32b5d0a commit 437d5e1

File tree

2 files changed

+64
-46
lines changed

2 files changed

+64
-46
lines changed

lib/main.js

Lines changed: 27 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,30 @@ class JavaLanguageClient extends AutoLanguageClient {
2121
getGrammarScopes () { return [ 'source.java' ] }
2222
getLanguageName () { return 'Java' }
2323
getServerName () { return 'Eclipse JDT' }
24+
// List of preferences available at:
25+
// https://github.com/eclipse/eclipse.jdt.ls/blob/master/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/preferences/Preferences.java
26+
getRootConfigurationKey() { return 'ide-java.server' }
27+
mapConfigurationObject(configuration) { return {java: configuration} }
2428

2529
constructor () {
2630
super()
2731
this.statusElement = document.createElement('span')
2832
this.statusElement.className = 'inline-block'
2933

3034
this.commands = {
31-
'java.ignoreIncompleteClasspath': () => { atom.config.set('ide-java.errors.incompleteClasspathSeverity', 'ignore') },
32-
'java.ignoreIncompleteClasspath.help': () => { shell.openExternal('https://github.com/atom/ide-java/wiki/Incomplete-Classpath-Warning') }
35+
'java.ignoreIncompleteClasspath': () => {
36+
atom.config.set('ide-java.server.errors.incompleteClasspath.severity', 'ignore')
37+
},
38+
'java.ignoreIncompleteClasspath.help': () => { shell.openExternal('https://github.com/atom/ide-java/wiki/Incomplete-Classpath-Warning') },
39+
}
40+
41+
// Migrate ide-java.errors.incompleteClasspathSeverity -> ide-java.server.errors.incompleteClasspath.severity
42+
// Migration added in v0.10.0; feel free to remove after a few versions
43+
const severity = atom.config.get('ide-java.errors.incompleteClasspathSeverity')
44+
if (severity) {
45+
atom.config.unset('ide-java.errors.incompleteClasspathSeverity')
46+
atom.config.unset('ide-java.errors')
47+
atom.config.set('ide-java.server.errors.incompleteClasspath.severity', severity)
3348
}
3449
}
3550

@@ -196,7 +211,7 @@ class JavaLanguageClient extends AutoLanguageClient {
196211

197212
preInitialization(connection) {
198213
connection.onCustom('language/status', (e) => this.updateStatusBar(`${e.type.replace(/^Started$/, '')} ${e.message}`))
199-
connection.onCustom('language/actionableNotification', this.actionableNotification.bind(this))
214+
connection.onCustom('language/actionableNotification', (notification) => this.actionableNotification(notification, connection))
200215
}
201216

202217
getInitializeParams(projectPath, process) {
@@ -205,11 +220,6 @@ class JavaLanguageClient extends AutoLanguageClient {
205220
params.initializationOptions = {};
206221
}
207222
params.initializationOptions.bundles = this.collectJavaExtensions();
208-
params.initializationOptions.settings = {
209-
java: {
210-
"java.signatureHelp.enabled": true
211-
}
212-
}
213223
return params;
214224
}
215225

@@ -246,39 +256,23 @@ class JavaLanguageClient extends AutoLanguageClient {
246256
}
247257
}
248258

249-
actionableNotification (notification) {
250-
if (notification.message.startsWith('Classpath is incomplete.')) {
251-
switch(atom.config.get('ide-java.errors.incompleteClasspathSeverity')) {
252-
case 'ignore': return
253-
case 'error': {
254-
notification.severity = 1
255-
break
256-
}
257-
case 'warning': {
258-
notification.severity = 2
259-
break
260-
}
261-
case 'info': {
262-
notification.severity = 3
263-
break
264-
}
265-
}
266-
}
267-
259+
actionableNotification (notification, connection) {
268260
const options = { dismissable: true, detail: this.getServerName() }
269261
if (Array.isArray(notification.commands)) {
270-
options.buttons = notification.commands.map(c => ({ text: c.title, onDidClick: (e) => onActionableButton(e, c.command) }))
271-
// TODO: Deal with the actions
262+
options.buttons = notification.commands.map(command => ({
263+
text: command.title,
264+
onDidClick: () => onActionableButton(command)
265+
}))
272266
}
273267

274268
const notificationDialog = this.createNotification(notification.severity, notification.message, options)
275269

276-
const onActionableButton = (event, commandName) => {
277-
const commandFunction = this.commands[commandName]
270+
const onActionableButton = (command) => {
271+
const commandFunction = this.commands[command.command]
278272
if (commandFunction != null) {
279-
commandFunction()
273+
commandFunction(command, connection)
280274
} else {
281-
console.log(`Unknown actionableNotification command '${commandName}'`)
275+
console.log(`Unknown actionableNotification command '${command.command}'`)
282276
}
283277
notificationDialog.dismiss()
284278
}

package.json

Lines changed: 37 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,22 +29,46 @@
2929
}
3030
}
3131
},
32-
"errors": {
32+
"server": {
3333
"order": 30,
3434
"type": "object",
35-
"title": "Warnings and Errors",
35+
"title": "Language Server",
36+
"description": "Settings that control language server functionality.",
3637
"properties": {
37-
"incompleteClasspathSeverity": {
38-
"type": "string",
39-
"title": "Incomplete Classpath Severity",
40-
"enum": [
41-
"ignore",
42-
"info",
43-
"warning",
44-
"error"
45-
],
46-
"default": "warning",
47-
"description": "Severity of the message when the classpath is incomplete for a Java file."
38+
"signatureHelp": {
39+
"type": "object",
40+
"title": "Signature Help",
41+
"properties": {
42+
"enabled": {
43+
"type": "boolean",
44+
"default": true,
45+
"description": "Controls whether signature help is enabled."
46+
}
47+
}
48+
},
49+
"errors": {
50+
"type": "object",
51+
"title": "Warnings and Errors",
52+
"properties": {
53+
"incompleteClasspath": {
54+
"type": "object",
55+
"title": "Incomplete Classpath",
56+
"properties": {
57+
"severity": {
58+
"type": "string",
59+
"title": "Incomplete Classpath Severity",
60+
"enum": [
61+
"ignore",
62+
"info",
63+
"warning",
64+
"error"
65+
],
66+
"default": "warning",
67+
"description": "Severity of the message when the classpath is incomplete for a Java file."
68+
}
69+
}
70+
}
71+
}
4872
}
4973
}
5074
}

0 commit comments

Comments
 (0)