emacs-lsp / lsp-mode

Emacs client/library for the Language Server Protocol
https://emacs-lsp.github.io/lsp-mode
GNU General Public License v3.0
4.75k stars 869 forks source link

Discussion: How to add support for Java language server #34

Closed tutysara closed 7 years ago

tutysara commented 7 years ago

I am tying to add support for java language server eclipse.jdt.ls which is used in VS Code.

I changed lsp-mode.el and added these code similar to haskell-mode.

(lsp-define-client 'java-mode "java" 'stdio #'lsp--java-get-root
                   :command '("java" "-Declipse.application=org.eclipse.jdt.ls.core.id1"
                              "-Dosgi.bundles.defaultStartLevel=4"
                              "-Declipse.product=org.eclipse.jdt.ls.core.product"
                              "-Dlog.protocol=true"
                              "-Dlog.level=ALL"
                              "-noverify"
                              "-Xmx1G"
                              "-jar"
                              "/Users/tutysara/.vscode/extensions/redhat.java-0.1.0/server/plugins/org.eclipse.equinox.launcher_1.4.0.v20161219-1356.jar"
                              "-configuration"
                              "/Users/tutysara/.vscode/extensions/redhat.java-0.1.0/server/config_mac"
                              "-data"
                              "/Users/tutysara/src/myprojects/java/restful/simple-service")
                   :name "Java Language Server")

and

(defun lsp--java-get-root ()
  (let ((dir default-directory))
    (message "getting java root")
    (if (string= dir "/")
        (user-error "Couldn't find java root")
      dir)))

I have the hardcoded values for the path to start with. I made these change to lsp-mode.el and evaluated the buffer.

When I switch to a java file and enable java-mode, nothing happens.

Is there any additional setup that I have to make.

vibhavp commented 7 years ago

Did you enable lsp-global-mode?

On 01-Apr-2017 12:57 AM, "tutysara" notifications@github.com wrote:

I am tying to add support for java language server eclipse.jdt.ls https://github.com/eclipse/eclipse.jdt.ls which is used in VS Code.

I changed lsp-mode.el and added these code similar to haskell-mode.

