Skip to content

new reusable functions for using PathConfig #2270

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 35 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
461c564
starting to factor PathConfig into its own module
jurgenvinju May 21, 2025
8e565a8
added and documented the inverse of relativize: resolve
jurgenvinju May 21, 2025
e7523ca
based interactions with PathConfig added
jurgenvinju May 21, 2025
f08b0a6
moved RascalConfigMode back to util::Reflective and started fixing th…
jurgenvinju May 21, 2025
4d168a3
factored all parameters of all 6 mapping functions into a LanguageFil…
jurgenvinju May 21, 2025
d730235
minor doc things
jurgenvinju May 21, 2025
7488c7c
inherited some tests from ReflectiveTests to test the new language-pa…
jurgenvinju May 21, 2025
27e8af8
commented back in forgotten docs
jurgenvinju May 21, 2025
ca95804
replacing generatedSources by resources and adding projectRoot, also …
jurgenvinju May 22, 2025
482149d
unused imports resolved to get to the real warnings
jurgenvinju May 22, 2025
d53058e
added inverse test
jurgenvinju May 22, 2025
689cca1
added another inverse test for pathConfig
jurgenvinju May 22, 2025
1c53e18
added the last inverse test
jurgenvinju May 22, 2025
ec4a370
docs
jurgenvinju May 22, 2025
f8c6567
brought back util::Monitor
jurgenvinju May 22, 2025
edacfc5
fixed tests
jurgenvinju May 22, 2025
cd99dc2
removed debug print
jurgenvinju May 22, 2025
6086609
minor improvements
jurgenvinju May 23, 2025
7410d75
docs
jurgenvinju May 23, 2025
887897f
layout
jurgenvinju May 23, 2025
746cdc9
added back generatedSources and completed with generatedResources for…
jurgenvinju May 25, 2025
3d405e4
details
jurgenvinju May 25, 2025
0aa5b0a
Merge branch 'main' into maintain-pathconfig
jurgenvinju May 25, 2025
2ff5504
imports
jurgenvinju May 25, 2025
1111db8
made all function names use strictly adaptations of the field names o…
jurgenvinju May 26, 2025
3bebab3
factoring out reusable functions and fixing tests
jurgenvinju May 26, 2025
3d38596
fixed issue in test
jurgenvinju May 26, 2025
b21db00
improved documentation
jurgenvinju May 26, 2025
e5adad2
naming consistency in doc strings
jurgenvinju May 26, 2025
dccc645
clean up
jurgenvinju May 26, 2025
ce3f91b
Merge branch 'main' into maintain-pathconfig
jurgenvinju May 26, 2025
6aeea6b
fixed merge issue
jurgenvinju May 26, 2025
d0a5cac
activated all tests in util:: modules. task manager wasn\'t running a…
jurgenvinju May 26, 2025
7678934
removed duplicate declaration due to sloppy manual merge
jurgenvinju May 26, 2025
2f6ebfb
Merge branch 'main' into maintain-pathconfig
jurgenvinju Jun 12, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 40 additions & 3 deletions src/org/rascalmpl/library/Location.rsc
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,57 @@ import Exception;

@synopsis{Extracts a path relative to a parent location.}
@description{
So from `x:///a/b` and `x:///a/b/c` this makes `relative:///c`.
If the outside does not envelop the inside, then the original loc is returned.
* From `x:///a/b` and `x:///a/b/c` this makes `relative:///c`.
* If the outside does not envelop the inside, then the original loc is returned.
}
@javaClass{org.rascalmpl.library.Prelude}
java loc relativize(loc outside, loc inside);

@synopsis{Find the first `haystack` folder the `needle` can be found in and relativize it, or fail.}
loc relativize(list[loc] haystack, loc needle) {
@description{
* From `[|x:///a/b|]` as haystack and `|x:///a/b/c|` as needle this makes `|relative:///c|`.
* If none of the `haystack` locations contain the `needle`, a `PathNotFound` exception is thrown.
}
loc relativize(list[loc] haystack, loc needle) throws PathNotFound {
if (h <- haystack, loc r := relativize(h, needle), r != needle) {
return r;
}
throw PathNotFound(needle);
}

@synsopis{Concatenate a relative path to a given surrounding path}
@description{
* `relative` must be of scheme `relative:///` or `SchemeNotSupported` will be thrown
* ((resolve)) is the opposite of ((relativize))
* the return value does not necessarily exist
}
loc resolve(loc outside, loc relative) = outside + relative.path when relative.scheme == "relative";
default loc resolve(loc _, loc relative) {
throw SchemeNotSupported(relative);
}

@synopsis{Find the right folder in which a relative location is to be found and return the complete path}
@description{
* `relative` must be of scheme `relative:///`
* ((resolve)) is the opposite of ((relativize))
* if a file can not be found in any of the `haystack` folders, then `PathNotFound`` is thrown.
* if `force` is true then a location relative to the first element of the haystack will be returned, even if the file was not found anywhere in the haystack.
}
loc resolve(list[loc] haystack, loc relative, bool force = false) throws PathNotFound {
assert relative.scheme == "relative";
assert haystack != [];

for (loc outside <- haystack, loc candidate := resolve(outside, relative), exists(candidate)) {
return candidate;
}

if (force && haystack != []) {
return resolve(haystack[0], relative);
}

throw PathNotFound(relative);
}

@synopsis{Shortens an absolute path to a jar inside the local maven repository.}
@javaClass{org.rascalmpl.library.Prelude}
java loc mavenize(loc jar);
Expand Down
2 changes: 1 addition & 1 deletion src/org/rascalmpl/library/util/Monitor.rsc
Original file line number Diff line number Diff line change
Expand Up @@ -241,4 +241,4 @@ test bool printLongUnfinishedLine() {
println("Done");
jobEnd("job");
return true;
}
}
323 changes: 319 additions & 4 deletions src/org/rascalmpl/library/util/PathConfig.rsc

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/org/rascalmpl/library/util/Reflective.rsc
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
module util::Reflective

extend util::PathConfig;

import IO;
import List;
import ParseTree;
Expand Down
243 changes: 0 additions & 243 deletions src/org/rascalmpl/library/util/tasks/Manager.java

This file was deleted.

Loading
Loading