From 810c84121b96295c79422f3971e6af6cf66d9cb5 Mon Sep 17 00:00:00 2001 From: Rodin Aarssen Date: Fri, 13 Dec 2024 16:25:58 +0100 Subject: [PATCH 1/4] Fixed logic around the fallback resolver returning null while resolving locations --- src/org/rascalmpl/uri/URIResolverRegistry.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/org/rascalmpl/uri/URIResolverRegistry.java b/src/org/rascalmpl/uri/URIResolverRegistry.java index 258fc34dd9c..9b35b998e8c 100644 --- a/src/org/rascalmpl/uri/URIResolverRegistry.java +++ b/src/org/rascalmpl/uri/URIResolverRegistry.java @@ -404,7 +404,8 @@ private ISourceLocation physicalLocation(ISourceLocation loc) throws IOException } var fallBack = fallbackLogicalResolver; if (fallBack != null) { - return resolveAndFixOffsets(loc == null ? original : loc, fallBack, Collections.emptyList()); + var fallbackResult = resolveAndFixOffsets(loc == null ? original : loc, fallBack, Collections.emptyList()); + return fallbackResult == null ? loc : fallbackResult; } return loc; } From aea1af5d701e41fa98a9bf55d3f4a8dc59b78dc2 Mon Sep 17 00:00:00 2001 From: Rodin Aarssen Date: Mon, 16 Dec 2024 15:11:59 +0100 Subject: [PATCH 2/4] Accounted for another edge case around the fallback resolver. Thanks @DavyLandman --- src/org/rascalmpl/uri/URIResolverRegistry.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/org/rascalmpl/uri/URIResolverRegistry.java b/src/org/rascalmpl/uri/URIResolverRegistry.java index 9b35b998e8c..a3ac007e83c 100644 --- a/src/org/rascalmpl/uri/URIResolverRegistry.java +++ b/src/org/rascalmpl/uri/URIResolverRegistry.java @@ -402,9 +402,11 @@ private ISourceLocation physicalLocation(ISourceLocation loc) throws IOException ILogicalSourceLocationResolver resolver = map.get(auth); loc = resolveAndFixOffsets(loc, resolver, map.values()); } - var fallBack = fallbackLogicalResolver; - if (fallBack != null) { - var fallbackResult = resolveAndFixOffsets(loc == null ? original : loc, fallBack, Collections.emptyList()); + if (loc == null) { + loc = original; + } + if (fallbackLogicalResolver != null) { + var fallbackResult = resolveAndFixOffsets(loc == null ? original : loc, fallbackLogicalResolver, Collections.emptyList()); return fallbackResult == null ? loc : fallbackResult; } return loc; From 9e1edde8b602fe5649eb77773a4c4ed424d74100 Mon Sep 17 00:00:00 2001 From: Rodin Aarssen Date: Mon, 16 Dec 2024 15:33:57 +0100 Subject: [PATCH 3/4] Improved handling of an edge case around the fallback resolver. --- src/org/rascalmpl/uri/URIResolverRegistry.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/org/rascalmpl/uri/URIResolverRegistry.java b/src/org/rascalmpl/uri/URIResolverRegistry.java index a3ac007e83c..ebb5852a1f0 100644 --- a/src/org/rascalmpl/uri/URIResolverRegistry.java +++ b/src/org/rascalmpl/uri/URIResolverRegistry.java @@ -406,7 +406,7 @@ private ISourceLocation physicalLocation(ISourceLocation loc) throws IOException loc = original; } if (fallbackLogicalResolver != null) { - var fallbackResult = resolveAndFixOffsets(loc == null ? original : loc, fallbackLogicalResolver, Collections.emptyList()); + var fallbackResult = resolveAndFixOffsets(loc, fallbackLogicalResolver, Collections.emptyList()); return fallbackResult == null ? loc : fallbackResult; } return loc; From 5a64534fca235bd30af643c0de56c281192c7b07 Mon Sep 17 00:00:00 2001 From: Rodin Aarssen Date: Wed, 18 Dec 2024 10:12:22 +0100 Subject: [PATCH 4/4] Improved handling of an edge case around the fallback resolver. --- src/org/rascalmpl/uri/URIResolverRegistry.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/org/rascalmpl/uri/URIResolverRegistry.java b/src/org/rascalmpl/uri/URIResolverRegistry.java index ebb5852a1f0..9051eb8c764 100644 --- a/src/org/rascalmpl/uri/URIResolverRegistry.java +++ b/src/org/rascalmpl/uri/URIResolverRegistry.java @@ -402,11 +402,9 @@ private ISourceLocation physicalLocation(ISourceLocation loc) throws IOException ILogicalSourceLocationResolver resolver = map.get(auth); loc = resolveAndFixOffsets(loc, resolver, map.values()); } - if (loc == null) { - loc = original; - } + if (fallbackLogicalResolver != null) { - var fallbackResult = resolveAndFixOffsets(loc, fallbackLogicalResolver, Collections.emptyList()); + var fallbackResult = resolveAndFixOffsets(loc == null ? original : loc, fallbackLogicalResolver, Collections.emptyList()); return fallbackResult == null ? loc : fallbackResult; } return loc;