(lsp-define-client 'java-mode "java" 'stdio #'lsp--java-get-root :command '("java" "-Declipse.application=org.eclipse.jdt.ls.core.id1" "-Dosgi.bundles.defaultStartLevel=4" "-Declipse.product=org.eclipse.jdt.ls.core.product" "-Dlog.protocol=true" "-Dlog.level=ALL" "-noverify" "-Xmx1G" "-jar" "/Users/tutysara/.vscode/extensions/redhat.java-0.1.0/server/plugins/org.eclipse.equinox.launcher_1.4.0.v20161219-1356.jar" "-configuration" "/Users/tutysara/.vscode/extensions/redhat.java-0.1.0/server/config_mac" "-data" "/Users/tutysara/src/myprojects/java/restful/simple-service") :name "Java Language Server")

and

(defun lsp--java-get-root () (let ((dir default-directory)) (message "getting java root") (if (string= dir "/") (user-error "Couldn't find java root") dir)))

I have the hardcoded values for the path to start with. I made these change to lsp-mode.el and evaluated the buffer.

When I switch to a java file and enable java-mode, nothing happens.

Is there any additional setup that I have to make.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/vibhavp/emacs-lsp/issues/34, or mute the thread https://github.com/notifications/unsubscribe-auth/ACCymBgWFtJupTgxs-z8aBE7WZhY2MWqks5rrVOPgaJpZM4MwEDP .

vibhavp commented 7 years ago

Additionally, java-mode should be automatically enabled when you open a .java file. lsp-mode uses find file hooks to see whether a programming minor mode is enabled, and then initialises a server.

tutysara commented 7 years ago

Yes I did enabled -- lsp-global-mode. When I open a java file I also see java-mode is enabled.

To test further, I created a go file, visited the file with lsp-global-mode turned on. Nothing happens there as well. If I do (xref-find-definition), it asks for a TAG file.

I am using spacemacs.

vibhavp commented 7 years ago

Have you tried executing the lsp-define-client call manually?

vibhavp commented 7 years ago

I tried executing your code (paste it to *scratch*, M-x eval-buffer), and creating .java files triggers lsp-mode on my machine.

tutysara commented 7 years ago

Let me try executing lsp-define-client manually Also let me try this with just emacs, not spacemacs and report. ty

tutysara commented 7 years ago

I tried by adding these to .spacemacs file and it worked.

(defun dotspacemacs/user-config ()
  "Configuration function for user code.
This function is called at the very end of Spacemacs initialization after
layers configuration.
This is the place where most of your configurations should be done. Unless it is
explicitly specified that a variable should be set before a package is loaded,
you should place your code here."
  (add-hook 'prog-mode-hook 'linum-mode)

  (require 'lsp-mode)
  (global-lsp-mode t)

I see these logs in the messages window when I open an java file

Start a new Language Server for this project? y
getting java root
1 Apr, 2017 7:31:40 PM >> initialize
Invalid face reference: compilation-message
Invalid face reference: quote
Invalid face reference: compilation-message
Invalid face reference: quote
1 Apr, 2017 7:31:40 PM Initializing Java Language Server 0.1.0.201703302338
Invalid face reference: compilation-message
Invalid face reference: quote
Invalid face reference: compilation-message
Invalid face reference: quote
Unknown notification language/status
1 Apr, 2017 7:31:40 PM Creating the default Java project
Invalid face reference: compilation-message
Invalid face reference: quote
Invalid face reference: compilation-message
Invalid face reference: quote
Invalid face reference: compilation-message
Invalid face reference: quote
Mark set
1 Apr, 2017 7:31:40 PM >> document/didOpen
Invalid face reference: compilation-message

lsp-capabilities returned this

Document sync method: Send full contents
The server provides hover support
The server provides completion support
The server provides goto definition support
The server provides references support
The server provides file symbol support
The server provides project symbol support
The server provides code actions
The server provides code lens
The server provides file formatting

If I start editing a java file, emacs freezes and I have to kill it.

tutysara commented 7 years ago

I saw docs for a java function in the code before it froze, so this is working.

Not sure how to check the freeze issue in emacs.

I connected visualvm to the running java process to see if there are deadlocks, I couldn't find anything.

tutysara commented 7 years ago

Was able to hit Ctlr+g and come out. This is the backtrace I have

Debugger entered--returning value: #("1 Apr, 2017 8:34:32 PM >> document/hover" 0 40 (face (quote compilation-message)))
  lsp--on-notification(#s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8 data ("jsonrpc" "2.0" "method" "window/logMessage" "params" #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8 data ("type" 3 "message" "1 Apr, 2017 8:34:32 PM >> document/hover" ...)) ...)))
  lsp--from-server("Content-Length: 129
\n
\n{\"jsonrpc\":\"2.0\",\"method\":\"window/logMessage\",\"params\":{\"type\":3,\"message\":\"1 Apr, 2017 8:34:32 PM \\u003e\\u003e document/hover\"}}")
  lsp--process-filter(#<process Java Language Server> "Content-Length: 39
\n
\n{\"jsonrpc\":\"2.0\",\"id\":\"30\",\"result\":{}}")
  accept-process-output(#<process Java Language Server>)
  lsp--process-filter(#<process Java Language Server> "Content-Length: 129
\n
\n{\"jsonrpc\":\"2.0\",\"method\":\"window/logMessage\",\"params\":{\"type\":3,\"message\":\"1 Apr, 2017 8:34:32 PM \\u003e\\u003e document/hover\"}}")
  accept-process-output(#<process Java Language Server>)
  lsp--stdio-send-sync("Content-Length: 292
\n
\n{\"jsonrpc\":\"2.0\",\"method\":\"textDocument/hover\",\"params\":{\"textDocument\":{\"uri\":\"file:///Users/tutysara/src/myprojects/java/BroadleafCommerce/common/src/main/java/org/broadleafcommerce/common/extensibility/jpa/MergePersistenceUnitManager.java\"},\"position\":{\"line\":324,\"character\":25}},\"id\":30}" #<process Java Language Server>)
  lsp--send-request((:jsonrpc "2.0" :method "textDocument/hover" :params (:textDocument (:uri "file:///Users/tutysara/src/myprojects/java/BroadleafCommerce/common/src/main/java/org/broadleafcommerce/common/extensibility/jpa/MergePersistenceUnitManager.java") :position (:line 324 :character 25)) :id 30))
  lsp-eldoc()
  eldoc-print-current-symbol-info()
  #[0 "\204�  \205�\n\303>?\205�\304 \207" [eldoc-mode global-eldoc-mode eldoc-documentation-function (nil ignore) eldoc-print-current-symbol-info] 2]()
  apply(#[0 "\204�    \205�\n\303>?\205�\304 \207" [eldoc-mode global-eldoc-mode eldoc-documentation-function (nil ignore) eldoc-print-current-symbol-info] 2] nil)
  timer-event-handler([t 0 0 500000 nil #[0 "\204�    \205�\n\303>?\205�\304 \207" [eldoc-mode global-eldoc-mode eldoc-documentation-function (nil ignore) eldoc-print-current-symbol-info] 2] nil idle 0])
vibhavp commented 7 years ago

Emacs hangs when lsp-mode is waiting for a reply from the language server. The latest commit adds a lsp-print-io variable, could you enable that and tell me the messages?

Also, what Emacs version are you using?

tutysara commented 7 years ago

Sure, let me get the latest version of lsp-mode and try. I am using -- GNU Emacs 25.1.1 (x86_64-apple-darwin16.4.0, NS appkit-1504.81 Version 10.12.3 (Build 16D32)) of 2017-03-22

vibhavp commented 7 years ago

This also might be related to a faulty parser: https://github.com/vibhavp/emacs-lsp/issues/36

tutysara commented 7 years ago

I have the vairable set and captured the messages when it froze, this is what I see

lsp--stdio-send-sync: Content-Length: 219

{"jsonrpc":"2.0","method":"textDocument/hover","params":{"textDocument":{"uri":"file:///Users/tutysara/src/myprojects/java/BroadleafCommerce/common/src/main/java/test.java"},"position":{"line":2,"character":7}},"id":17}
Output from language server: Content-Length: 129

{"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"2 Apr, 2017 3:06:51 AM \u003e\u003e document/hover"}}
Output from language server: Content-Length: 39

{"jsonrpc":"2.0","id":"17","result":{}}
error in process filter: Quit [2 times]
Quit

See if this helps

vibhavp commented 7 years ago

The parser has been rewritten, could you see if emacs hangs again?

tutysara commented 7 years ago

@vibhavp thank you, let me check and update

tutysara commented 7 years ago

I see these in messages --

Start a new Language Server for this project? (y or n) y
getting java root
lsp--stdio-send-sync: Content-Length: 182

{"jsonrpc":"2.0","method":"initialize","params":{"processId":41800,"rootPath":"/Users/tutysara/src/myprojects/java/BroadleafCommerce/common/src/main/java/","capabilities":{}},"id":1}
error in process filter: Error parsing language server output: (wrong-type-argument stringp nil) [2 times]
Output from language server: {"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"4 Apr, 2017 4:59:05 AM Initializing Java Language Server 0.1.0.201703302338"}}
4 Apr, 2017 4:59:05 AM Initializing Java Language Server 0.1.0.201703302338
Invalid face reference: compilation-message
Invalid face reference: quote
Invalid face reference: compilation-message
Invalid face reference: quote
Output from language server: {"jsonrpc":"2.0","method":"language/status","params":{"type":"Starting","message":"Init..."}}
Unknown notification language/status
Output from language server: {"jsonrpc":"2.0","method":"language/status","params":{"type":"Starting","message":"10%"}}
Unknown notification language/status
error in process filter: Error parsing language server output: (wrong-type-argument stringp nil) [2 times]
Output from language server: {"jsonrpc":"2.0","method":"language/status","params":{"type":"Starting","message":"17%"}}
Unknown notification language/status
Output from language server: {"jsonrpc":"2.0","method":"language/status","params":{"type":"Starting","message":"23%"}}
Unknown notification language/status
lsp--initialize: Wrong type argument: hash-table-p, nil
Output from language server: {"jsonrpc":"2.0","method":"language/status","params":{"type":"Started","message":"Ready"}}
Unknown notification language/status

After the update the hover functionality which worked previously, stopped working.

Did a regression by installing go-language server and tested it with a go file. I see an error there as well.

Start a new Language Server for this project? y
lsp--stdio-send-sync: Content-Length: 150

{"jsonrpc":"2.0","method":"initialize","params":{"processId":53322,"rootPath":"/Users/tutysara/src/myprojects/go/test-lsp/","capabilities":{}},"id":1}
Quit
eldoc error: (file-error Searching for program No such file or directory gocode) [2 times]
Auto-evilification could not remap these functions in map ‘edebug-mode-map’:
   - ‘edebug-Go-nonstop-mode’ originally mapped on ‘G’
lsp-capabilities: Wrong type argument: hash-table-p, nil
vibhavp commented 7 years ago

The go-languagserver errors seem to be because lsp is conflicting with gocode, and other helper modes. Try disabling them, as lsp-mode works perfectly with go on my machine.

language/status is eclipse.jdt.ls's own notification type, which I'll add support for.

tutysara commented 7 years ago

Ok the communication between java server works well now without emacs freeze. Thank you. I see the help text when I hover over a function, eldoc works.

  1. I see an error End position lies outside document range from server when I deleted a line in the middle of a java file and rewrote it, here are the full logs
    
    lsp--stdio-send-async: Content-Length: 526

{"jsonrpc":"2.0","method":"textDocument/didChange","params":{"textDocument":{"uri":"file:///Users/tutysara/src/myprojects/java/BroadleafCommerce/common/src/main/java/test.java","version":21},"contentChanges":[{"range":{"start":{"line":6,"character":21},"end":{"line":6,"character":22}},"rangeLength":1,"text":"i"},{"range":{"start":{"line":6,"character":22},"end":{"line":6,"character":23}},"rangeLength":1,"text":"n"},{"range":{"start":{"line":6,"character":23},"end":{"line":6,"character":24}},"rangeLength":1,"text":"t"}]}} Output from language server: {"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"5 Apr, 2017 7:14:56 AM \u003e\u003e document/didChange"}} 5 Apr, 2017 7:14:56 AM >> document/didChange Invalid face reference: compilation-message Invalid face reference: quote Invalid face reference: compilation-message Invalid face reference: quote Output from language server: {"jsonrpc":"2.0","method":"window/logMessage","params":{"type":1,"message":"5 Apr, 2017 7:14:56 AM Failed to apply changes\nEnd position lies outside document range\norg.eclipse.text.edits.MalformedTreeException: End position lies outside document range\n\tat org.eclipse.text.edits.TextEditProcessor.checkIntegrityDo(TextEditProcessor.java:178)\n\tat org.eclipse.text.edits.TextEdit.dispatchCheckIntegrity(TextEdit.java:741)\n\tat org.eclipse.text.edits.TextEditProcessor.performEdits(TextEditProcessor.java:151)\n\tat org.eclipse.text.edits.TextEdit.apply(TextEdit.java:709)\n\tat org.eclipse.jdt.ls.core.internal.handlers.DocumentLifeCycleHandler.handleChanged(DocumentLifeCycleHandler.java:188)\n\tat org.eclipse.jdt.ls.core.internal.handlers.DocumentLifeCycleHandler.access$2(DocumentLifeCycleHandler.java:162)\n\tat org.eclipse.jdt.ls.core.internal.handlers.DocumentLifeCycleHandler$3.run(DocumentLifeCycleHandler.java:88)\n\tat org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2240)\n\tat org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2262)\n\tat org.eclipse.jdt.ls.core.internal.handlers.DocumentLifeCycleHandler.didChange(DocumentLifeCycleHandler.java:85)\n\tat org.eclipse.jdt.ls.core.internal.handlers.JDTLanguageServer.didChange(JDTLanguageServer.java:353)\n\tat sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)\n\tat sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)\n\tat java.lang.reflect.Method.invoke(Method.java:498)\n\tat org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.lambda$null$0(GenericEndpoint.java:49)\n\tat org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.notify(GenericEndpoint.java:104)\n\tat org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.handleNotification(RemoteEndpoint.java:165)\n\tat org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.consume(RemoteEndpoint.java:136)\n\tat org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.handleMessage(StreamMessageProducer.java:149)\n\tat org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.listen(StreamMessageProducer.java:77)\n\tat org.eclipse.lsp4j.jsonrpc.json.ConcurrentMessageProcessor.run(ConcurrentMessageProcessor.java:68)\n\tat java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)\n\tat java.util.concurrent.FutureTask.run(FutureTask.java:266)\n\tat java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)\n\tat java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)\n\tat java.lang.Thread.run(Thread.java:745)\n"}} 5 Apr, 2017 7:14:56 AM Failed to apply changes End position lies outside document range org.eclipse.text.edits.MalformedTreeException: End position lies outside document range at org.eclipse.text.edits.TextEditProcessor.checkIntegrityDo(TextEditProcessor.java:178) at org.eclipse.text.edits.TextEdit.dispatchCheckIntegrity(TextEdit.java:741) at org.eclipse.text.edits.TextEditProcessor.performEdits(TextEditProcessor.java:151)


2. Find references `(xref-find-references)`  throws an error, here are the logs --

lsp--stdio-send-sync: Content-Length: 74

{"jsonrpc":"2.0","method":"textDocument/references","params":null,"id":26} error in process filter: Error parsing language server output: (wrong-type-argument stringp nil) [2 times]

3. Completion at point , throws an error `Index out of bounds`, here are the logs --

{"jsonrpc":"2.0","method":"textDocument/completion","params":{"textDocument":{"uri":"file:///Users/tutysara/src/myprojects/java/BroadleafCommerce/common/src/main/java/test.java"},"position":{"line":6,"character":13}},"id":3} Output from language server: {"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"5 Apr, 2017 7:47:12 AM \u003e\u003e document/completion"}} 5 Apr, 2017 7:47:12 AM >> document/completion Invalid face reference: compilation-message Invalid face reference: quote Invalid face reference: compilation-message Invalid face reference: quote Output from language server: {"jsonrpc":"2.0","method":"window/logMessage","params":{"type":1,"message":"5 Apr, 2017 7:47:12 AM Problem with codeComplete for file:///Users/tutysara/src/myprojects/java/BroadleafCommerce/common/src/main/java/test.java\nIndex out of bounds\nJava Model Exception: Java Model Status [Index out of bounds]\n\tat org.eclipse.jdt.internal.core.Openable.codeComplete(Openable.java:121)\n\tat org.eclipse.jdt.internal.core.CompilationUnit.codeComplete(CompilationUnit.java:357)\n\tat org.eclipse.jdt.internal.core.CompilationUnit.codeComplete(CompilationUnit.java:345)\n\tat org.eclipse.jdt.ls.core.internal.handlers.CompletionHandler.computeContentAssist(CompletionHandler.java:79)\n\tat org.eclipse.jdt.ls.core.internal.handlers.CompletionHandler.lambda$0(CompletionHandler.java:39)\n\tat java.util.concurrent.CompletableFuture.uniApply(CompletableFuture.java:602)\n\tat java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:577)\n\tat java.util.concurrent.CompletableFuture$Completion.exec(CompletableFuture.java:443)\n\tat java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)\n\tat java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)\n\tat java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692)\n\tat java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157)\n"}} 5 Apr, 2017 7:47:12 AM Problem with codeComplete for file:///Users/tutysara/src/myprojects/java/BroadleafCommerce/common/src/main/java/test.java Index out of bounds Java Model Exception: Java Model Status [Index out of bounds] at org.eclipse.jdt.internal.core.Openable.codeComplete(Openable.java:121) at org.eclipse.jdt.internal.core.CompilationUnit.codeComplete(CompilationUnit.java:357) at org.eclipse.jdt.internal.core.CompilationUnit.codeComplete(CompilationUnit.java:345) at org.eclipse.jdt.ls.core.internal.handlers.CompletionHandler.computeContentAssist(CompletionHandler.java:79) at org.eclipse.jdt.ls.core.internal.handlers.CompletionHandler.lambda$0(CompletionHandler.java:39)


The test java file I am using 
``` java
import java.io.*;
class Test{
    public static void main(String args[]){
        System.out.println("hello lsp");
        String test="test";
        System.out.println(test);
        test.
    }
}
vibhavp commented 7 years ago

Out of range positions are an issue with pyls too. I'll see what I can do.

tutysara commented 7 years ago

ok thank you. Reach out to me if you need help testing.

vibhavp commented 7 years ago

Okay, looks like the out of range problems were because of changes not being flushed before a request was made to the server. I've also fixed the Error parsing language server output: errors which were due to stderr output also being fed to the filter.

Could you try testing again?

tutysara commented 7 years ago

I see Completion at point working now, but it is a bit slow when there are many options

Output from language server: {"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"5 Apr, 2017 8:51:25 PM Completion request completed"}}
5 Apr, 2017 8:51:25 PM Completion request completed
Invalid face reference: compilation-message
Invalid face reference: quote
Invalid face reference: compilation-message
Invalid face reference: quote
Output from language server: {"jsonrpc":"2.0","id":"46","result":{"isIncomplete":false,"items":[{"label":"java.awt.im","kind":9,"sortText":"zzzzzzzcbf","data":{"pid":"0","rid":"15","uri":"file:/Users/tutysara/src/myprojects/java/BroadleafCommerce/common/src/main/java/test.java"}},{"label":"java.lang.annotation","kind":9,"sortText":"zzzzzzzcbf","data":{"pid":"1","rid":"15","uri":"file:/Users/tutysara/src/myprojects/java/BroadleafCommerce/common/src/main/java/test.java"}},{"label":"java.nio.channels.spi","kind":9,"sortText":"zzzzzzzcbf","data":{"pid":"2","rid":"15","uri":"file:/Users/tutysara/src/myprojects/java/BroadleafCommerce/common/src/main/java/test.java"}},{"label":"java.nio.file","kind":9,"sortText":"zzzzzzzcbf","data":{"pid":"3","rid":"15","uri":"file:/Users/tutysara/src/myprojects/java/BroadleafCommerce/common/src/main/java/test.java"}},{"label":"java.beans.beancontext","kind":9,"sortText":"zzzzzzzcbf","data":{"pid":"4","rid":"15","uri":"file:/Users/tutysara/src/myprojects/java/BroadleafCommerce/common/src/main/java/test.java"}},{"label":"java.util.concurrent","kind":9,"sortText":"zzzzzzzcbf","data":{"pid":"5","rid":"15","uri":"file:/Users/tutysara/src/myprojects/java/BroadleafCommerce/common/src/main/java/test.java"}},{"label":"java.awt.geom","kind":9,"sortText":"zzzzzzzcbf","data":{"pid":"6","rid":"15","uri":"file:/Users/tutysara/src/myprojects/java/BroadleafCommerce/common/src/main/java/test.java"}},{"label":"java.awt.image","kind":9,"sortText":"zzzzzzzcbf","data":{"pid":"7","rid":"15","uri":"file:/Users/tutysara/src/myprojects/java/BroadleafCommerce/common/src/main/java/test.java"}},{"label":"java.awt.dnd","kind":9,"sortText":"zzzzzzzcbf","data":{"pid":"8","rid":"15","uri":"file:/Users/tutysara/src/myprojects/java/BroadleafCommerce/common/src/main/java/test.java"}},{"label":"java.awt.event","kind":9,"sortText":"zzzzzzzcbf","data":{"pid":"9","rid":"15","uri":"file:/Users/tutysara/src/myprojects/java/BroadleafCommerce/common/src/main/java/test.java"}},{"label":"java.security.interfaces","kind":9,"sortText":"zzzzzzzcbf","data":{"pid":"10","rid":"15","uri":"file:/Users/tutysara/src/myprojects/java/BroadleafCommerce/common/src/main/java/test.java"}},{"label":"java.time.temporal","kind":9,"sortText":"zzzzzzzcbf","data":{"pid":"11","rid":"15","uri":"file:/Users/tutysara/src/myprojects/java/BroadleafCommerce/common/src/main/java/test.java"}},{"label":"java.awt.font","kind":9,"sortText":"zzzzzzzcbf","data":{"pid":"12","rid":"15","uri":"file:/Users/tutysara/src/myprojects/java/BroadleafCommerce/common/src/main/java/test.java"}},{"label":"java.lang.reflect","kind":9,"sortText":"zzzzzzzcbf","data":{"pid":"13","rid":"15","uri":"file:/Users/tutysara/src/myprojects/java/BroadleafCommerce/common/src/main/java/test.java"}},{"label":"java.applet","kind":9,"sortText":"zzzzzzzcbf","data":{"pid":"14","rid":"15","uri":"file:/Users/tutysara/src/myprojects/java/BroadleafCommerce/common/src/main/java/test.java"}},{"label":"java.time.zone","kind":9,"sortText":"zzzzzzzcbf","data":{"pid":"15","rid":"15","uri":"file:/Users/tutysara/src/myprojects/java/BroadleafCommerce/common/src/main/java/test.java"}},{"label":"java.text.spi","kind":9,"sortText":"zzzzzzzcbf","data":{"pid":"16","rid":"15","uri":"file:/Users/tutysara/src/myprojects/java/BroadleafCommerce/common/src/main/java/test.java"}},{"label":"java.awt.image.renderable","kind":9,"sortText":"zzzzzzzcbf","data":{"pid":"17","rid":"15","uri":"file:/Users/tutysara/src/myprojects/java/BroadleafCommerce/common/src/main/java/test.java"}},{"label":"java.rmi.server","kind":9,"sortText":"zzzzzzzcbf","data":{"pid":"18","rid":"15","uri":"file:/Users/tutysara/src/myprojects/java/BroadleafCommerce/common/src/main/java/test.java"}},{"label":"java.util.concurrent.locks","kind":9,"sortText":"zzzzzzzcbf","data":{"pid":"19","rid":"15","uri":"file:/Users/tutysara/src/myprojects/java/BroadleafCommerce/common/src/main/java/test.java"}},{"label":"java.security.cert","kind":9,"sortText":"zzzzzzzcbf","data":{"pid":"20","rid":"15","uri":"file:/Users/tutysara/src/myprojects/java/BroadleafCommerce/common/src/main/java/test.java"}},{"label":"java.text","kind":9,"sortText":"zzzzzzzcbf","data":{"pid":"21","rid":"15","uri":"file:/Users/tutysara/src/myprojects/java/BroadleafCommerce/common/src/main/java/test.java"}},{"label":"java.util.concurrent.atomic","kind":9,"sortText":"zzzzzzzcbf","data":{"pid":"22","rid":"15","uri":"file:/Users/tutysara/src/myprojects/java/BroadleafCommerce/common/src/main/java/test.java"}},{"label":"java.awt","kind":9,"sortText":"zzzzzzzcbf","data":{"pid":"23","rid":"15","uri":"file:/Users/tutysara/src/myprojects/java/BroadleafCommerce/common/src/main/java/test.java"}},{"label":"java.security.spec","kind":9,"sortText":"zzzzzzzcbf","data":{"pid":"24","rid":"15","uri":"file:/Users/tutysara/src/myprojects/java/BroadleafCommerce/common/src/main/java/test.java"}},{"label":"java.nio","kind":9,"sortText":"zzzzzzzcbf","data":{"pid":"25","rid":"15","uri":"file:/Users/tutysara/src/myprojects/java/BroadleafCommerce/common/src/main/java/test.java"}},{"label":"java.util.logging","kind":9,"sortText":"zzzzzzzcbf","data":{"pid":"26","rid":"15","uri":"file:/Users/tutysara/src/myprojects/java/BroadleafCommerce/common/src/main/java/test.java"}},{"label":"java.awt.im.spi","kind":9,"sortText":"zzzzzzzcbf","data":{"pid":"27","rid":"15","uri":"file:/Users/tutysara/src/myprojects/java/BroadleafCommerce/common/src/main/java/test.java"}},{"label":"java.rmi","kind":9,"sortText":"zzzzzzzcbf","data":{"pid":"28","rid":"15","uri":"file:/Users/tutysara/src/myprojects/java/BroadleafCommerce/common/src/main/java/test.java"}},{"label":"java.lang.invoke","kind":9,"sortText":"zzzzzzzcbf","data":{"pid":"29","rid":"15","uri":"file:/Users/tutysara/src/myprojects/java/BroadleafCommerce/common/src/main/java/test.java"}},{"label":"java.security.acl","kind":9,"sortText":"zzzzzzzcbf","data":{"pid":"30","rid":"15","uri":"file:/Users/tutysara/src/myprojects/java/BroadleafCommerce/common/src/main/java/test.java"}},{"label":"java.nio.channels","kind":9,"sortText":"zzzzzzzcbf","data":{"pid":"31","rid":"15","uri":"file:/Users/tutysara/src/myprojects/java/BroadleafCommerce/common/src/main/java/test.java"}},{"label":"java.lang.ref","kind":9,"sortText":"zzzzzzzcbf","data":{"pid":"32","rid":"15","uri":"file:/Users/tutysara/src/myprojects/java/BroadleafCommerce/common/src/main/java/test.java"}},{"label":"java.util.regex","kind":9,"sortText":"zzzzzzzcbf","data":{"pid":"33","rid":"15","uri":"file:/Users/tutysara/src/myprojects/java/BroadleafCommerce/common/src/main/java/test.java"}},{"label":"java.rmi.dgc","kind":9,"sortText":"zzzzzzzcbf","data":{"pid":"34","rid":"15","uri":"file:/Users/tutysara/src/myprojects/java/BroadleafCommerce/common/src/main/java/test.java"}},{"label":"java.nio.file.spi","kind":9,"sortText":"zzzzzzzcbf","data":{"pid":"35","rid":"15","uri":"file:/Users/tutysara/src/myprojects/java/BroadleafCommerce/common/src/main/java/test.java"}},{"label":"java.nio.charset","kind":9,"sortText":"zzzzzzzcbf","data":{"pid":"36","rid":"15","uri":"file:/Users/tutysara/src/myprojects/java/BroadleafCommerce/common/src/main/java/test.java"}},{"label":"java.security","kind":9,"sortText":"zzzzzzzcbf","data":{"pid":"37","rid":"15","uri":"file:/Users/tutysara/src/myprojects/java/BroadleafCommerce/common/src/main/java/test.java"}},{"label":"java.awt.datatransfer","kind":9,"sortText":"zzzzzzzcbf","data":{"pid":"38","rid":"15","uri":"file:/Users/tutysara/src/myprojects/java/BroadleafCommerce/common/src/main/java/test.java"}},{"label":"java.time.chrono","kind":9,"sortText":"zzzzzzzcbf","data":{"pid":"39","rid":"15","uri":"file:/Users/tutysara/src/myprojects/java/BroadleafCommerce/common/src/main/java/test.java"}},{"label":"java.util.function","kind":9,"sortText":"zzzzzzzcbf","data":{"pid":"40","rid":"15","uri":"file:/Users/tutysara/src/myprojects/java/BroadleafCommerce/common/src/main/java/test.java"}},{"label":"java.util.jar","kind":9,"sortText":"zzzzzzzcbf","data":{"pid":"41","rid":"15","uri":"file:/Users/tutysara/src/myprojects/java/BroadleafCommerce/common/src/main/java/test.java"}},{"label":"java.awt.dnd.peer","kind":9,"sortText":"zzzzzzzcbf","data":{"pid":"42","rid":"15","uri":"file:/Users/tutysara/src/myprojects/java/BroadleafCommerce/common/src/main/java/test.java"}},{"label":"java.lang.instrument","kind":9,"sortText":"zzzzzzzcbf","data":{"pid":"43","rid":"15","uri":"file:/Users/tutysara/src/myprojects/java/BroadleafCommerce/common/src/main/java/test.java"}},{"label":"java.rmi.activation","kind":9,"sortText":"zzzzzzzcbf","data":{"pid":"44","rid":"15","uri":"file:/Users/tutysara/src/myprojects/java/BroadleafCommerce/common/src/main/java/test.java"}},{"label":"java.math","kind":9,"sortText":"zzzzzzzcbf","data":{"pid":"45","rid":"15","uri":"file:/Users/tutysara/src/myprojects/java/BroadleafCommerce/common/src/main/java/test.java"}},{"label":"java.util.spi","kind":9,"sortText":"zzzzzzzcbf","data":{"pid":"46","rid":"15","uri":"file:/Users/tutysara/src/myprojects/java/BroadleafCommerce/common/src/main/java/test.java"}},{"label":"java.net","kind":9,"sortText":"zzzzzzzcbf","data":{"pid":"47","rid":"15","uri":"file:/Users/tutysara/src/myprojects/java/BroadleafCommerce/common/src/main/java/test.java"}},{"label":"java.awt.color","kind":9,"sortText":"zzzzzzzcbf","data":{"pid":"48","rid":"15","uri":"file:/Users/tutysara/src/myprojects/java/BroadleafCommerce/common/src/main/java/test.java"}},{"label":"java.util","kind":9,"sortText":"zzzzzzzcbf","data":{"pid":"49","rid":"15","uri":"file:/Users/tutysara/src/myprojects/java/BroadleafCommerce/common/src/main/java/test.java"}},{"label":"java.awt.peer","kind":9,"sortText":"zzzzzzzcbf","data":{"pid":"50","rid":"15","uri":"file:/Users/tutysara/src/myprojects/java/BroadleafCommerce/common/src/main/java/test.java"}},{"label":"java.rmi.registry","kind":9,"sortText":"zzzzzzzcbf","data":{"pid":"51","rid":"15","uri":"file:/Users/tutysara/src/myprojects/java/BroadleafCommerce/common/src/main/java/test.java"}},{"label":"java.beans","kind":9,"sortText":"zzzzzzzcbf","data":{"pid":"52","rid":"15","uri":"file:/Users/tutysara/src/myprojects/java/BroadleafCommerce/common/src/main/java/test.java"}},{"label":"java.awt.print","kind":9,"sortText":"zzzzzzzcbf","data":{"pid":"53","rid":"15","uri":"file:/Users/tutysara/src/myprojects/java/BroadleafCommerce/common/src/main/java/test.java"}},{"label":"java.lang","kind":9,"sortText":"zzzzzzzcbf","data":{"pid":"54","rid":"15","uri":"file:/Users/tutysara/src/myprojects/java/BroadleafCommerce/common/src/main/java/test.java"}},{"label":"java.io","kind":9,"sortText":"zzzzzzzcbf","data":{"pid":"55","rid":"15","uri":"file:/Users/tutysara/src/myprojects/java/BroadleafCommerce/common/src/main/java/test.java"}},{"label":"java.util.prefs","kind":9,"sortText":"zzzzzzzcbf","data":{"pid":"56","rid":"15","uri":"file:/Users/tutysara/src/myprojects/java/BroadleafCommerce/common/src/main/java/test.java"}},{"label":"java.time","kind":9,"sortText":"zzzzzzzcbf","data":{"pid":"57","rid":"15","uri":"file:/Users/tutysara/src/myprojects/java/BroadleafCommerce/common/src/main/java/test.java"}},{"label":"java.lang.management","kind":9,"sortText":"zzzzzzzcbf","data":{"pid":"58","rid":"15","uri":"file:/Users/tutysara/src/myprojects/java/BroadleafCommerce/common/src/main/java/test.java"}},{"label":"java.nio.file.attribute","kind":9,"sortText":"zzzzzzzcbf","data":{"pid":"59","rid":"15","uri":"file:/Users/tutysara/src/myprojects/java/BroadleafCommerce/common/src/main/java/test.java"}},{"label":"java.time.format","kind":9,"sortText":"zzzzzzzcbf","data":{"pid":"60","rid":"15","uri":"file:/Users/tutysara/src/myprojects/java/BroadleafCommerce/common/src/main/java/test.java"}},{"label":"java.sql","kind":9,"sortText":"zzzzzzzcbf","data":{"pid":"61","rid":"15","uri":"file:/Users/tutysara/src/myprojects/java/BroadleafCommerce/common/src/main/java/test.java"}},{"label":"java.util.stream","kind":9,"sortText":"zzzzzzzcbf","data":{"pid":"62","rid":"15","uri":"file:/Users/tutysara/src/myprojects/java/BroadleafCommerce/common/src/main/java/test.java"}},{"label":"java.util.zip","kind":9,"sortText":"zzzzzzzcbf","data":{"pid":"63","rid":"15","uri":"file:/Users/tutysara/src/myprojects/java/BroadleafCommerce/common/src/main/java/test.java"}},{"label":"java.nio.charset.spi","kind":9,"sortText":"zzzzzzzcbf","data":{"pid":"64","rid":"15","uri":"file:/Users/tutysara/src/myprojects/java/BroadleafCommerce/common/src/main/java/test.java"}}]}}

I still see the issue -- Error parsing language server output

Output from language server: {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"uri":"file:///Users/tutysara/src/myprojects/java/BroadleafCommerce/common/src/main/java/test.java","diagnostics":[{"range":{"start":{"line":0,"character":0},"end":{"line":0,"character":72}},"severity":1,"code":"1610612972","source":"Java","message":"Syntax error on token(s), misplaced construct(s)"},{"range":{"start":{"line":1,"character":11},"end":{"line":1,"character":12}},"severity":1,"code":"1610612940","source":"Java","message":"Syntax error on token \".\", ; expected"},{"range":{"start":{"line":1,"character":30},"end":{"line":1,"character":34}},"severity":1,"code":"1610612940","source":"Java","message":"Syntax error on token \"void\", @ expected"},{"range":{"start":{"line":1,"character":40},"end":{"line":1,"character":46}},"severity":1,"code":"1610612967","source":"Java","message":"Syntax error on token \"String\", instanceof expected after this token"},{"range":{"start":{"line":2,"character":8},"end":{"line":2,"character":40}},"severity":1,"code":"1610612972","source":"Java","message":"Syntax error on token(s), misplaced construct(s)"},{"range":{"start":{"line":3,"character":26},"end":{"line":3,"character":27}},"severity":1,"code":"1610612940","source":"Java","message":"Syntax error on token \";\", :: expected"},{"range":{"start":{"line":4,"character":32},"end":{"line":4,"character":33}},"severity":1,"code":"1610612940","source":"Java","message":"Syntax error on token \";\", [ expected"},{"range":{"start":{"line":5,"character":12},"end":{"line":5,"character":13}},"severity":1,"code":"1610612968","source":"Java","message":"Syntax error on token \".\", delete this token"},{"range":{"start":{"line":5,"character":12},"end":{"line":5,"character":13}},"severity":1,"code":"1610612976","source":"Java","message":"Syntax error, insert \"]\" to complete ArrayAccess"},{"range":{"start":{"line":5,"character":12},"end":{"line":5,"character":13}},"severity":1,"code":"1610612976","source":"Java","message":"Syntax error, insert \";\" to complete BlockStatementopt"}]}}
error in process filter: Error parsing language server output: (error Flycheck cannot use lsp in this buffer, type M-x flycheck-verify-setup for more details) [2 times]

We also have -- End position lies outside document range, here are the logs --


lsp--stdio-send-async: Content-Length: 420

{"jsonrpc":"2.0","method":"textDocument/didChange","params":{"textDocument":{"uri":"file:///Users/tutysara/src/myprojects/java/BroadleafCommerce/common/src/main/java/test.java","version":38},"contentChanges":[{"range":{"start":{"line":6,"character":32},"end":{"line":6,"character":33}},"rangeLength":1,"text":"f"},{"range":{"start":{"line":6,"character":32},"end":{"line":6,"character":32}},"rangeLength":0,"text":""}]}}
Output from language server: {"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"5 Apr, 2017 8:51:25 PM \u003e\u003e document/didChange"}}
5 Apr, 2017 8:51:25 PM >> document/didChange
Invalid face reference: compilation-message
Invalid face reference: quote
Invalid face reference: compilation-message
Invalid face reference: quote
Output from language server: {"jsonrpc":"2.0","method":"window/logMessage","params":{"type":1,"message":"5 Apr, 2017 8:51:25 PM Failed to apply changes\nEnd position lies outside document range\norg.eclipse.text.edits.MalformedTreeException: End position lies outside document range\n\tat org.eclipse.text.edits.TextEditProcessor.checkIntegrityDo(TextEditProcessor.java:178)\n\tat org.eclipse.text.edits.TextEdit.dispatchCheckIntegrity(TextEdit.java:741)\n\tat org.eclipse.text.edits.TextEditProcessor.performEdits(TextEditProcessor.java:151)\n\tat org.eclipse.text.edits.TextEdit.apply(TextEdit.java:709)\n\tat org.eclipse.jdt.ls.core.internal.handlers.DocumentLifeCycleHandler.handleChanged(DocumentLifeCycleHandler.java:188)\n\tat org.eclipse.jdt.ls.core.internal.handlers.DocumentLifeCycleHandler.access$2(DocumentLifeCycleHandler.java:162)\n\tat org.eclipse.jdt.ls.core.internal.handlers.DocumentLifeCycleHandler$3.run(DocumentLifeCycleHandler.java:88)\n\tat org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2240)\n\tat org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2262)\n\tat org.eclipse.jdt.ls.core.internal.handlers.DocumentLifeCycleHandler.didChange(DocumentLifeCycleHandler.java:85)\n\tat org.eclipse.jdt.ls.core.internal.handlers.JDTLanguageServer.didChange(JDTLanguageServer.java:353)\n\tat sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)\n\tat sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)\n\tat java.lang.reflect.Method.invoke(Method.java:498)\n\tat org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.lambda$null$0(GenericEndpoint.java:49)\n\tat org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.notify(GenericEndpoint.java:104)\n\tat org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.handleNotification(RemoteEndpoint.java:165)\n\tat org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.consume(RemoteEndpoint.java:136)\n\tat org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.handleMessage(StreamMessageProducer.java:149)\n\tat org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.listen(StreamMessageProducer.java:77)\n\tat org.eclipse.lsp4j.jsonrpc.json.ConcurrentMessageProcessor.run(ConcurrentMessageProcessor.java:68)\n\tat java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)\n\tat java.util.concurrent.FutureTask.run(FutureTask.java:266)\n\tat java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)\n\tat java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)\n\tat java.lang.Thread.run(Thread.java:745)\n"}}
5 Apr, 2017 8:51:25 PM Failed to apply changes
End position lies outside document range
org.eclipse.text.edits.MalformedTreeException: End position lies outside document range
SerialVelocity commented 7 years ago

@vibhavp Did you end up adding support for language/status?