Skip to content

Commit

Permalink
Merge branch 'main' into json-lazy-parser-unparser
Browse files Browse the repository at this point in the history
  • Loading branch information
jurgenvinju committed Dec 11, 2024
2 parents 785a8b7 + 571dc3f commit 477708a
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/org/rascalmpl/library/util/Reflective.rsc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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: <candidateAsList>, modpath: <modulePathAsList>");
// println("cand: <candidateAsList>, modpath: <modulePathAsList>");
n = commonPrefix(reverse(candidateAsList), modulePathReversed);

if(n > longestSuffix){
Expand All @@ -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 <moduleLoc>;\nsrcs=<pcfg.srcs>;\nlibs=<pcfg.libs>";
Expand Down

0 comments on commit 477708a

Please sign in to comment.