diff --git a/tools/enso4igv/IGV.md b/tools/enso4igv/IGV.md index 525ee339486..8d44aceae2e 100644 --- a/tools/enso4igv/IGV.md +++ b/tools/enso4igv/IGV.md @@ -5,9 +5,9 @@ [Enso language](http://enso.org) runtime engine is built on top of [GraalVM](http://graalvm.org) and its _Truffle framework_. Enso, as a good citizen of the GraalVM ecosystem, benefits from polyglot capabilities of GraalVM -as well as its rich tooling offering. One of such tools is _IGV_ - the _Ideal -Graph Visualizer_ - an excellent tool to get insights into behavior of Graal -compiler. +as well as its rich tooling offering. One of such tools is +[IGV - the _Ideal Graph Visualizer_](https://www.graalvm.org/jdk22/tools/igv/) - +an excellent tool to get insights into behavior of Graal compiler. This document shows how to use _IGV_ with the _Enso language_. The command line instructions format is Unix oriented. Use instructions appropriate for your @@ -17,13 +17,14 @@ major operating systems. ## Installation -Visit [GraalVM.org](http://graalvm.org) download page and continue towards -_enterprise edition_ option. There is an _Ideal Graph Visualizer_ option. After -clicking through the confirmation dialogs you should get a ZIP - I've just got -`idealgraphvisualizer-22.1.0.zip` and then: +Visit [GraalVM's IGV page](https://www.graalvm.org/jdk22/tools/igv/) to read and +download _IGV_. Or follow +[this link](https://lafo.ssw.uni-linz.ac.at/pub/idealgraphvisualizer/idealgraphvisualizer-0.31-cb98bbf5fef-all.zip) +to get ZIP with the most up to date version of _Ideal Graph Visualizer_ (as of +June 2024). Then: ```bash -$ unzip idealgraphvisualizer-22.1.0.zip +$ unzip idealgraphvisualizer-*.zip $ ./idealgraphvisualizer/bin/idealgraphvisualizer --userdir /tmp/emptyuserdir ``` diff --git a/tools/enso4igv/pom.xml b/tools/enso4igv/pom.xml index 0081177bda0..6f726c8be49 100644 --- a/tools/enso4igv/pom.xml +++ b/tools/enso4igv/pom.xml @@ -5,7 +5,7 @@ enso4igv nbm Enso Language Support for NetBeans & Ideal Graph Visualizer - 1.35-SNAPSHOT + 1.36-SNAPSHOT diff --git a/tools/enso4igv/src/main/java/org/enso/tools/enso4igv/EnsoDataObject.java b/tools/enso4igv/src/main/java/org/enso/tools/enso4igv/EnsoDataObject.java index f217d7fd4a6..50bdb882dd2 100644 --- a/tools/enso4igv/src/main/java/org/enso/tools/enso4igv/EnsoDataObject.java +++ b/tools/enso4igv/src/main/java/org/enso/tools/enso4igv/EnsoDataObject.java @@ -1,6 +1,9 @@ package org.enso.tools.enso4igv; import java.io.IOException; +import java.util.Set; +import java.util.logging.Level; +import java.util.logging.Logger; import org.netbeans.core.spi.multiview.MultiViewElement; import org.netbeans.core.spi.multiview.text.MultiViewEditorElement; import org.netbeans.modules.textmate.lexer.api.GrammarRegistration; @@ -40,6 +43,17 @@ import org.openide.windows.TopComponent; position = 100, separatorAfter = 200 ), + @ActionReference( + path = "Loaders/application/x-enso/Actions", + id = @ActionID(category = "Project", id = "org.netbeans.modules.project.ui.RunSingle"), + position = 230 + ), + @ActionReference( + path = "Loaders/application/x-enso/Actions", + id = @ActionID(category = "Debug", id = "org.netbeans.modules.debugger.ui.actions.DebugFileAction"), + position = 270, + separatorAfter = 290 + ), @ActionReference( path = "Loaders/application/x-enso/Actions", id = @ActionID(category = "Edit", id = "org.openide.actions.CutAction"), @@ -83,13 +97,27 @@ import org.openide.windows.TopComponent; path = "Loaders/application/x-enso/Actions", id = @ActionID(category = "System", id = "org.openide.actions.PropertiesAction"), position = 1400 - ) + ), + + // editor popups + @ActionReference( + path = "Editors/application/x-enso/Popup", + id = @ActionID(category = "Project", id = "org.netbeans.modules.project.ui.RunSingle"), + position = 30 + ), + @ActionReference( + path = "Editors/application/x-enso/Popup", + id = @ActionID(category = "Debug", id = "org.netbeans.modules.debugger.ui.actions.DebugFileAction"), + position = 70, + separatorAfter = 90 + ), + }) public class EnsoDataObject extends MultiDataObject { - public EnsoDataObject(FileObject pf, MultiFileLoader loader) throws DataObjectExistsException, IOException { super(pf, loader); registerEditor("application/x-enso", true); + registerTruffleMimeType("application/x-enso"); } @Override @@ -110,4 +138,20 @@ public class EnsoDataObject extends MultiDataObject { return new MultiViewEditorElement(lkp); } + private void registerTruffleMimeType(String mime) throws IOException { + ClassLoader all = Lookup.getDefault().lookup(ClassLoader.class); + if (all == null) { + all = EnsoDataObject.class.getClassLoader(); + } + try { + var clazz = all.loadClass("org.netbeans.modules.debugger.jpda.truffle.MIMETypes"); + var getDefault = clazz.getMethod("getDefault"); + var mimeTypes = getDefault.invoke(null); + var get = clazz.getMethod("get"); + var toSet = (Set)get.invoke(mimeTypes); + toSet.add(mime); + } catch (ReflectiveOperationException ex) { + Installer.LOG.log(Level.WARNING, "Cannot register breakpoints for Enso", ex); + } + } } diff --git a/tools/enso4igv/src/main/java/org/enso/tools/enso4igv/Installer.java b/tools/enso4igv/src/main/java/org/enso/tools/enso4igv/Installer.java new file mode 100644 index 00000000000..31cf6fbc356 --- /dev/null +++ b/tools/enso4igv/src/main/java/org/enso/tools/enso4igv/Installer.java @@ -0,0 +1,26 @@ +package org.enso.tools.enso4igv; + +import java.util.logging.Level; +import java.util.logging.Logger; +import org.openide.modules.ModuleInstall; +import org.openide.util.Lookup; +import org.openide.util.NbPreferences; + +public class Installer extends ModuleInstall { + static final Logger LOG = Logger.getLogger(EnsoDataObject.class.getName()); + + @Override + public void restored() { + try { + ClassLoader all = Lookup.getDefault().lookup(ClassLoader.class); + if (all == null) { + all = Installer.class.getClassLoader(); + } + var clazz = all.loadClass("org.netbeans.modules.project.ui.api.ProjectActionUtils"); + var pref = NbPreferences.forModule(clazz); + pref.putBoolean("openSubprojects", true); + } catch (ClassNotFoundException ex) { + LOG.log(Level.WARNING, "Cannot register breakpoints for Enso", ex); + } + } +} diff --git a/tools/enso4igv/src/main/nbm/manifest.mf b/tools/enso4igv/src/main/nbm/manifest.mf index 4c4e240ddb7..048c4c387b9 100644 --- a/tools/enso4igv/src/main/nbm/manifest.mf +++ b/tools/enso4igv/src/main/nbm/manifest.mf @@ -1,5 +1,6 @@ Manifest-Version: 1.0 +OpenIDE-Module-Install: org/enso/tools/enso4igv/Installer.class OpenIDE-Module-Layer: org/enso/tools/enso4igv/layer.xml OpenIDE-Module-Localizing-Bundle: org/enso/tools/enso4igv/Bundle.properties Multi-Release: true -OpenIDE-Module-Recommends: cnb.org.netbeans.modules.java.kit +OpenIDE-Module-Recommends: cnb.org.netbeans.modules.java.kit, cnb.org.netbeans.modules.debugger.jpda.truffle, cnd.org.netbeans.modules.terminal, cnd.org.netbeans.modules.git diff --git a/tools/enso4igv/src/main/resources/org/enso/tools/enso4igv/layer.xml b/tools/enso4igv/src/main/resources/org/enso/tools/enso4igv/layer.xml index 47ffd1c6b73..3fa2df1ded8 100644 --- a/tools/enso4igv/src/main/resources/org/enso/tools/enso4igv/layer.xml +++ b/tools/enso4igv/src/main/resources/org/enso/tools/enso4igv/layer.xml @@ -16,6 +16,23 @@ + + + + + + + + + + + + + + + + +