Skip to content
Merged
Changes from all commits
Commits
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
22 changes: 17 additions & 5 deletions src/org/rascalmpl/uri/URIResolverRegistry.java
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,8 @@ else if (loc.hasOffsetLength()) { // the logical location offsets relative to th
* </ul>
*/
private ISourceLocation physicalLocation(@NonNull ISourceLocation loc) throws IOException {
ISourceLocation resolved = null;

var scheme = loc.getScheme();
var resolversByAuth = logicalResolvers.get(scheme);

Expand All @@ -402,7 +404,7 @@ private ISourceLocation physicalLocation(@NonNull ISourceLocation loc) throws IO
throw new UnsupportedAuthorityException(scheme, auth);
}

var resolved = resolveAndFixOffsets(loc, resolver);
resolved = resolveAndFixOffsets(loc, resolver);
if (resolved == null) {
throw new UnsupportedAuthorityException(scheme, auth);
}
Expand All @@ -411,13 +413,23 @@ private ISourceLocation physicalLocation(@NonNull ISourceLocation loc) throws IO
}

// Case: `loc` is known to be logical and has a remote resolver
if (externalRegistry != null && externalRegistry.supportsLogical(scheme)) {
var resolved = resolveAndFixOffsets(loc, externalRegistry);
return resolved != null ? physicalLocation(resolved) : null;
else if (externalRegistry != null && externalRegistry.supportsLogical(scheme)) {
resolved = resolveAndFixOffsets(loc, externalRegistry);
if (resolved == null) {
return resolved;
}
}

// Case: `loc` is unknown to be logical
return loc;
else {
return loc;
}

// At this point, `resolved` cannot be null, but it could still be a logical location (e.g., logical location
// `foo:///` resolves to logical location `bar:///`, which in turn resolves to physical location `file:///`).
assert resolved != null;
var resolvedResolved = physicalLocation(resolved);
return resolvedResolved != null ? resolvedResolved : resolved;
}

private @NonNull ISourceLocation tryResolve(@NonNull ISourceLocation loc) throws IOException {
Expand Down
Loading