Code Monkey home page Code Monkey logo

lsp-java's Introduction

title description root_file
LSP Mode - Language Server Protocol support for Emacs
Language Server Protocol support with multiples languages support for Emacs
README.md

CI

Language Server Protocol Support for Emacs

LSP mode


homepageinstallationlanguagessettingstutorialstroubleshootingscreenshotsFAQ


Why?

  • ❤️ Community Driven
  • 💎 Fully featured - supports all features in Language Server Protocol v3.14.
  • 🚀 Fast - see performance section.
  • 🌟 Flexible - choose between full-blown IDE with flashy UI or minimal distraction free.
  • ⚙️ Easy to configure - works out of the box and automatically upgrades if additional packages are present.

Overview

Client for Language Server Protocol (v3.14). lsp-mode aims to provide IDE-like experience by providing optional integration with the most popular Emacs packages like company, flycheck and projectile.

  • Non-blocking asynchronous calls
  • Real-time Diagnostics/linting via flycheck (recommended) or flymake when Emacs > 26 (requires flymake>=1.0.5)
  • Code completion - company-capf / completion-at-point (note that company-lsp is no longer supported).
  • Hovers - using lsp-ui
  • Code actions - via lsp-execute-code-action, modeline (recommended) or lsp-ui sideline.
  • Code outline - using builtin imenu or helm-imenu
  • Code navigation - using builtin xref, lsp-treemacs tree views or lsp-ui peek functions.
  • Code lens
  • Symbol highlights
  • Formatting
  • Project errors on modeline
  • Debugger - dap-mode
  • Breadcrumb on headerline
  • Helm integration - helm-lsp
  • Ivy integration - lsp-ivy
  • Consult integration - consult-lsp
  • Treemacs integration - lsp-treemacs
  • Semantic tokens as defined by LSP 3.16 (compatible language servers include recent development builds of clangd and rust-analyzer)
  • which-key integration for better discovery
  • iedit
  • dired
  • ido

Presentations/demos

See also

  • lsp-docker - provide docker image with preconfigured language servers with corresponding emacs configuration.
  • company-box - company frontend with icons.
  • dap-mode - Debugger integration for lsp-mode.
  • eglot - An alternative minimal LSP implementation.
  • which-key - Emacs package that displays available keybindings in popup
  • projectile - Project Interaction Library for Emacs
  • emacs-tree-sitter - Faster, fine-grained code highlighting via tree-sitter.
  • gccemacs - modified Emacs capable of compiling and running Emacs Lisp as native code.

Contributions

Contributions are very much welcome!

NOTE Documentation for clients is generated from doc comments in the clients themselves (see lsp-doc.el) and some metadata (see lsp-clients.json) so please submit corrections accordingly.

Support the project

The emacs-lsp organization has more than 20,000 lines of code, to keep all of this working, we need to implement new features and help the community on a lot of issues.

You can help us keep going and improving it by supporting the project

Members

Here it is a list of the current lsp-mode members and what they are primary working on/responsible for.

kurnevsky
kurnevsky

Scala | Rust
seagle0128
seagle0128

Go | Python MS
sebastiansturm
sebastiansturm

lsp-mode core | C++
vibhavp
vibhavp

lsp-mode core
yyoncho
yyoncho

lsp-mode core | Java
ericdallo
ericdallo

Dart/Flutter | Clojure
danielmartin
danielmartin

C++ | Swift
kiennq
kiennq

completions | pwsh
nbfalcon
nbfalcon

lsp-mode core | iedit
psibi
psibi

Terraform | Nix
razzmatazz
razzmatazz

C# | F#
jcs090218
jcs090218

lsp-mode core

lsp-java's People

Contributors

aaronzinhoo avatar aconchillo avatar andrewbanchich avatar arichiardi avatar bogdanp avatar dakra avatar dsyzling avatar ebobby avatar ericdallo avatar igjoshua avatar jadler avatar jashank avatar jcs090218 avatar jherrlin avatar jonasws avatar joshtrn avatar juergenhoetzel avatar kols avatar kostafey avatar lenbok avatar lsund avatar mahinshaw avatar mzacho avatar thathai avatar vibhavp avatar wenhoujx avatar wyuenho avatar xiangqingw avatar yejianfengblue avatar yyoncho avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

lsp-java's Issues

Document how to start the lsp java server

Similar to #1 I think we should document how to start the language server from within emacs.

I have the server downloaded and in the correct location, and I can start it manually, but I am unsure how to do this within emacs using lsp-mode and lsp-java.

async install of the eclipse jdt language server

Hey,

As lsp-java reckons eclipse server is not installed ask then install it. But install it in a way that prevent us to do anything else until its done!

Pdf-tools use a nice way to install its server (async-shell-command) that wont stuck Emacs while on that.

That is it!

Awesome extension!
Thanks!

Doesn't work for Java files

Emacs 25.3 on Ubuntu 16.04 LTS

My configuration is:

(use-package lsp-java
  :commands lsp-java-enable
  :init (add-hook 'java-mode-hook #'lsp-java-enable))

Error:

