Skip to content

Commit

Permalink
Support --module-path in VSCode extension (#10146)
Browse files Browse the repository at this point in the history
  • Loading branch information
JaroslavTulach authored May 31, 2024
1 parent ffdfc71 commit 500e398
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/enso4igv.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
# Why do we subtract a number? Read versioning policy!
# https://github.com/enso-org/enso/pull/7861#discussion_r1333133490
echo "POM_VERSION=`mvn -q -DforceStdout help:evaluate -Dexpression=project.version | cut -f1 -d -`" >> "$GITHUB_ENV"
echo "MICRO_VERSION=`expr $GITHUB_RUN_NUMBER - 2250`" >> "$GITHUB_ENV"
echo "MICRO_VERSION=`expr $GITHUB_RUN_NUMBER - 2930`" >> "$GITHUB_ENV"
- name: Update project version
working-directory: tools/enso4igv
Expand Down
2 changes: 1 addition & 1 deletion tools/enso4igv/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<artifactId>enso4igv</artifactId>
<packaging>nbm</packaging>
<name>Enso Language Support for NetBeans &amp; Ideal Graph Visualizer</name>
<version>1.33-SNAPSHOT</version>
<version>1.35-SNAPSHOT</version>
<build>
<plugins>
<plugin>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import java.io.InputStream;
import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Properties;
Expand Down Expand Up @@ -42,6 +41,7 @@ final class EnsoSbtClassPathProvider extends ProjectOpenedHook
private static final String BOOT = "classpath/boot";
private static final String SOURCE = "classpath/source";
private static final String COMPILE = "classpath/compile";
private static final String MODULES_COMPILE = "modules/compile";
private final EnsoSbtProject project;
private final SourceGroup[] sources;

Expand All @@ -52,11 +52,18 @@ final class EnsoSbtClassPathProvider extends ProjectOpenedHook

@Override
public ClassPath findClassPath(FileObject file, String type) {
var res = findClassPathImpl(file, type);
LOG.log(Level.FINE, "findClassPath{0} for {1} yields {2}", new Object[]{type, file, res});
return res;
}

private ClassPath findClassPathImpl(FileObject file, String type) {
for (var g : sources) {
if (g instanceof EnsoSources i && i.controlsSource(file)) {
var cp = switch (type) {
case SOURCE -> i.srcCp;
case COMPILE -> i.cp;
case MODULES_COMPILE -> i.moduleCp;
case BOOT -> i.platform.getBootstrapLibraries();
default -> null;
};
Expand Down Expand Up @@ -89,7 +96,8 @@ public void projectClosed() {
private static SourceGroup[] computeSbtClassPath(EnsoSbtProject prj) {
var sources = new ArrayList<SourceGroup>();
var platform = JavaPlatform.getDefault();
var roots = new LinkedHashSet<>();
var roots = new LinkedHashSet<FileObject>();
var modulePath = new LinkedHashSet<FileObject>();
var generatedSources = new LinkedHashSet<FileObject>();
var source = "21";
var options = new ArrayList<String>();
Expand Down Expand Up @@ -136,6 +144,22 @@ private static SourceGroup[] computeSbtClassPath(EnsoSbtProject prj) {
i++;
continue;
}
if ("--module-path".equals(prop) && next != null) {
var paths = next.split(File.pathSeparator);
for (var element : paths) {
FileObject fo = findProjectFileObject(prj, element);
if (fo != null) {
if (fo.isFolder()) {
modulePath.add(fo);
} else {
var jarRoot = FileUtil.getArchiveRoot(fo);
modulePath.add(jarRoot);
}
}
}
i++;
continue;
}
if ("-s".equals(prop) && next != null) {
var fo = FileUtil.toFileObject(new File(next));
if (fo != null) {
Expand Down Expand Up @@ -193,8 +217,9 @@ private static SourceGroup[] computeSbtClassPath(EnsoSbtProject prj) {
}

var cp = ClassPathSupport.createClassPath(roots.toArray(new FileObject[0]));
var moduleCp = ClassPathSupport.createClassPath(modulePath.toArray(new FileObject[0]));
var srcCp = ClassPathSupport.createClassPath(srcRoots.toArray(new FileObject[0]));
var s = new EnsoSources(cp, srcCp, platform, outputDir, source, options);
var s = new EnsoSources(cp, moduleCp, srcCp, platform, outputDir, source, options);
if ("main".equals(s.getName())) {
sources.add(0, s);
} else {
Expand Down Expand Up @@ -363,7 +388,9 @@ public SourceForBinaryQuery.Result findSourceRoots(URL binaryRoot) {
}

record EnsoSources(
ClassPath cp, ClassPath srcCp,
ClassPath cp,
ClassPath moduleCp,
ClassPath srcCp,
JavaPlatform platform,
FileObject output,
String source, List<String> options
Expand Down

0 comments on commit 500e398

Please sign in to comment.