29
29
import org .rascalmpl .uri .jar .JarURIResolver ;
30
30
import org .rascalmpl .util .maven .Artifact ;
31
31
import org .rascalmpl .util .maven .ArtifactCoordinate ;
32
+ import org .rascalmpl .util .maven .MavenMessages ;
32
33
import org .rascalmpl .util .maven .MavenParser ;
33
34
import org .rascalmpl .util .maven .ModelResolutionError ;
34
35
import org .rascalmpl .util .maven .Scope ;
@@ -603,12 +604,13 @@ private static void addArtifactToPathConfig(Artifact art, ISourceLocation manife
603
604
ISourceLocation projectLoc = URIUtil .correctLocation ("project" , art .getCoordinate ().getArtifactId (), "" );
604
605
if (reg .exists (projectLoc )) {
605
606
if (mode == RascalConfigMode .INTERPRETER ) {
606
- messages .append (Messages .info ("Redirected: " + art .getCoordinate () + " to: " + projectLoc , getPomXmlLocation (manifestRoot )));
607
+ // Note that this is not the main project pom so art.getOrigin() should not be null
608
+ messages .append (MavenMessages .info ("Redirected: " + art .getCoordinate () + " to: " + projectLoc , art ));
607
609
}
608
610
addProjectAndItsDependencies (mode , srcs , libs , messages , projectLoc );
609
611
}
610
612
else {
611
- messages .append (Messages .error ("Declared dependency does not exist: " + art .getCoordinate (), getPomXmlLocation ( manifestRoot ) ));
613
+ messages .append (MavenMessages .error ("Declared dependency does not exist: " + art .getCoordinate (), art ));
612
614
}
613
615
return ;
614
616
}
@@ -625,7 +627,7 @@ private static void addArtifactToPathConfig(Artifact art, ISourceLocation manife
625
627
return ;
626
628
}
627
629
if (libProjectName .equals ("rascal-lsp" )) {
628
- checkLSPVersionsMatch (manifestRoot , messages , dep );
630
+ checkLSPVersionsMatch (manifestRoot , messages , dep , art );
629
631
// we'll be adding the rascal-lsp by hand later
630
632
// so we ignore the rascal-lsp dependency
631
633
return ;
@@ -636,7 +638,7 @@ private static void addArtifactToPathConfig(Artifact art, ISourceLocation manife
636
638
// The project we depend on is available in the current workspace.
637
639
// so we configure for using the current state of that project.
638
640
if (mode == RascalConfigMode .INTERPRETER ) {
639
- messages .append (Messages .info ("Redirected: " + art .getCoordinate () + " to: " + projectLoc , getPomXmlLocation ( manifestRoot ) ));
641
+ messages .append (MavenMessages .info ("Redirected: " + art .getCoordinate () + " to: " + projectLoc , art ));
640
642
}
641
643
addProjectAndItsDependencies (mode , srcs , libs , messages , projectLoc );
642
644
}
@@ -648,7 +650,7 @@ private static void addArtifactToPathConfig(Artifact art, ISourceLocation manife
648
650
}
649
651
}
650
652
} catch (URISyntaxException e ) {
651
- messages .append (Messages .error ("Could not convert " + art .getCoordinate () + " to a loc: " + e , manifestRoot ));
653
+ messages .append (MavenMessages .error ("Could not convert " + art .getCoordinate () + " to a loc: " + e , art ));
652
654
}
653
655
}
654
656
@@ -659,19 +661,19 @@ private static void addProjectAndItsDependencies(RascalConfigMode mode, IListWri
659
661
buildNormalProjectConfig (projectLoc , mode , childMavenClasspath , false , srcs , libs , messages );
660
662
}
661
663
662
- private static void checkLSPVersionsMatch (ISourceLocation manifestRoot , IListWriter messages , ISourceLocation dep ) throws IOException {
664
+ private static void checkLSPVersionsMatch (ISourceLocation manifestRoot , IListWriter messages , ISourceLocation jarLocation , Artifact artifact ) throws IOException {
663
665
// Rascal LSP is special because the VScode extension pre-loads it into the parametric DSL VM.
664
666
// If the version is different, then the debugger may point to the wrong code, and also the Rascal
665
667
// IDE features like "jump-to-definition" could be off.
666
668
try {
667
669
var loadedRascalLsp = resolveProjectOnClasspath ("rascal-lsp" );
668
670
var reg = URIResolverRegistry .getInstance ();
669
- try (InputStream in = reg .getInputStream (loadedRascalLsp ); InputStream in2 = reg .getInputStream (dep )) {
671
+ try (InputStream in = reg .getInputStream (loadedRascalLsp ); InputStream in2 = reg .getInputStream (jarLocation )) {
670
672
var version = new Manifest (in ).getMainAttributes ().getValue ("Specification-Version" );
671
673
var otherVersion = new Manifest (in2 ).getMainAttributes ().getValue ("Specification-Version" );
672
674
673
675
if (version != null && !version .equals (otherVersion )) {
674
- 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, for that reason we've replaced it with the effective one, please update your pom.xml." , getPomXmlLocation ( manifestRoot ) ));
676
+ messages .append (MavenMessages .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, for that reason we've replaced it with the effective one, please update your pom.xml." , artifact ));
675
677
}
676
678
}
677
679
}
0 commit comments