redhat-developer / quarkus-ls

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

Improve User tag snippet completion #785

Closed angelozerr closed 1 year ago

angelozerr commented 1 year ago

Improve User tag snippet completion

Fixes #784

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

angelozerr commented 1 year ago

Here a demo with the current work of this PR:

RenardeFormCompletion

angelozerr commented 1 year ago

I have improved completion with user tag parameters by using computing the optional state of each parameter.

Here a demo:

FormElementCompletion

@FromMage I think this issue could interest you and should improve the use of renarde user tag.

datho7561 commented 1 year ago

If I have the following custom tag: ( I don't know if custom tags support the type declarations )

{@java.lang.String title}
<hr />
<h3>{title.toUpperCase}</h3>
{nested-content}
<hr />

then the snippet doesn't generate title as a parameter to the custom tag

datho7561 commented 1 year ago

If you have this custom tag:

<hr />
<h3>{titularTitle}</h3>
{#set subTitle="some text"}
  <small>{subTitle}</small>
{/set}
<p>
    {nested-content}
</p>
<hr />

Then the snippet inserts subTitle as a parameter. I think this case is hard to handle. Unless you disagree and think you could handle this case easily, I think we should do this in a different PR.

JessicaJHee commented 1 year ago

This feature works well! I don't have any suggestions so far but will take a look at the code once it is ready

angelozerr commented 1 year ago

Then the snippet inserts subTitle as a parameter. I think this case is hard to handle. Unless you disagree and think you could handle this case easily, I think we should do this in a different PR.

It should be fixed now.

angelozerr commented 1 year ago

If I have the following custom tag: ( I don't know if custom tags support the type declarations )

{@java.lang.String title}
<hr />
<h3>{title.toUpperCase}</h3>
{nested-content}
<hr />

then the snippet doesn't generate title as a parameter to the custom tag

Are you sure? I have add a test with your sample and it is working.

But your sample give me a new idea. For the moment I consider that all parameter are string (when parameter value is generated, I generate double quote). I think it should be really nice to use this parameter declaration type to know if it is a string or not to avoid generating double quote if it is not a string. We could do that in a an another PR.

datho7561 commented 1 year ago

Are you sure? I have add a test with your sample and it is working.

I tried it again with the latest push, and it's still not working. It provides completion for the parameter when I open it like this:

{#user |}
{/user}

but the snippet still doesn't add the title when I first open it, despite the fact that it's required.

angelozerr commented 1 year ago

I tried it again with the latest push, and it's still not working. It provides completion for the parameter when I open it like this:

Oh sorry I though it was a problem to collect the parameter but not for required state. Fixed with test.

FroMage commented 1 year ago

Great!