Search in sources :

Example 1 with ExtendedDataModelParameter

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

the class QuteCodeLens method collectDataModelCodeLenses.

private static void collectDataModelCodeLenses(ExtendedDataModelTemplate templateDataModel, Template template, SharedSettings settings, List<CodeLens> lenses, CancelChecker cancelChecker) {
    if (templateDataModel == null || templateDataModel.getSourceType() == null) {
        return;
    }
    cancelChecker.checkCanceled();
    String projectUri = template.getProjectUri();
    boolean canSupportJavaDefinition = settings.getCommandCapabilities().isCommandSupported(COMMAND_JAVA_DEFINITION);
    // Method/Field which is bound with the template
    String title = createCheckedTemplateTitle(templateDataModel);
    Range range = LEFT_TOP_RANGE;
    Command command = !canSupportJavaDefinition ? new Command(title, "") : new Command(title, COMMAND_JAVA_DEFINITION, Arrays.asList(templateDataModel.toJavaDefinitionParams(projectUri)));
    CodeLens codeLens = new CodeLens(range, command, null);
    lenses.add(codeLens);
    // Parameters of the template
    List<ExtendedDataModelParameter> parameters = templateDataModel.getParameters();
    if (parameters != null) {
        for (ExtendedDataModelParameter parameter : parameters) {
            String parameterTitle = createParameterTitle(parameter);
            Command parameterCommand = !canSupportJavaDefinition ? new Command(title, "") : new Command(parameterTitle, COMMAND_JAVA_DEFINITION, Arrays.asList(parameter.toJavaDefinitionParams(projectUri)));
            CodeLens parameterCodeLens = new CodeLens(range, parameterCommand, null);
            lenses.add(parameterCodeLens);
        }
    }
}
Also used : CodeLens(org.eclipse.lsp4j.CodeLens) Command(org.eclipse.lsp4j.Command) ExtendedDataModelParameter(com.redhat.qute.project.datamodel.ExtendedDataModelParameter) Range(org.eclipse.lsp4j.Range)

Example 2 with ExtendedDataModelParameter

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

the class QuteCompletionsForExpression method doCompleteExpressionForObjectPartWithCheckedTemplate.

private void doCompleteExpressionForObjectPartWithCheckedTemplate(Template template, Range range, CompletionList list) {
    ExtendedDataModelTemplate dataModel = javaCache.getDataModelTemplate(template).getNow(null);
    if (dataModel == null || dataModel.getParameters() == null) {
        return;
    }
    for (ExtendedDataModelParameter parameter : dataModel.getParameters()) {
        CompletionItem item = new CompletionItem();
        item.setLabel(parameter.getKey());
        item.setKind(CompletionItemKind.Reference);
        TextEdit textEdit = new TextEdit(range, parameter.getKey());
        item.setTextEdit(Either.forLeft(textEdit));
        list.getItems().add(item);
    }
}
Also used : CompletionItem(org.eclipse.lsp4j.CompletionItem) ExtendedDataModelParameter(com.redhat.qute.project.datamodel.ExtendedDataModelParameter) TextEdit(org.eclipse.lsp4j.TextEdit) ExtendedDataModelTemplate(com.redhat.qute.project.datamodel.ExtendedDataModelTemplate)

Aggregations

ExtendedDataModelParameter (com.redhat.qute.project.datamodel.ExtendedDataModelParameter)2 ExtendedDataModelTemplate (com.redhat.qute.project.datamodel.ExtendedDataModelTemplate)1 CodeLens (org.eclipse.lsp4j.CodeLens)1 Command (org.eclipse.lsp4j.Command)1 CompletionItem (org.eclipse.lsp4j.CompletionItem)1 Range (org.eclipse.lsp4j.Range)1 TextEdit (org.eclipse.lsp4j.TextEdit)1