Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IndexOutOfBoundsException repro #41

Open
ewenmaclean opened this issue Mar 20, 2022 · 4 comments
Open

IndexOutOfBoundsException repro #41

ewenmaclean opened this issue Mar 20, 2022 · 4 comments

Comments

@ewenmaclean
Copy link

ewenmaclean commented Mar 20, 2022

Thank you for this excellent repo which has been really helpful. I have reproduced the following trace with the repo and a standard monaco server (harder to repro in VSCode but hopefully this gives an indication and this is very much the same issue as that linked below):

(relates to eclipse/xtext-core#1451 )

SEVERE: Internal error: java.lang.IndexOutOfBoundsException: Position [
  line = 8
  character = 7
] text was : Hello Xtext!
Hello VSCode from Xtext!
Hello ThisFile from Other!

java.util.concurrent.CompletionException: java.lang.IndexOutOfBoundsException: Position [
  line = 8
  character = 7
] text was : Hello Xtext!
Hello VSCode from Xtext!
Hello ThisFile from Other!

	at java.base/java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:331)
	at java.base/java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:346)
	at java.base/java.util.concurrent.CompletableFuture$UniAccept.tryFire(CompletableFuture.java:704)
	at java.base/java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:506)
	at java.base/java.util.concurrent.CompletableFuture.completeExceptionally(CompletableFuture.java:2088)
	at org.eclipse.xtext.ide.server.concurrent.AbstractRequest.logAndCompleteExceptionally(AbstractRequest.java:73)
	at org.eclipse.xtext.ide.server.concurrent.ReadRequest.lambda$doRun$0(ReadRequest.java:69)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: java.lang.IndexOutOfBoundsException: Position [
  line = 8
  character = 7
] text was : Hello Xtext!
Hello VSCode from Xtext!
Hello ThisFile from Other!

	at org.eclipse.xtext.ide.server.Document.getOffSet(Document.java:62)
	at org.eclipse.xtext.ide.server.hover.HoverService.hover(HoverService.java:53)
	at org.eclipse.xtext.ide.server.LanguageServerImpl.lambda$hover$32(LanguageServerImpl.java:718)
	at org.eclipse.xtext.ide.server.WorkspaceManager.doRead(WorkspaceManager.java:438)
	at org.eclipse.xtext.ide.server.LanguageServerImpl.hover(LanguageServerImpl.java:717)
	at org.eclipse.xtext.ide.server.LanguageServerImpl.lambda$hover$31(LanguageServerImpl.java:704)
	at org.eclipse.xtext.ide.server.concurrent.ReadRequest.lambda$doRun$0(ReadRequest.java:66)
	... 5 more

to repro: on this fork and branch:

https://github.com/ewenmaclean/xtext-languageserver-example/tree/IndexOutOfBoundsError

in the monaco-server dir run yarn then yarn prepare in the server dir. Then yarn start from the server dir to start - you will get an editor at http://localhost:3000.

Now do the following - add the text:

Hello Xtext!
Hello VSCode from Xtext!
Hello ThisFile from Other!

then paste in at the end


Hello you!

Now hover over the validation error at "you!". Now delete this section, then press ctrl-Z so it reappears and then hover over the "you!" error again and you should get the error trace above

@cdietrich
Copy link
Owner

cdietrich commented Mar 20, 2022

sorry i have no idea how current the monaco thing is. and if the lsp versions match.
and if they work together at all.
also may time is very very restricted,
so can you either provide a reproducing unit test
or give me some weeks of time

at a first try yarn does not seem to start the server

i also dont see a line 8 at all in your sample snippet.

@cdietrich
Copy link
Owner

when i debug in vscode i get this undo

{
  "jsonrpc": "2.0",
  "method": "textDocument/didChange",
  "params": {
    "textDocument": {
      "version": 8,
      "uri": "file:///home/dietrich/git/xtext-languageserver-example/demo/a.mydsl"
    },
    "contentChanges": [
      {
        "range": {
          "start": {
            "line": 4,
            "character": 0
          },
          "end": {
            "line": 5,
            "character": 10
          }
        },
        "rangeLength": 11,
        "text": ""
      }
    ]
  }
}

@ewenmaclean
Copy link
Author

yes you are right - it is wrapped in a websocket typescript implementation. You are right in vscode it seems to indeed send a request but not monaco so I will attempt to look more closely there. Line 8 not being referred to is another manifestation of the problem - it is in the snippet after the second snippet is pasted and then undone.

Thank you very much for looking and for the help- I think it is clear that this problem is with the monaco LSP implementation and used to be with VSCode but now seems to be fixed. I will keep investigating the difference

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants