Search in sources :

Example 1 with QuteJavaDefinitionParams

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

the class QuteDefinition method findDefinitionFromParameterDeclaration.

private CompletableFuture<List<? extends LocationLink>> findDefinitionFromParameterDeclaration(int offset, ParameterDeclaration parameterDeclaration, Template template) {
    String projectUri = template.getProjectUri();
    if (projectUri != null && parameterDeclaration.isInJavaTypeName(offset)) {
        RangeOffset range = parameterDeclaration.getJavaTypeNameRange(offset);
        if (range != null) {
            String className = template.getText(range);
            QuteJavaDefinitionParams params = new QuteJavaDefinitionParams(className, projectUri);
            return findJavaDefinition(params, () -> QutePositionUtility.createRange(range, template));
        }
    }
    return NO_DEFINITION;
}
Also used : QuteJavaDefinitionParams(com.redhat.qute.commons.QuteJavaDefinitionParams) RangeOffset(com.redhat.qute.parser.template.RangeOffset)

Example 2 with QuteJavaDefinitionParams

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

the class ExtendedDataModelTemplate method toJavaDefinitionParams.

public QuteJavaDefinitionParams toJavaDefinitionParams(String projectUri) {
    String sourceType = getSourceType();
    String sourceField = getSourceField();
    String sourceMethod = getSourceMethod();
    QuteJavaDefinitionParams params = new QuteJavaDefinitionParams(sourceType, projectUri);
    params.setSourceField(sourceField);
    params.setSourceMethod(sourceMethod);
    return params;
}
Also used : QuteJavaDefinitionParams(com.redhat.qute.commons.QuteJavaDefinitionParams)

Example 3 with QuteJavaDefinitionParams

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

the class QuteDefinition method findDefinitionFromJavaMember.

private CompletableFuture<List<? extends LocationLink>> findDefinitionFromJavaMember(JavaElementInfo member, Part part, String projectUri) {
    if (member == null) {
        return NO_DEFINITION;
    }
    String sourceType = member.getJavaElementKind() == JavaElementKind.TYPE ? member.getName() : ((JavaMemberInfo) member).getSourceType();
    if (sourceType == null) {
        return NO_DEFINITION;
    }
    QuteJavaDefinitionParams params = new QuteJavaDefinitionParams(sourceType, projectUri);
    if (member != null) {
        switch(member.getJavaElementKind()) {
            case FIELD:
                params.setSourceField(member.getName());
                break;
            case METHOD:
                params.setSourceMethod(member.getName());
                break;
            default:
        }
    }
    return findJavaDefinition(params, () -> QutePositionUtility.createRange(part));
}
Also used : QuteJavaDefinitionParams(com.redhat.qute.commons.QuteJavaDefinitionParams)

Example 4 with QuteJavaDefinitionParams

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

the class QuteSupportForTemplateDelegateCommandHandler method createQuteJavaDefinitionParams.

private static QuteJavaDefinitionParams createQuteJavaDefinitionParams(List<Object> arguments, String commandId) {
    Map<String, Object> obj = getFirst(arguments);
    if (obj == null) {
        throw new UnsupportedOperationException(String.format("Command '%s' must be called with one QuteJavaDefinitionParams argument!", commandId));
    }
    // Get project name from the java file URI
    String templateFileUri = getString(obj, PROJECT_URI_ATTR);
    if (templateFileUri == null) {
        throw new UnsupportedOperationException(String.format("Command '%s' must be called with required QuteJavaDefinitionParams.projectUri !", commandId));
    }
    String sourceType = getString(obj, SOURCE_TYPE_ATTR);
    if (sourceType == null) {
        throw new UnsupportedOperationException(String.format("Command '%s' must be called with required QuteJavaDefinitionParams.sourceType!", commandId));
    }
    QuteJavaDefinitionParams params = new QuteJavaDefinitionParams(sourceType, templateFileUri);
    String sourceField = getString(obj, SOURCE_FIELD_ATTR);
    params.setSourceField(sourceField);
    String sourceMethod = getString(obj, SOURCE_METHOD_ATTR);
    params.setSourceMethod(sourceMethod);
    String methodParameter = getString(obj, SOURCE_PARAMETER_ATTR);
    params.setSourceParameter(methodParameter);
    boolean dataMethodInvocation = getBoolean(obj, DATA_METHOD_INVOCATION_ATTR);
    params.setDataMethodInvocation(dataMethodInvocation);
    return params;
}
Also used : QuteJavaDefinitionParams(com.redhat.qute.commons.QuteJavaDefinitionParams) ArgumentUtils.getString(com.redhat.qute.jdt.internal.ls.ArgumentUtils.getString)

Example 5 with QuteJavaDefinitionParams

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

the class ExtendedDataModelParameter method toJavaDefinitionParams.

public QuteJavaDefinitionParams toJavaDefinitionParams(String projectUri) {
    ExtendedDataModelTemplate dataModelTemplate = getTemplate();
    String sourceType = dataModelTemplate.getSourceType();
    String sourceField = dataModelTemplate.getSourceField();
    String sourceMethod = dataModelTemplate.getSourceMethod();
    String sourceParameter = getKey();
    QuteJavaDefinitionParams params = new QuteJavaDefinitionParams(sourceType, projectUri);
    params.setSourceField(sourceField);
    params.setSourceMethod(sourceMethod);
    params.setSourceParameter(sourceParameter);
    params.setDataMethodInvocation(isDataMethodInvocation());
    return params;
}
Also used : QuteJavaDefinitionParams(com.redhat.qute.commons.QuteJavaDefinitionParams)

Aggregations

QuteJavaDefinitionParams (com.redhat.qute.commons.QuteJavaDefinitionParams)5 ArgumentUtils.getString (com.redhat.qute.jdt.internal.ls.ArgumentUtils.getString)1 RangeOffset (com.redhat.qute.parser.template.RangeOffset)1