-
Notifications
You must be signed in to change notification settings - Fork 15
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
Fragment support between Java / Template file #769
Conversation
@angelozerr this looks amazing, great work! |
dafc10f
to
0015610
Compare
@datho7561 if you have time you can start to review this PR. Code should be clean and there are tests for Qute LS side. I need to write tests for Qute JDT side. |
The link from a Java file to the template opens the template file, but it doesn't seem to place the cursor on the corresponding fragment declaration section. Do you think it's possible to do that? It looks like the fragment id is being passed as a part of the code lens data |
...m.redhat.qute.jdt/src/main/java/com/redhat/qute/commons/datamodel/DataModelBaseTemplate.java
Outdated
Show resolved
Hide resolved
...ls/com.redhat.qute.ls/src/main/java/com/redhat/qute/commons/datamodel/DataModelTemplate.java
Show resolved
Hide resolved
...ls/com.redhat.qute.ls/src/main/java/com/redhat/qute/commons/datamodel/DataModelTemplate.java
Show resolved
Hide resolved
...ls/com.redhat.qute.ls/src/main/java/com/redhat/qute/commons/datamodel/DataModelTemplate.java
Show resolved
Hide resolved
@@ -118,7 +121,7 @@ public boolean visit(FieldDeclaration node) { | |||
.getLocationExpressionFromConstructorParameter(variable.getName().getIdentifier()); | |||
} | |||
String fieldName = variable.getName().getIdentifier(); | |||
collectTemplateLink(node, locationExpression, getTypeDeclaration(node), null, fieldName); | |||
collectTemplateLink(node, locationExpression, getTypeDeclaration(node), null, fieldName, false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't seem to get the links that appear on fields to show the fact that they link to a fragment. For instance if I have the field:
@Inject
@Location("myCoolTemplate.html")
Template myCoolTemplate$myFragment;
I get a code lens that links to the template and clicking it works as expected, but nothing is listed about the fragment in the code lens message.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it allowed to write a field with $ to support fragment? I have not seen that in the doc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then ignoreFragments
should be true
here, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to my understand of the doc, the field name (which can contain $) has not the same behavior of method name of CheckedTemplate.
See https://quarkus.io/guides/qute-reference#fragments
@Inject
Template item;
String useTheFragment() {
return item.getFragment("item_aliases")
.data("aliases", List.of("Foo","Bar"))
.render();
}
For field, fragment is supported when Template#getFragment is called. I don't support this usecase for the moment. But it makes no senses to write a Template instance field with $ to manage fragment.
43981e5
to
b6c0bac
Compare
I think it is possible by implementing a custom command but I would like to do that in a separate PR.
Indeed, it will be used in a future PR. |
df9e1c1
to
4159b14
Compare
Ok now there are tests for codelens + diagnostics with fragment on Qute JDT side. |
If I reference a fragment with id @CheckedTemplate()
public static class MyTemplate {
public static native TemplateInstance myTemplate$();
} However, if I try to declare a template with id |
According to https://quarkus.io/guides/qute-reference#type_safe_fragments the fragment id is everything after the last public static native TemplateInstance myTemplate$otherText$fragment(); Then the CodeLens displays the fragment id as |
...edhat.qute.ls/src/main/java/com/redhat/qute/project/datamodel/ExtendedDataModelFragment.java
Show resolved
Hide resolved
...edhat.qute.ls/src/main/java/com/redhat/qute/project/datamodel/ExtendedDataModelTemplate.java
Outdated
Show resolved
Hide resolved
I think in this usecase, the method should be bound with the Qute html template |
I don't think so. If I try to build the application with this in the code, then it gives the following compilation error:
|
7d7800b
to
73ca612
Compare
See redhat-developer/vscode-quarkus#563 Signed-off-by: azerr <[email protected]>
Empty fragment should be take care of. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great. Thanks, Angelo!
Fragment support between Java / Template file
See redhat-developer/vscode-quarkus#563
Signed-off-by: azerr [email protected]