Skip to content

Commit

Permalink
added proper warning for conflicting rascal-lsp instances on the clas…
Browse files Browse the repository at this point in the history
…spath
  • Loading branch information
jurgenvinju committed Sep 16, 2024
1 parent ac8080f commit 11739c4
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/org/rascalmpl/library/util/PathConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.StringWriter;
import java.net.URISyntaxException;
Expand All @@ -15,6 +16,8 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.jar.Manifest;

import org.rascalmpl.interpreter.utils.RascalManifest;
import org.rascalmpl.library.Messages;
import org.rascalmpl.uri.URIResolverRegistry;
Expand Down Expand Up @@ -481,6 +484,28 @@ public static PathConfig fromSourceProjectRascalManifest(ISourceLocation manifes
rascalProject = dep;
}

// Rascal LSP is special because the VScode extension pre-loads it into the parametric DSL VM.
// If the version is different, then the debugger may point to the wrong code, and also the Rascal
// IDE features like "jump-to-definition" could be off.
if (libProjectName.equals("rascal-lsp")) {
try {
var loadedRascalLsp = resolveDependencyFromResourcesOnCurrentClasspath("rascal-lsp");

try (InputStream in = reg.getInputStream(loadedRascalLsp), InputStream in2 = reg.getInputStream(dep)) {
var version = new Manifest(in).getMainAttributes().getValue("Specification-Version");
var otherVersion = new Manifest(in2).getfMainAttributes().getValue("Specification-Version");

if (version.equals(otherVersion)) {
messages.append(Messages.warning("Pom.xml dependency on rascal-lsp has version " + otherVersion + " while the effective version in the VScode extension is " + version + ". This can have funny effects in the IDE while debugging or code browsing.", getPomXmlLocation(manifestRoot)));
}
}
}
catch (FileNotFoundException e) {
// this is ok. there is not a duplicate presence of rascal-lsp.
}

}

if (libProjectName != null) {
if (reg.exists(projectLoc) && dep != rascalProject) {
// The project we depend on is available in the current workspace.
Expand Down

0 comments on commit 11739c4

Please sign in to comment.