Debugger entered--Lisp error: (void-function lsp-java-get--root)
  lsp-java-get--root()
  funcall(lsp-java-get--root)
  (lsp--should-start-p (funcall (progn nil (or (and (memq (aref client 0) cl-struct-lsp--client-tags)) (signal (quote wrong-type-argument) (list (quote lsp--client) client))) (aref client 6))))
  (if (lsp--should-start-p (funcall (progn nil (or (and (memq (aref client 0) cl-struct-lsp--client-tags)) (signal (quote wrong-type-argument) (list (quote lsp--client) client))) (aref client 6)))) (progn (lsp-mode 1) (lsp--start client)) (message "Not initializing project %s" root))
  (if lsp-mode nil nil (if (lsp--should-start-p (funcall (progn nil (or (and (memq ... cl-struct-lsp--client-tags)) (signal (quote wrong-type-argument) (list ... client))) (aref client 6)))) (progn (lsp-mode 1) (lsp--start client)) (message "Not initializing project %s" root)))
  (let ((client (make-lsp--client :language-id "java" :send-sync (function lsp--stdio-send-sync) :send-async (function lsp--stdio-send-async) :new-connection (lsp--make-stdio-connection "lsp-java" (lsp-java--ls-command) nil) :get-root (function lsp-java-get--root) :ignore-regexps (quote ("^SLF4J: " "^Listening for transport dt_socket at address: "))))) (if lsp-mode nil nil (if (lsp--should-start-p (funcall (progn nil (or (and ...) (signal ... ...)) (aref client 6)))) (progn (lsp-mode 1) (lsp--start client)) (message "Not initializing project %s" root))))
  lsp-java-enable()
  run-hooks(change-major-mode-after-body-hook prog-mode-hook c-mode-common-hook java-mode-hook java-mode-hook)
  apply(run-hooks (change-major-mode-after-body-hook prog-mode-hook c-mode-common-hook java-mode-hook java-mode-hook))
  run-mode-hooks(java-mode-hook)
  java-mode()
  set-auto-mode-0(java-mode nil)
  set-auto-mode()
  normal-mode(t)
  after-find-file(nil nil t nil nil)
  revert-buffer--default(t t)
  revert-buffer(t t)
  revert-current-buffer()
  funcall-interactively(revert-current-buffer)
  call-interactively(revert-current-buffer nil nil)
  command-execute(revert-current-buffer)

If I changed to

(lsp-define-stdio-client lsp-java "java" #'lsp-java--get-root (lsp-java--ls-command)
                         :ignore-regexps
                         '("^SLF4J: "
                           "^Listening for transport dt_socket at address: "))

Got this error:

Found more than one java language server entry points: (/home/avamar/.emacs.d/eclipse.jdt.ls/server/plugins/org.eclipse.equinox.launcher_1.4.0.v20161219-1356.jar /home/avamar/.emacs.d/eclipse.jdt.ls/server/plugins/org.eclipse.equinox.launcher_1.4.0.v20161219-1356.jar.pack.gz)
using config for config_linux
Entering debugger...

