From b0a1e22e9165cfa87cc5ad2c99c6a37522879dd7 Mon Sep 17 00:00:00 2001 From: "Jurgen J. Vinju" Date: Tue, 24 Sep 2024 19:23:31 +0200 Subject: [PATCH 1/8] dealing with changes downstream of removing the lib scheme, and independent other changes to the rascal project that have not been promoted here yet --- rascal-lsp/META-INF/RASCAL.MF | 1 - rascal-lsp/pom.xml | 4 +-- .../vscode/lsp/BaseLanguageServer.java | 11 ++++---- .../vscode/lsp/rascal/model/PathConfigs.java | 8 +----- .../vscode/lsp/terminal/LSPTerminalREPL.java | 28 ++++++++++++------- .../lsp/terminal/TerminalIDEClient.java | 2 +- .../uri/jsonrpc/messages/PathConfigMode.java | 2 +- .../vscode/lsp/util/EvaluatorUtil.java | 19 +++++++++---- .../lang/rascal/tests/rename/TestUtils.rsc | 2 +- 9 files changed, 44 insertions(+), 33 deletions(-) diff --git a/rascal-lsp/META-INF/RASCAL.MF b/rascal-lsp/META-INF/RASCAL.MF index 1a3bf9195..0fedd8066 100644 --- a/rascal-lsp/META-INF/RASCAL.MF +++ b/rascal-lsp/META-INF/RASCAL.MF @@ -1,3 +1,2 @@ Project-Name: rascal-lsp Source: src/main/rascal -Require-Libraries: |lib://typepal/|, |lib://rascal-core/| diff --git a/rascal-lsp/pom.xml b/rascal-lsp/pom.xml index 1a6a71159..9fe379a99 100644 --- a/rascal-lsp/pom.xml +++ b/rascal-lsp/pom.xml @@ -65,7 +65,7 @@ org.rascalmpl rascal - 0.40.7 + 0.40.8-SNAPSHOT org.rascalmpl @@ -176,7 +176,7 @@ ${project.basedir}/src/main/rascal/lang/rascal/lsp/refactor/WorkspaceInfo.rsc ${project.basedir}/src/main/rascal/lang/rascal/tests/rename - |lib://rascal-lsp| + |mvn://${project.groupId}~${project.name}~${project.version}}| false diff --git a/rascal-lsp/src/main/java/org/rascalmpl/vscode/lsp/BaseLanguageServer.java b/rascal-lsp/src/main/java/org/rascalmpl/vscode/lsp/BaseLanguageServer.java index 28d441cc8..f50bb8643 100644 --- a/rascal-lsp/src/main/java/org/rascalmpl/vscode/lsp/BaseLanguageServer.java +++ b/rascal-lsp/src/main/java/org/rascalmpl/vscode/lsp/BaseLanguageServer.java @@ -253,10 +253,11 @@ public CompletableFuture supplyProjectCompilationClasspath(URIParamete return CompletableFuture.supplyAsync(() -> { try { if (projectFolder.getUri() == null) { - return classLoaderFiles(PathConfig.getDefaultClassloadersList()); + return classLoaderFiles(IRascalValueFactory.getInstance().list(PathConfig.resolveCurrentRascalRuntimeJar())); } + PathConfig pcfg = findPathConfig(projectFolder.getLocation(), RascalConfigMode.COMPILER); - return classLoaderFiles(pcfg.getClassloaders()); + return classLoaderFiles(pcfg.getLibsAndTarget()); } catch (IOException | URISyntaxException e) { logger.catching(e); @@ -288,12 +289,12 @@ private static URI[] toURIArray(IList src) { public CompletableFuture[]> supplyPathConfig(PathConfigParameter projectFolder) { return CompletableFuture.supplyAsync(() -> { try { + // TODO: why are we not communicating the JSON representation of the PathConfig constructor? var pcfg = PathConfig.fromSourceProjectMemberRascalManifest(projectFolder.getLocation(), projectFolder.getMode().mapConfigMode()); - Two[] result = new Two[4]; + @SuppressWarnings("unchecked") + Two[] result = new Two[2]; result[0] = new Two<>("Sources", toURIArray(pcfg.getSrcs())); result[1] = new Two<>("Libraries", toURIArray(pcfg.getLibs())); - result[2] = new Two<>("Java Compiler Path", toURIArray(pcfg.getJavaCompilerPath())); - result[3] = new Two<>("Classloaders", toURIArray(pcfg.getClassloaders())); return result; } catch (IOException | URISyntaxException e) { logger.catching(e); diff --git a/rascal-lsp/src/main/java/org/rascalmpl/vscode/lsp/rascal/model/PathConfigs.java b/rascal-lsp/src/main/java/org/rascalmpl/vscode/lsp/rascal/model/PathConfigs.java index 6f99cac4e..d7e97c5dc 100644 --- a/rascal-lsp/src/main/java/org/rascalmpl/vscode/lsp/rascal/model/PathConfigs.java +++ b/rascal-lsp/src/main/java/org/rascalmpl/vscode/lsp/rascal/model/PathConfigs.java @@ -170,13 +170,7 @@ private static boolean hasParentSection(URIResolverRegistry reg, ISourceLocation } private static PathConfig actualBuild(ISourceLocation projectRoot) { - try { - return PathConfig.fromSourceProjectRascalManifest(projectRoot, RascalConfigMode.COMPILER); - } - catch (IOException e) { - logger.error("Could not figure out path config for: {}, falling back to default", projectRoot, e); - return new PathConfig(); - } + return PathConfig.fromSourceProjectRascalManifest(projectRoot, RascalConfigMode.COMPILER); } diff --git a/rascal-lsp/src/main/java/org/rascalmpl/vscode/lsp/terminal/LSPTerminalREPL.java b/rascal-lsp/src/main/java/org/rascalmpl/vscode/lsp/terminal/LSPTerminalREPL.java index fa0791180..7f9e79efc 100644 --- a/rascal-lsp/src/main/java/org/rascalmpl/vscode/lsp/terminal/LSPTerminalREPL.java +++ b/rascal-lsp/src/main/java/org/rascalmpl/vscode/lsp/terminal/LSPTerminalREPL.java @@ -49,8 +49,6 @@ import org.rascalmpl.interpreter.result.IRascalResult; import org.rascalmpl.interpreter.result.ResultFactory; import org.rascalmpl.interpreter.utils.RascalManifest; -import org.rascalmpl.jline.Terminal; -import org.rascalmpl.jline.TerminalFactory; import org.rascalmpl.library.util.PathConfig; import org.rascalmpl.library.util.PathConfig.RascalConfigMode; import org.rascalmpl.repl.BaseREPL; @@ -71,6 +69,9 @@ import io.usethesource.vallang.IValue; import io.usethesource.vallang.IValueFactory; import io.usethesource.vallang.io.StandardTextWriter; +import org.rascalmpl.jline.TerminalFactory; +import org.rascalmpl.jline.Terminal; +import org.rascalmpl.jline.internal.Configuration; /** * This class runs a Rascal terminal REPL that @@ -89,8 +90,9 @@ public LSPTerminalREPL(Terminal terminal, IDEServices services, OutputStream std private static String getRascalLspVersion() { try { + var lspJar = PathConfig.resolveProjectOnClasspath("rascal-lsp"); return new Manifest(URIResolverRegistry.getInstance() - .getInputStream(URIUtil.correctLocation("lib", "rascal-lsp", "META-INF/MANIFEST.MF"))) + .getInputStream(URIUtil.getChildLocation(lspJar, "META-INF/MANIFEST.MF"))) .getMainAttributes().getValue("Specification-Version"); } catch (IOException e) { return "Unknown"; @@ -144,8 +146,7 @@ protected Evaluator constructEvaluator(InputStream input, OutputStream stdout, O IValueFactory vf = ValueFactoryFactory.getValueFactory(); Evaluator evaluator = new Evaluator(vf, input, stderr, stdout, services, root, heap); evaluator.addRascalSearchPathContributor(StandardLibraryContributor.getInstance()); - evaluator.addRascalSearchPath(URIUtil.correctLocation("lib", "rascal-lsp", "")); - + URIResolverRegistry reg = URIResolverRegistry.getInstance(); ISourceLocation projectDir = ShellEvaluatorFactory.inferProjectRoot(new File(System.getProperty("user.dir"))); @@ -160,9 +161,12 @@ protected Evaluator constructEvaluator(InputStream input, OutputStream stdout, O debugServer = new DebugSocketServer(evaluator, (TerminalIDEClient) services); try { + var lspJar = PathConfig.resolveProjectOnClasspath("rascal-lsp"); + evaluator.addRascalSearchPath(lspJar); + PathConfig pcfg; if (projectDir != null) { - pcfg = PathConfig.fromSourceProjectRascalManifest(projectDir, RascalConfigMode.INTERPETER); + pcfg = PathConfig.fromSourceProjectRascalManifest(projectDir, RascalConfigMode.INTERPRETER); } else { pcfg = new PathConfig(); @@ -183,17 +187,21 @@ protected Evaluator constructEvaluator(InputStream input, OutputStream stdout, O reg.watch(resolvedPath, true, d -> sourceLocationChanged(resolvedPath, d)); } + var rascalJar = PathConfig.resolveCurrentRascalRuntimeJar(); + var projectTarget = URIUtil.correctLocation("target", projectName, ""); + ClassLoader cl = new SourceLocationClassLoader( - pcfg.getClassloaders() - .append(URIUtil.correctLocation("lib", "rascal","")) - .append(URIUtil.correctLocation("lib", "rascal-lsp","")) - .append(URIUtil.correctLocation("target", projectName, "")), + pcfg.getLibs() + .append(rascalJar) + .append(lspJar) + .append(projectTarget), ClassLoader.getSystemClassLoader() ); evaluator.addClassLoader(cl); } catch (IOException e) { + // TODO: don't we have a logger for this? e.printStackTrace(new PrintStream(stderr)); } diff --git a/rascal-lsp/src/main/java/org/rascalmpl/vscode/lsp/terminal/TerminalIDEClient.java b/rascal-lsp/src/main/java/org/rascalmpl/vscode/lsp/terminal/TerminalIDEClient.java index 8414456b3..cebcc1f07 100644 --- a/rascal-lsp/src/main/java/org/rascalmpl/vscode/lsp/terminal/TerminalIDEClient.java +++ b/rascal-lsp/src/main/java/org/rascalmpl/vscode/lsp/terminal/TerminalIDEClient.java @@ -69,7 +69,7 @@ public class TerminalIDEClient implements IDEServices { private final IRascalMonitor monitor; public TerminalIDEClient(int port, IRascalMonitor monitor) throws IOException { - @SuppressWarnings("java:S2095") // we don't have to close the socket, we are passing it off to the lsp4j framework + @SuppressWarnings({ "java:S2095", "resource" }) // we don't have to close the socket, we are passing it off to the lsp4j framework Socket socket = new Socket(InetAddress.getLoopbackAddress(), port); socket.setTcpNoDelay(true); Launcher launch = new Launcher.Builder() diff --git a/rascal-lsp/src/main/java/org/rascalmpl/vscode/lsp/uri/jsonrpc/messages/PathConfigMode.java b/rascal-lsp/src/main/java/org/rascalmpl/vscode/lsp/uri/jsonrpc/messages/PathConfigMode.java index 656b7a371..ce413cfdd 100644 --- a/rascal-lsp/src/main/java/org/rascalmpl/vscode/lsp/uri/jsonrpc/messages/PathConfigMode.java +++ b/rascal-lsp/src/main/java/org/rascalmpl/vscode/lsp/uri/jsonrpc/messages/PathConfigMode.java @@ -43,7 +43,7 @@ public int getValue() { public RascalConfigMode mapConfigMode() { switch (this) { - case INTERPRETER: return RascalConfigMode.INTERPETER; + case INTERPRETER: return RascalConfigMode.INTERPRETER; case COMPILER: return RascalConfigMode.COMPILER; default: throw new IllegalArgumentException("Missing case: " + this); } diff --git a/rascal-lsp/src/main/java/org/rascalmpl/vscode/lsp/util/EvaluatorUtil.java b/rascal-lsp/src/main/java/org/rascalmpl/vscode/lsp/util/EvaluatorUtil.java index 961836874..2858df1a7 100644 --- a/rascal-lsp/src/main/java/org/rascalmpl/vscode/lsp/util/EvaluatorUtil.java +++ b/rascal-lsp/src/main/java/org/rascalmpl/vscode/lsp/util/EvaluatorUtil.java @@ -64,7 +64,6 @@ import org.rascalmpl.interpreter.utils.LimitedResultWriter; import org.rascalmpl.library.util.PathConfig; import org.rascalmpl.shell.ShellEvaluatorFactory; -import org.rascalmpl.uri.URIUtil; import org.rascalmpl.vscode.lsp.BaseWorkspaceService; import org.rascalmpl.vscode.lsp.IBaseLanguageClient; import org.rascalmpl.vscode.lsp.IBaseTextDocumentService; @@ -243,11 +242,17 @@ public static CompletableFuture makeFutureEvaluator(ExecutorService e eval.getConfiguration().setRascalJavaClassPathProperty(System.getProperty("rascal.compilerClasspath")); eval.addClassLoader(RascalLanguageServer.class.getClassLoader()); eval.addClassLoader(IValue.class.getClassLoader()); + if (addRascalCore) { - eval.addRascalSearchPath(URIUtil.correctLocation("lib", "typepal", "")); - eval.addRascalSearchPath(URIUtil.correctLocation("lib", "rascal-core", "")); + var rascalCoreJar = PathConfig.resolveProjectOnClasspath("rascal-core"); + var typePalJar = PathConfig.resolveProjectOnClasspath("typepal"); + + eval.addRascalSearchPath(typePalJar); + eval.addRascalSearchPath(rascalCoreJar); } - eval.addRascalSearchPath(URIUtil.correctLocation("lib", "rascal-lsp", "")); + + var rascalLspJar = PathConfig.resolveProjectOnClasspath("rascal-lsp"); + eval.addRascalSearchPath(rascalLspJar); if (pcfg != null) { for (IValue src : pcfg.getSrcs()) { @@ -259,7 +264,11 @@ public static CompletableFuture makeFutureEvaluator(ExecutorService e jobSuccess = true; return eval; - } finally { + } + catch (IOException e) { + throw new RuntimeException(e); + } + finally { services.jobEnd(jobName, jobSuccess); } }, exec); diff --git a/rascal-lsp/src/main/rascal/lang/rascal/tests/rename/TestUtils.rsc b/rascal-lsp/src/main/rascal/lang/rascal/tests/rename/TestUtils.rsc index d28a5e5d6..d3109391e 100644 --- a/rascal-lsp/src/main/rascal/lang/rascal/tests/rename/TestUtils.rsc +++ b/rascal-lsp/src/main/rascal/lang/rascal/tests/rename/TestUtils.rsc @@ -175,7 +175,7 @@ bool testRename(str stmtsStr, int cursorAtOldNameOccurrence = 0, str oldName = " private PathConfig getTestPathConfig(loc testDir) { return pathConfig( bin=testDir + "bin", - libs=[|lib://rascal|], + libs=[|std://rascal|], srcs=[testDir + "rascal"], resources=testDir + "bin", generatedSources=testDir + "generated-sources" From 208b360cdacfd31826616bb2cb19c6d3d7ff5704 Mon Sep 17 00:00:00 2001 From: "Jurgen J. Vinju" Date: Tue, 24 Sep 2024 19:50:12 +0200 Subject: [PATCH 2/8] use of the new mvn project/group separator --- rascal-lsp/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rascal-lsp/pom.xml b/rascal-lsp/pom.xml index 9fe379a99..cc144f001 100644 --- a/rascal-lsp/pom.xml +++ b/rascal-lsp/pom.xml @@ -176,7 +176,7 @@ ${project.basedir}/src/main/rascal/lang/rascal/lsp/refactor/WorkspaceInfo.rsc ${project.basedir}/src/main/rascal/lang/rascal/tests/rename - |mvn://${project.groupId}~${project.name}~${project.version}}| + |mvn://${project.groupId}--${project.name}--${project.version}| false From a3a60459600cca05b68d0dfbb537da994a571e39 Mon Sep 17 00:00:00 2001 From: "Jurgen J. Vinju" Date: Tue, 24 Sep 2024 19:53:36 +0200 Subject: [PATCH 3/8] removed unused import --- .../java/org/rascalmpl/vscode/lsp/terminal/LSPTerminalREPL.java | 1 - 1 file changed, 1 deletion(-) diff --git a/rascal-lsp/src/main/java/org/rascalmpl/vscode/lsp/terminal/LSPTerminalREPL.java b/rascal-lsp/src/main/java/org/rascalmpl/vscode/lsp/terminal/LSPTerminalREPL.java index 7f9e79efc..76f5f763f 100644 --- a/rascal-lsp/src/main/java/org/rascalmpl/vscode/lsp/terminal/LSPTerminalREPL.java +++ b/rascal-lsp/src/main/java/org/rascalmpl/vscode/lsp/terminal/LSPTerminalREPL.java @@ -71,7 +71,6 @@ import io.usethesource.vallang.io.StandardTextWriter; import org.rascalmpl.jline.TerminalFactory; import org.rascalmpl.jline.Terminal; -import org.rascalmpl.jline.internal.Configuration; /** * This class runs a Rascal terminal REPL that From 96f748ee0c25ee1ec48dd220ee198e74aaa0700a Mon Sep 17 00:00:00 2001 From: "Jurgen J. Vinju" Date: Wed, 25 Sep 2024 14:44:05 +0200 Subject: [PATCH 4/8] finetuning terminal configuration --- .../vscode/lsp/terminal/LSPTerminalREPL.java | 34 +++++++++++++------ .../vscode/lsp/util/RascalServices.java | 4 +-- 2 files changed, 24 insertions(+), 14 deletions(-) diff --git a/rascal-lsp/src/main/java/org/rascalmpl/vscode/lsp/terminal/LSPTerminalREPL.java b/rascal-lsp/src/main/java/org/rascalmpl/vscode/lsp/terminal/LSPTerminalREPL.java index 76f5f763f..9d5912e83 100644 --- a/rascal-lsp/src/main/java/org/rascalmpl/vscode/lsp/terminal/LSPTerminalREPL.java +++ b/rascal-lsp/src/main/java/org/rascalmpl/vscode/lsp/terminal/LSPTerminalREPL.java @@ -171,11 +171,29 @@ protected Evaluator constructEvaluator(InputStream input, OutputStream stdout, O pcfg = new PathConfig(); pcfg.addSourceLoc(URIUtil.rootLocation("std")); } - - evaluator.getErrorPrinter().println("Rascal Version: " + RascalManifest.getRascalVersionNumber()); - evaluator.getErrorPrinter().println("Rascal-lsp Version: " + getRascalLspVersion()); - new StandardTextWriter(true).write(pcfg.asConstructor(), evaluator.getErrorPrinter()); + var rascalLspLib = PathConfig.resolveProjectOnClasspath("rascal-lsp"); + + // the interpreter must find the Rascal sources of util::LanguageServer etc. + pcfg = pcfg.addSourceLoc(rascalLspLib); + + // the interpreter must load the Java parts for calling util::IDEServices and registerLanguage + pcfg = pcfg.addLibLoc(rascalLspLib); + + var out = evaluator.getOutPrinter(); + + out.println("Rascal Version: " + RascalManifest.getRascalVersionNumber()); + out.println("Rascal-lsp Version: " + getRascalLspVersion()); + out.println("Source folders:"); + pcfg.getSrcs().forEach((f) -> out.println(" ".repeat(4) + f)); + out.println("Library locations:"); + pcfg.getLibs().forEach((l) -> out.println(" ".repeat(4) + l)); + out.println("Target folder:"); + out.println(" ".repeat(4) + pcfg.getBin()); + out.flush(); + + services.registerDiagnostics(pcfg.getMessages()); + for (IValue srcPath : pcfg.getSrcs()) { ISourceLocation path = (ISourceLocation)srcPath; evaluator.addRascalSearchPath(path); @@ -186,14 +204,8 @@ protected Evaluator constructEvaluator(InputStream input, OutputStream stdout, O reg.watch(resolvedPath, true, d -> sourceLocationChanged(resolvedPath, d)); } - var rascalJar = PathConfig.resolveCurrentRascalRuntimeJar(); - var projectTarget = URIUtil.correctLocation("target", projectName, ""); - ClassLoader cl = new SourceLocationClassLoader( - pcfg.getLibs() - .append(rascalJar) - .append(lspJar) - .append(projectTarget), + pcfg.getLibsAndTarget(), ClassLoader.getSystemClassLoader() ); diff --git a/rascal-lsp/src/main/java/org/rascalmpl/vscode/lsp/util/RascalServices.java b/rascal-lsp/src/main/java/org/rascalmpl/vscode/lsp/util/RascalServices.java index 93cafecce..1beb2c132 100644 --- a/rascal-lsp/src/main/java/org/rascalmpl/vscode/lsp/util/RascalServices.java +++ b/rascal-lsp/src/main/java/org/rascalmpl/vscode/lsp/util/RascalServices.java @@ -38,8 +38,6 @@ public class RascalServices { public static ITree parseRascalModule(ISourceLocation loc, char[] input) { - IActionExecutor actions = new NoActionExecutor(); - return new RascalParser().parse(Parser.START_MODULE, loc.getURI(), input, actions, - new DefaultNodeFlattener<>(), new UPTRNodeFactory(true)); + IActionExecutor actions = new NoActionExecutor(); return new RascalParser().parse(Parser.START_MODULE, loc.getURI(), input, actions, new DefaultNodeFlattener<>(), new UPTRNodeFactory(true)); } } From 7220539e1f56465c5f7e0c1efa72148aade249bb Mon Sep 17 00:00:00 2001 From: "Jurgen J. Vinju" Date: Wed, 25 Sep 2024 14:54:17 +0200 Subject: [PATCH 5/8] better configuration --- .../org/rascalmpl/vscode/lsp/terminal/LSPTerminalREPL.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/rascal-lsp/src/main/java/org/rascalmpl/vscode/lsp/terminal/LSPTerminalREPL.java b/rascal-lsp/src/main/java/org/rascalmpl/vscode/lsp/terminal/LSPTerminalREPL.java index 9d5912e83..05a17fc91 100644 --- a/rascal-lsp/src/main/java/org/rascalmpl/vscode/lsp/terminal/LSPTerminalREPL.java +++ b/rascal-lsp/src/main/java/org/rascalmpl/vscode/lsp/terminal/LSPTerminalREPL.java @@ -37,6 +37,7 @@ import java.util.Set; import java.util.SortedSet; import java.util.concurrent.ConcurrentHashMap; +import java.util.jar.JarEntry; import java.util.jar.Manifest; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -60,6 +61,7 @@ import org.rascalmpl.uri.URIResolverRegistry; import org.rascalmpl.uri.URIUtil; import org.rascalmpl.uri.classloaders.SourceLocationClassLoader; +import org.rascalmpl.uri.jar.JarURIResolver; import org.rascalmpl.values.ValueFactoryFactory; import org.rascalmpl.vscode.lsp.dap.DebugSocketServer; import org.rascalmpl.vscode.lsp.uri.ProjectURIResolver; @@ -175,7 +177,7 @@ protected Evaluator constructEvaluator(InputStream input, OutputStream stdout, O var rascalLspLib = PathConfig.resolveProjectOnClasspath("rascal-lsp"); // the interpreter must find the Rascal sources of util::LanguageServer etc. - pcfg = pcfg.addSourceLoc(rascalLspLib); + pcfg = pcfg.addSourceLoc(JarURIResolver.jarify(rascalLspLib)); // the interpreter must load the Java parts for calling util::IDEServices and registerLanguage pcfg = pcfg.addLibLoc(rascalLspLib); From 65f8039b30dcaab4f4f53c714e64578a346bfe6f Mon Sep 17 00:00:00 2001 From: "Jurgen J. Vinju" Date: Wed, 25 Sep 2024 14:58:01 +0200 Subject: [PATCH 6/8] explain the path config situation better --- .../org/rascalmpl/vscode/lsp/terminal/LSPTerminalREPL.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rascal-lsp/src/main/java/org/rascalmpl/vscode/lsp/terminal/LSPTerminalREPL.java b/rascal-lsp/src/main/java/org/rascalmpl/vscode/lsp/terminal/LSPTerminalREPL.java index 05a17fc91..d7692b491 100644 --- a/rascal-lsp/src/main/java/org/rascalmpl/vscode/lsp/terminal/LSPTerminalREPL.java +++ b/rascal-lsp/src/main/java/org/rascalmpl/vscode/lsp/terminal/LSPTerminalREPL.java @@ -186,9 +186,9 @@ protected Evaluator constructEvaluator(InputStream input, OutputStream stdout, O out.println("Rascal Version: " + RascalManifest.getRascalVersionNumber()); out.println("Rascal-lsp Version: " + getRascalLspVersion()); - out.println("Source folders:"); + out.println("Rascal Module folders:"); pcfg.getSrcs().forEach((f) -> out.println(" ".repeat(4) + f)); - out.println("Library locations:"); + out.println("JVM Class loading path:"); pcfg.getLibs().forEach((l) -> out.println(" ".repeat(4) + l)); out.println("Target folder:"); out.println(" ".repeat(4) + pcfg.getBin()); From 432e5c74b12ab1c79410ff15a3a7a2df00d50a1c Mon Sep 17 00:00:00 2001 From: "Jurgen J. Vinju" Date: Wed, 25 Sep 2024 20:18:16 +0200 Subject: [PATCH 7/8] removed some dead code and improved labels --- .../rascalmpl/vscode/lsp/terminal/LSPTerminalREPL.java | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/rascal-lsp/src/main/java/org/rascalmpl/vscode/lsp/terminal/LSPTerminalREPL.java b/rascal-lsp/src/main/java/org/rascalmpl/vscode/lsp/terminal/LSPTerminalREPL.java index d7692b491..8897403ee 100644 --- a/rascal-lsp/src/main/java/org/rascalmpl/vscode/lsp/terminal/LSPTerminalREPL.java +++ b/rascal-lsp/src/main/java/org/rascalmpl/vscode/lsp/terminal/LSPTerminalREPL.java @@ -151,10 +151,6 @@ protected Evaluator constructEvaluator(InputStream input, OutputStream stdout, O URIResolverRegistry reg = URIResolverRegistry.getInstance(); ISourceLocation projectDir = ShellEvaluatorFactory.inferProjectRoot(new File(System.getProperty("user.dir"))); - String projectName = "unknown-project"; - if (projectDir != null) { - projectName = new RascalManifest().getProjectName(projectDir); - } reg.registerLogical(new ProjectURIResolver(services::resolveProjectLocation)); reg.registerLogical(new TargetURIResolver(services::resolveProjectLocation)); @@ -186,9 +182,9 @@ protected Evaluator constructEvaluator(InputStream input, OutputStream stdout, O out.println("Rascal Version: " + RascalManifest.getRascalVersionNumber()); out.println("Rascal-lsp Version: " + getRascalLspVersion()); - out.println("Rascal Module folders:"); + out.println("Rascal module folders:"); pcfg.getSrcs().forEach((f) -> out.println(" ".repeat(4) + f)); - out.println("JVM Class loading path:"); + out.println("JVM class loading paths:"); pcfg.getLibs().forEach((l) -> out.println(" ".repeat(4) + l)); out.println("Target folder:"); out.println(" ".repeat(4) + pcfg.getBin()); From b7c33ce34cc4dc9b25f4b522a5b664c50a417b7d Mon Sep 17 00:00:00 2001 From: "Jurgen J. Vinju" Date: Wed, 25 Sep 2024 20:39:01 +0200 Subject: [PATCH 8/8] reuse print of PathConfig --- .../vscode/lsp/terminal/LSPTerminalREPL.java | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/rascal-lsp/src/main/java/org/rascalmpl/vscode/lsp/terminal/LSPTerminalREPL.java b/rascal-lsp/src/main/java/org/rascalmpl/vscode/lsp/terminal/LSPTerminalREPL.java index 8897403ee..73c954bf3 100644 --- a/rascal-lsp/src/main/java/org/rascalmpl/vscode/lsp/terminal/LSPTerminalREPL.java +++ b/rascal-lsp/src/main/java/org/rascalmpl/vscode/lsp/terminal/LSPTerminalREPL.java @@ -37,7 +37,6 @@ import java.util.Set; import java.util.SortedSet; import java.util.concurrent.ConcurrentHashMap; -import java.util.jar.JarEntry; import java.util.jar.Manifest; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -70,7 +69,6 @@ import io.usethesource.vallang.ISourceLocation; import io.usethesource.vallang.IValue; import io.usethesource.vallang.IValueFactory; -import io.usethesource.vallang.io.StandardTextWriter; import org.rascalmpl.jline.TerminalFactory; import org.rascalmpl.jline.Terminal; @@ -179,16 +177,11 @@ protected Evaluator constructEvaluator(InputStream input, OutputStream stdout, O pcfg = pcfg.addLibLoc(rascalLspLib); var out = evaluator.getOutPrinter(); - - out.println("Rascal Version: " + RascalManifest.getRascalVersionNumber()); - out.println("Rascal-lsp Version: " + getRascalLspVersion()); - out.println("Rascal module folders:"); - pcfg.getSrcs().forEach((f) -> out.println(" ".repeat(4) + f)); - out.println("JVM class loading paths:"); - pcfg.getLibs().forEach((l) -> out.println(" ".repeat(4) + l)); - out.println("Target folder:"); - out.println(" ".repeat(4) + pcfg.getBin()); - out.flush(); + + out.println("Rascal " + RascalManifest.getRascalVersionNumber()); + out.println("Rascal-lsp " + getRascalLspVersion()); + + pcfg.printInterpreterConfigurationStatus(out); services.registerDiagnostics(pcfg.getMessages());