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 <azerr@redhat.com>
  • Loading branch information
angelozerr committed Nov 7, 2024
1 parent b4ad7df commit 12d40ce
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ public class TemplateGlobalAnnotationSupport extends AbstractAnnotationTypeRefer
TEMPLATE_GLOBAL_ANNOTATION
};

private static final String GLOBAL_NAMESPACE = "global";

@Override
protected String[] getAnnotationNames() {
return ANNOTATION_NAMES;
Expand Down Expand Up @@ -133,6 +135,7 @@ private void collectResolversForTemplateGlobal(PsiMember member, PsiAnnotation t
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
6 changes: 4 additions & 2 deletions src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -683,8 +683,10 @@
implementationClass="com.redhat.devtools.intellij.qute.psi.internal.template.datamodel.TemplateDataAnnotationSupport"/>
<qute.dataModelProvider
implementationClass="com.redhat.devtools.intellij.qute.psi.internal.template.datamodel.TemplateEnumAnnotationSupport"/>
<qute.dataModelProvider
implementationClass="com.redhat.devtools.intellij.qute.psi.internal.template.datamodel.TemplateGlobalAnnotationSupport"/>
<qute.dataModelProvider namespaces="global,"
description="Global Variables."
url="https://quarkus.io/guides/qute-reference#global_variables"
implementationClass="com.redhat.devtools.intellij.qute.psi.internal.template.datamodel.TemplateGlobalAnnotationSupport"/>
<qute.dataModelProvider
implementationClass="com.redhat.devtools.intellij.qute.psi.internal.template.datamodel.TypeSafeMessageBundlesSupport"/>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -345,21 +345,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

0 comments on commit 12d40ce

Please sign in to comment.