Skip to content

Commit

Permalink
feat: support for global namespace
Browse files Browse the repository at this point in the history
Signed-off-by: azerr <[email protected]>
  • Loading branch information
angelozerr committed Nov 7, 2024
1 parent 21ef00e commit 29a810a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -352,21 +352,21 @@ private static void testValueResolversFromTemplateGlobal(List<ValueResolverInfo>
// public class Globals {

// static int age = 40;
assertValueResolver(null, "age : int", "org.acme.qute.Globals", null, true, resolvers);
assertValueResolver("global", "age : int", "org.acme.qute.Globals", null, true, resolvers);

// static String name;
assertValueResolver(null, "name : java.lang.String", "org.acme.qute.Globals", null, true, resolvers);
assertValueResolver("global", "name : java.lang.String", "org.acme.qute.Globals", null, true, resolvers);

// static Color[] myColors() {
// return new Color[] { Color.RED, Color.BLUE };
// }
assertValueResolver(null, "myColors() : org.acme.qute.Color[]", "org.acme.qute.Globals", null, true, resolvers);
assertValueResolver("global", "myColors() : org.acme.qute.Color[]", "org.acme.qute.Globals", null, true, resolvers);

// @TemplateGlobal(name = "currentUser")
// static String user() {
// return "Mia";
// }
assertValueResolver(null, "user() : java.lang.String", "org.acme.qute.Globals", "currentUser", true, resolvers);
assertValueResolver("global", "user() : java.lang.String", "org.acme.qute.Globals", "currentUser", true, resolvers);
// }
}

Expand Down
5 changes: 4 additions & 1 deletion qute.jdt/com.redhat.qute.jdt/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,10 @@
<provider class="com.redhat.qute.jdt.internal.template.datamodel.TemplateExtensionAnnotationSupport" />
<provider class="com.redhat.qute.jdt.internal.template.datamodel.TemplateDataAnnotationSupport" />
<provider class="com.redhat.qute.jdt.internal.template.datamodel.TemplateEnumAnnotationSupport" />
<provider class="com.redhat.qute.jdt.internal.template.datamodel.TemplateGlobalAnnotationSupport" />
<provider namespaces="global,"
description="Global Variables."
url="https://quarkus.io/guides/qute-reference#global_variables"
class="com.redhat.qute.jdt.internal.template.datamodel.TemplateGlobalAnnotationSupport" />
<provider class="com.redhat.qute.jdt.internal.template.datamodel.TypeSafeMessageBundlesSupport" />
</extension>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ public class TemplateGlobalAnnotationSupport extends AbstractAnnotationTypeRefer

private static final String[] ANNOTATION_NAMES = { TEMPLATE_GLOBAL_ANNOTATION };

private static final String GLOBAL_NAMESPACE = "global";

@Override
protected String[] getAnnotationNames() {
return ANNOTATION_NAMES;
Expand Down Expand Up @@ -123,6 +125,7 @@ private void collectResolversForTemplateGlobal(IMember member, IAnnotation templ
ValueResolverInfo resolver = new ValueResolverInfo();
resolver.setSourceType(sourceType);
resolver.setSignature(typeResolver.resolveSignature(member));
resolver.setNamespace(GLOBAL_NAMESPACE);
resolver.setKind(ValueResolverKind.TemplateGlobal);
// Constant value for {@link #name()} indicating that the field/method name
// should be used
Expand Down

0 comments on commit 29a810a

Please sign in to comment.