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

Add CodeActions to resolve syntax errors related to sections #838

Merged

Conversation

JessicaJHee
Copy link
Member

Fixes #821

@JessicaJHee
Copy link
Member Author

Currently for the UNTERMINATED_SECTION code action, I insert the section end tag after any child content. I'm not sure if this is this best approach or the end tag should be generated fight after the start tag.

This is the current behavior:

Peek 2023-03-29 12-42

@angelozerr
Copy link
Contributor

@JessicaJHee your PR looks very good.

I would like to merge my PR #832 before yours and as I did some refactoring you will need to change your code (JavaDataModelCache has changed and now code action uses QuteProjectRegistry instead). The resolveJavaType is done with project and not with java data model cache.

// {/if}
codeActionForUnterminatedSection.doCodeActions(request, codeActionResolveFutures, codeActions);
break;
case SECTION_END_DOES_NOT_MATCH_START:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you could add case SECTION_BLOCK_END_DOES_NOT_MATCH_START here (no tested)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case I should correct the end tag to {/else} or {/if}?

It seems like the following case is allowed since I get no errors when I build Quarkus:

{#if true}
    Hello
    {#else}
    Hi
    {/else} // --> error is reported here - I have added a test case for this
{/if}

But at the moment we report error since we declare {#else}, {#case}, and {#is} as empty sections here:

return CaseSection.TAG.equals(tag) || ElseSection.TAG.equals(tag) || IsSection.TAG.equals(tag);

Copy link
Contributor

@angelozerr angelozerr Mar 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok thanks for your feedback. It is more complicated that I though. We can do that in a separate PR. Please create an issue for that.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have created an issue here: #844

@JessicaJHee JessicaJHee force-pushed the 821-codeaction-syntax-section branch from 94fd458 to 9e27460 Compare March 30, 2023 16:39
@angelozerr
Copy link
Contributor

@JessicaJHee please fix conflict

@JessicaJHee JessicaJHee force-pushed the 821-codeaction-syntax-section branch from 9e27460 to 830605f Compare March 30, 2023 17:20
@datho7561 datho7561 self-requested a review March 31, 2023 12:53
@JessicaJHee JessicaJHee force-pushed the 821-codeaction-syntax-section branch from 830605f to 37b4ae7 Compare March 31, 2023 14:44
@JessicaJHee JessicaJHee force-pushed the 821-codeaction-syntax-section branch from 37b4ae7 to f9e614b Compare March 31, 2023 15:17
Signed-off-by: Jessica He <jhe@redhat.com>
@JessicaJHee JessicaJHee force-pushed the 821-codeaction-syntax-section branch from f9e614b to d23dd13 Compare March 31, 2023 16:21
@angelozerr angelozerr merged commit 2335469 into redhat-developer:master Mar 31, 2023
@angelozerr
Copy link
Contributor

I love your work @JessicaJHee, thanks so much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CodeActions to resolve syntax errors related to sections
3 participants