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..cc144f001 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..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
@@ -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;
@@ -62,6 +60,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;
@@ -70,7 +69,8 @@
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;
/**
* This class runs a Rascal terminal REPL that
@@ -89,8 +89,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,15 +145,10 @@ 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")));
- String projectName = "unknown-project";
- if (projectDir != null) {
- projectName = new RascalManifest().getProjectName(projectDir);
- }
reg.registerLogical(new ProjectURIResolver(services::resolveProjectLocation));
reg.registerLogical(new TargetURIResolver(services::resolveProjectLocation));
@@ -160,19 +156,35 @@ 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();
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(JarURIResolver.jarify(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 " + RascalManifest.getRascalVersionNumber());
+ out.println("Rascal-lsp " + getRascalLspVersion());
+
+ pcfg.printInterpreterConfigurationStatus(out);
+
+ services.registerDiagnostics(pcfg.getMessages());
+
for (IValue srcPath : pcfg.getSrcs()) {
ISourceLocation path = (ISourceLocation)srcPath;
evaluator.addRascalSearchPath(path);
@@ -184,16 +196,14 @@ protected Evaluator constructEvaluator(InputStream input, OutputStream stdout, O
}
ClassLoader cl = new SourceLocationClassLoader(
- pcfg.getClassloaders()
- .append(URIUtil.correctLocation("lib", "rascal",""))
- .append(URIUtil.correctLocation("lib", "rascal-lsp",""))
- .append(URIUtil.correctLocation("target", projectName, "")),
+ pcfg.getLibsAndTarget(),
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/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));
}
}
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"