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 from hover request #63

Closed
petervdonovan opened this issue Jun 24, 2022 · 3 comments
Closed

IndexOutOfBoundsException from hover request #63

petervdonovan opened this issue Jun 24, 2022 · 3 comments
Labels
bug Something isn't working

Comments

@petervdonovan
Copy link
Contributor

The following error message appeared while I was testing the LF formatter in VS Code:

	at java.base/java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:332)
	at java.base/java.util.concurrent.CompletableFuture.andTree(CompletableFuture.java:1527)
	at java.base/java.util.concurrent.CompletableFuture.andTree(CompletableFuture.java:1517)
	at java.base/java.util.concurrent.CompletableFuture.andTree(CompletableFuture.java:1517)
	at java.base/java.util.concurrent.CompletableFuture.allOf(CompletableFuture.java:2419)
	at org.eclipse.xtext.ide.server.concurrent.RequestManager.cancel(RequestManager.java:114)
	at org.eclipse.xtext.ide.server.concurrent.RequestManager.runWrite(RequestManager.java:80)
	at org.eclipse.xtext.ide.server.LanguageServerImpl.runBuildable(LanguageServerImpl.java:457)
	at org.eclipse.xtext.ide.server.LanguageServerImpl.didChange(LanguageServerImpl.java:397)
	at jdk.internal.reflect.GeneratedMethodAccessor82.invoke(Unknown Source)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
	at org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.lambda$null$0(GenericEndpoint.java:65)
	at org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.notify(GenericEndpoint.java:152)
	at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.handleNotification(RemoteEndpoint.java:220)
	at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.consume(RemoteEndpoint.java:187)
	at org.eclipse.lsp4j.jsonrpc.validation.ReflectiveMessageValidator.consume(ReflectiveMessageValidator.java:68)
	at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.handleMessage(StreamMessageProducer.java:194)
	at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.listen(StreamMessageProducer.java:94)
	at org.eclipse.lsp4j.jsonrpc.json.ConcurrentMessageProcessor.run(ConcurrentMessageProcessor.java:113)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
	at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: java.lang.IndexOutOfBoundsException: Position [
  line = 32
  character = 43
] text was : // Test logical action with delay.
target TypeScript

reactor GeneratedDelay {
    input y_in: number
    
    output y_out: number
    
    logical action act(100 msec)
    
    state y_state: number(0)

    reaction(y_in) -> act {=
        y_state = y_in as number;
        actions.act.schedule(0, null);
    =}
    
    reaction(act) -> y_out {=
        y_out = y_state;
    =}
}

reactor Source {
    output out: number

    reaction(startup) -> out {=
        out = 1;
    =}
}

reactor Sink(a: number(0), b: number(0), c: number(0), d: number(0)) {
    input x: number

    reaction(x) {=
        const elapsed_logical = util.getElapsedLogicalTime();
        const logical = util.getCurrentLogicalTime();
        const physical = util.getCurrentPhysicalTime();
        console.log("Logical, physical, and elapsed logical: " + logical + physical + elapsed_logical);
        const oneHundredMsec = TimeValue.msec(100);
        if (!elapsed_logical.isEqualTo(oneHundredMsec)) {
            util.requestErrorStop("Expected " + oneHundredMsec + " but got " + elapsed_logical);
        } else {
            console.log("SUCCESS. Elapsed logical time is " + elapsed_logical);
        }
    =}
}

main reactor ActionDelay {
    source = new Source()
    sink = new Sink()
    g = new GeneratedDelay()
    
    source.out -> g.y_in
    g.y_out -> sink.x
}

	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

Perhaps this happened because the content of the document changed during the request -- I'm not sure.

I wonder if this is something that we can tolerate until we decide it is time to move away from Xtext.

@petervdonovan petervdonovan added the bug Something isn't working label Jun 24, 2022
@lhstrh
Copy link
Member

lhstrh commented Jun 27, 2022

Is there a way to make calls to the formatting blocking?

@petervdonovan
Copy link
Contributor Author

Is there a way to make calls to the formatting blocking?

Maybe... If we did that, then I think we might have to implement it on the client side (TS), so that the requests do not get interleaved. There might be a way to intercept them.

Another alternative would be for the server to fail more gracefully when it receives these invalid requests. I think XText has a way for us to bind our own hover provider, which can probably extend the one that they provide.

petervdonovan added a commit to lf-lang/lingua-franca that referenced this issue Jul 2, 2022
@petervdonovan
Copy link
Contributor Author

This seems to have been fixed by lf-lang/lingua-franca@9bd1792.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants