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

Qute: Improve error column location in error message #26479

Open
JessicaJHee opened this issue Jun 30, 2022 · 5 comments
Open

Qute: Improve error column location in error message #26479

JessicaJHee opened this issue Jun 30, 2022 · 5 comments
Labels
area/qute The template engine kind/enhancement New feature or request

Comments

@JessicaJHee
Copy link

JessicaJHee commented Jun 30, 2022

Description

After building the Quarkus application, this a sample of the error that is received.

 [error]: Build step io.quarkus.qute.deployment.QuteProcessor#processTemplateErrors threw an exception: io.quarkus.qute.TemplateException: Found incorrect expressions (2):
        [1] ItemResource/items.html:13:22 - {item.pric}: Property/method [pric] not found on class [org.acme.qute.Item] nor handled by an extension method
        [2] ItemResource/items.html:16:47 - {item.discountedPricesss}: Property/method [discountedPricesss] not found on class [org.acme.qute.Item] nor handled by an extension method

When trying to capture this error to display in an IDE, we would need the column value to be at the error token in order to highlight the error range correctly. Currently, the error column location is reported at the cursor in the screenshot, causing the underline to be in the incorrect position.

image
{#if item|.pric < 15}
image
<strong>|{item.discountedPricesss}

Implementation ideas

To fix this, it would be nice to have the location changed to:
{#if item.|pric < 15}
<strong>{item.|discountedPricesss}

@JessicaJHee JessicaJHee added the kind/enhancement New feature or request label Jun 30, 2022
@quarkus-bot quarkus-bot bot added the area/qute The template engine label Jun 30, 2022
@quarkus-bot
Copy link

quarkus-bot bot commented Jun 30, 2022

/cc @mkouba

@mkouba
Copy link
Contributor

mkouba commented Jul 7, 2022

I'm not sure I fully understand the isssue but the format has been changed in 2.10 (#25810) and the error message should look like: [1] ItemResource/items.html:13:22 - {item.pric}: Property/method [pric] not found on class [org.acme.qute.Item] nor handled by an extension method, i.e. the column points to the start of the pric property. Is that something what you're looking for, or?

@JessicaJHee
Copy link
Author

I'm apologize, the sample I pasted was incorrect. The format of the error message is perfect, just the location of the column. Currently, the error is reported at 13:22, which is at the end of the item property and not at the start of the pric property. I believe it should be reported at 13:23. In the second error, the error is reported at 16:47, where it would be preferred to be reported at 16:53 (start of the discountedPricesss element)

Current behavior (where '|' indicates the reported location of the error) :

{#if item|.pric < 15}    [13:22]
<strong>|{item.discountedPricesss}    [16:47]

Preferred behavior:

{#if item.|pric < 15}    [13:23]
<strong>{item.|discountedPricesss}    [16:53]

@mkouba
Copy link
Contributor

mkouba commented Jul 8, 2022

I see. So in general Qute reports the beginning of an expression, i.e. column 47 for {item.discountedPricesss}. This is expected. However, in case of a section parameter ({#if}), it's a bit more complicated because there is no expression node in the template tree. I think that we try to compute the value and it seems there's a bug. It should be column 18 or something like that (the beginning of the expression).

Now, we could try to improve the "precision" and match an actual property instead of an expression but we need to find out how difficult it would be (and whether it's worth the effort) and also fix the bug first.

@mkouba
Copy link
Contributor

mkouba commented Jul 8, 2022

I don't see an easy way to reliably identify the column of an expression used as a section param. Therefore, we'll report the column of the section for the moment and we'll try to improve the io.quarkus.qute.SectionHelperFactory API later.

mkouba added a commit to mkouba/quarkus that referenced this issue Jul 8, 2022
- there is no easy way to reliably identify the column of an expression
used as a section param, therefore, we'll report the column of the
containing section/block for the moment
- related to quarkusio#26479
mkouba added a commit to mkouba/quarkus that referenced this issue Jul 8, 2022
- there is no easy way to reliably identify the column of an expression
used as a section param, therefore, we'll report the column of the
containing section/block for the moment
- related to quarkusio#26479
gsmet pushed a commit to gsmet/quarkus that referenced this issue Jul 18, 2022
- there is no easy way to reliably identify the column of an expression
used as a section param, therefore, we'll report the column of the
containing section/block for the moment
- related to quarkusio#26479

(cherry picked from commit d588d8b)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/qute The template engine kind/enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants