Skip to content

Commit

Permalink
feat: Qute: add support for template records
Browse files Browse the repository at this point in the history
Fixes redhat-developer#956

Signed-off-by: azerr <[email protected]>
  • Loading branch information
angelozerr committed Jul 10, 2024
1 parent 51aa262 commit 2a4afe0
Show file tree
Hide file tree
Showing 2 changed files with 1,894 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import org.eclipse.jdt.core.dom.Expression;
import org.eclipse.jdt.core.dom.FieldDeclaration;
import org.eclipse.jdt.core.dom.MethodDeclaration;
import org.eclipse.jdt.core.dom.RecordDeclaration;
import org.eclipse.jdt.core.dom.SimpleName;
import org.eclipse.jdt.core.dom.SimpleType;
import org.eclipse.jdt.core.dom.StringLiteral;
Expand All @@ -55,6 +56,7 @@
* <ul>
* <li>declared methods which have class annotated with @CheckedTemplate.</li>
* <li>declared field which have Template as type.</li>
* <li>declared record which implements TemplateInstance.</li>
* </ul>
*
* @author Angelo ZERR
Expand Down Expand Up @@ -92,6 +94,16 @@ public boolean visit(CompilationUnit node) {
return super.visit(node);
}


/**
* Support for "TypeSafe Templates"
*
* <p>
* private Template items;
* </p>
*
* @see <a href="https://quarkus.io/guides/qute-reference#typesafe_templates">TypeSafe Templates</a>
*/
@Override
public boolean visit(FieldDeclaration node) {
Type type = node.getType();
Expand Down Expand Up @@ -140,7 +152,18 @@ private AnnotationLocationSupport getAnnotationLocationSupport() {
}
return annotationLocationSupport;
}


/**
* Support for "TypeSafe Templates"
*
* <p>
* @CheckedTemplate
* public static class Templates {
* public static native TemplateInstance book(Book book);
* </p>
*
* @see <a href="https://quarkus.io/guides/qute-reference#typesafe_templates">TypeSafe Templates</a>
*/
@SuppressWarnings("rawtypes")
@Override
public boolean visit(TypeDeclaration node) {
Expand All @@ -167,6 +190,17 @@ public boolean visit(TypeDeclaration node) {
return super.visit(node);
}

/**
* Support for "Template Records"
*
* @ses <a href="https://quarkus.io/guides/qute-reference#template-records">Template Records</a>
*/
@Override
public boolean visit(RecordDeclaration node) {

return super.visit(node);
}

/**
* Returns true if @CheckedTemplate annotation declares that fragment must be
* ignored and false otherwise.
Expand Down
Loading

0 comments on commit 2a4afe0

Please sign in to comment.