diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs index d556b15bdc7..bfb64b01411 100644 --- a/.git-blame-ignore-revs +++ b/.git-blame-ignore-revs @@ -14,3 +14,6 @@ a004c2604cef592975f60a572c4a03491b2f7971 # Revert and re-application of a merge commit 3d5369b35a00bddc085d722010baf329580b1c68 b277ae88b653f039b576717f8d9ecd56e5dbd2fe + +# Reverts of commits +9775112e739b03fb292f01d5303d50031e267322 diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index fdaa54a44ec..ec8897de12d 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -8,7 +8,8 @@ on: pull_request: branches: - main - - 'feat/*' + - 'feat/**' + - 'feature/**' env: MAVEN_OPTS: "-Xmx4G -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn -Dorg.slf4j.simpleLogger.showDateTime=true -Djava.awt.headless=true" IS_OWN_PR: "${{ secrets.MAVEN_MIRROR_URL }}" diff --git a/pom.xml b/pom.xml index 82073b97177..b877b356845 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ org.rascalmpl rascal - 0.43.0-RC13-SNAPSHOT + 0.43.1-RC13-SNAPSHOT jar @@ -201,7 +201,6 @@ ${project.basedir}/src/org/rascalmpl/library - |std:///| diff --git a/src/org/rascalmpl/compiler/CheckTestSources.rsc b/src/org/rascalmpl/compiler/CheckTestSources.rsc index 9fcd3de8496..34fe25dc206 100644 --- a/src/org/rascalmpl/compiler/CheckTestSources.rsc +++ b/src/org/rascalmpl/compiler/CheckTestSources.rsc @@ -66,7 +66,7 @@ void checkTestSources(list[str] cmdLineArgs) { if("all" in cmdLineArgs){ modulesToCheck = getRascalModules(REPO + "rascal/src/org/rascalmpl/library", pcfg); } else { - testFolders = [ //|std:///lang/rascal/tests|, + testFolders = [ //|project://rascal/src/org/rascalmpl/library/lang/rascal/tests|, //REPO + "/rascal-core/lang/rascalcore/check::tests", REPO + "/typepal/src/" ]; diff --git a/src/org/rascalmpl/compiler/CompileTestSources.rsc b/src/org/rascalmpl/compiler/CompileTestSources.rsc index 5ee3f9e6f05..f9ce0e4b87a 100644 --- a/src/org/rascalmpl/compiler/CompileTestSources.rsc +++ b/src/org/rascalmpl/compiler/CompileTestSources.rsc @@ -145,7 +145,7 @@ void compileTestSources(PathConfig pcfg) { // total += d; //} - testFolder = |std:///lang/rascal/|; + testFolder = |project://rascal/src/org/rascalmpl/library/lang/rascal/|; testModules = [ replaceAll(file[extension=""].path[1..], "/", "::") | loc file <- find(testFolder, "rsc") // all Rascal source files diff --git a/src/org/rascalmpl/compiler/lang/rascalcore/check/TestConfigs.rsc b/src/org/rascalmpl/compiler/lang/rascalcore/check/TestConfigs.rsc index 9e28048727f..b712c5e0b92 100644 --- a/src/org/rascalmpl/compiler/lang/rascalcore/check/TestConfigs.rsc +++ b/src/org/rascalmpl/compiler/lang/rascalcore/check/TestConfigs.rsc @@ -75,14 +75,14 @@ public loc testModulesRoot = testRoot + "src"; private int npc = 0; @synopsis{PathConfig for testing generated modules in |memory://test-modules/| in memory file system, not depending on any outside libraries.} @description{ -* gets source files exclusively from |memory://test-modules/| and |std:///| (for library code) +* gets source files exclusively from |memory://test-modules/| and |project://rascal/src/org/rascalmpl/library/| (for library code) * generates bin files in the in-memory file system } public PathConfig getDefaultTestingPathConfig() { npc += 1; snpc = ""; return pathConfig( - srcs = [ testModulesRoot, |std:///| ], + srcs = [ testModulesRoot, |project://rascal/src/org/rascalmpl/library/| ], bin = testRoot + "rascal-tests-bin-", generatedSources = testRoot + "generated-test-sources-", generatedResources = testRoot + "generated-test-resources-", diff --git a/src/org/rascalmpl/compiler/lang/rascalcore/compile/AREADME.txt b/src/org/rascalmpl/compiler/lang/rascalcore/compile/AREADME.txt index 4c9f817a307..d6f82fcaf41 100644 --- a/src/org/rascalmpl/compiler/lang/rascalcore/compile/AREADME.txt +++ b/src/org/rascalmpl/compiler/lang/rascalcore/compile/AREADME.txt @@ -71,13 +71,13 @@ config void config( // Inspect type checker configuration file Query select = none()) // Query to define what to show Examples: -compile(|std:///experiments/Compiler/Examples/Fac.rsc|); +compile(|project://rascal/src/org/rascalmpl/library/experiments/Compiler/Examples/Fac.rsc|); -execute(|std:///experiments/Compiler/Examples/Fac.rsc|, []); -execute(|std:///experiments/Compiler/Examples/Fac.rsc|, [], recompile=true); -execute(|std:///experiments/Compiler/Examples/Fac.rsc|, [], profile=true); +execute(|project://rascal/src/org/rascalmpl/library/experiments/Compiler/Examples/Fac.rsc|, []); +execute(|project://rascal/src/org/rascalmpl/library/experiments/Compiler/Examples/Fac.rsc|, [], recompile=true); +execute(|project://rascal/src/org/rascalmpl/library/experiments/Compiler/Examples/Fac.rsc|, [], profile=true); -inspect(|std:///experiments/Compiler/Examples/Fac.rsc|) +inspect(|project://rascal/src/org/rascalmpl/library/experiments/Compiler/Examples/Fac.rsc|) Directory structure: diff --git a/src/org/rascalmpl/compiler/lang/rascalcore/compile/Examples/RascalExtraction.rsc b/src/org/rascalmpl/compiler/lang/rascalcore/compile/Examples/RascalExtraction.rsc index 53412d70803..0ca27c7d5db 100644 --- a/src/org/rascalmpl/compiler/lang/rascalcore/compile/Examples/RascalExtraction.rsc +++ b/src/org/rascalmpl/compiler/lang/rascalcore/compile/Examples/RascalExtraction.rsc @@ -37,7 +37,7 @@ import util::Reflective; value main() = compareAll(); value compareAll() { - moduleLoc = |std:///experiments/Compiler/Rascal2muRascal/RascalExpression.rsc|; + moduleLoc = |project://rascal/src/org/rascalmpl/library/experiments/Compiler/Rascal2muRascal/RascalExpression.rsc|; //moduleLoc = |project://rascal/src/org/rascalmpl/library/experiments/Compiler/Examples/Tst3.rsc|; m = parse(#start[Module], moduleLoc).top; t = cpuTime(); diff --git a/src/org/rascalmpl/compiler/lang/rascalcore/compile/Examples/RascalMetrics.rsc b/src/org/rascalmpl/compiler/lang/rascalcore/compile/Examples/RascalMetrics.rsc index 1f3355de8c5..004b345d34b 100644 --- a/src/org/rascalmpl/compiler/lang/rascalcore/compile/Examples/RascalMetrics.rsc +++ b/src/org/rascalmpl/compiler/lang/rascalcore/compile/Examples/RascalMetrics.rsc @@ -45,13 +45,13 @@ value main() value measure(){ - //moduleLoc = |std:///lang/rascal/syntax/Rascal.rsc|; - moduleLoc = |std:///experiments/Compiler/RVM/AST.rsc|; - //moduleLoc = |std:///experiments/Compiler/RVM/Syntax.rsc|; - //moduleLoc = |std:///experiments/Compiler/muRascal/Syntax.rsc|; - //moduleLoc = |std:///experiments/Compiler/muRascal/AST.rsc|; - //moduleLoc = |std:///demo/lang/Pico/Syntax.rsc|; - //moduleLoc = |std:///demo/lang/Exp/Concrete/NoLayout/Syntax.rsc|; + //moduleLoc = |project://rascal/src/org/rascalmpl/library/lang/rascal/syntax/Rascal.rsc|; + moduleLoc = |project://rascal/src/org/rascalmpl/library/experiments/Compiler/RVM/AST.rsc|; + //moduleLoc = |project://rascal/src/org/rascalmpl/library/experiments/Compiler/RVM/Syntax.rsc|; + //moduleLoc = |project://rascal/src/org/rascalmpl/library/experiments/Compiler/muRascal/Syntax.rsc|; + //moduleLoc = |project://rascal/src/org/rascalmpl/library/experiments/Compiler/muRascal/AST.rsc|; + //moduleLoc = |project://rascal/src/org/rascalmpl/library/demo/lang/Pico/Syntax.rsc|; + //moduleLoc = |project://rascal/src/org/rascalmpl/library/demo/lang/Exp/Concrete/NoLayout/Syntax.rsc|; m = parse(#start[Module], moduleLoc).top; stats = (); nonterm = {}; diff --git a/src/org/rascalmpl/interpreter/load/IRascalSearchPathContributor.java b/src/org/rascalmpl/interpreter/load/IRascalSearchPathContributor.java index 95d26ee9253..1b3de4ef51d 100644 --- a/src/org/rascalmpl/interpreter/load/IRascalSearchPathContributor.java +++ b/src/org/rascalmpl/interpreter/load/IRascalSearchPathContributor.java @@ -11,11 +11,11 @@ *******************************************************************************/ package org.rascalmpl.interpreter.load; -import java.util.List; +import java.util.Queue; import io.usethesource.vallang.ISourceLocation; public interface IRascalSearchPathContributor { - void contributePaths(List path); + void contributePaths(Queue path); String getName(); } diff --git a/src/org/rascalmpl/interpreter/load/RascalSearchPath.java b/src/org/rascalmpl/interpreter/load/RascalSearchPath.java index 36efd08a475..c4da4a79ddb 100644 --- a/src/org/rascalmpl/interpreter/load/RascalSearchPath.java +++ b/src/org/rascalmpl/interpreter/load/RascalSearchPath.java @@ -17,13 +17,16 @@ import java.io.IOException; import java.net.URISyntaxException; import java.util.ArrayList; +import java.util.Collection; import java.util.Collections; import java.util.LinkedList; import java.util.List; +import java.util.Queue; import org.rascalmpl.interpreter.Configuration; import org.rascalmpl.uri.URIResolverRegistry; import org.rascalmpl.uri.URIUtil; + import io.usethesource.vallang.ISourceLocation; /** @@ -41,7 +44,8 @@ public RascalSearchPath() { } public void addPathContributor(IRascalSearchPathContributor contrib) { - if(!contributors.contains(contrib)){ + if (!contributors.contains(contrib)) { + // Later contributors take precedence over earlier ones. Insert at the front. contributors.add(0, contrib); } } @@ -103,12 +107,12 @@ public ISourceLocation getRootForModule(String module) { } } - public List collect() { - List paths = new LinkedList(); + public Collection collect() { + Queue paths = new LinkedList(); for (IRascalSearchPathContributor c : contributors) { c.contributePaths(paths); } - + return paths; } diff --git a/src/org/rascalmpl/interpreter/load/SourceLocationListContributor.java b/src/org/rascalmpl/interpreter/load/SourceLocationListContributor.java index 2702eb399a3..66e2214d066 100644 --- a/src/org/rascalmpl/interpreter/load/SourceLocationListContributor.java +++ b/src/org/rascalmpl/interpreter/load/SourceLocationListContributor.java @@ -1,6 +1,6 @@ package org.rascalmpl.interpreter.load; -import java.util.List; +import java.util.Queue; import io.usethesource.vallang.IList; import io.usethesource.vallang.ISourceLocation; @@ -18,9 +18,9 @@ public SourceLocationListContributor(String label, IList sourceLocations) { } @Override - public void contributePaths(List path) { + public void contributePaths(Queue path) { for (IValue elem : locs) { - path.add(((ISourceLocation) elem)); + path.add((ISourceLocation) elem); } } diff --git a/src/org/rascalmpl/interpreter/load/StandardLibraryContributor.java b/src/org/rascalmpl/interpreter/load/StandardLibraryContributor.java deleted file mode 100644 index 5b48cda82b0..00000000000 --- a/src/org/rascalmpl/interpreter/load/StandardLibraryContributor.java +++ /dev/null @@ -1,54 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011-2013 CWI - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - - * * Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI - * * Atze van der Ploeg - A.J.van.der.Ploeg@cwi.nl - CWI - * * Davy Landman - Davy.Landman@cwi.nl -*******************************************************************************/ -package org.rascalmpl.interpreter.load; - -import java.util.List; - -import org.rascalmpl.uri.URIUtil; - -import io.usethesource.vallang.ISourceLocation; - - -public class StandardLibraryContributor implements - IRascalSearchPathContributor { - - private StandardLibraryContributor() { } - - private static class InstanceHolder { - public static StandardLibraryContributor sInstance = new StandardLibraryContributor(); - } - - @Override - public String getName() { - return "std"; - } - - public static StandardLibraryContributor getInstance() { - return InstanceHolder.sInstance; - } - - public void contributePaths(List l) { - l.add(URIUtil.rootLocation("std")); - } - - @Override - public String toString() { - return "|std:///|"; - } - - @Override - public boolean equals(Object obj) { - return obj == this; - } -} diff --git a/src/org/rascalmpl/interpreter/load/URIContributor.java b/src/org/rascalmpl/interpreter/load/URIContributor.java index 48c82279dce..d1b740cf1c9 100644 --- a/src/org/rascalmpl/interpreter/load/URIContributor.java +++ b/src/org/rascalmpl/interpreter/load/URIContributor.java @@ -12,7 +12,7 @@ *******************************************************************************/ package org.rascalmpl.interpreter.load; -import java.util.List; +import java.util.Queue; import io.usethesource.vallang.ISourceLocation; @@ -30,8 +30,8 @@ public String getName() { } @Override - public void contributePaths(List path) { - path.add(0, uri); + public void contributePaths(Queue path) { + path.add(uri); } @Override diff --git a/src/org/rascalmpl/library/IO.rsc b/src/org/rascalmpl/library/IO.rsc index 3725a6a2e05..a3535ef9bbf 100644 --- a/src/org/rascalmpl/library/IO.rsc +++ b/src/org/rascalmpl/library/IO.rsc @@ -204,7 +204,7 @@ import IO; Does the library file `IO.rsc` exist? ```rascal-shell,continue -exists(|std:///IO.rsc|); +exists(|project://rascal/src/org/rascalmpl/library/IO.rsc|); ``` } @javaClass{org.rascalmpl.library.Prelude} @@ -218,7 +218,7 @@ import IO; ``` Find the file `IO.rsc` in the standard library: ```rascal-shell,continue -find("IO.rsc", [|std:///|]); +find("IO.rsc", [|project://rascal/src/org/rascalmpl/library/|]); ``` } public loc find(str name, list[loc] path) throws PathNotFound { @@ -367,7 +367,7 @@ import IO; ``` Determine the last modification date of the Rascal standard library: ```rascal-shell,continue -lastModified(|std:///IO.rsc|); +lastModified(|project://rascal/src/org/rascalmpl/library/IO.rsc|); ``` } @javaClass{org.rascalmpl.library.Prelude} @@ -384,7 +384,7 @@ import IO; ``` Determine the last modification date of the Rascal standard library: ```rascal-shell,continue -created(|std:///IO.rsc|); +created(|project://rascal/src/org/rascalmpl/library/IO.rsc|); ``` } @javaClass{org.rascalmpl.library.Prelude} @@ -412,7 +412,7 @@ import IO; ``` List all entries in the standard library: ```rascal-shell,continue -listEntries(|std:///|); +listEntries(|project://rascal/src/org/rascalmpl/library/|); ``` } @javaClass{org.rascalmpl.library.Prelude} diff --git a/src/org/rascalmpl/library/index.md b/src/org/rascalmpl/library/index.md index b8d56ac67d2..0533fc75eb5 100644 --- a/src/org/rascalmpl/library/index.md +++ b/src/org/rascalmpl/library/index.md @@ -21,11 +21,11 @@ println("Hello Rascal!"); The ((Library:module:IO)) module is otherwise most commonly used, because it contains ((println)). -The standard library has its own location scheme `std:///` which can be used to explore +The standard library has its own location scheme `project://rascal/src/org/rascalmpl/library/` which can be used to explore its folder structure on the REPL. Note that source locations have auto-complete for the path component. ```rascal-shell -|std:///|.ls +|project://rascal/src/org/rascalmpl/library/|.ls ``` These are the entry points to the entire library: diff --git a/src/org/rascalmpl/library/lang/rascal/grammar/tests/Compare.rsc b/src/org/rascalmpl/library/lang/rascal/grammar/tests/Compare.rsc index 72be006293a..5f5faa31146 100644 --- a/src/org/rascalmpl/library/lang/rascal/grammar/tests/Compare.rsc +++ b/src/org/rascalmpl/library/lang/rascal/grammar/tests/Compare.rsc @@ -8,8 +8,8 @@ import Set; value main() = compare3(); value compare1() { - INT = split("\n", readFile(|std:///lang/rascal/grammar/tests/generated_parsers/CParserINT.java|)); - COMP = split("\n", readFile(|std://lang/rascal/grammar/tests/generated_parsers/CParserCOMP.java|)); + INT = split("\n", readFile(|project://rascal/src/org/rascalmpl/library/lang/rascal/grammar/tests/generated_parsers/CParserINT.java|)); + COMP = split("\n", readFile(|project://rascal/src/org/rascalmpl/library/lang/rascal/grammar/tests/generated_parsers/CParserCOMP.java|)); INTSET = toSet(INT); COMPSET = toSet(COMP); diff --git a/src/org/rascalmpl/library/lang/rascal/grammar/tests/ParserGeneratorTests.rsc b/src/org/rascalmpl/library/lang/rascal/grammar/tests/ParserGeneratorTests.rsc index 1723c7fd455..9d68ff3aa19 100644 --- a/src/org/rascalmpl/library/lang/rascal/grammar/tests/ParserGeneratorTests.rsc +++ b/src/org/rascalmpl/library/lang/rascal/grammar/tests/ParserGeneratorTests.rsc @@ -307,16 +307,16 @@ bool sameLines(str s1, str s2) = size(removeEmptyLines(s1) - removeEmptyLines(s2 test bool tstNewGenerateGEMPTY() = sameLines(newGenerate("org.rascalmpl.library.lang.rascal.grammar.tests.generated_parsers", "GEMPTYParser", GEMPTY), - readFile(|std:///lang/rascal/grammar/tests/generated_parsers/GEMPTYParser.java.gz|)); + readFile(|project://rascal/src/org/rascalmpl/library/lang/rascal/grammar/tests/generated_parsers/GEMPTYParser.java.gz|)); test bool tstNewGenerateG0() = sameLines(newGenerate("org.rascalmpl.library.lang.rascal.grammar.tests.generated_parsers", "G0Parser", G0), - readFile(|std:///lang/rascal/grammar/tests/generated_parsers/G0Parser.java.gz|)); + readFile(|project://rascal/src/org/rascalmpl/library/lang/rascal/grammar/tests/generated_parsers/G0Parser.java.gz|)); test bool tstNewGenerateGEXP() = sameLines(newGenerate("org.rascalmpl.library.lang.rascal.grammar.tests.generated_parsers", "GEXPParser", GEXP), - readFile(|std:///lang/rascal/grammar/tests/generated_parsers/GEXPParser.java.gz|)); + readFile(|project://rascal/src/org/rascalmpl/library/lang/rascal/grammar/tests/generated_parsers/GEXPParser.java.gz|)); test bool tstNewGenerateGEXPPRIO() = sameLines(newGenerate("org.rascalmpl.library.lang.rascal.grammar.tests.generated_parsers", "GEXPPRIOParser", GEXPPRIO), - readFile(|std:///lang/rascal/grammar/tests/generated_parsers/GEXPPRIOParser.java.gz|)); + readFile(|project://rascal/src/org/rascalmpl/library/lang/rascal/grammar/tests/generated_parsers/GEXPPRIOParser.java.gz|)); diff --git a/src/org/rascalmpl/library/lang/rascal/syntax/tests/ParsingRegressionTests.rsc b/src/org/rascalmpl/library/lang/rascal/syntax/tests/ParsingRegressionTests.rsc index 20de62fb49c..1f4cf9d2df5 100644 --- a/src/org/rascalmpl/library/lang/rascal/syntax/tests/ParsingRegressionTests.rsc +++ b/src/org/rascalmpl/library/lang/rascal/syntax/tests/ParsingRegressionTests.rsc @@ -40,7 +40,7 @@ public bool testModules(list[loc] files, list[loc] _) { } -public test bool StandardLibrary() = testModules([f | /file(f) <- crawl(|std:///|), f.extension == "rsc", /experiments/ !:= f.path], []); +public test bool StandardLibrary() = testModules([f | /file(f) <- crawl(|project://rascal/src/org/rascalmpl/library/|), f.extension == "rsc", /experiments/ !:= f.path], []); public test bool testTutor() = testModules([f | /file(f) <- crawl(|tutor:///|), f.extension == "rsc"], [|tutor:///|]); diff --git a/src/org/rascalmpl/library/lang/rascal/tests/basic/IsDefined.rsc b/src/org/rascalmpl/library/lang/rascal/tests/basic/IsDefined.rsc index 178a39c03e3..cf39d92b79b 100644 --- a/src/org/rascalmpl/library/lang/rascal/tests/basic/IsDefined.rsc +++ b/src/org/rascalmpl/library/lang/rascal/tests/basic/IsDefined.rsc @@ -19,8 +19,8 @@ test bool isDefinedLoc1() = |project://x/y.txt|(5,4,<1,5>,<1,9>).begin?; test bool isDefinedLoc2() = |project://x/y.txt|(5,4,<1,5>,<1,9>).end?; test bool isDefinedLoc3() = !(|project://x/y.txt|(5,4,<1,5>,<1,9>).host?); -test bool isDefinedLoc4() = !(|std:///List.rsc|.ls?); -test bool isDefinedLoc5() = |std:///util|.ls?; +test bool isDefinedLoc4() = !(|project://rascal/src/org/rascalmpl/library/List.rsc|.ls?); +test bool isDefinedLoc5() = |project://rascal/src/org/rascalmpl/library/util|.ls?; // Lists diff --git a/src/org/rascalmpl/library/lang/rascal/tests/concrete/ModulesWithStoredParsers.rsc b/src/org/rascalmpl/library/lang/rascal/tests/concrete/ModulesWithStoredParsers.rsc index b7545bf768b..a415fae7d3b 100644 --- a/src/org/rascalmpl/library/lang/rascal/tests/concrete/ModulesWithStoredParsers.rsc +++ b/src/org/rascalmpl/library/lang/rascal/tests/concrete/ModulesWithStoredParsers.rsc @@ -29,7 +29,7 @@ PathConfig getTestPathConfig(loc root) { pcfg = getProjectPathConfig(root); pcfg.bin = root + "target/classes"; // remove std to avoid generating parsers for all modules in the library that contain syntax definitions - pcfg.srcs -= [|std:///|]; + pcfg.srcs -= [|project://rascal/src/org/rascalmpl/library/|]; return pcfg; } diff --git a/src/org/rascalmpl/library/lang/rascal/tests/concrete/recovery/ErrorRecoveryBenchmark.rsc b/src/org/rascalmpl/library/lang/rascal/tests/concrete/recovery/ErrorRecoveryBenchmark.rsc index e63564a78b6..b846431715e 100644 --- a/src/org/rascalmpl/library/lang/rascal/tests/concrete/recovery/ErrorRecoveryBenchmark.rsc +++ b/src/org/rascalmpl/library/lang/rascal/tests/concrete/recovery/ErrorRecoveryBenchmark.rsc @@ -23,15 +23,15 @@ void runTestJson() { testRecoveryJson(); } void runTestPico() { testRecoveryPico(); } void runTestRascal() { testRecoveryRascal(); } -FileStats testRecoveryC() = testErrorRecovery(|std:///lang/c90/syntax/C.rsc|, "TranslationUnit", |std:///lang/c90/examples/hello-world.c|); -FileStats testRecoveryDiff() = testErrorRecovery(|std:///lang/diff/unified/UnifiedDiff.rsc|, "DiffFile", |std:///lang/diff/unified/examples/example.diff|); -FileStats testRecoveryDot() = testErrorRecovery(|std:///lang/dot/syntax/Dot.rsc|, "DOT", |std:///lang/dot/examples/parser-state.dot|); -FileStats testRecoveryJava() = testErrorRecovery(|std:///lang/java/syntax/Java15.rsc|, "CompilationUnit", zippedFile("m3/snakes-and-ladders-project-source.zip", "src/snakes/LastSquare.java")); -FileStats testRecoveryJson() = testErrorRecovery(|std:///lang/json/syntax/JSON.rsc|, "JSONText", |std:///lang/json/examples/ex01.json|); -FileStats testRecoveryPico() = testErrorRecovery(|std:///lang/pico/syntax/Main.rsc|, "Program", |std:///lang/pico/examples/fac.pico|); -FileStats testRecoveryRascal() = testErrorRecovery(|std:///lang/rascal/syntax/Rascal.rsc|, "Module", |std:///lang/rascal/vis/ImportGraph.rsc|); +FileStats testRecoveryC() = testErrorRecovery(|project://rascal/src/org/rascalmpl/library/lang/c90/syntax/C.rsc|, "TranslationUnit", |project://rascal/src/org/rascalmpl/library/lang/c90/examples/hello-world.c|); +FileStats testRecoveryDiff() = testErrorRecovery(|project://rascal/src/org/rascalmpl/library/lang/diff/unified/UnifiedDiff.rsc|, "DiffFile", |project://rascal/src/org/rascalmpl/library/lang/diff/unified/examples/example.diff|); +FileStats testRecoveryDot() = testErrorRecovery(|project://rascal/src/org/rascalmpl/library/lang/dot/syntax/Dot.rsc|, "DOT", |project://rascal/src/org/rascalmpl/library/lang/dot/examples/parser-state.dot|); +FileStats testRecoveryJava() = testErrorRecovery(|project://rascal/src/org/rascalmpl/library/lang/java/syntax/Java15.rsc|, "CompilationUnit", zippedFile("m3/snakes-and-ladders-project-source.zip", "src/snakes/LastSquare.java")); +FileStats testRecoveryJson() = testErrorRecovery(|project://rascal/src/org/rascalmpl/library/lang/json/syntax/JSON.rsc|, "JSONText", |project://rascal/src/org/rascalmpl/library/lang/json/examples/ex01.json|); +FileStats testRecoveryPico() = testErrorRecovery(|project://rascal/src/org/rascalmpl/library/lang/pico/syntax/Main.rsc|, "Program", |project://rascal/src/org/rascalmpl/library/lang/pico/examples/fac.pico|); +FileStats testRecoveryRascal() = testErrorRecovery(|project://rascal/src/org/rascalmpl/library/lang/rascal/syntax/Rascal.rsc|, "Module", |project://rascal/src/org/rascalmpl/library/lang/rascal/vis/ImportGraph.rsc|); -FileStats testMemoBug() = testErrorRecovery(|std:///lang/rascal/syntax/Rascal.rsc|, "Module", |std:///lang/rascal/tests/concrete/PostParseFilter.rsc|); +FileStats testMemoBug() = testErrorRecovery(|project://rascal/src/org/rascalmpl/library/lang/rascal/syntax/Rascal.rsc|, "Module", |project://rascal/src/org/rascalmpl/library/lang/rascal/tests/concrete/PostParseFilter.rsc|); void runLanguageTests() { testRecoveryC(); @@ -50,5 +50,5 @@ int main(list[str] args) { return 0; } -int rascalSmokeTest() = main(["source-loc=|std:///|", "max-amb-depth=2", "max-files=3", "max-file-size=500", "sample-window=3", "random-seed=1", "count-nodes=true"]); -int rascalStandardTest() = main(["source-loc=|std:///|", "max-files=1000", "max-file-size=5120"]); \ No newline at end of file +int rascalSmokeTest() = main(["source-loc=|project://rascal/src/org/rascalmpl/library/|", "max-amb-depth=2", "max-files=3", "max-file-size=500", "sample-window=3", "random-seed=1", "count-nodes=true"]); +int rascalStandardTest() = main(["source-loc=|project://rascal/src/org/rascalmpl/library/|", "max-files=1000", "max-file-size=5120"]); \ No newline at end of file diff --git a/src/org/rascalmpl/library/lang/rascal/tests/concrete/recovery/ParseBenchmark.rsc b/src/org/rascalmpl/library/lang/rascal/tests/concrete/recovery/ParseBenchmark.rsc index 9795414b8d0..e7bb923bebe 100644 --- a/src/org/rascalmpl/library/lang/rascal/tests/concrete/recovery/ParseBenchmark.rsc +++ b/src/org/rascalmpl/library/lang/rascal/tests/concrete/recovery/ParseBenchmark.rsc @@ -22,7 +22,7 @@ import lang::rascal::\syntax::Rascal; import lang::rascal::grammar::definition::Modules; public data ParseBenchmarkConfig = parseBenchmarkConfig( - loc syntaxFile = |std:///lang/rascal/syntax/Rascal.rsc|, + loc syntaxFile = |project://rascal/src/org/rascalmpl/library/lang/rascal/syntax/Rascal.rsc|, str topSort = "Module", str extension = ".rsc", loc files = |unknown:///|, @@ -133,4 +133,4 @@ int main(list[str] args) { return 0; } -public int benchmarkRascal() = main(["files=|std:///|"]); +public int benchmarkRascal() = main(["files=|project://rascal/src/org/rascalmpl/library/|"]); diff --git a/src/org/rascalmpl/library/lang/rascal/tests/concrete/recovery/RecoveryTestSupport.rsc b/src/org/rascalmpl/library/lang/rascal/tests/concrete/recovery/RecoveryTestSupport.rsc index 1a001ccab5a..5923dbe1f62 100644 --- a/src/org/rascalmpl/library/lang/rascal/tests/concrete/recovery/RecoveryTestSupport.rsc +++ b/src/org/rascalmpl/library/lang/rascal/tests/concrete/recovery/RecoveryTestSupport.rsc @@ -716,7 +716,7 @@ RecoveryTestConfig createRecoveryTestConfig(list[str] args) { private RecoveryTestConfig createSyntaxConfig(str spec) { println("Determining test config based on syntax spec: "); switch (spec) { - case "rascal": return recoveryTestConfig(syntaxFile=|std:///lang/rascal/syntax/Rascal.rsc|, topSort="Module", ext=".rsc"); + case "rascal": return recoveryTestConfig(syntaxFile=|project://rascal/src/org/rascalmpl/library/lang/rascal/syntax/Rascal.rsc|, topSort="Module", ext=".rsc"); case "java18": return recoveryTestConfig(syntaxFile=|cwd:///src/lang/java/syntax/Java18.rsc|, topSort="CompilationUnit", ext=".java"); case "java15": return recoveryTestConfig(syntaxFile=|cwd:///src/lang/java/syntax/Java15.rsc|, topSort="CompilationUnit", ext=".java"); case "cobol": return recoveryTestConfig(syntaxModule="lang::vscobolii::Main", topSort="VSCobolII", ext=".CBL"); diff --git a/src/org/rascalmpl/library/lang/rascal/tests/concrete/recovery/bugs/DataTypeSlow.rsc b/src/org/rascalmpl/library/lang/rascal/tests/concrete/recovery/bugs/DataTypeSlow.rsc index b4e0e149937..5b1bf48a325 100644 --- a/src/org/rascalmpl/library/lang/rascal/tests/concrete/recovery/bugs/DataTypeSlow.rsc +++ b/src/org/rascalmpl/library/lang/rascal/tests/concrete/recovery/bugs/DataTypeSlow.rsc @@ -11,7 +11,7 @@ import util::Benchmark; bool testDataType() { normalParser = parser(#start[Module], allowRecovery=false); recoveryParser = parser(#start[Module], allowRecovery=true, maxAmbDepth=1000); - loc source = |std:///lang/rascal/tests/functionality/DataType.rsc?deletedUntilEol=253:8344:8395|; + loc source = |project://rascal/src/org/rascalmpl/library/lang/rascal/tests/functionality/DataType.rsc?deletedUntilEol=253:8344:8395|; str input = getTestInput(source); //println("input: "); diff --git a/src/org/rascalmpl/library/lang/rascal/tests/concrete/recovery/bugs/FCASlow.rsc b/src/org/rascalmpl/library/lang/rascal/tests/concrete/recovery/bugs/FCASlow.rsc index d5cbceabf09..497a22d834b 100644 --- a/src/org/rascalmpl/library/lang/rascal/tests/concrete/recovery/bugs/FCASlow.rsc +++ b/src/org/rascalmpl/library/lang/rascal/tests/concrete/recovery/bugs/FCASlow.rsc @@ -12,7 +12,7 @@ This tests the slowest error recovery in all tests < 10kb */ bool testFCA() { recoveryParser = parser(#start[Module], allowRecovery=true, allowAmbiguity=true, maxAmbDepth=1000); - loc source = |std:///analysis/formalconcepts/FCA.rsc?deletedUntilEol=54:2242:2261|; + loc source = |project://rascal/src/org/rascalmpl/library/analysis/formalconcepts/FCA.rsc?deletedUntilEol=54:2242:2261|; str input = getTestInput(source); //println("input: "); Tree result = recoveryParser(input, source); diff --git a/src/org/rascalmpl/library/lang/rascal/tests/concrete/recovery/bugs/FlowGraphOutOfMemoryBug.rsc b/src/org/rascalmpl/library/lang/rascal/tests/concrete/recovery/bugs/FlowGraphOutOfMemoryBug.rsc index 80814fd1472..af2543cea42 100644 --- a/src/org/rascalmpl/library/lang/rascal/tests/concrete/recovery/bugs/FlowGraphOutOfMemoryBug.rsc +++ b/src/org/rascalmpl/library/lang/rascal/tests/concrete/recovery/bugs/FlowGraphOutOfMemoryBug.rsc @@ -11,7 +11,7 @@ import String; test bool testFlowGraphBug() { standardParser = parser(#start[Module], allowRecovery=false, allowAmbiguity=true); recoveryParser = parser(#start[Module], allowRecovery=true, allowAmbiguity=true); - loc source = |std:///analysis/m3/FlowGraph.rsc|; + loc source = |project://rascal/src/org/rascalmpl/library/analysis/m3/FlowGraph.rsc|; input = readFile(source); // Resulted in extremely long runtime and eventually an out-of-memory exception testSingleCharDeletions(standardParser, recoveryParser, source, input, 200, 150, 100, 100, begin=387, end=387); diff --git a/src/org/rascalmpl/library/lang/rascal/tests/concrete/recovery/bugs/InfiniteLoopBug.rsc b/src/org/rascalmpl/library/lang/rascal/tests/concrete/recovery/bugs/InfiniteLoopBug.rsc index 450771c6491..90aaf279b93 100644 --- a/src/org/rascalmpl/library/lang/rascal/tests/concrete/recovery/bugs/InfiniteLoopBug.rsc +++ b/src/org/rascalmpl/library/lang/rascal/tests/concrete/recovery/bugs/InfiniteLoopBug.rsc @@ -18,7 +18,7 @@ import ParseTree; import IO; test bool testInfiniteLoop() { - str input = readFile(|std:///lang/rascal/tests/concrete/recovery/bugs/InfiniteLoopInput.txt|); + str input = readFile(|project://rascal/src/org/rascalmpl/library/lang/rascal/tests/concrete/recovery/bugs/InfiniteLoopInput.txt|); p = parser(#start[Module], allowRecovery=true, allowAmbiguity=true); println("starting parse"); p(input, |unknown:///?visualize=false|); diff --git a/src/org/rascalmpl/library/lang/rascal/tests/concrete/recovery/bugs/OvertakeBug.rsc b/src/org/rascalmpl/library/lang/rascal/tests/concrete/recovery/bugs/OvertakeBug.rsc index 4d9f6e4463d..2e583123fb2 100644 --- a/src/org/rascalmpl/library/lang/rascal/tests/concrete/recovery/bugs/OvertakeBug.rsc +++ b/src/org/rascalmpl/library/lang/rascal/tests/concrete/recovery/bugs/OvertakeBug.rsc @@ -17,7 +17,7 @@ import ParseTree; import IO; bool testOvertakeBug() { - str input = readFile(|std:///lang/rascal/tests/concrete/recovery/bugs/OvertakeBugInput.txt|); + str input = readFile(|project://rascal/src/org/rascalmpl/library/lang/rascal/tests/concrete/recovery/bugs/OvertakeBugInput.txt|); parser(#Module, allowRecovery=true, allowAmbiguity=true)(input, |unknown:///?visualize=false|); // If the parse completes without crashing, the test succeeds return true; diff --git a/src/org/rascalmpl/library/lang/rascal/tests/concrete/recovery/bugs/OvertakenNullableBug.rsc b/src/org/rascalmpl/library/lang/rascal/tests/concrete/recovery/bugs/OvertakenNullableBug.rsc index 340aa6f4690..1b89f63d4ce 100644 --- a/src/org/rascalmpl/library/lang/rascal/tests/concrete/recovery/bugs/OvertakenNullableBug.rsc +++ b/src/org/rascalmpl/library/lang/rascal/tests/concrete/recovery/bugs/OvertakenNullableBug.rsc @@ -22,7 +22,7 @@ import IO; test bool testOvertakeNullableBug() { standardParser = parser(#start[Module], allowRecovery=false, allowAmbiguity=true); recoveryParser = parser(#start[Module], allowRecovery=true, allowAmbiguity=true); - loc source = |std:///lang/rascal/tests/library/analysis/statistics/DescriptiveTests.rsc|; + loc source = |project://rascal/src/org/rascalmpl/library/lang/rascal/tests/library/analysis/statistics/DescriptiveTests.rsc|; input = readFile(source); testDeleteUntilEol(standardParser, recoveryParser, source, input, 200, 100, 100, 100, begin=561, end=561); diff --git a/src/org/rascalmpl/library/lang/rascal/tests/concrete/recovery/bugs/Patterns3Slow.rsc b/src/org/rascalmpl/library/lang/rascal/tests/concrete/recovery/bugs/Patterns3Slow.rsc index 88db0738738..9ec7b42fff3 100644 --- a/src/org/rascalmpl/library/lang/rascal/tests/concrete/recovery/bugs/Patterns3Slow.rsc +++ b/src/org/rascalmpl/library/lang/rascal/tests/concrete/recovery/bugs/Patterns3Slow.rsc @@ -13,7 +13,7 @@ import IO; This tests the slowest error recovery in all tests < 10kb */ bool testPatterns3() { - loc source = |std:///lang/rascal/tests/concrete/Patterns3.rsc?deletedUntilEol=85:2133:2136|; + loc source = |project://rascal/src/org/rascalmpl/library/lang/rascal/tests/concrete/Patterns3.rsc?deletedUntilEol=85:2133:2136|; str input = getTestInput(source); recoveryParser = parser(#start[Module], allowRecovery=true, allowAmbiguity=true, maxRecoveryAttempts=50, maxRecoveryTokens=30); diff --git a/src/org/rascalmpl/library/lang/rascal/tests/concrete/recovery/bugs/PreferAvoidSlow.rsc b/src/org/rascalmpl/library/lang/rascal/tests/concrete/recovery/bugs/PreferAvoidSlow.rsc index 52a794da0b0..0c29e9a9dc8 100644 --- a/src/org/rascalmpl/library/lang/rascal/tests/concrete/recovery/bugs/PreferAvoidSlow.rsc +++ b/src/org/rascalmpl/library/lang/rascal/tests/concrete/recovery/bugs/PreferAvoidSlow.rsc @@ -9,7 +9,7 @@ import IO; bool testPreferAvoid() { recoveryParser = parser(#start[Module], allowRecovery=true, allowAmbiguity=true, maxAmbDepth=1000); - loc source = |std:///lang/sdf2/filters/PreferAvoid.rsc?deletedUntilEol=8:208:271|; + loc source = |project://rascal/src/org/rascalmpl/library/lang/sdf2/filters/PreferAvoid.rsc?deletedUntilEol=8:208:271|; str input = getTestInput(source); println("input: "); Tree result = recoveryParser(input, source); diff --git a/src/org/rascalmpl/library/lang/rascal/tests/library/analysis/formalconcepts/FCATest.rsc b/src/org/rascalmpl/library/lang/rascal/tests/library/analysis/formalconcepts/FCATest.rsc index 8045ac7e812..21ab8e0d46d 100644 --- a/src/org/rascalmpl/library/lang/rascal/tests/library/analysis/formalconcepts/FCATest.rsc +++ b/src/org/rascalmpl/library/lang/rascal/tests/library/analysis/formalconcepts/FCATest.rsc @@ -71,7 +71,7 @@ bool checkNoUnRelatedConcepts(rel[&TObject, &TAttribute] input) { } test bool fcaHasExpectedOutput() { - result = fca(readCxt(|std:///lang/rascal/tests/library/analysis/formalconcepts/FCxt1.cxt|)); - reference = readBinaryValueFile(#ConceptLattice[str,str], |std:///lang/rascal/tests/library/analysis/formalconcepts/FCxt1.fca|); + result = fca(readCxt(|project://rascal/src/org/rascalmpl/library/lang/rascal/tests/library/analysis/formalconcepts/FCxt1.cxt|)); + reference = readBinaryValueFile(#ConceptLattice[str,str], |project://rascal/src/org/rascalmpl/library/lang/rascal/tests/library/analysis/formalconcepts/FCxt1.fca|); return result == reference; } diff --git a/src/org/rascalmpl/library/lang/rascal/tests/library/lang/html/IOTests.rsc b/src/org/rascalmpl/library/lang/rascal/tests/library/lang/html/IOTests.rsc index b4e5d5aacf2..f027212072e 100644 --- a/src/org/rascalmpl/library/lang/rascal/tests/library/lang/html/IOTests.rsc +++ b/src/org/rascalmpl/library/lang/rascal/tests/library/lang/html/IOTests.rsc @@ -3,7 +3,7 @@ module lang::rascal::tests::library::lang::html::IOTests import lang::html::IO; import IO; -private loc exampleHTML = |std:///lang/html/examples/example.html|; +private loc exampleHTML = |project://rascal/src/org/rascalmpl/library/lang/html/examples/example.html|; test bool simpleParseTest() = html(_) := readHTMLFile(exampleHTML); diff --git a/src/org/rascalmpl/library/lang/rascal/tests/library/lang/json/JSONIOTests.rsc b/src/org/rascalmpl/library/lang/rascal/tests/library/lang/json/JSONIOTests.rsc index 350a355e7fc..87ff97f4ec3 100644 --- a/src/org/rascalmpl/library/lang/rascal/tests/library/lang/json/JSONIOTests.rsc +++ b/src/org/rascalmpl/library/lang/rascal/tests/library/lang/json/JSONIOTests.rsc @@ -110,7 +110,7 @@ bool originTest(loc example) { } test bool originTracking() { - files = [ l | loc l <- |std:///lang/rascal/tests/library/lang/json|.ls, l.extension == "json"]; + files = [ l | loc l <- |project://rascal/src/org/rascalmpl/library/lang/rascal/tests/library/lang/json|.ls, l.extension == "json"]; return (true | it && originTest(example) | loc example <- files); } @@ -185,7 +185,7 @@ value toDefaultValue(real r) = r - round(r) == 0 default value toDefaultValue(value x) = x; test bool accurateParseErrors() { - ex = readFile(|std:///lang/rascal/tests/library/lang/json/glossary.json|); + ex = readFile(|project://rascal/src/org/rascalmpl/library/lang/rascal/tests/library/lang/json/glossary.json|); broken = ex[..size(ex)/2] + ex[size(ex)/2+10..]; try { diff --git a/src/org/rascalmpl/library/lang/rascal/tests/library/lang/xml/XMLIOTests.rsc b/src/org/rascalmpl/library/lang/rascal/tests/library/lang/xml/XMLIOTests.rsc index 5513ca7018b..4b11082074c 100644 --- a/src/org/rascalmpl/library/lang/rascal/tests/library/lang/xml/XMLIOTests.rsc +++ b/src/org/rascalmpl/library/lang/rascal/tests/library/lang/xml/XMLIOTests.rsc @@ -73,12 +73,12 @@ test bool namespacesMultiple() test bool originTrackingElements() { - loc l = |std:///lang/rascal/tests/library/lang/xml/glossary.xml|; + loc l = |project://rascal/src/org/rascalmpl/library/lang/rascal/tests/library/lang/xml/glossary.xml|; return originTracking(readXML(l, trackOrigins=true), readFile(l)); } test bool originTrackingElementsWithEndTags() { - loc l = |std:///lang/rascal/tests/library/lang/xml/glossary.xml|; + loc l = |project://rascal/src/org/rascalmpl/library/lang/rascal/tests/library/lang/xml/glossary.xml|; return originTracking(readXML(l, trackOrigins=true, includeEndTags=true), readFile(l)); } @@ -100,8 +100,8 @@ private bool originTracking(node example, str content) { } test bool streamingAPI() { - loc l = |std:///lang/rascal/tests/library/lang/xml/glossary.xml|; - next = streamXML(|std:///lang/rascal/tests/library/lang/xml/glossary.xml|, "GlossEntry"); + loc l = |project://rascal/src/org/rascalmpl/library/lang/rascal/tests/library/lang/xml/glossary.xml|; + next = streamXML(|project://rascal/src/org/rascalmpl/library/lang/rascal/tests/library/lang/xml/glossary.xml|, "GlossEntry"); return just(node _) := next() && nothing() := next(); } \ No newline at end of file diff --git a/src/org/rascalmpl/library/util/PathConfig.java b/src/org/rascalmpl/library/util/PathConfig.java index 9524d596468..a2861a9d389 100644 --- a/src/org/rascalmpl/library/util/PathConfig.java +++ b/src/org/rascalmpl/library/util/PathConfig.java @@ -22,7 +22,6 @@ import org.rascalmpl.interpreter.Configuration; import org.rascalmpl.interpreter.utils.RascalManifest; import org.rascalmpl.library.Messages; -import org.rascalmpl.uri.StandardLibraryURIResolver; import org.rascalmpl.uri.URIResolverRegistry; import org.rascalmpl.uri.URIUtil; import org.rascalmpl.uri.file.MavenRepositoryURIResolver; @@ -369,8 +368,12 @@ public static ISourceLocation resolveProjectOnClasspath(String projectName) thro throw new FileNotFoundException(projectName + " jar could not be located in the current runtime classpath"); } - public static ISourceLocation resolveCurrentRascalRuntimeJar() throws IOException { - return resolveProjectOnClasspath("rascal"); + public static ISourceLocation resolveCurrentRascalRuntime() throws IOException { + return MavenRepositoryURIResolver.mavenize(resolveProjectOnClasspath("rascal")); + } + + public static ISourceLocation resolveCurrentStandardLibrary() throws IOException { + return URIUtil.getChildLocation(JarURIResolver.jarify(resolveCurrentRascalRuntime()), "org/rascalmpl/library"); } public static ISourceLocation inferProjectRoot(Class clazz) throws IOException { @@ -392,8 +395,8 @@ public static ISourceLocation inferProjectRoot(Class clazz) throws IOExceptio public static ISourceLocation inferProjectRoot(ISourceLocation member) { ISourceLocation current = member; URIResolverRegistry reg = URIResolverRegistry.getInstance(); - while (current != null && reg.exists(current) && reg.isDirectory(current)) { - if (reg.exists(URIUtil.getChildLocation(current, "META-INF/RASCAL.MF"))) { + while (current != null && reg.exists(current)) { + if (reg.isDirectory(current) && reg.exists(URIUtil.getChildLocation(current, "META-INF/RASCAL.MF"))) { return current; } @@ -441,21 +444,19 @@ public static PathConfig parse(String pathConfigString) throws IOException { * Configure paths for the rascal project itself, so if someone has rascal open in their IDE for example, or is starting a REPL for rascal */ private static void buildRascalSelfApplicationConfig(ISourceLocation workspaceRascal, RascalConfigMode mode, List mavenClassPath, IListWriter srcs, IListWriter libs, IListWriter messages) throws IOException { + // we want to help rascal devs work on rascal to at least get type-check errors, so if we're in compile mode, you get the source path + // but otherwise, you always get the boostrap Rascal in your REPL + var stdSrc = URIUtil.getChildLocation(workspaceRascal, "src/org/rascalmpl/library"); + srcs.append(stdSrc); + if (mode == RascalConfigMode.INTERPRETER) { - // if you want to test rascal changes, use RascalShell class and run it as a java process - srcs.append(URIUtil.rootLocation("std")); - - messages.append(Messages.info("Bootstrap |std:///| = " + StandardLibraryURIResolver.getDebugBootstrapLocation(), workspaceRascal)); - // add our own jar to the lib path to make sure rascal classes are found - var runtime = resolveCurrentRascalRuntimeJar(); + messages.append(Messages.info("Bootstrap stdlib = " + stdSrc, workspaceRascal)); + + // add our own jar/target folder to the lib path to make sure rascal classes are found + var runtime = resolveCurrentRascalRuntime(); libs.append(runtime); messages.append(Messages.info("Bootstrap runtime = " + runtime, workspaceRascal)); } - else { - // we want to help rascal devs work on rascal to at least get type-check errors, so if we're in compile mode, you get the source path - // but otherwise, you alway get the `std:///` in your repl - srcs.append(URIUtil.getChildLocation(workspaceRascal, "src/org/rascalmpl/library")); - } // compiler & tutor only paths srcs.append(URIUtil.getChildLocation(workspaceRascal, "src/org/rascalmpl/compiler")); @@ -487,7 +488,7 @@ private static void buildRascalSelfApplicationConfig(ISourceLocation workspaceRa } // the interpreter should pick up the typepal sources - // and so should the typechecker, otherwise it might get type-checked against the wrong `std:///` jar (namely from it's pom.xml) + // and so should the typechecker, otherwise it might get type-checked against the wrong standard library (namely from it's pom.xml) if (typepal != null) { srcs.append(typepal); } else { @@ -499,20 +500,22 @@ private static void buildRascalSelfApplicationConfig(ISourceLocation workspaceRa * Configure paths for the rascal-lsp project when it's open in the IDE (the runtime inside rascal-lsp is not configured here) */ private static void buildRascalLSPConfig(ISourceLocation manifestRoot, RascalConfigMode mode, List mavenClasspath, IListWriter srcs, IListWriter libs, IListWriter messages) throws IOException { - var insideRascalJar = JarURIResolver.jarify(resolveCurrentRascalRuntimeJar()); + var currentRascalRuntime = resolveCurrentRascalRuntime(); + var insideRascalJar = JarURIResolver.jarify(currentRascalRuntime); + var rascalLibrary = URIUtil.getChildLocation(insideRascalJar, "org/rascalmpl/library"); var rascalCompiler = URIUtil.getChildLocation(insideRascalJar, "org/rascalmpl/compiler"); var typepal = URIUtil.getChildLocation(insideRascalJar, "org/rascalmpl/typepal"); if (mode == RascalConfigMode.INTERPRETER) { - // we're building a repl for the rascal-lsp project + // we're building a REPL for the rascal-lsp project // so this is a rascal-lsp developer working on code in rascal-lsp // most stuff flows from the - srcs.append(URIUtil.rootLocation("std")); + srcs.append(rascalLibrary); srcs.append(rascalCompiler); srcs.append(typepal); } else { - libs.append(JarURIResolver.jarify(resolveCurrentRascalRuntimeJar())); + libs.append(insideRascalJar); // while it's tempting to see if the rascal project is there, and we might be able to get the rascal compiler tpls from the target folder. // as long as we're hard wiring the rascal compler to follow the runtime // we have to let the type-checker for rascal-lsp re-type-check rascal compiler @@ -520,7 +523,7 @@ private static void buildRascalLSPConfig(ISourceLocation manifestRoot, RascalCon srcs.append(rascalCompiler); srcs.append(typepal); } - libs.append(resolveCurrentRascalRuntimeJar()); // add our own jar to the lib path to make sure rascal classes are found + libs.append(currentRascalRuntime); // add our own jar to the lib path to make sure rascal classes are found translateSources(manifestRoot, srcs, messages); @@ -547,23 +550,42 @@ private static void translateSources(ISourceLocation manifestRoot, IListWriter s } } + public static boolean isRascalArtifact(Artifact art) { + var coord = art.getCoordinate(); + return coord.getArtifactId().equals("rascal") + && coord.getGroupId().equals("org.rascalmpl"); + } + private static void buildNormalProjectConfig(ISourceLocation manifestRoot, RascalConfigMode mode, List mavenClasspath, boolean isRoot, IListWriter srcs, IListWriter libs, IListWriter messages) throws IOException, URISyntaxException { if (isRoot) { - if (mode == RascalConfigMode.INTERPRETER) { - srcs.append(URIUtil.rootLocation("std")); // you'll always get rascal from standard in case of interpreter mode - libs.append(resolveCurrentRascalRuntimeJar()); // add our own jar to the lib path to make sure rascal classes are found + ISourceLocation rascal; + var rascalFromPom = mavenClasspath.stream() + .filter(PathConfig::isRascalArtifact) + .findFirst() + .map(Artifact::getResolved) + .map(Path::toUri) + .map(vf::sourceLocation) + .map(MavenRepositoryURIResolver::mavenize) + .map(JarURIResolver::jarify); + + if (rascalFromPom.isPresent()) { + // Explicit Rascal dependency in the pom.xml + rascal = rascalFromPom.get(); + } else { + // Fall back to current runtime Rascal and warn the user + rascal = JarURIResolver.jarify(resolveCurrentRascalRuntime()); + messages.append(Messages.warning(String.format("No Rascal dependency found in pom.xml. Using %s instead.", rascal.getURI()), getPomXmlLocation(manifestRoot))); } - else { - assert mode == RascalConfigMode.COMPILER: "should be compiler"; - // untill we go pom.xml first, you'll always get the rascal jar from our runtime - // not the one you requested in the pom.xml - libs.append(JarURIResolver.jarify(resolveCurrentRascalRuntimeJar())); + + libs.append(rascal); + if (mode == RascalConfigMode.INTERPRETER) { + // The compiler does not need sources, but the interpreter does. + srcs.append(URIUtil.getChildLocation(rascal, "org/rascalmpl/library")); } } - // This processes Rascal libraries we can find in maven dependencies, - // and we add them to the srcs unless a project is open with the same name, then we defer to its srcs + // and we add them to the libs unless a project is open with the same name, then we defer to its srcs // to make it easier to edit projects in the IDE for (var art : mavenClasspath) { addArtifactToPathConfig(art, manifestRoot, mode, srcs, libs, messages); @@ -581,20 +603,6 @@ private static void buildNormalProjectConfig(ISourceLocation manifestRoot, Rasca libs.append(URIUtil.getChildLocation(manifestRoot, "target/classes")); } } - - // We add rascal-lsp to the PathConfig if it is present on the classpath - // This version of rascal-lsp is added last, so an explicit rascal-lsp dependency takes precedence - try { - var lsp = PathConfig.resolveProjectOnClasspath("rascal-lsp"); - if (mode == RascalConfigMode.INTERPRETER) { - srcs.append(URIUtil.getChildLocation(JarURIResolver.jarify(lsp), "library")); - } - // the interpreter must load the Java parts for calling util::IDEServices and registerLanguage - addLibraryToLibPath(URIResolverRegistry.getInstance(), libs, mode, lsp); - } - catch (IOException e) { - // This is expected when rascal-lsp is not on the classpath - } } private static void addArtifactToPathConfig(Artifact art, ISourceLocation manifestRoot, RascalConfigMode mode, IListWriter srcs, @@ -633,9 +641,6 @@ private static void addArtifactToPathConfig(Artifact art, ISourceLocation manife } if (libProjectName.equals("rascal-lsp")) { checkLSPVersionsMatch(manifestRoot, messages, dep, art); - // we'll be adding the rascal-lsp by hand later - // so we ignore the rascal-lsp dependency - return; } ISourceLocation projectLoc = URIUtil.correctLocation("project", libProjectName, ""); @@ -907,11 +912,11 @@ private static void addLibraryToLibPath(URIResolverRegistry reg, IListWriter lib } } - private static ISourceLocation getRascalMfLocation(ISourceLocation project) { + public static ISourceLocation getRascalMfLocation(ISourceLocation project) { return URIUtil.getChildLocation(project, RascalManifest.META_INF_RASCAL_MF); } - private static ISourceLocation getPomXmlLocation(ISourceLocation project) { + public static ISourceLocation getPomXmlLocation(ISourceLocation project) { try { ISourceLocation pomxml = URIUtil.getChildLocation(project, "pom.xml"); return URIResolverRegistry.getInstance().logicalToPhysical(pomxml); diff --git a/src/org/rascalmpl/library/vis/Graphs.rsc b/src/org/rascalmpl/library/vis/Graphs.rsc index d499153b4d7..a072b3fa9ff 100644 --- a/src/org/rascalmpl/library/vis/Graphs.rsc +++ b/src/org/rascalmpl/library/vis/Graphs.rsc @@ -202,7 +202,7 @@ Providing locations as node identities automatically transforms them to node lin ```rascal-shell import vis::Graphs; import IO; -d = [<|std:///|, e> | e <- |std:///|.ls]; +d = [<|project://rascal/src/org/rascalmpl/library/|, e> | e <- |project://rascal/src/org/rascalmpl/library/|.ls]; d += [ | <_, e> <- d, isDirectory(e), f <- e.ls]; graph(d, \layout=defaultDagreLayout()); // here we adapt the node labeler to show only the last file name in the path of the location: diff --git a/src/org/rascalmpl/repl/completers/RascalQualifiedNames.java b/src/org/rascalmpl/repl/completers/RascalQualifiedNames.java index 314b52afd25..c4b2d3ad30d 100644 --- a/src/org/rascalmpl/repl/completers/RascalQualifiedNames.java +++ b/src/org/rascalmpl/repl/completers/RascalQualifiedNames.java @@ -36,6 +36,7 @@ import java.util.stream.Collectors; import org.rascalmpl.uri.URIResolverRegistry; +import org.rascalmpl.uri.URIUtil; import org.rascalmpl.values.ValueFactoryFactory; /** @@ -73,7 +74,7 @@ private static void assureKeywordsAreScrapped() { String rascalGrammar = ""; URIResolverRegistry reg = URIResolverRegistry.getInstance(); - try (Reader grammarReader = reg.getCharacterReader(ValueFactoryFactory.getValueFactory().sourceLocation("std", "", "/lang/rascal/syntax/Rascal.rsc"))) { + try (Reader grammarReader = reg.getCharacterReader(ValueFactoryFactory.getValueFactory().sourceLocation(URIUtil.fromURL(RascalQualifiedNames.class.getResource("/org/rascalmpl/library/lang/rascal/syntax/Rascal.rsc"))))) { StringBuilder res = new StringBuilder(); char[] chunk = new char[8 * 1024]; int read; diff --git a/src/org/rascalmpl/shell/AbstractCommandlineTool.java b/src/org/rascalmpl/shell/AbstractCommandlineTool.java index fc03195559b..d4d87626c71 100644 --- a/src/org/rascalmpl/shell/AbstractCommandlineTool.java +++ b/src/org/rascalmpl/shell/AbstractCommandlineTool.java @@ -50,7 +50,7 @@ public abstract class AbstractCommandlineTool { public static int main(String mainModule, String[] sourceFolders, String[] args, Terminal term, IRascalMonitor monitor, PrintWriter err, PrintWriter out) { try { var eval = ShellEvaluatorFactory.getBasicEvaluator(term.reader(), out, err, monitor); - var rascalJar = JarURIResolver.jarify(PathConfig.resolveCurrentRascalRuntimeJar()); + var rascalJar = JarURIResolver.jarify(PathConfig.resolveCurrentRascalRuntime()); for (String folder : sourceFolders) { var src = URIUtil.getChildLocation(rascalJar, folder); @@ -100,7 +100,7 @@ else if (result.getType().isInteger()) { public static int main(String mainModule, String[] sourceFolders, Map args, Terminal term, IRascalMonitor monitor, PrintWriter err, PrintWriter out) { try { var eval = ShellEvaluatorFactory.getBasicEvaluator(term.reader(), out, err, monitor); - var rascalJar = JarURIResolver.jarify(PathConfig.resolveCurrentRascalRuntimeJar()); + var rascalJar = JarURIResolver.jarify(PathConfig.resolveCurrentRascalRuntime()); for (String folder : sourceFolders) { var src = URIUtil.getChildLocation(rascalJar, folder); diff --git a/src/org/rascalmpl/shell/ShellEvaluatorFactory.java b/src/org/rascalmpl/shell/ShellEvaluatorFactory.java index d96b5c3637d..e4b6f0dbbed 100644 --- a/src/org/rascalmpl/shell/ShellEvaluatorFactory.java +++ b/src/org/rascalmpl/shell/ShellEvaluatorFactory.java @@ -1,5 +1,6 @@ package org.rascalmpl.shell; +import java.io.IOException; import java.io.PrintWriter; import java.io.Reader; import java.util.List; @@ -11,7 +12,6 @@ import org.rascalmpl.interpreter.Evaluator; import org.rascalmpl.interpreter.env.GlobalEnvironment; import org.rascalmpl.interpreter.env.ModuleEnvironment; -import org.rascalmpl.interpreter.load.StandardLibraryContributor; import org.rascalmpl.interpreter.utils.RascalManifest; import org.rascalmpl.library.Messages; import org.rascalmpl.library.util.PathConfig; @@ -37,7 +37,11 @@ public static Evaluator getBasicEvaluator(Reader input, PrintWriter stdout, Prin var heap = new GlobalEnvironment(); var root = heap.addModule(new ModuleEnvironment(rootEnvironment, heap)); var evaluator = new Evaluator(ValueFactoryFactory.getValueFactory(), input, stderr, stdout, root, heap, monitor); - evaluator.addRascalSearchPathContributor(StandardLibraryContributor.getInstance()); + try { + evaluator.addRascalSearchPath(PathConfig.resolveCurrentStandardLibrary()); + } catch (IOException e) { + monitor.warning("No Rascal runtime found", URIUtil.unknownLocation()); + } return evaluator; } diff --git a/src/org/rascalmpl/tutor/lang/rascal/tutor/examples/Test/Libraries/Boolean/Boolean.remote b/src/org/rascalmpl/tutor/lang/rascal/tutor/examples/Test/Libraries/Boolean/Boolean.remote index 8816436b0ab..d685dbf9389 100644 --- a/src/org/rascalmpl/tutor/lang/rascal/tutor/examples/Test/Libraries/Boolean/Boolean.remote +++ b/src/org/rascalmpl/tutor/lang/rascal/tutor/examples/Test/Libraries/Boolean/Boolean.remote @@ -1 +1 @@ -|std:///Boolean.rsc| \ No newline at end of file +|project://rascal/src/org/rascalmpl/library/Boolean.rsc| \ No newline at end of file diff --git a/src/org/rascalmpl/uri/StandardLibraryURIResolver.java b/src/org/rascalmpl/uri/StandardLibraryURIResolver.java deleted file mode 100644 index fd8270e1f15..00000000000 --- a/src/org/rascalmpl/uri/StandardLibraryURIResolver.java +++ /dev/null @@ -1,68 +0,0 @@ -package org.rascalmpl.uri; - -import java.io.IOException; - -import org.rascalmpl.library.util.PathConfig; -import org.rascalmpl.uri.jar.JarURIResolver; -import io.usethesource.vallang.ISourceLocation; - -/** - * Provides transparant access to the source code of the one and only standard library - * that should be on the source path of the interpreter, which is contained in the same - * jar as the current interpreter is from. - * - * The std:/// scheme is mainly used by the interpreter, to load library modules; but it is also the location - * of distributed sources of the standard library for use in the debugger. The references - * that the type-checker produces for UI feature in the IDE also depend on this scheme. - * - * This is accomplished by: - * 1. rewriting all the references to the source locations of the library in - * project://rascal/src/org/rascalmpl/library/...` to `std:///...`. This is done by the "packager" - * 2. copying all the .rsc files of the library to the jar in the right location (mvn resources plugin) - * 3. resolving std:/// to the same location inside of the jar - * 4. **not** having more than one standard library in the classpath of the JVM, or more than one - * standard library in the libs path of a PathConfig. - */ -public class StandardLibraryURIResolver implements ILogicalSourceLocationResolver { - private static final ISourceLocation currentRascalJar = - URIUtil.getChildLocation( - JarURIResolver.jarify( - resolveCurrentRascalJar() - ), - "org/rascalmpl/library" - ); - - private static ISourceLocation resolveCurrentRascalJar() { - try { - return PathConfig.resolveCurrentRascalRuntimeJar(); - } - catch (IOException e) { - // this will be reported elsewhere in PathConfig.messages - - return URIUtil.unknownLocation(); - } - } - - @Override - public ISourceLocation resolve(ISourceLocation input) throws IOException { - return URIUtil.getChildLocation(currentRascalJar, input.getPath()); - } - - @Override - public String scheme() { - return "std"; - } - - @Override - public String authority() { - return ""; - } - - /* - * Not for general use, but necessary information about the bill of - * materials for bootstrapping (running Rascal to implement Rascal). - */ - public static ISourceLocation getDebugBootstrapLocation() { - return currentRascalJar; - } - -} diff --git a/src/org/rascalmpl/uri/URIUtil.java b/src/org/rascalmpl/uri/URIUtil.java index 45b76d98e56..154096dd7a0 100644 --- a/src/org/rascalmpl/uri/URIUtil.java +++ b/src/org/rascalmpl/uri/URIUtil.java @@ -19,6 +19,7 @@ import java.net.URLDecoder; import java.nio.charset.StandardCharsets; import java.nio.file.Path; +import java.util.Set; import org.rascalmpl.values.ValueFactoryFactory; @@ -66,30 +67,43 @@ public static URI createFile(String path) throws URISyntaxException { } return fixUnicode(file.toURI()); } - + + private static final Set CONTAINER_SCHEMES = Set.of("jar", "zip", "compressed"); + /** - * Some URLs exist which are not strictly in compliance with RFC 2396. Their toURI() method will then produce - * bad URI syntax leading to IO exceptions later. This method tries to circumvent the problem by decoding - * the content of the URL first back to basic UTF8 characters and then recoding the URI from scratch. - * - * @param url a possibly non-rfc-2396 compliant URL + * Some URLs exist which are not strictly in compliance with RFC 2396. Their toURI() method will + * then produce bad URI syntax leading to IO exceptions later. This method tries to circumvent the + * problem by decoding the content of the URL first back to basic UTF8 characters and then recoding + * the URI from scratch. + * + * @param url a possibly non-rfc-2396 compliant URL * @return (hopefully) a correctly encoded URI * @throws URISyntaxException when either the decoder of URLs or the encoder of URIs finds a bad input. */ public static URI fromURL(URL url) throws URISyntaxException { - try { - return create( - url.getProtocol(), - decodeURLPart(url.getAuthority()), - decodeURLPart(url.getPath()), - url.getQuery() == null ? null : decodeURLPart(url.getQuery()), - url.getRef() == null ? null : decodeURLPart(url.getRef())); - } - catch (UnsupportedEncodingException e) { - throw new URISyntaxException(url.toString(), e.getMessage()); - } + try { + var scheme = url.getProtocol(); + var path = decodeURLPart(url.getPath()); + + // Fix URLs like `jar:file:/C:/`, where the protocol ia `jar`, but we want scheme `jar+file` + if (url.getAuthority() == null || url.getAuthority().isEmpty()) { + var schemePart = scheme; + int schemeEnd; + while (CONTAINER_SCHEMES.contains(schemePart) && (schemeEnd = path.indexOf(':')) > 0) { + schemePart = path.substring(0, schemeEnd); + scheme += "+" + schemePart; + path = path.substring(schemeEnd + 1); + } + } + return create(scheme, decodeURLPart(url.getAuthority()), path, + url.getQuery() == null ? null : decodeURLPart(url.getQuery()), + url.getRef() == null ? null : decodeURLPart(url.getRef())); + } + catch (UnsupportedEncodingException e) { + throw new URISyntaxException(url.toString(), e.getMessage()); + } } - + private static String decodeURLPart(String part) throws UnsupportedEncodingException { return part == null || part.isEmpty() ? "" : URLDecoder.decode(part, StandardCharsets.UTF_8.name()); } diff --git a/src/org/rascalmpl/uri/file/MavenRepositoryURIResolver.java b/src/org/rascalmpl/uri/file/MavenRepositoryURIResolver.java index c335b7c2a6f..7ce6841816b 100644 --- a/src/org/rascalmpl/uri/file/MavenRepositoryURIResolver.java +++ b/src/org/rascalmpl/uri/file/MavenRepositoryURIResolver.java @@ -111,7 +111,7 @@ private static final boolean isCaseInsensitive(URIResolverRegistry reg, ISourceL } } - public MavenRepositoryURIResolver(URIResolverRegistry reg) throws IOException, URISyntaxException { + public MavenRepositoryURIResolver(URIResolverRegistry reg) throws URISyntaxException { this.reg = reg; this.rootIsCaseSensitive = !isCaseInsensitive(reg, root); } @@ -125,7 +125,7 @@ private static ISourceLocation inferMavenRepositoryLocation() throws URISyntaxEx * @return a file:/// reference to the jar file that is designated by the authority. * @throws IOException when the authority does not designate a jar file */ - private ISourceLocation resolveJar(ISourceLocation input) throws IOException { + public ISourceLocation resolveJar(ISourceLocation input) throws IOException { String authority = input.getAuthority(); if (authority.isEmpty()) { diff --git a/src/org/rascalmpl/uri/remote/jsonrpc/SourceLocationResponse.java b/src/org/rascalmpl/uri/remote/jsonrpc/SourceLocationResponse.java index a4a509965d1..a78170f4b29 100644 --- a/src/org/rascalmpl/uri/remote/jsonrpc/SourceLocationResponse.java +++ b/src/org/rascalmpl/uri/remote/jsonrpc/SourceLocationResponse.java @@ -28,16 +28,18 @@ import java.util.Objects; +import org.checkerframework.checker.nullness.qual.Nullable; + import io.usethesource.vallang.ISourceLocation; public class SourceLocationResponse { - private final ISourceLocation loc; + private final @Nullable ISourceLocation loc; - public SourceLocationResponse(ISourceLocation loc) { + public SourceLocationResponse(@Nullable ISourceLocation loc) { this.loc = loc; } - public ISourceLocation getLocation() { + public @Nullable ISourceLocation getLocation() { return loc; } diff --git a/src/org/rascalmpl/uri/resolvers.config b/src/org/rascalmpl/uri/resolvers.config index c25d506cf23..cb365c536cd 100644 --- a/src/org/rascalmpl/uri/resolvers.config +++ b/src/org/rascalmpl/uri/resolvers.config @@ -3,7 +3,6 @@ org.rascalmpl.uri.file.TempURIResolver org.rascalmpl.uri.CompressedStreamResolver org.rascalmpl.uri.remote.HttpsURIResolver org.rascalmpl.uri.remote.HttpURIResolver -org.rascalmpl.uri.StandardLibraryURIResolver org.rascalmpl.uri.classloaders.SystemClassloaderResolver org.rascalmpl.uri.jar.JarURIResolver org.rascalmpl.uri.zip.ZipURIResolver @@ -16,4 +15,5 @@ org.rascalmpl.uri.file.SystemPathURIResolver org.rascalmpl.uri.libraries.MemoryResolver org.rascalmpl.uri.unsupported.UnknownURIResolver org.rascalmpl.uri.unsupported.LibraryURIResolver +org.rascalmpl.uri.unsupported.StandardLibraryURIResolver diff --git a/src/org/rascalmpl/uri/unsupported/StandardLibraryURIResolver.java b/src/org/rascalmpl/uri/unsupported/StandardLibraryURIResolver.java new file mode 100644 index 00000000000..b3bbf82d03c --- /dev/null +++ b/src/org/rascalmpl/uri/unsupported/StandardLibraryURIResolver.java @@ -0,0 +1,13 @@ +package org.rascalmpl.uri.unsupported; + +/** + * Used to provide transparant access to the source code of the one and only standard library, + * but is now defunct. One should use a direct URI, like `mvn://`, `project://`, `jar+file://`, etc. + */ +public class StandardLibraryURIResolver extends UnsupportedURIResolver { + + public StandardLibraryURIResolver() { + super("std", "The std scheme has been removed; please rewrite to mvn scheme, jar+file or similar."); + } + +} diff --git a/test/org/rascalmpl/benchmark/Visiting/ProdVersusType.rsc b/test/org/rascalmpl/benchmark/Visiting/ProdVersusType.rsc index f31bed20fb4..c2c7f12e2db 100644 --- a/test/org/rascalmpl/benchmark/Visiting/ProdVersusType.rsc +++ b/test/org/rascalmpl/benchmark/Visiting/ProdVersusType.rsc @@ -66,7 +66,7 @@ int ProdMatch(Tree tr) { } } value main(){ - m = parseModuleWithSpaces(|std:///List.rsc|); + m = parseModuleWithSpaces(|project://rascal/src/org/rascalmpl/library/List.rsc|); warmup(m); println("ProdMatch:"); a = ProdMatch(m); diff --git a/test/org/rascalmpl/compiler/CheckStdLibTest.java b/test/org/rascalmpl/compiler/CheckStdLibTest.java index ab6dfd77c9e..7170f345744 100644 --- a/test/org/rascalmpl/compiler/CheckStdLibTest.java +++ b/test/org/rascalmpl/compiler/CheckStdLibTest.java @@ -60,11 +60,11 @@ private void simulateShadedTypePal() throws IOException { typepal = MavenRepositoryURIResolver.mavenize(typepal); typepal = JarURIResolver.jarify(typepal); - URIResolverRegistry.getInstance().copy(typepal, URIUtil.getChildLocation(PathConfig.resolveCurrentRascalRuntimeJar(), "org/rascalmpl/typepal"), true, true); + URIResolverRegistry.getInstance().copy(typepal, URIUtil.getChildLocation(PathConfig.resolveCurrentRascalRuntime(), "org/rascalmpl/typepal"), true, true); } private void cleanSimulatedTypePal() throws IOException { - URIResolverRegistry.getInstance().remove(URIUtil.getChildLocation(PathConfig.resolveCurrentRascalRuntimeJar(), "org/rascalmpl/typepal"), true); + URIResolverRegistry.getInstance().remove(URIUtil.getChildLocation(PathConfig.resolveCurrentRascalRuntime(), "org/rascalmpl/typepal"), true); } private ISourceLocation rascalProjectRoot(ISourceLocation stdLibRoot) { diff --git a/test/org/rascalmpl/test/util/URIUtilTests.java b/test/org/rascalmpl/test/util/URIUtilTests.java new file mode 100644 index 00000000000..821ede612cb --- /dev/null +++ b/test/org/rascalmpl/test/util/URIUtilTests.java @@ -0,0 +1,42 @@ +package org.rascalmpl.test.util; + +import static org.junit.Assert.assertEquals; + +import java.net.MalformedURLException; +import java.net.URISyntaxException; +import java.net.URL; + +import org.junit.Test; +import org.rascalmpl.uri.URIUtil; +import org.rascalmpl.values.ValueFactoryFactory; + +import io.usethesource.vallang.ISourceLocation; +import io.usethesource.vallang.IValueFactory; + +public class URIUtilTests { + + private static final IValueFactory VF = ValueFactoryFactory.getValueFactory(); + + private static ISourceLocation toLoc(URL url) throws URISyntaxException { + return VF.sourceLocation(URIUtil.fromURL(url)); + } + + @Test + public void javaResourceUrl() throws MalformedURLException, URISyntaxException { + var loc = toLoc(new URL("jar:file:/a/b.jar!/c")); + assertEquals(VF.sourceLocation("jar+file", "", "/a/b.jar!/c"), loc); + } + + @Test + public void javaWindowsResourceUrl() throws MalformedURLException, URISyntaxException { + var loc = toLoc(new URL("jar:file:/C:/a/b.jar!/c")); + assertEquals(VF.sourceLocation("jar+file", "", "/C:/a/b.jar!/c"), loc); + } + + @Test + public void jarUrl() throws MalformedURLException, URISyntaxException { + var loc = toLoc(new URL("file:/C:/a/b.jar")); + assertEquals(VF.sourceLocation("file", "", "/C:/a/b.jar"), loc); + } + +} diff --git a/test/org/rascalmpl/util/maven/poms/rascal/expected-path-list.txt b/test/org/rascalmpl/util/maven/poms/rascal/expected-path-list.txt index b77125f41b1..aa436284b14 100644 --- a/test/org/rascalmpl/util/maven/poms/rascal/expected-path-list.txt +++ b/test/org/rascalmpl/util/maven/poms/rascal/expected-path-list.txt @@ -92,7 +92,7 @@ org/jline/jline-terminal/3.27.0/jline-terminal-3.27.0.jar org/jsoup/jsoup/1.23.1/jsoup-1.23.1.jar org/nanohttpd/nanohttpd/2.3.1/nanohttpd-2.3.1.jar org/ow2/asm/asm/9.7/asm-9.7.jar -org/rascalmpl/typepal/0.15.1/typepal-0.15.1.jar +org/rascalmpl/typepal/0.17.0-RC3/typepal-0.17.0-RC3.jar org/slf4j/slf4j-api/1.7.36/slf4j-api-1.7.36.jar org/slf4j/slf4j-nop/1.7.36/slf4j-nop-1.7.36.jar org/sonatype/plexus/plexus-build-api/0.0.7/plexus-build-api-0.0.7.jar diff --git a/test/org/rascalmpl/util/maven/poms/rascal/pom.xml b/test/org/rascalmpl/util/maven/poms/rascal/pom.xml index 9b636893976..d8290ddb97d 100644 --- a/test/org/rascalmpl/util/maven/poms/rascal/pom.xml +++ b/test/org/rascalmpl/util/maven/poms/rascal/pom.xml @@ -141,7 +141,6 @@ ${project.basedir}/src/org/rascalmpl/compiler --> - |std:///| ${project.basedir}/FUNDING ${project.basedir}/CITATION.md |https://github.com/usethesource/rascal/issues| @@ -392,7 +391,7 @@ org.rascalmpl typepal - 0.15.1 + 0.17.0-RC3 provided