Search in sources :

Example 1 with DataModelParameter

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

the class MockQuteProject method loadDataModelProject.

@Override
protected synchronized CompletableFuture<ExtendedDataModelProject> loadDataModelProject() {
    DataModelProject<DataModelTemplate<DataModelParameter>> project = new DataModelProject<DataModelTemplate<DataModelParameter>>();
    project.setTemplates(templates);
    project.setValueResolvers(valueResolvers);
    project.setNamespaceResolverInfos(namespaceResolverInfos);
    return CompletableFuture.completedFuture(new ExtendedDataModelProject(project));
}
Also used : DataModelParameter(com.redhat.qute.commons.datamodel.DataModelParameter) DataModelTemplate(com.redhat.qute.commons.datamodel.DataModelTemplate) ExtendedDataModelProject(com.redhat.qute.project.datamodel.ExtendedDataModelProject) DataModelProject(com.redhat.qute.commons.datamodel.DataModelProject) ExtendedDataModelProject(com.redhat.qute.project.datamodel.ExtendedDataModelProject)

Example 2 with DataModelParameter

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

the class QuteGenerateTemplateContentCommandHandlerTest method createItemInfo.

private GenerateTemplateInfo createItemInfo() {
    GenerateTemplateInfo info = new GenerateTemplateInfo();
    info.setProjectUri(PROJECT_URI);
    List<DataModelParameter> parameters = new ArrayList<>();
    DataModelParameter parameter = new DataModelParameter();
    parameter.setKey("item");
    parameter.setSourceType("org.acme.Item");
    parameters.add(parameter);
    info.setParameters(parameters);
    return info;
}
Also used : DataModelParameter(com.redhat.qute.commons.datamodel.DataModelParameter) ArrayList(java.util.ArrayList) GenerateTemplateInfo(com.redhat.qute.commons.datamodel.GenerateTemplateInfo)

Example 3 with DataModelParameter

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

the class QuteGenerateTemplateContentCommandHandlerTest method createListItemsInfo.

private GenerateTemplateInfo createListItemsInfo() {
    GenerateTemplateInfo info = new GenerateTemplateInfo();
    info.setProjectUri(PROJECT_URI);
    List<DataModelParameter> parameters = new ArrayList<>();
    DataModelParameter parameter = new DataModelParameter();
    parameter.setKey("items");
    parameter.setSourceType("java.util.List<org.acme.Item>");
    parameters.add(parameter);
    info.setParameters(parameters);
    return info;
}
Also used : DataModelParameter(com.redhat.qute.commons.datamodel.DataModelParameter) ArrayList(java.util.ArrayList) GenerateTemplateInfo(com.redhat.qute.commons.datamodel.GenerateTemplateInfo)

Example 4 with DataModelParameter

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

the class TemplateDataCollector method visitParameter.

@Override
protected boolean visitParameter(Object name, Object type) {
    String paramName = null;
    if (name instanceof StringLiteral) {
        paramName = ((StringLiteral) name).getLiteralValue();
    }
    if (paramName != null) {
        String paramType = "java.lang.Object";
        if (type instanceof Expression) {
            ITypeBinding binding = ((Expression) type).resolveTypeBinding();
            paramType = binding.getQualifiedName();
        }
        if (paramName != null && template.getParameter(paramName) == null) {
            DataModelParameter parameter = new DataModelParameter();
            parameter.setKey(paramName);
            parameter.setSourceType(paramType);
            parameter.setDataMethodInvocation(true);
            template.addParameter(parameter);
        }
    }
    return true;
}
Also used : DataModelParameter(com.redhat.qute.commons.datamodel.DataModelParameter) StringLiteral(org.eclipse.jdt.core.dom.StringLiteral) Expression(org.eclipse.jdt.core.dom.Expression) ITypeBinding(org.eclipse.jdt.core.dom.ITypeBinding)

Example 5 with DataModelParameter

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

the class CheckedTemplateSupport method collectDataModelTemplateForCheckedTemplate.

/**
 * Collect data model template from @CheckedTemplate.
 *
 * @param type      the Java type.
 * @param templates the data model templates to update with collect of template.
 * @param monitor   the progress monitor.
 * @throws JavaModelException
 */
private static void collectDataModelTemplateForCheckedTemplate(IType type, List<DataModelTemplate<DataModelParameter>> templates, IProgressMonitor monitor) throws JavaModelException {
    boolean innerClass = type.getParent() != null && type.getParent().getElementType() == IJavaElement.TYPE;
    String className = !innerClass ? null : JDTTypeUtils.getSimpleClassName(type.getCompilationUnit() != null ? type.getCompilationUnit().getElementName() : type.getClassFile().getElementName());
    // Loop for each methods (book, book) and create a template data model per
    // method.
    IMethod[] methods = type.getMethods();
    for (IMethod method : methods) {
        DataModelTemplate<DataModelParameter> template = createTemplateDataModel(method, className, type, monitor);
        templates.add(template);
    }
}
Also used : DataModelParameter(com.redhat.qute.commons.datamodel.DataModelParameter) IMethod(org.eclipse.jdt.core.IMethod)

Aggregations

DataModelParameter (com.redhat.qute.commons.datamodel.DataModelParameter)14 ArrayList (java.util.ArrayList)6 DataModelTemplate (com.redhat.qute.commons.datamodel.DataModelTemplate)5 GenerateTemplateInfo (com.redhat.qute.commons.datamodel.GenerateTemplateInfo)4 DataModelProject (com.redhat.qute.commons.datamodel.DataModelProject)3 List (java.util.List)2 JavaModelException (org.eclipse.jdt.core.JavaModelException)2 ITypeBinding (org.eclipse.jdt.core.dom.ITypeBinding)2 JavaElementKind (com.redhat.qute.commons.JavaElementKind)1 ResolvedJavaTypeInfo (com.redhat.qute.commons.ResolvedJavaTypeInfo)1 QuteDataModelProjectParams (com.redhat.qute.commons.datamodel.QuteDataModelProjectParams)1 NamespaceResolverInfo (com.redhat.qute.commons.datamodel.resolvers.NamespaceResolverInfo)1 NamespacePart (com.redhat.qute.parser.expression.NamespacePart)1 ExtendedDataModelProject (com.redhat.qute.project.datamodel.ExtendedDataModelProject)1 FieldValueResolver (com.redhat.qute.project.datamodel.resolvers.FieldValueResolver)1 MethodValueResolver (com.redhat.qute.project.datamodel.resolvers.MethodValueResolver)1 TypeValueResolver (com.redhat.qute.project.datamodel.resolvers.TypeValueResolver)1 MATCH_NAME_ANY (com.redhat.qute.project.datamodel.resolvers.ValueResolver.MATCH_NAME_ANY)1 Template (io.quarkus.qute.Template)1 InputStream (java.io.InputStream)1