Search in sources :

Example 1 with ValueResolverInfo

use of com.redhat.qute.commons.datamodel.resolvers.ValueResolverInfo in project quarkus-ls by redhat-developer.

the class MockQuteProject method createValueResolver.

protected static ValueResolverInfo createValueResolver(String namespace, String named, String matchName, String sourceType, String signature) {
    ValueResolverInfo resolver = new ValueResolverInfo();
    resolver.setNamespace(namespace);
    resolver.setNamed(named);
    resolver.setMatchName(matchName);
    resolver.setSourceType(sourceType);
    resolver.setSignature(signature);
    return resolver;
}
Also used : ValueResolverInfo(com.redhat.qute.commons.datamodel.resolvers.ValueResolverInfo)

Example 2 with ValueResolverInfo

use of com.redhat.qute.commons.datamodel.resolvers.ValueResolverInfo in project quarkus-ls by redhat-developer.

the class TemplateExtensionSupport method collectResolversForTemplateExtension.

private static void collectResolversForTemplateExtension(IMethod method, IAnnotation templateExtension, List<ValueResolverInfo> resolvers, ITypeResolver typeResolver) {
    ValueResolverInfo resolver = new ValueResolverInfo();
    resolver.setSourceType(method.getDeclaringType().getFullyQualifiedName());
    resolver.setSignature(typeResolver.resolveMethodSignature(method));
    try {
        String namespace = AnnotationUtils.getAnnotationMemberValue(templateExtension, TEMPLATE_EXTENSION_ANNOTATION_NAMESPACE);
        String matchName = AnnotationUtils.getAnnotationMemberValue(templateExtension, TEMPLATE_EXTENSION_ANNOTATION_MATCH_NAME);
        resolver.setNamespace(namespace);
        if (StringUtils.isNotEmpty(matchName)) {
            resolver.setMatchName(matchName);
        }
    } catch (JavaModelException e) {
        LOGGER.log(Level.SEVERE, "Error while getting annotation member value of '" + method.getElementName() + "'.", e);
    }
    if (!resolvers.contains(resolver)) {
        resolvers.add(resolver);
    }
}
Also used : JavaModelException(org.eclipse.jdt.core.JavaModelException) ValueResolverInfo(com.redhat.qute.commons.datamodel.resolvers.ValueResolverInfo)

Example 3 with ValueResolverInfo

use of com.redhat.qute.commons.datamodel.resolvers.ValueResolverInfo in project quarkus-ls by redhat-developer.

the class InjectNamespaceResolverSupport method collectResolversForInject.

private static void collectResolversForInject(IType type, String named, List<ValueResolverInfo> resolvers) {
    ValueResolverInfo resolver = new ValueResolverInfo();
    resolver.setNamed(named);
    resolver.setSourceType(type.getFullyQualifiedName());
    resolver.setSignature(type.getFullyQualifiedName());
    resolver.setNamespace(INJECT_NAMESPACE);
    resolvers.add(resolver);
}
Also used : ValueResolverInfo(com.redhat.qute.commons.datamodel.resolvers.ValueResolverInfo)

Example 4 with ValueResolverInfo

use of com.redhat.qute.commons.datamodel.resolvers.ValueResolverInfo in project quarkus-ls by redhat-developer.

the class TemplateGetDataModelProjectTest method assertValueResolver.

private static void assertValueResolver(String namespace, String signature, String sourceType, String named, List<ValueResolverInfo> resolvers) {
    Optional<ValueResolverInfo> result = resolvers.stream().filter(r -> signature.equals(r.getSignature())).findFirst();
    Assert.assertFalse("Find '" + signature + "' value resolver.", result.isEmpty());
    ValueResolverInfo resolver = result.get();
    Assert.assertEquals(namespace, resolver.getNamespace());
    Assert.assertEquals(signature, resolver.getSignature());
    Assert.assertEquals(sourceType, resolver.getSourceType());
}
Also used : QuteProjectTest.loadMavenProject(com.redhat.qute.jdt.QuteProjectTest.loadMavenProject) DataModelTemplate(com.redhat.qute.commons.datamodel.DataModelTemplate) DataModelProject(com.redhat.qute.commons.datamodel.DataModelProject) ValueResolverInfo(com.redhat.qute.commons.datamodel.resolvers.ValueResolverInfo) Test(org.junit.Test) QuteSupportForTemplate(com.redhat.qute.jdt.QuteSupportForTemplate) List(java.util.List) QuteProjectTest.getJDTUtils(com.redhat.qute.jdt.QuteProjectTest.getJDTUtils) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) DataModelParameter(com.redhat.qute.commons.datamodel.DataModelParameter) QuteDataModelProjectParams(com.redhat.qute.commons.datamodel.QuteDataModelProjectParams) Optional(java.util.Optional) QuteMavenProjectName(com.redhat.qute.jdt.QuteProjectTest.QuteMavenProjectName) Assert(org.junit.Assert) ValueResolverInfo(com.redhat.qute.commons.datamodel.resolvers.ValueResolverInfo)

Example 5 with ValueResolverInfo

use of com.redhat.qute.commons.datamodel.resolvers.ValueResolverInfo in project quarkus-ls by redhat-developer.

the class TemplateGetDataModelProjectTest method quteQuickStart.

@Test
public void quteQuickStart() throws Exception {
    loadMavenProject(QuteMavenProjectName.qute_quickstart);
    QuteDataModelProjectParams params = new QuteDataModelProjectParams(QuteMavenProjectName.qute_quickstart);
    DataModelProject<DataModelTemplate<DataModelParameter>> project = QuteSupportForTemplate.getInstance().getDataModelProject(params, getJDTUtils(), new NullProgressMonitor());
    Assert.assertNotNull(project);
    // Test templates
    testTemplates(project);
    // Test value resolvers
    List<ValueResolverInfo> resolvers = project.getValueResolvers();
    Assert.assertNotNull(resolvers);
    Assert.assertFalse(resolvers.isEmpty());
    testValueResolversFomTemplateExtension(resolvers);
    testValueResolversFomInject(resolvers);
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) QuteDataModelProjectParams(com.redhat.qute.commons.datamodel.QuteDataModelProjectParams) ValueResolverInfo(com.redhat.qute.commons.datamodel.resolvers.ValueResolverInfo) DataModelTemplate(com.redhat.qute.commons.datamodel.DataModelTemplate) Test(org.junit.Test)

Aggregations

ValueResolverInfo (com.redhat.qute.commons.datamodel.resolvers.ValueResolverInfo)6 DataModelTemplate (com.redhat.qute.commons.datamodel.DataModelTemplate)2 QuteDataModelProjectParams (com.redhat.qute.commons.datamodel.QuteDataModelProjectParams)2 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)2 Test (org.junit.Test)2 DataModelParameter (com.redhat.qute.commons.datamodel.DataModelParameter)1 DataModelProject (com.redhat.qute.commons.datamodel.DataModelProject)1 QuteMavenProjectName (com.redhat.qute.jdt.QuteProjectTest.QuteMavenProjectName)1 QuteProjectTest.getJDTUtils (com.redhat.qute.jdt.QuteProjectTest.getJDTUtils)1 QuteProjectTest.loadMavenProject (com.redhat.qute.jdt.QuteProjectTest.loadMavenProject)1 QuteSupportForTemplate (com.redhat.qute.jdt.QuteSupportForTemplate)1 List (java.util.List)1 Optional (java.util.Optional)1 JavaModelException (org.eclipse.jdt.core.JavaModelException)1 Assert (org.junit.Assert)1