redhat-developer / quarkus-ls

Language server for Quarkus tooling
Eclipse Public License 2.0
43 stars 15 forks source link

Hovering "missing close tag" parser error yields `Exception` in CodeAction code #812

Closed datho7561 closed 1 year ago

datho7561 commented 1 year ago

Here is an example Qute template:

<html>

{! {#switch myString}
  {#case "asdf"}
  <h3>title</h3>
{/switch} !}

{#each items}

{#each items}
  {it.name}
{/each}

{#each items}

{#each items}
  {it.name}
{/each}

{/}

<p>
</p>

</html>

The error appears in the wrong place (it should be at the end of the file), and when you hover it, there is an Exception in the CodeAction code:

Mar. 13, 2023 12:15:55 P.M. com.redhat.qute.services.QuteCodeActions doCodeActions
SEVERE: Failed creating CodeAction Request
com.redhat.qute.ls.commons.BadLocationException: The character value, {7} of the line24}, is out of bounds.
    at com.redhat.qute.ls.commons.TreeLineTracker.getOffsetAt(TreeLineTracker.java:1246)
    at com.redhat.qute.ls.commons.TextDocument.offsetAt(TextDocument.java:71)
    at com.redhat.qute.parser.template.Template.offsetAt(Template.java:88)
    at com.redhat.qute.services.AbstractPositionRequest.<init>(AbstractPositionRequest.java:34)
    at com.redhat.qute.services.codeactions.CodeActionRequest.<init>(CodeActionRequest.java:51)
    at com.redhat.qute.services.QuteCodeActions.doCodeActions(QuteCodeActions.java:102)
    at com.redhat.qute.services.QuteLanguageService.doCodeActions(QuteLanguageService.java:104)
    at com.redhat.qute.ls.template.TemplateFileTextDocumentService.lambda$codeAction$9(TemplateFileTextDocumentService.java:165)
    at com.redhat.qute.ls.commons.ModelTextDocuments.lambda$computeModelAsyncCompose$1(ModelTextDocuments.java:144)
    at java.base/java.util.concurrent.CompletableFuture$UniCompose.tryFire(Unknown Source)
    at java.base/java.util.concurrent.CompletableFuture$Completion.exec(Unknown Source)
    at java.base/java.util.concurrent.ForkJoinTask.doExec(Unknown Source)
    at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(Unknown Source)
    at java.base/java.util.concurrent.ForkJoinPool.scan(Unknown Source)
    at java.base/java.util.concurrent.ForkJoinPool.runWorker(Unknown Source)
angelozerr commented 1 year ago

Could you give us the location where you hover the template please?

datho7561 commented 1 year ago

The error marker, which should appear after <p>|