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

Commit 6333c12

Browse files
Winston LiuWinston Liu
authored andcommitted
Enable sending configuration changes to the language server
1 parent d9460f7 commit 6333c12

File tree

2 files changed

+54
-46
lines changed

2 files changed

+54
-46
lines changed

lib/main.js

Lines changed: 17 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,19 @@ class JavaLanguageClient extends AutoLanguageClient {
2121
getGrammarScopes () { return [ 'source.java' ] }
2222
getLanguageName () { return 'Java' }
2323
getServerName () { return 'Eclipse JDT' }
24+
getRootConfigurationKey() { return 'ide-java.server' }
25+
mapConfigurationObject(configuration) { return {java: configuration} }
2426

2527
constructor () {
2628
super()
2729
this.statusElement = document.createElement('span')
2830
this.statusElement.className = 'inline-block'
2931

3032
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') }
33+
'java.ignoreIncompleteClasspath': () => {
34+
atom.config.set('ide-java.server.errors.incompleteClasspath.severity', 'ignore')
35+
},
36+
'java.ignoreIncompleteClasspath.help': () => { shell.openExternal('https://github.com/atom/ide-java/wiki/Incomplete-Classpath-Warning') },
3337
}
3438
}
3539

@@ -196,7 +200,7 @@ class JavaLanguageClient extends AutoLanguageClient {
196200

197201
preInitialization(connection) {
198202
connection.onCustom('language/status', (e) => this.updateStatusBar(`${e.type.replace(/^Started$/, '')} ${e.message}`))
199-
connection.onCustom('language/actionableNotification', this.actionableNotification.bind(this))
203+
connection.onCustom('language/actionableNotification', (notification) => this.actionableNotification(notification, connection))
200204
}
201205

202206
getInitializeParams(projectPath, process) {
@@ -205,11 +209,7 @@ class JavaLanguageClient extends AutoLanguageClient {
205209
params.initializationOptions = {};
206210
}
207211
params.initializationOptions.bundles = this.collectJavaExtensions();
208-
params.initializationOptions.settings = {
209-
java: {
210-
"java.signatureHelp.enabled": true
211-
}
212-
}
212+
params.initializationOptions.settings = atom.config.get(this.getRootConfigurationKey())
213213
return params;
214214
}
215215

@@ -246,39 +246,23 @@ class JavaLanguageClient extends AutoLanguageClient {
246246
}
247247
}
248248

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-
249+
actionableNotification (notification, connection) {
268250
const options = { dismissable: true, detail: this.getServerName() }
269251
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
252+
options.buttons = notification.commands.map(command => ({
253+
text: command.title,
254+
onDidClick: () => onActionableButton(command)
255+
}))
272256
}
273257

274258
const notificationDialog = this.createNotification(notification.severity, notification.message, options)
275259

276-
const onActionableButton = (event, commandName) => {
277-
const commandFunction = this.commands[commandName]
260+
const onActionableButton = (command) => {
261+
const commandFunction = this.commands[command.command]
278262
if (commandFunction != null) {
279-
commandFunction()
263+
commandFunction(command, connection)
280264
} else {
281-
console.log(`Unknown actionableNotification command '${commandName}'`)
265+
console.log(`Unknown actionableNotification command '${command.command}'`)
282266
}
283267
notificationDialog.dismiss()
284268
}

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)