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

Execute and debug .enso files with bin/enso in VSCode #8923

Merged
merged 13 commits into from
Feb 12, 2024

Conversation

JaroslavTulach
Copy link
Member

@JaroslavTulach JaroslavTulach commented Feb 1, 2024

Pull Request Description

Let's untie the VSCode Enso extension from sbt commands. Let's open any Enso file in the editor and then use F5 or Ctrl-F5 to execute it. Let the user choose which bin/enso script to use for execution completely skipping the need for sbt.

Checklist

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

  • The documentation has been updated in d87ba6e
  • Screenshots/screencasts have been attached, if there are any visual changes. For interactive or animated visual changes, a screencast is preferred.
  • All code follows the
    Java,
    style guides.
  • All code has been tested:
    • Support debugging (not only execution)
    • When in IGV run with --dump-graphs - done in 2fb11ac
    • Let @ola-lis publish new version of the extension

if (lkp.lookup(EnsoDataObject.class) != null) {
return true;
} else {
var fo = lkp.lookup(FileObject.class);
Copy link
Member Author

Choose a reason for hiding this comment

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

I'd be simpler to do just lookup(EnsoDataObject.class) != null, but that doesn't work currently. I needs apache/netbeans#7011 (comment) fix first which is going to be part of NetBeans 21 only. E.g. we need to keep this lookup(FileObject.class).getLookup().lookup(EnsoDataObject.class)) workaround.

@JaroslavTulach
Copy link
Member Author

JaroslavTulach commented Feb 1, 2024

To witness what has been done so far follow these instructions: Get NetBeans sources at

commit 1c19e60bc6b995e5c0228eca4785ec4ad7a26171 (origin/master, origin/HEAD, master)
Merge: f84f06453f a0968f906f
Author: Dusan Balek <dusan.balek@oracle.com>
Date:   Fri Jan 26 10:24:06 2024 +0100

at least that's a commit known to work. Follow instructions in VSCode extension BUILD. E.g.

netbeans$ ant build
netbeans$ cd java/java.lsp.server
java.lsp.server$ ant build-vscode-ext

In parallel follow Enso instructions to build VSIX file

$ENSO_REPO_ROOT/tools/enso4igv$ mvn clean package nbm:cluster -Pvsix
...
[INFO]Created NetBeans module cluster(s) at /home/devel/NetBeansProjects/enso/enso/tools/enso4igv/target/netbeans_clusters
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
...

and then execute everything as:

netbeans/java/java.lsp.server/vscode$  npm run nbcode -- --jdkhome ~/bin/graalvm -J-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=8000 -J-Dnetbeans.extra.dirs=$ENSO_REPO_ROOT/tools/enso4igv/target/netbeans_clusters/extra

Listening for transport dt_socket at address: 8000

once the JVM based LSP is started also launch VSCode with:

netbeans/java/java.lsp.server/vscode$ code --extensionDevelopmentPath=`pwd`

then you'll be able to open .enso file and invoke it with Ctrl+F5 (choose debug with Java+ if asked):

Select enso executable

After locating and pasting the enso executable there (for example $ENSO_REPO_ROOT/./built-distribution/enso-engine-0.0.0-dev-linux-amd64/enso-0.0.0-dev/bin/enso) the .enso file gets executed and output is printed in the area below editor:

Executed

Or (rather than building the extension yourself), download the .vsix file from here and install enso4vscode-1.31.129.vsix manually!

</dependencies>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<netbeans.version>RELEASE113</netbeans.version>
<netbeans.version>RELEASE140</netbeans.version>
Copy link
Member Author

@JaroslavTulach JaroslavTulach Feb 1, 2024

Choose a reason for hiding this comment

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

While working on this code base, I am trying to make sure the code works as:

The biggest challenge is support for IGV as it is not being updated to run on latest NetBeans version too frequently.

However for this PR I need DialogDisplayer.notifyFuture (thank you, @sdedic) which is only available since NetBeans 14 - e.g. we have to upgrade.

Copy link
Member Author

@JaroslavTulach JaroslavTulach Feb 1, 2024

Choose a reason for hiding this comment

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

With oracle/graal#8290 the Enso IGV Plugin version 1.31.129 can be installed into IGV:

Installation

Copy link
Member Author

@JaroslavTulach JaroslavTulach Feb 1, 2024

Choose a reason for hiding this comment

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

Once the .nbm file is installed into IGV, one can press Shift-F6 inside of a .enso file and get the same behavior as in the VSCode extension:

Exec in IGV

@radeusgd
Copy link
Member

radeusgd commented Feb 1, 2024

Let the user choose which bin/enso script to use for execution

It sounds like it could make sense to also allow to choose to run using the launcher. Not necessarily in this PR, but I think it would be a neat improvement.

Copy link
Member

@radeusgd radeusgd left a comment

Choose a reason for hiding this comment

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

This looks very cool!

@JaroslavTulach JaroslavTulach changed the title Execute .enso files with bin/enso in VSCode Execute and debug .enso files with bin/enso in VSCode Feb 2, 2024
private final ExplicitProcessParameters params;
private final Future<String> computeAddress;

DebugAndLaunch(FileObject script, ProcessBuilder builder, ExplicitProcessParameters params) {
Copy link
Member Author

@JaroslavTulach JaroslavTulach Feb 2, 2024

Choose a reason for hiding this comment

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

I've got debugging working. Execute VSCode with empty directories:

$ code  --extensions-dir /tmp/ext --user-data-dir /tmp/usr

install the .vsix 1.31.138 extension and open some .enso file

Select java+ debugging

Stop on breakpoint

Right now the debugging seems to work when there is no workspace opened - opening root of Enso repository as workspace prevents the debugging to work. Still investigating how to fix that.

Copy link
Member

@jdunkerley jdunkerley left a comment

Choose a reason for hiding this comment

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

This is great - nice to have a more official way than my quick solution :)

@JaroslavTulach
Copy link
Member Author

If you open root of Enso repository as VSCode folder, then choose preconfigured Launch Enso File debug configuration before debugging a .enso file:

Launch Enso File in a Project

The rest of the workflow remains the same.

@JaroslavTulach
Copy link
Member Author

I have done manual testing VSCode extension enso4vscode-1.33.29.vsix and I think it works. @ola-lis, can you please upload the .vsix file to the VSCode marketplace?

@JaroslavTulach JaroslavTulach added the CI: Clean build required CI runners will be cleaned before and after this PR is built. label Feb 9, 2024
@JaroslavTulach
Copy link
Member Author

Let the user choose which bin/enso script to use for execution

It sounds like it could make sense to also allow to choose to run using the launcher. Not necessarily in this PR, but I think it would be a neat improvement.

I am not using launcher myself, but it should be fairly trivial to update the extension to work with it. The code should be somewhere here, if you want to enhance it to also work with the launcher.

@JaroslavTulach JaroslavTulach added CI: Keep up to date Automatically update this PR to the latest develop. CI: Ready to merge This PR is eligible for automatic merge labels Feb 12, 2024
@mergify mergify bot merged commit ca9125f into develop Feb 12, 2024
26 of 27 checks passed
@mergify mergify bot deleted the wip/jtulach/VSCodeExec branch February 12, 2024 06:38
@JaroslavTulach
Copy link
Member Author

Extension version 1.33.29 is available at Microsoft marketplace. Thank you, @ola-lis!

mergify bot pushed a commit that referenced this pull request Apr 18, 2024
Turns out that #8923 isn't enough to support debugging of `Vector_Spec.enso` when root of Enso repository is opened as a folder/workspace. To allow debugging of `Vector_Spec.enso` two changes are needed. One is provided in this PR, the other one will be integrated as apache/netbeans#7105
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI: Clean build required CI runners will be cleaned before and after this PR is built. CI: Keep up to date Automatically update this PR to the latest develop. CI: Ready to merge This PR is eligible for automatic merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants