Closed angelozerr closed 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):
Here a demo with the PR:
@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:
With this PR which uses our fault tolerant parser, you will see :
@mkouba @FroMage here a good sample why we need fault tolerant parser with proper location.
Here is a case that isn't handled yet:
{#if asdf??}
{/}
{/}
{/}
{/}
{#if condition} {/if} {/}
ops seems like it's the same case as David mentioned
Here is a case that isn't handled yet:
It should be fixed:
ops seems like it's the same case as David mentioned
Indeed it is the same usecase.
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!
Initialize Qute syntax validator with fault tolerant to support section errors
Fixes #812
Signed-off-by: azerr azerr@redhat.com