Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Evaluation of CompletionStage and Uni Objects #832

Merged
merged 1 commit into from
Mar 30, 2023

Conversation

angelozerr
Copy link
Contributor

Support for Evaluation of CompletionStage and Uni Objects

Fixes #826

@angelozerr
Copy link
Contributor Author

Here the file that I have used for test:

{@java.util.concurrent.CompletableFuture<java.util.List<String>> items}

{#for item in items}
	{item.blank}
{/for}

and here a demo:

CompletionStageDemo

@angelozerr
Copy link
Contributor Author

I notice that there are some trouble when the expected items is not an iterable like:

{@String items}

{#for item in items}
	{item.blank}
{/for}

We have a popup error when we try to hover name property, teh inlay hint shows String after item although it should not show the type. I need to investigate the problem.

But I think the problem is the same in master.

@@ -31,6 +32,9 @@ public class ResolvedJavaTypeInfo extends JavaTypeInfo {

private static final String JAVA_LANG_ITERABLE_TYPE = "java.lang.Iterable";

private static final List<String> WRAPPED_TYPES = Arrays.asList("java.util.concurrent.CompletionStage",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WRAPPER_TYPES

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are the types that do the wrapping, so they should be called WRAPPER_TYPES. The wrapped type is the type parameter eg. in Uni<List<String>>, uni is wrapping List<String>, List<String> is wrapped by Uni, Uni is a wrapper type, List<String> is a wrapped type.

@angelozerr angelozerr force-pushed the refactor-java-resolve branch 5 times, most recently from ed8dbb3 to 7e6b26d Compare March 28, 2023 16:56
@angelozerr
Copy link
Contributor Author

We have a popup error when we try to hover name property, teh inlay hint shows String after item although it should not show the type. I need to investigate the problem.

It should be fixed.

@angelozerr angelozerr force-pushed the refactor-java-resolve branch 3 times, most recently from 663cfc9 to 42a3519 Compare March 29, 2023 14:10
@angelozerr angelozerr marked this pull request as ready for review March 29, 2023 14:15
@angelozerr
Copy link
Contributor Author

angelozerr commented Mar 29, 2023

Ok the PR can be reviewed now. I have wrotten a lot of tests, so I'm more confident to integrate it in the release.

@fbricon @datho7561 @JessicaJHee please play with my PR to check I have not broken something.

@datho7561 datho7561 self-requested a review March 29, 2023 18:07
@datho7561
Copy link
Contributor

Doesn't seem to be working for me:

uni-auto-await-not-working

@datho7561
Copy link
Contributor

Actually, the completion is working, the code lens for the {#if is working, but the validation is not working. Another case where it's broken:

method-invocation-uni

@angelozerr
Copy link
Contributor Author

@datho7561 is the sample #832 (comment) is working for you?

@angelozerr
Copy link
Contributor Author

Could you share your sample please.

@datho7561
Copy link
Contributor

datho7561 commented Mar 29, 2023

CompletionStagePOJO.java

package org.acme;

import java.util.Arrays;
import java.util.List;
import java.util.concurrent.CompletableFuture;

import io.smallrye.mutiny.Uni;

public class CompletionStagePOJO {
    public Uni<List<String>> getMyStrings() {
        return Uni.createFrom().item(Arrays.asList("my string", "my other string"));
    }

    public CompletableFuture<List<String>> getOtherStrings() {
        return CompletableFuture.completedFuture(Arrays.asList("my string", "my other string"));
    }
}

completion-stage-template.html

{@org.acme.CompletionStagePOJO obj}

{#for stringElt in obj.myStrings}
    {stringElt.codePointAt(0)}
{/for}

{obj.myStrings.add("sandwich")}

@angelozerr
Copy link
Contributor Author

Doesn't seem to be working for me:

It should working now, I didn't the cover of Java Type returned by a method. Thanks for haved testing this usecase.

@angelozerr angelozerr force-pushed the refactor-java-resolve branch 2 times, most recently from fa2b1d7 to 65b8ebf Compare March 30, 2023 07:52
Copy link
Contributor

@datho7561 datho7561 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code is working well, I haven't run into any bugs. I added a few comments, but feel free to merge once you've addressed them.

@@ -31,6 +32,9 @@ public class ResolvedJavaTypeInfo extends JavaTypeInfo {

private static final String JAVA_LANG_ITERABLE_TYPE = "java.lang.Iterable";

private static final List<String> WRAPPED_TYPES = Arrays.asList("java.util.concurrent.CompletionStage",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are the types that do the wrapping, so they should be called WRAPPER_TYPES. The wrapped type is the type parameter eg. in Uni<List<String>>, uni is wrapping List<String>, List<String> is wrapped by Uni, Uni is a wrapper type, List<String> is a wrapped type.

@datho7561 datho7561 merged commit f0a9a66 into redhat-developer:master Mar 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support for Evaluation of CompletionStage and Uni Objects
3 participants