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));
}
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;
}
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;
}
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;
}
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);
}
}
Aggregations