Debugger entered--Lisp error: (error "lsp-java: Cannot communicate with the process (exit)")
  signal(error ("lsp-java: Cannot communicate with the process (exit)"))
  error("%s: Cannot communicate with the process (%s)" "lsp-java" exit)
  lsp--stdio-send-async("Content-Length: 323
\n
\n{\"jsonrpc\":\"2.0\",\"method\":\"textDocument/didOpen\",\"params\":{\"textDocument\":{\"uri\":\"file:///home/avamar/junk/2017/10/23-141813.java\",\"languageId\":\"java\",\"version\":0,\"text\":\"import System;\\n\\npublic class HelloWorld {\\n    public static void main(String[] args) {\\n        System.out.println(\\\"Hello World!\\\");\\n    }\\n}\\n\"}}}" #<process lsp-java>)
  lsp--send-notification((:jsonrpc "2.0" :method "textDocument/didOpen" :params (:textDocument (:uri "file:///home/avamar/junk/2017/10/23-141813.java" :languageId "java" :version 0 :text "import System;\n\npublic class HelloWorld {\n    public static void main(String[] args) {\n        System.out.println(\"Hello World!\");\n    }\n}\n"))))
  lsp--text-document-did-open()
  lsp--start([cl-struct-lsp--client "java" lsp--stdio-send-sync lsp--stdio-send-async nil #[514 "\302\203	

Unable to make lsp--send-request-async return data in callback

With the following function:

(defun simple-lsp-hover-req-async ()
  (lsp--send-request-async (lsp--make-request
                           "textDocument/hover"
                           `(:textDocument (:uri "file:///usr/lib/erlang/lib/jinterface-1.8/java_src/com/ericsson/otp/erlang/AbstractConnection.java")
                                           :position
                                           (:line
                                            147
                                            :character 30)))
                           (lambda (x) (message "HELLO"))
                          ))

I am unable to get the lambda callback to fire and show "HELLO" into the echo are or Messages buffer.
I have tried same function in a python-lsp project and the callback does fire and I am able to see "HELLO" message. The sync version of this function works as expected.

When lsp-print-io is set to t, I see that the server is generating this:
Output from language server: {"jsonrpc":"2.0","id":"5","result":{"contents":[{"language":"java","value":"void java.io.PrintStream.println(char[] x)"}]}}
However i get nothing back in the callback, and when lsp-print-io is set to nil I get nothing back.

Redundant in (add-hook 'java-mode-hook #'lsp-java-enable) README?

(add-hook 'java-mode-hook #'lsp-java-enable) occurs both in

(require 'lsp-java)
(add-hook 'java-mode-hook #'lsp-java-enable)

and

(use-package lsp-java
...
config:
(add-hook 'java-mode-hook  'lsp-java-enable)
...)

IIRC, only one of the two line existing is enough, right?

(wrong-type-argument arrayp nil) after lsp-java-update-user-settings

Trying to get LSP set up for the first time and running into this error:

Debugger entered--Lisp error: (wrong-type-argument arrayp nil)
  lsp--set-configuration(((java (jdt (ls (vmargs . "-noverify -Xmx1G -XX:+UseG1GC -XX:+UseStringDeduplication"))) (errors (incompleteClasspath (severity . warning))) (configuration (updateBuildConfiguration . automatic) (maven)) (trace (server . verbose)) (import (gradle (enabled . t)) (maven (enabled . t)) (exclusions "**/node_modules/**" "**/.metadata/**" "**/archetype-resources/**" "**/META-INF/maven/**")) (referencesCodeLens (enabled . t)) (progressReports (enabled . t)) (signatureHelp (enabled . t)) (implementationsCodeLens (enabled . t)) (format (enabled . t) (settings (profile) (url)) (comments (enabled))) (saveActions (organizeImports . t)) (contentProvider) (autobuild (enabled . t)) (completion (favoriteStaticMembers "org.junit.Assert.*" "org.junit.Assume.*" "org.junit.jupiter.api.Assertions.*" "org.junit.jupiter.api.Assumptions.*" "org.junit.jupiter.api.DynamicContainer.*" "org.junit.jupiter.api.DynamicTest.*") (importOrder "java" "javax" "com" "org")))))
  lsp-java-update-user-settings()
  lsp-java--after-start()
  apply(lsp-java--after-start nil)
  #[128 "\300\302�\"\300\301�\"\210\207" [apply lsp-java--after-start #[nil "\301\302\303\304\305\306\307\310\311\312 \313\306\314\315\316\306\317\320\321\322�\"\323\324 \325\326\327\330\327F\257�\331\332\333\334\335\306&�\207" [lsp-java--workspace-folders lsp--enable-stdio-client lsp-java :language-id "java" :language-id-fn nil :root-directory-fn #[nil "�\207" [lsp-java-workspace-dir] 1] :command lsp-java--ls-command :command-fn :ignore-regexps ("^SLF4J: " "^Listening for transport dt_socket at address: ") :ignore-messages :extra-init-params :workspaceFolders mapcar lsp--path-to-uri :settings lsp-java--settings :extendedClientCapabilities :progressReportProvider t :classFileContentsSupport :initialize-fn lsp-java--client-initialized :enable-function lsp-java-enable :prefix-function] 26 nil nil] nil] 5 nil nil]()
  apply(#[128 "\300\302�\"\300\301�\"\210\207" [apply lsp-java--after-start #[nil "\301\302\303\304\305\306\307\310\311\312 \313\306\314\315\316\306\317\320\321\322�\"\323\324 \325\326\327\330\327F\257�\331\332\333\334\335\306&�\207" [lsp-java--workspace-folders lsp--enable-stdio-client lsp-java :language-id "java" :language-id-fn nil :root-directory-fn #[nil "�\207" [lsp-java-workspace-dir] 1] :command lsp-java--ls-command :command-fn :ignore-regexps ("^SLF4J: " "^Listening for transport dt_socket at address: ") :ignore-messages :extra-init-params :workspaceFolders mapcar lsp--path-to-uri :settings lsp-java--settings :extendedClientCapabilities :progressReportProvider t :classFileContentsSupport :initialize-fn lsp-java--client-initialized :enable-function lsp-java-enable :prefix-function] 26 nil nil] nil] 5 nil nil] nil)
  lsp-java-enable()
  eval((lsp-java-enable) nil)
  eval-expression((lsp-java-enable) nil)
  funcall-interactively(eval-expression (lsp-java-enable) nil)
  call-interactively(eval-expression nil nil)
  command-execute(eval-expression)

After calling lsp-java-enable

I am configuring lsp-mode and lsp-java like so:

  (use-package lsp-mode
    :commands lsp-mode)
  (use-package lsp-java
    :commands lsp-java-enable
    :config (setq lsp-java-server-install-dir "~/bin/jdt/"
                  lsp-java-trace-server 'verbose
                  lsp-java--workspace-folders (list "/Users/nbarnw/projects/nike/marketing-segment-dm-poc"))
              (add-hook 'java-mode-hook 'flycheck-mode))

I am using the 2018-05-04 build of the JDT Server and Emacs 25.3

I think the root error is that the Language Server is not starting properly, because I find this in *Messages*:

/Users/nbarnw/.homesick/repos/dotfiles/home/.emacs.d/workspace/: lsp-java has exited (exited abnormally with code 13)

Building/Running

I set the workspace with this statement,
(setq lsp-java--workspace-folders (list "~/workspace/"))
,but still the lsp-java-build-project doesn't work.
Nothing comes up, no error message either
Is there any other config I should do??
And is there a way of running the code within this mode??

Support Java 10

It appears, that to work properly in Java 10 mode, jdt.ls may need more parameters passed in.

Judging from vscode exception:

if (requirements.java_version > 8) {
		params.push('--add-modules=ALL-SYSTEM',
					'--add-opens',
					'java.base/java.util=ALL-UNNAMED',
					'--add-opens',
					'java.base/java.lang=ALL-UNNAMED');
}

Also, gradle and maven support should not be blindly forced to "true". Jdt.ls is very sensitive to unusual project configurations and the only mode that really can be trusted to work is eclipse .project/.classfile (this is used by default when gradle and maven support are disabled in the config).

Can't resolve type and common problems

Just try to use Emacs and this plugin to develop Spring application and fact some problems.

  1. I am using Eclipse IDE to develop Spring project and after that I tried to import the Spring MVC project into Emacs and everything is working fine but when I open and close Emacs for about 10 times, the project start to get error. The error is that it can't resolve type of library. I have tried some command such as:
  • lsp-java-update-server
  • lsp-workspace-restart
  • lsp-java-build-project
    But it still can't fix the problem and the only way to solve this is to delete all downloaded files ( eclipse jdt ) and let it re-download all the file again. I don't know if there is a way to solve this problem effectively.
  1. Auto completion is working properly after import the project, but how about building the project into War or Jar file? I have tried to use lsp-java-build-project when the project is working but after calling this command, in the Message buffer, it shows error about can't resolve type.

  2. How can I manually refresh gradle like in eclipse so it will download needed dependency that's listed inside the build.gradle file?

  3. @yyoncho, will dap-java or dap-mode work with Spring MVC project using tomcat? I have tried to make it works but it does not. I am not sure how to configure it the right way or how to run/build the project. Please guide me how to run project and how to debug. I have tried using this example but might because I do not know how run the project or I do not understand this configuration. https://github.com/yyoncho/dap-mode#example

  4. How about something like console in Eclipse? I am trying to see the output message or log but I could not find it.

Document how to get the language server

Hi!

I wanted to try out lsp-java but I'm stuck trying to find a server download.

A little bit of documentation in the package header and / or README.md wouldn't hurt. :)

project / workspace folders

is there any way to specify a workspace / project folder after startup?

great work BTW really enjoying using it

Make java executable path configurable

It is rather common to have multiple JDK versions installed side by side, especially considering the increase in rate of new major Java version releases, with new features and all.

There should be a way to specify the desired java runner path rather than relying on default "java" executable.

Some more documentation on what to expect

Im trying to get lsp-java working in a spacemacs layer but I find it hard to know what to exepct, below are the questions I have:

  1. Right now I can only jump into classes that are in the same project, for example I can not jump into the String class.
  2. When I look for references with M - ? it looks like im just doing a word search project wide and it does not take into account scope etc, just spelling.
  3. What is the difference between adding a project to the workspace variable and not adding it. I see im getting some functionality even if im not adding it but im not sure what exactly is the difference.
  4. On the eclipse.jdt.ls project site there is information that the project also has maven and gradel support, is any of that functionality provided with the lsp protocol and in this project?

Wrong source folder

In some cases when I open a maven project, which by default has its sources under src/main/java lsp-java still things that the source folder is src.

This is quite annoying as it suggests prefixing all interal package with main.java.

There is no known way on how to configure the source folder (though for maven I think it makes sense to have it autoconfigured).

Can it be made possible to refuse edits?

Sorry if this part is off topic but I just want to say that I am very impressed with the recent work on lsp-java. It went from being a sort of companion to eclipse for me to being usable on its own. Seems much more professional now. Kudos.

I don't know whether this is an lsp-java thing or just an lsp-mode thing, but sometimes edits are made
(e.g. an import like org.junit.Assert.* is changed to org.junit.assertTrue) that I would rather not be made. Would it be possible to somehow refuse those edits?

Thank you!

Found more than one java language server entry points due to regexp matching .pack.gz files

In lsp-java.el:

(server-jar-filenames (directory-files plugindir t "org.eclipse.equinox.launcher_.*")))

also matches jar.pack.gz files in recent Eclipse JDT Server distributions, resulting in a "Found more than one java language server entry points" error. The problem can be fixed by making the pattern more restrictive, as follows:

(server-jar-filenames (directory-files plugindir t "org.eclipse.equinox.launcher_.*.jar$")))

Go to declaration sometimes works, mostly not

This happens both with M-. and C-u M-.

Looks to me like some sort of path handling bug on the elisp side.

The messages file shows the following diagnostic:

//... omitted
May 30, 2018 6:13:51 PM >> document/hover
May 30, 2018 6:13:51 PM >> document/documentSymbol
May 30, 2018 6:13:51 PM >> document/definition
insert-file-contents-literally: Read error: Is a directory, <directory source file is in>
May 30, 2018 6:13:51 PM >> document/documentHighlight
May 30, 2018 6:13:51 PM >> document/codeAction

wrong-type-argument lsp--workspace nil

From the bottom: this was solved by not running lsp-mode before lsp-java-enable.


This is the error I get when I run lsp-java-enable in a Java buffer with lsp-mode on.

Here is my configuration:

(use-package lsp-mode
  :ensure t
  :defer t
  :init
  (add-hook 'prog-mode-hook 'lsp-mode))

(use-package lsp-java
  :ensure t
  :defer t
  :init
  (require 'lsp-java)
  (setq lsp-java--workspace-folders (list "/path/to/java/project"))
  (add-hook 'java-mode-hook #'lsp-java-enable))

I have the latest versions of all of lsp-mode, lsp-java, and the language server.

Tab characters in generated code

When I trigger a code action like "Create field", I find that, when the field is created, it's indented with tab characters instead of using spaces (my configuration). Is there a setting I can change?

Thanks.

Internal server error during initialization

I have the following java file -

public class UnionFind {
    public static void main(String[] args) {
        System.out.println("Hello world");
    }
}

When I try to open it after setting up lsp-mode and lsp-java according to the readme, I get the following message -

using config for config_mac
Nov 26, 2017 1:26:34 AM >> initialize
Nov 26, 2017 1:26:34 AM Initializing Java Language Server 0.9.0.201711260243
Error from the Language Server: Internal error. (Internal Error)
File mode specification error: (lsp-empty-response-error initialize)

The *lsp-java stderr* buffer is blank. Using Emacs version 27.0.5 on Mac OS X Sierra via Homebrew. Problem occurs with both latest server and the 201710161512 version installed in the default path.

Can't disable organize imports on save.

I wanted to disable organize imports on save with no luck.

Tried both via customize and by explicitly setting in my configuration:

(setq lsp-java-organize-imports nil)

But none of that works. Each time I save I get my imports organized (and some times replaces the right imports with the wrong one, completely breaking the plugin).

java.lang.NoClassDefFoundError: javax/annotation/processing/AbstractProcessor

Hi,

sorry if I'm reporting this in the wrong project, but I expect this to have something to do with how lsp-java interprets my multi-module Java project.

foo-core is a 3rd level Maven module in a project structure like this:

proj/foo/foo-core

The class it cannot find is defined in the module's POM and everything builds with mvn (of course).

Can you direct me in the right direction for solving this?

Cheers,

-Torstein

Error from: ~/.emacs.d/workspace/.metadata/.log:

!ENTRY org.eclipse.core.resources 4 75 2018-09-18 09:00:51.086
!MESSAGE Errors occurred during the build.
!SUBENTRY 1 org.eclipse.jdt.core 4 75 2018-09-18 09:00:51.086
!MESSAGE Errors running builder 'Java Builder' on project 'foo-core'.
!STACK 0
java.lang.NoClassDefFoundError: javax/annotation/processing/AbstractProcessor
        at java.base/java.lang.ClassLoader.findBootstrapClass(Native Method)
        at java.base/java.lang.ClassLoader.findBootstrapClassOrNull(ClassLoader.java:1248)
        at java.base/java.lang.System$2.findBootstrapClassOrNull(System.java:2123)
        at java.base/jdk.internal.loader.ClassLoaders$BootClassLoader.loadClassOrNull(ClassLoaders.java:125)
        at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:617)
        at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:641)
        at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:617)
        at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:580)
        at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:185)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:550)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:550)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:496)
        at org.eclipse.jdt.apt.core.internal.AnnotationProcessorFactoryLoader.loadJava6FactoryClasses(AnnotationProcessorFactoryLoader.java:641)
        at org.eclipse.jdt.apt.core.internal.AnnotationProcessorFactoryLoader.loadFactories(AnnotationProcessorFactoryLoader.java:580)
        at org.eclipse.jdt.apt.core.internal.AnnotationProcessorFactoryLoader.getJava6FactoriesAndAttributesForProject(AnnotationProcessorFactoryLoader.java:458)
        at org.eclipse.jdt.internal.apt.pluggable.core.dispatch.IdeAnnotationProcessorManager.processAnnotations(IdeAnnotationProcessorManager.java:134)
        at org.eclipse.jdt.internal.compiler.Compiler.processAnnotations(Compiler.java:940)
        at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:450)
        at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:426)
        at org.eclipse.jdt.internal.core.builder.AbstractImageBuilder.compile(AbstractImageBuilder.java:386)
        at org.eclipse.jdt.internal.core.builder.BatchImageBuilder.compile(BatchImageBuilder.java:214)
        at org.eclipse.jdt.internal.core.builder.AbstractImageBuilder.compile(AbstractImageBuilder.java:318)
        at org.eclipse.jdt.internal.core.builder.BatchImageBuilder.build(BatchImageBuilder.java:79)
        at org.eclipse.jdt.internal.core.builder.JavaBuilder.buildAll(JavaBuilder.java:262)
        at org.eclipse.jdt.internal.core.builder.JavaBuilder.build(JavaBuilder.java:180)
        at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:798)
        at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:45)
        at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:219)
        at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:262)
        at org.eclipse.core.internal.events.BuildManager$1.run(BuildManager.java:315)
        at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:45)
        at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:318)
        at org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:370)
        at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:391)
        at org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBuildJob.java:145)
        at org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJob.java:235)
        at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)

Can't install: org.eclipse.che.ls.jdt:jdt.ls.extension.product:tar.gz:0.0.1-SNAPSHOT is missing

It seems whatever snapshot was being used has disappeared from maven.codenvycorp.com:

jan@jinkpad:/tmp/lsp-java-install $ sh mvnw -U \
 -Djdt.js.server.root=/home/jan/.emacs.d/eclipse.jdt.ls/server/ \
 -Djunit.runner.root=/home/jan/.emacs.d/eclipse.jdt.ls/server/test-runner \
 -Djunit.runner.fileName=junit-platform-console-standalone.jar \
 -Djava.debug.root=/home/jan/.emacs.d/eclipse.jdt.ls/server/bundles \
 clean package
[INFO] Scanning for projects...
[INFO]
[INFO] -------------------------< lsp-java:lsp-java >--------------------------
[INFO] Building lsp-java 1.0.0-SNAPSHOT
[INFO] --------------------------------[ pom ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ lsp-java ---
[INFO]
[INFO] --- maven-dependency-plugin:3.1.1:unpack (unpack) @ lsp-java ---
[INFO] Configured Artifact: org.eclipse.che.ls.jdt:jdt.ls.extension.product:0.0.1-SNAPSHOT:tar.gz
Downloading from codenvy-public-repo: https://maven.codenvycorp.com/content/groups/public/org/eclipse/che/ls/jdt/jdt.ls.extension.product/0.0.1-SNAPSHOT/maven-metadata.xml
Downloading from codenvy-public-repo: https://maven.codenvycorp.com/content/groups/public/org/eclipse/che/ls/jdt/jdt.ls.extension.product/0.0.1-SNAPSHOT/jdt.ls.extension.product-0.0.1-SNAPSHOT.pom
[WARNING] The POM for org.eclipse.che.ls.jdt:jdt.ls.extension.product:tar.gz:0.0.1-SNAPSHOT is missing, no dependency information available
Downloading from codenvy-public-repo: https://maven.codenvycorp.com/content/groups/public/org/eclipse/che/ls/jdt/jdt.ls.extension.product/0.0.1-SNAPSHOT/jdt.ls.extension.product-0.0.1-SNAPSHOT.tar.gz
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.298 s
[INFO] Finished at: 2018-10-05T20:34:35+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-dependency-plugin:3.1.1:unpack (unpack) on project lsp-java: Unable to find/resolve artifact.: Could not find artifact org.eclipse.che.ls.jdt:jdt.ls.extension.product:tar.gz:0.0.1-SNAPSHOT in codenvy-public-repo (https://maven.codenvycorp.com/content/groups/public/) -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]

If I manually open the server's generated directory list for that snapshot artifact, the directory is there, but there's only a .md5 and .sha1 file there, the rest is wiped. The files that are there are dated Oct 1st, so something happened recently.

Expose che-ls-jdt methods

Here it is the list of methods that are available in backend but not exposed in lsp-java.

This task is tracking the front end work required to expose the method if feasible.

  • che.jdt.ls.extension.classpathTree
  • che.jdt.ls.extension.configuration.getJavaCoreOptions
  • che.jdt.ls.extension.configuration.getPreferences
  • che.jdt.ls.extension.configuration.updateJavaCoreOptions
  • che.jdt.ls.extension.configuration.updatePreferences
  • che.jdt.ls.extension.debug.findResourcesByFqn
  • che.jdt.ls.extension.debug.identifyFqnInResource
  • che.jdt.ls.extension.debug.identifyFqnInResource
  • che.jdt.ls.extension.detectTest
  • che.jdt.ls.extension.effectivePom
  • che.jdt.ls.extension.externalLibraries
  • che.jdt.ls.extension.externalLibrariesChildren
  • che.jdt.ls.extension.findImplementers
  • che.jdt.ls.extension.findTestByCursor
  • che.jdt.ls.extension.findTestFromEntry
  • che.jdt.ls.extension.findTestFromFolder
  • che.jdt.ls.extension.findTestFromProject
  • che.jdt.ls.extension.findTestInFile
  • che.jdt.ls.extension.import.organizeImports
  • che.jdt.ls.extension.libraryChildren
  • che.jdt.ls.extension.libraryContentByPath
  • che.jdt.ls.extension.libraryContentURL
  • che.jdt.ls.extension.libraryEntry
  • che.jdt.ls.extension.mavenProjects
  • che.jdt.ls.extension.outputDir
  • che.jdt.ls.extension.plain.createProject
  • che.jdt.ls.extension.plain.getProjectSourceLocations
  • che.jdt.ls.extension.plain.sourceFolders
  • che.jdt.ls.extension.plain.updateClasspath
  • che.jdt.ls.extension.pom.diagnostics
  • che.jdt.ls.extension.reImportMavenProject
  • che.jdt.ls.extension.refactoring.move.command
  • che.jdt.ls.extension.refactoring.move.get.destinations.command
  • che.jdt.ls.extension.refactoring.move.validate
  • che.jdt.ls.extension.refactoring.move.verify.destination
  • che.jdt.ls.extension.refactoring.rename
  • che.jdt.ls.extension.refactoring.rename.get.linked.elements
  • che.jdt.ls.extension.refactoring.rename.get.type
  • che.jdt.ls.extension.refactoring.rename.validate.new.name
  • che.jdt.ls.extension.resolveClasspath
  • che.jdt.ls.extension.updateWorkspace
  • che.jdt.ls.extension.usages
  • org.eclipse.che.jdt.ls.extension.filestructure

Too many debug messages

Debug messages often obscure important information (like, for example, when I'm performing a search, I often can't see what I'm typing because <date> >> document/hover is being displayed instead). Would it be possible to show these messages only when a given configuration variable is set?

customize build directory

Hi, I am using lsp-mode with a spring webapp. To use the auto redeploy feature of spring devtools it needs to see changes to the classpath. Our app places all classes in build/classes/java/main/... . The language server puts the classes in bin/main/... . Anyway to specify the path to the classes?

void-function 'command' when starting lsp-mode

When I do M-x lsp-mode in a Java buffer, I get the following backtrace:

Debugger entered--Lisp error: (void-function command)
  command()
  #[514 "\301\203	\301 \202\302 \211:\203\211\202\211C\303@!\204%\304\305\306@\"!\210\307\310\300\311\312\313\314\315\f\316\317\320\300\321Q!&\f\262\207" ["Java Language Server" nil command executable-find error format "Couldn't find executable %s" make-process :name :connection-type pipe :command :filter :sentinel :stderr generate-new-buffer-name "*" " stderr"] 20 "\n\n(fn FILTER SENTINEL)"](#[514 "\306\301\306\307\306:\203,@\262\310\"\203!\306\262\306\211\262\202\"\307\203,A\262\202\2034\307\2025\211\266\204\203}\3111F\312\300\"0\202|\313\300!\210\300\314H>\204Y\315\316\317\300D\"\210\300\211\320\306I\266\300\314H>\204o\315\316\317\300D\"\210\300\211\321\306I\266\322\323\"\262\210\300\314H>\204\214\315\316\317\300D\"\210\300\321H\205\244\3241\236\306\325!)0\207\210\307\326\327!\207" [[cl-struct-lsp--parser nil nil nil nil nil nil 0 nil nil nil [cl-struct-lsp--workspace #2 "java" 0 #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8 data ( ...)) nil "/home/hinmanm/es/elasticsearch/" [cl-struct-lsp--client "java" lsp--stdio-send-sync lsp--stdio-send-async stdio #[514 "\301\203	\301 \202\302 \211:\203\211\202\211C\303@!\204%\304\305\306@\"!\210\307\310\300\311\312\313\314\315\f\316\317\320\300\321Q!&\f\262\207" ["Java Language Server" nil command executable-find error format "Couldn't find executable %s" make-process :name :connection-type pipe :command :filter :sentinel :stderr generate-new-buffer-name "*" " stderr"] 20 "\n\n(fn FILTER SENTINEL)"] lsp-java--get-root ("^SLF4J: " "^Listening for transport dt_socket at address: ") #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8 data ( ...))] nil nil nil nil nil] #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8 data ( ...)) #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8 data ("workspace/applyEdit" lsp--workspace-apply-edit-handler ...))] ("^SLF4J: " "^Listening for transport dt_socket at address: ") lsp--no-response cl-struct-lsp--parser-tags inhibit-quit quit-flag nil t string-match (error) lsp--parser-read lsp--parser-reset 0 signal wrong-type-argument lsp--parser 2 1 error "Error parsing language server output: %s" (quit) accept-process-output eval (ignore nil)] 9 "\n\n(fn PROC OUTPUT)"] #[514 "\303\300!\205`r\300q\210	\304H\n>\204\305\306\307	D\"\210	\310H\211\205]\211@r\211q\210\311\312	\304H\n>\2047\305\306\307	D\"\210	\313H\314	\304H\n>\204J\305\306\307	D\"\210	\315H!$\210\316 \210)A\266\202\202\262)\207" [#<buffer IndexShardRoutingTable.java> lsp--cur-workspace cl-struct-lsp--workspace-tags buffer-live-p 0 signal wrong-type-argument lsp--workspace 11 message "%s: %s has exited (%s)" 6 process-name 9 lsp--uninitialize-workspace] 12 "\n\n(fn P EXIT-STR)"])
  lsp--start()
  lsp-mode(toggle)
  funcall-interactively(lsp-mode toggle)
  call-interactively(lsp-mode record nil)
  command-execute(lsp-mode record)
  helm-M-x(nil #("lsp-mode" 0 8 (match-part "lsp-mode")))
  funcall-interactively(helm-M-x nil #("lsp-mode" 0 8 (match-part "lsp-mode")))
  call-interactively(helm-M-x nil nil)
  command-execute(helm-M-x)

It looks like it's trying to format an error message, but I can't tell what from?

Really slow when first open a java file

Hi! I want to say that this is a really impressive project and great work for Emac-users who want to do Java development!

My problem is, when I installed this package, added some configuration to my init file just like that in Quick Start section in your instruction, and opened a java file (I had set the project directory right), my Emacs got really really slow for about 20 sec. Meanwhile I pretty much couldn't do anything, even moving my cursor became really slow too. After 20 sec or so, everything went right and it worked amazingly. Now the thing is, every time I restart emacs and open a java file, this process happens again, which is pretty annoying though. I don't know if it is meant to be like this, or I am misconfiguring something? :)

eclipse/lsp4j throws Exception on "initialized" method

This is most likely a result of change
eclipse-lsp4j/lsp4j@aee5a6b

WARNUNG: Notification threw an exception: {
  "jsonrpc": "2.0",
  "method": "initialized"
}
java.lang.IllegalArgumentException: wrong number of arguments
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.lambda$null$0(GenericEndpoint.java:49)
	at org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.notify(GenericEndpoint.java:108)
	at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.handleNotification(RemoteEndpoint.java:165)
	at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.consume(RemoteEndpoint.java:136)
	at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.handleMessage(StreamMessageProducer.java:149)
	at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.listen(StreamMessageProducer.java:77)
	at org.eclipse.lsp4j.jsonrpc.json.ConcurrentMessageProcessor.run(ConcurrentMessageProcessor.java:84)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:745)

  "jsonrpc": "2.0",
  "method": "initialized"
}

This is fixed by changing the elisp client from

   (lsp--send-notification (lsp--make-notification "initialized" nil))

to

       (lsp--send-notification (lsp--make-notification "initialized" '(:dummy 1)))

According to http://www.jsonrpc.org/specification#request_object:

  • params

A Structured value that holds the parameter values to be used during the invocation of the method. This member MAY be omitted.

So I consider this a eclipse/lsp4j bug.

First element of company menu for import

When I choose the first option of the company-recommanding lists without any other typing,
all the words from import are gone and the last class name only leaves.

ex) [import java.io.]
company list
-->Console
ObjectStreamClass
PushbackInputStream
.....
after hit the enter
[Console;]

File watch functionality renders Emacs unusable

After updating to the most recent lsp-java, I am unable to open any java files because when I try it, Emacs immediately complains about an excessive number of files being open. I can't then do anything to debug because Emacs doesn't let me.

Setting lsp-java-enable-file-watch to nil fixes the problem.

`lsp-java--get-root` is called too early

Loading lsp-java causes (lsp-define-stdio-client 'java-mode "java" ...) to be evaluated, one of the argument of this function is (lsp-java--ls-command), which in turn will call (lsp-java--get-root), which will return the current directory at whatever point lsp-java has been loaded, instead of when the lsp-mode has been enabled. If you use emacs in server mode and eagerly load lsp-java in your config, you will likely see Couldn’t find java root, using:/ in your logs.
It seems that lsp-define-stdio-client needs to be changed to take a function that returns the command used for running the server, instead of a list of strings.

Unknown symbols don't throw an error

I just set up lsp-mode and lsp-java as the README.mds suggested. And this code doesn't result in errors.

public class Main {
    public static void main(String[] args) {
       abc.def();
    }
}

Is there more to the setup of the language server than the README shows?

Debugger entered--Lisp error: (error "Process lsp-java not running")

Hey, lsp-java despite working correctly on java files as I close Emacs it issues:
https://gist.github.com/j3kyl/f8af88cde5ce06588684ac3831a2e781

I installed eclipse jdt ls via lsp-java (.emacs.d/eclipse..)

my lsp-mode config is minimal - as I am still learning java:
https://gitlab.com/j3kyl/dots/blob/master/.emacs.d/external/init-external-common-packages.el

Thanks!

Emacs 27.0.50
Debian SID
OpenJDK Runtime Environment (build 10.0.2+13-Debian-1)
OpenJDK 64-Bit Server VM (build 10.0.2+13-Debian-1, mixed mode)
maven/unstable,unstable,now 3.5.3-1 all [installed]     
eclipse-jdt [installed]

Running

Sorry, I am very new to Java and I finished all the setup. Everything is working, how do I run my code from the buffer? :✖️

My buffer content:

public class Testando {
    public static void main(String[] args) {
        System.out.println("Hello, world!");
    }
}

File Testando.java

Thx

Doesn't seem to work with Lombok

I'm using Lombok to generate getters and setters for my DTOs, but it seems those generated methods aren't being detected. For example, I see

image

I have everything up-to-date, including the Eclipse server. I tried lsp-intellij yesterday and there are no complains there (although I did have to install the Lombok plugin on Intellij for it to work).

Apparently one has to add a few flags to the java command, but I'm not sure how to do that with lsp-java, or even if it is possible.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.