From 566349a2ff6cb907a39844309727dde081574154 Mon Sep 17 00:00:00 2001 From: paulklint Date: Tue, 10 Dec 2024 17:17:19 +0100 Subject: [PATCH 1/2] Added debug print. --- src/org/rascalmpl/library/util/Reflective.rsc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/org/rascalmpl/library/util/Reflective.rsc b/src/org/rascalmpl/library/util/Reflective.rsc index 9b3c693bc01..7982523ad7b 100644 --- a/src/org/rascalmpl/library/util/Reflective.rsc +++ b/src/org/rascalmpl/library/util/Reflective.rsc @@ -219,7 +219,7 @@ str getModuleName(loc moduleLoc, PathConfig pcfg){ if(lastName[0] == "$"){ candidateAsList = [*candidateAsList[..-1],lastName[1..]]; } - //println("cand: , modpath: "); + println("cand: , modpath: "); n = commonPrefix(reverse(candidateAsList), modulePathReversed); if(n > longestSuffix){ From 571dc3f01893aca1a0f5f68855574aeb1739e4a6 Mon Sep 17 00:00:00 2001 From: paulklint Date: Tue, 10 Dec 2024 20:36:55 +0100 Subject: [PATCH 2/2] Fixed getModuleName for library case --- src/org/rascalmpl/library/util/Reflective.rsc | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/org/rascalmpl/library/util/Reflective.rsc b/src/org/rascalmpl/library/util/Reflective.rsc index 7982523ad7b..a610850f975 100644 --- a/src/org/rascalmpl/library/util/Reflective.rsc +++ b/src/org/rascalmpl/library/util/Reflective.rsc @@ -195,7 +195,11 @@ str getModuleName(loc moduleLoc, PathConfig pcfg){ while(modulePathNoExt[0] == "/"){ modulePathNoExt = modulePathNoExt[1..]; } + modulePathAsList = split("/", modulePathNoExt); + if(modulePathAsList[0] == "rascal"){ + modulePathAsList = modulePathAsList[1..]; + } modulePathReversed = reverse(modulePathAsList); int longestSuffix = 0; @@ -215,11 +219,7 @@ str getModuleName(loc moduleLoc, PathConfig pcfg){ } candidateAsList = split("/", candidate); - lastName = candidateAsList[-1]; - if(lastName[0] == "$"){ - candidateAsList = [*candidateAsList[..-1],lastName[1..]]; - } - println("cand: , modpath: "); + // println("cand: , modpath: "); n = commonPrefix(reverse(candidateAsList), modulePathReversed); if(n > longestSuffix){ @@ -229,6 +229,10 @@ str getModuleName(loc moduleLoc, PathConfig pcfg){ } if(longestSuffix > 0){ + lastName = modulePathAsList[-1]; + if(lastName[0] == "$"){ + modulePathAsList = [*modulePathAsList[..-1],lastName[1..]]; + } return intercalate("::", modulePathAsList[size(modulePathAsList) - longestSuffix .. ]); } throw "No module name found for ;\nsrcs=;\nlibs=";