Skip to content
This repository was archived by the owner on Dec 15, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 27 additions & 33 deletions lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,30 @@ class JavaLanguageClient extends AutoLanguageClient {
getGrammarScopes () { return [ 'source.java' ] }
getLanguageName () { return 'Java' }
getServerName () { return 'Eclipse JDT' }
// List of preferences available at:
// https://github.com/eclipse/eclipse.jdt.ls/blob/master/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/preferences/Preferences.java
getRootConfigurationKey() { return 'ide-java.server' }
mapConfigurationObject(configuration) { return {java: configuration} }

constructor () {
super()
this.statusElement = document.createElement('span')
this.statusElement.className = 'inline-block'

this.commands = {
'java.ignoreIncompleteClasspath': () => { atom.config.set('ide-java.errors.incompleteClasspathSeverity', 'ignore') },
'java.ignoreIncompleteClasspath.help': () => { shell.openExternal('https://github.com/atom/ide-java/wiki/Incomplete-Classpath-Warning') }
'java.ignoreIncompleteClasspath': () => {
atom.config.set('ide-java.server.errors.incompleteClasspath.severity', 'ignore')
},
'java.ignoreIncompleteClasspath.help': () => { shell.openExternal('https://github.com/atom/ide-java/wiki/Incomplete-Classpath-Warning') },
}

// Migrate ide-java.errors.incompleteClasspathSeverity -> ide-java.server.errors.incompleteClasspath.severity
// Migration added in v0.10.0; feel free to remove after a few versions
const severity = atom.config.get('ide-java.errors.incompleteClasspathSeverity')
if (severity) {
atom.config.unset('ide-java.errors.incompleteClasspathSeverity')
atom.config.unset('ide-java.errors')
atom.config.set('ide-java.server.errors.incompleteClasspath.severity', severity)
}
}

Expand Down Expand Up @@ -196,7 +211,7 @@ class JavaLanguageClient extends AutoLanguageClient {

preInitialization(connection) {
connection.onCustom('language/status', (e) => this.updateStatusBar(`${e.type.replace(/^Started$/, '')} ${e.message}`))
connection.onCustom('language/actionableNotification', this.actionableNotification.bind(this))
connection.onCustom('language/actionableNotification', (notification) => this.actionableNotification(notification, connection))
}

getInitializeParams(projectPath, process) {
Expand All @@ -205,11 +220,6 @@ class JavaLanguageClient extends AutoLanguageClient {
params.initializationOptions = {};
}
params.initializationOptions.bundles = this.collectJavaExtensions();
params.initializationOptions.settings = {
java: {
"java.signatureHelp.enabled": true
}
}
return params;
}

Expand Down Expand Up @@ -246,39 +256,23 @@ class JavaLanguageClient extends AutoLanguageClient {
}
}

actionableNotification (notification) {
if (notification.message.startsWith('Classpath is incomplete.')) {
switch(atom.config.get('ide-java.errors.incompleteClasspathSeverity')) {
case 'ignore': return
case 'error': {
notification.severity = 1
break
}
case 'warning': {
notification.severity = 2
break
}
case 'info': {
notification.severity = 3
break
}
}
}

actionableNotification (notification, connection) {
const options = { dismissable: true, detail: this.getServerName() }
if (Array.isArray(notification.commands)) {
options.buttons = notification.commands.map(c => ({ text: c.title, onDidClick: (e) => onActionableButton(e, c.command) }))
// TODO: Deal with the actions
options.buttons = notification.commands.map(command => ({
text: command.title,
onDidClick: () => onActionableButton(command)
}))
}

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

const onActionableButton = (event, commandName) => {
const commandFunction = this.commands[commandName]
const onActionableButton = (command) => {
const commandFunction = this.commands[command.command]
if (commandFunction != null) {
commandFunction()
commandFunction(command, connection)
} else {
console.log(`Unknown actionableNotification command '${commandName}'`)
console.log(`Unknown actionableNotification command '${command.command}'`)
}
notificationDialog.dismiss()
}
Expand Down
50 changes: 37 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,46 @@
}
}
},
"errors": {
"server": {
"order": 30,
"type": "object",
"title": "Warnings and Errors",
"title": "Language Server",
"description": "Settings that control language server functionality.",
"properties": {
"incompleteClasspathSeverity": {
"type": "string",
"title": "Incomplete Classpath Severity",
"enum": [
"ignore",
"info",
"warning",
"error"
],
"default": "warning",
"description": "Severity of the message when the classpath is incomplete for a Java file."
"signatureHelp": {
"type": "object",
"title": "Signature Help",
"properties": {
"enabled": {
"type": "boolean",
"default": true,
"description": "Controls whether signature help is enabled."
}
}
},
"errors": {
"type": "object",
"title": "Warnings and Errors",
"properties": {
"incompleteClasspath": {
"type": "object",
"title": "Incomplete Classpath",
"properties": {
"severity": {
"type": "string",
"title": "Incomplete Classpath Severity",
"enum": [
"ignore",
"info",
"warning",
"error"
],
"default": "warning",
"description": "Severity of the message when the classpath is incomplete for a Java file."
}
}
}
}
}
}
}
Expand Down