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

Send info about function values #7168

Merged

Conversation

4e6
Copy link
Contributor

@4e6 4e6 commented Jun 29, 2023

Pull Request Description

close #6957

Extend ExpressionUpdate message and send a function schema if the returned value is a function.

Important Notes

Checklist

Please ensure that the following checklist has been satisfied before submitting the PR:

  • The documentation has been updated, if necessary.
  • All code follows the
    Scala,
    Java,
    and
    Rust
    style guides. In case you are using a language not listed above, follow the Rust style guide.
  • All code has been tested:
    • Unit tests have been written where possible.

@4e6 4e6 self-assigned this Jun 29, 2023
Copy link
Contributor

@hubertp hubertp left a comment

Choose a reason for hiding this comment

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

Overall LGTM, minor questions/comments

public static int[] collectNotAppliedArguments(Function function) {
FunctionSchema functionSchema = function.getSchema();
Object[] preAppliedArguments = function.getPreAppliedArguments();
boolean isStatic = preAppliedArguments[0] instanceof Type;
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this reliable? We could have an argument which is a type but the function is not a static?

Copy link
Contributor Author

@4e6 4e6 Jun 30, 2023

Choose a reason for hiding this comment

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

Yes, to resolve the function the self argument has to be present. And at this point, the function is resolved.
If the function is not static, the self argument will be something like UnboxingAtom I believe.

4e6 and others added 3 commits June 30, 2023 13:58
…untime.scala

Co-authored-by: Hubert Plociniczak <hubert.plociniczak@gmail.com>
…reter/instrument/IdExecutionService.java

Co-authored-by: Hubert Plociniczak <hubert.plociniczak@gmail.com>
@4e6 4e6 added the CI: Ready to merge This PR is eligible for automatic merge label Jun 30, 2023
@mergify mergify bot merged commit 66894bd into develop Jun 30, 2023
25 of 26 checks passed
@mergify mergify bot deleted the wip/db/6957-send-info-about-function-values-to-the-ide branch June 30, 2023 13:31
Copy link
Member

@JaroslavTulach JaroslavTulach left a comment

Choose a reason for hiding this comment

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

I'd like to know what will happen when schema changes? Will updates be delivered? Is that a covered test case?

}

public static int[] collectNotAppliedArguments(Function function) {
FunctionSchema functionSchema = function.getSchema();
Object[] preAppliedArguments = function.getPreAppliedArguments();
Copy link
Member

Choose a reason for hiding this comment

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

What if the preAppliedArguments array has zero size? Will the next line not throw an ArrayIndexOutOfBoundsException?

Option(
ctx.executionService.toDisplayString(warnings(0).getValue)
val warnings =
Option.when(
Copy link
Member

Choose a reason for hiding this comment

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

Replacing if with Option.when! I can only say: I am not fan of such aggressive functional rewrites.

@@ -953,6 +963,109 @@ class RuntimeServerTest
)
}

it should "send method pointer updates of partially applied type method returning a method" in {
Copy link
Member

Choose a reason for hiding this comment

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

What will happen when the result is a function and remains a function yet its schema changes on subsequent evaluation of the result? Will we deliver an update to value/schema?

I am envisioning following test case:

f a b c = a + b + c

fn what = case what of
    0 -> f
    1 -> f 3
    2 -> f 3 8
    _ -> f 3 8 9

what will happen if some code invoke fn 1 first and then the code get changed and invokes fn 2 - will the IDE be notified about the schema change?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI: Ready to merge This PR is eligible for automatic merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Send info about function values to the IDE
3 participants