Convert org.pkl.core.util POJOs to record classes (#750)

This commit is contained in:
Kushal Pisavadia
2024-11-11 18:00:33 +00:00
committed by GitHub
parent 0d199892b8
commit ff60f61cbb
5 changed files with 8 additions and 33 deletions

View File

@@ -54,7 +54,7 @@ public final class ImportGlobMemberBodyNode extends ExpressionNode {
private VmTyped importModule(VmObjectLike mapping, String path) {
@SuppressWarnings("unchecked")
var globElements = (Map<String, ResolvedGlobElement>) mapping.getExtraStorage();
var importUri = globElements.get(path).getUri();
var importUri = globElements.get(path).uri();
var context = VmContext.get(this);
try {
context.getSecurityManager().checkImportModule(currentModule.getUri(), importUri);

View File

@@ -41,7 +41,7 @@ public class ReadGlobMemberBodyNode extends ExpressionNode {
private Object readResource(VmObjectLike mapping, String path) {
@SuppressWarnings("unchecked")
var globElements = (Map<String, ResolvedGlobElement>) mapping.getExtraStorage();
var resourceUri = VmUtils.getMapValue(globElements, path).getUri();
var resourceUri = VmUtils.getMapValue(globElements, path).uri();
var resource = VmContext.get(this).getResourceManager().read(resourceUri, this).orElse(null);
if (resource == null) {
CompilerDirectives.transferToInterpreter();

View File

@@ -114,7 +114,7 @@ public class VmImportAnalyzer {
entry.stringValue());
var globImports =
elements.values().stream()
.map(ResolvedGlobElement::getUri)
.map(ResolvedGlobElement::uri)
.map(ImportGraph.Import::new)
.toList();
result.addAll(globImports);

View File

@@ -45,29 +45,12 @@ public final class GlobResolver {
}
}
public static final class ResolvedGlobElement {
private final String path;
private final URI uri;
private final boolean isDirectory;
public record ResolvedGlobElement(String path, URI uri, boolean isDirectory) {
public ResolvedGlobElement(String path, URI uri, boolean isDirectory) {
this.path = path;
this.uri = uri.normalize();
this.isDirectory = isDirectory;
}
public String getPath() {
return path;
}
public URI getUri() {
return uri;
}
public boolean isDirectory() {
return isDirectory;
}
}
private static final char NULL = 0;
@@ -434,15 +417,15 @@ public final class GlobResolver {
listElementCallCount);
for (var element : matchedElements) {
if (isLeaf) {
result.put(element.getPath(), element);
result.put(element.path(), element);
} else if (element.isDirectory()) {
resolveHierarchicalGlob(
securityManager,
reader,
globPatternParts,
idx + 1,
element.getUri(),
element.getPath(),
element.uri(),
element.path(),
hasAbsoluteGlob,
result,
listElementCallCount);

View File

@@ -48,15 +48,7 @@ public abstract class YamlResolver implements ScalarResolver {
return Tag.STR;
}
private static final class ResolverTuple {
private final Tag tag;
private final Pattern regexp;
ResolverTuple(Tag tag, Pattern regexp) {
this.tag = tag;
this.regexp = regexp;
}
private record ResolverTuple(Tag tag, Pattern regexp) {
@Override
public String toString() {
return "Tuple tag=" + tag + " regexp=" + regexp;