Skip to content

Commit

Permalink
fixed weird compiler issue not seen before
Browse files Browse the repository at this point in the history
  • Loading branch information
jurgenvinju committed Nov 16, 2023
1 parent 27b52d1 commit d85f086
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions src/org/rascalmpl/uri/URIResolverRegistry.java
Original file line number Diff line number Diff line change
Expand Up @@ -972,29 +972,30 @@ public void watch(ISourceLocation loc, boolean recursive, final Consumer<ISource
loc = URIUtil.getParentLocation(loc);
}

ISourceLocation resolved = safeResolve(loc);
final ISourceLocation finalLocCopy = loc;
final ISourceLocation resolvedLoc = safeResolve(loc);

Consumer<ISourceLocationChanged> newCallback = !resolved.equals(loc) ?
Consumer<ISourceLocationChanged> newCallback = !resolvedLoc.equals(loc) ?
// we resolved logical resolvers in order to use native watchers as much as possible
// for efficiency sake, but this breaks the logical URI abstraction. We have to undo
// this renaming before we trigger the callback.
changes -> {
ISourceLocation relative = URIUtil.relativize(resolved, changes.getLocation());
ISourceLocation unresolved = URIUtil.getChildLocation(loc, relative.getPath());
ISourceLocation relative = URIUtil.relativize(resolvedLoc, changes.getLocation());
ISourceLocation unresolved = URIUtil.getChildLocation(finalLocCopy, relative.getPath());
callback.accept(ISourceLocationWatcher.makeChange(unresolved, changes.getChangeType(), changes.getType()));
}
: callback;

ISourceLocationWatcher watcher = watchers.getOrDefault(resolved.getScheme(), fallbackWatcher);
ISourceLocationWatcher watcher = watchers.getOrDefault(resolvedLoc.getScheme(), fallbackWatcher);
if (watcher != null) {
watcher.watch(resolved, callback);
watcher.watch(resolvedLoc, callback);
}
else {
watching.computeIfAbsent(resolved, k -> ConcurrentHashMap.newKeySet()).add(newCallback);
watching.computeIfAbsent(resolvedLoc, k -> ConcurrentHashMap.newKeySet()).add(newCallback);
}

if (isDirectory(resolved) && recursive) {
for (ISourceLocation elem : list(resolved)) {
if (isDirectory(resolvedLoc) && recursive) {
for (ISourceLocation elem : list(resolvedLoc)) {
if (isDirectory(elem)) {
try {
watch(elem, recursive, newCallback);
Expand Down

0 comments on commit d85f086

Please sign in to comment.