mirror of
https://github.com/apple/pkl.git
synced 2026-01-18 01:17:00 +01:00
Convert org.pkl.core.util POJOs to record classes (#750)
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user