Skip to content

Commit 4fafcc0

Browse files
committed
Rename roots class and functions for less verbosity.
1 parent 55594e5 commit 4fafcc0

File tree

4 files changed

+18
-18
lines changed

4 files changed

+18
-18
lines changed

rascal-lsp/src/main/java/org/rascalmpl/vscode/lsp/rascal/model/PathConfigs.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,11 @@ public class PathConfigs {
6868
private static final URIResolverRegistry reg = URIResolverRegistry.getInstance();
6969
private final Map<ISourceLocation, Pair<PathConfig, Instant>> currentPathConfigs = new ConcurrentHashMap<>();
7070
private final PathConfigUpdater updater = new PathConfigUpdater(currentPathConfigs);
71-
private final ProjectRoots projectRoots = new ProjectRoots();
71+
private final Projects projects = new Projects();
7272
private final LoadingCache<ISourceLocation, ISourceLocation> translatedRoots =
7373
Caffeine.newBuilder()
7474
.expireAfterAccess(Duration.ofMinutes(20))
75-
.build(projectRoots::inferProjectRoot);
75+
.build(projects::inferRoot);
7676

7777
private final Executor executor;
7878
private final PathConfigDiagnostics diagnostics;
@@ -85,7 +85,7 @@ public PathConfigs(Executor executor, PathConfigDiagnostics diagnostics) {
8585
}
8686

8787
public void expungePathConfig(ISourceLocation project) {
88-
var projectRoot = projectRoots.inferProjectRoot(project);
88+
var projectRoot = projects.inferRoot(project);
8989
try {
9090
updater.unregisterProject(project);
9191
} catch (IOException e) {

rascal-lsp/src/main/java/org/rascalmpl/vscode/lsp/rascal/model/ProjectRoots.java renamed to rascal-lsp/src/main/java/org/rascalmpl/vscode/lsp/rascal/model/Projects.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,18 +31,18 @@
3131

3232
import io.usethesource.vallang.ISourceLocation;
3333

34-
public class ProjectRoots {
34+
public class Projects {
3535

3636
/**
3737
* Infers the shallowest possible root of the project that `origin` is in.
3838
*/
39-
public ISourceLocation inferProjectRoot(ISourceLocation origin) {
40-
var innerRoot = inferDeepestProjectRoot(origin);
41-
var outerRoot = inferDeepestProjectRoot(URIUtil.getParentLocation(innerRoot));
39+
public ISourceLocation inferRoot(ISourceLocation origin) {
40+
var innerRoot = inferDeepestRoot(origin);
41+
var outerRoot = inferDeepestRoot(URIUtil.getParentLocation(innerRoot));
4242

4343
while (!innerRoot.equals(outerRoot) && isSameProject(innerRoot, outerRoot)) {
4444
innerRoot = outerRoot;
45-
outerRoot = inferDeepestProjectRoot(URIUtil.getParentLocation(innerRoot));
45+
outerRoot = inferDeepestRoot(URIUtil.getParentLocation(innerRoot));
4646
}
4747

4848
return isSameProject(innerRoot, outerRoot)
@@ -59,7 +59,7 @@ private boolean isSameProject(ISourceLocation root1, ISourceLocation root2) {
5959
/**
6060
* Infers the longest project root-like path that `member` is in. Might return a sub-directory of `target/`.
6161
*/
62-
private ISourceLocation inferDeepestProjectRoot(ISourceLocation origin) {
62+
private ISourceLocation inferDeepestRoot(ISourceLocation origin) {
6363
var manifest = new RascalManifest();
6464
var root = origin;
6565

rascal-lsp/src/main/rascal/lsp/lang/rascal/lsp/IDECheckerWrapper.rsc

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ map[loc, set[Message]] checkFile(loc l, set[loc] workspaceFolders, start[Module]
7979
openFileHeader = openFile.top.header.name;
8080
checkForImports = [openFile];
8181
checkedForImports = {};
82-
initialProject = inferProjectRoot(l);
82+
initialProject = inferRoot(l);
8383

8484
rel[loc, loc] dependencies = {};
8585

@@ -88,7 +88,7 @@ map[loc, set[Message]] checkFile(loc l, set[loc] workspaceFolders, start[Module]
8888
while (tree <- checkForImports) {
8989
step2("Calculating imports for <tree.top.header.name>", 1);
9090
currentSrc = tree.src.top;
91-
currentProject = inferProjectRoot(currentSrc);
91+
currentProject = inferRoot(currentSrc);
9292
if (currentProject in workspaceFolders && currentProject.file notin {"rascal", "rascal-lsp"}) {
9393
for (i <- tree.top.header.imports, i has \module) {
9494
modName = "<i.\module>";
@@ -102,7 +102,7 @@ map[loc, set[Message]] checkFile(loc l, set[loc] workspaceFolders, start[Module]
102102
if (mlpt.src.top notin checkedForImports) {
103103
checkForImports += mlpt;
104104
jobTodo("Building dependency graph");
105-
dependencies += <currentProject, inferProjectRoot(mlpt.src.top)>;
105+
dependencies += <currentProject, inferRoot(mlpt.src.top)>;
106106
}
107107
}
108108
}
@@ -123,7 +123,7 @@ map[loc, set[Message]] checkFile(loc l, set[loc] workspaceFolders, start[Module]
123123
if (cyclicDependencies != {}) {
124124
return (l : {error("Cyclic dependencies detected between projects {<intercalate(", ", [*cyclicDependencies])>}. This is not supported. Fix your project setup.", l)});
125125
}
126-
modulesPerProject = classify(checkedForImports, loc(loc l) {return inferProjectRoot(l);});
126+
modulesPerProject = classify(checkedForImports, loc(loc l) {return inferRoot(l);});
127127
msgs = [];
128128

129129
upstreamDependencies = {project | project <- reverse(order(dependencies)), project in modulesPerProject, project != initialProject};
@@ -196,7 +196,7 @@ set[loc] locateRascalModules(str fqn, PathConfig pcfg, PathConfig(loc file) getP
196196
// Check the source directories
197197
return {fileLoc | dir <- pcfg.srcs, fileLoc := dir + fileName, exists(fileLoc)}
198198
// And libraries available in the current workspace
199-
+ {fileLoc | lib <- pcfg.libs, inWorkspace(workspaceFolders, lib), dir <- getPathConfig(inferProjectRoot(lib)).srcs, fileLoc := dir + fileName, exists(fileLoc)};
199+
+ {fileLoc | lib <- pcfg.libs, inWorkspace(workspaceFolders, lib), dir <- getPathConfig(inferRoot(lib)).srcs, fileLoc := dir + fileName, exists(fileLoc)};
200200
}
201201

202202
loc targetToProject(loc l) {
@@ -207,8 +207,8 @@ loc targetToProject(loc l) {
207207
}
208208

209209
@synopsis{Infers the root of the project that `member` is in.}
210-
@javaClass{org.rascalmpl.vscode.lsp.rascal.model.ProjectRoots}
211-
java loc inferProjectRoot(loc member);
210+
@javaClass{org.rascalmpl.vscode.lsp.rascal.model.Projects}
211+
java loc inferRoot(loc member);
212212

213213
map[loc, set[Message]] filterAndFix(list[ModuleMessages] messages, set[loc] workspaceFolders) {
214214
set[Message] empty = {};

rascal-lsp/src/test/java/org/rascalmpl/vscode/lsp/rascal/model/PathConfigsTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,11 @@ public class PathConfigsTest {
4343
private static final IRascalValueFactory VF = IRascalValueFactory.getInstance();
4444
private static final URIResolverRegistry reg = URIResolverRegistry.getInstance();
4545

46-
private final ProjectRoots roots = new ProjectRoots();
46+
private final Projects roots = new Projects();
4747

4848
private void checkRoot(ISourceLocation project, String modulePath) throws URISyntaxException {
4949
var m = VF.sourceLocation(project.getScheme(), project.getAuthority(), project.getPath() + "/" + modulePath);
50-
var root = roots.inferProjectRoot(m);
50+
var root = roots.inferRoot(m);
5151
assertEquals(project, root);
5252
}
5353

0 commit comments

Comments
 (0)