redhat-developer / quarkus-ls

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

Initialize Qute syntax validator with fault tolerant to support section errors #820

Closed angelozerr closed 1 year ago

angelozerr commented 1 year ago

Initialize Qute syntax validator with fault tolerant to support section errors

Fixes #812

Signed-off-by: azerr azerr@redhat.com

angelozerr commented 1 year ago

In this PR, I have started to implement Qute validator for syntax for the real Qute error code:

QuteSyntaxValidator improves the syntax validation of the real Qute parser by reporting:

Takes a sample:

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

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

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

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

Here a screenshot with the real Qute parser which report just the first error on a position (and not range):

image

Here a demo with the PR:

QuteErrorWithFaultTolerant

angelozerr commented 1 year ago

@datho7561 @JessicaJHee you can review the PR.

Here a sample file that you could use:


{#if true}Hello{#else}Hi{/elsa}{/if} {!SECTION_BLOCK_END_DOES_NOT_MATCH_START!}

{# foo=1 /} {! NO_SECTION_NAME !}

{#foo true /} {! NO_SECTION_HELPER_FOUND !}

{#if true}Hello {true}!{/for} {! SECTION_END_DOES_NOT_MATCH_START !}

{#let true}
    Bye...
{/let}
    Hello
{/let} {!SECTION_START_NOT_FOUND,!}

{#if true}Hello {true} {!UNTERMINATED_SECTION!}

If you try with the master, you will see just one error with strange error range which uses the real Qute parser:

image

With this PR which uses our fault tolerant parser, you will see :

image

@mkouba @FroMage here a good sample why we need fault tolerant parser with proper location.

datho7561 commented 1 year ago

Here is a case that isn't handled yet:

{#if asdf??}

{/}

{/}

{/}

{/}
JessicaJHee commented 1 year ago
{#if condition}

{/if}
{/}

ops seems like it's the same case as David mentioned

angelozerr commented 1 year ago

Here is a case that isn't handled yet:

It should be fixed:

image

ops seems like it's the same case as David mentioned

Indeed it is the same usecase.

angelozerr commented 1 year ago

Thanks so much @datho7561 @JessicaJHee for your great review.

Now as we have proper range and we have support for multiple errors it would be very nice to provide code actions for each error code.

I think it will not an hatd task.

If you have time and you are interested dont hesitate to create pas. Thanks!