mirror of
https://github.com/apple/pkl.git
synced 2026-04-20 07:21:32 +02: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) {
|
private VmTyped importModule(VmObjectLike mapping, String path) {
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
var globElements = (Map<String, ResolvedGlobElement>) mapping.getExtraStorage();
|
var globElements = (Map<String, ResolvedGlobElement>) mapping.getExtraStorage();
|
||||||
var importUri = globElements.get(path).getUri();
|
var importUri = globElements.get(path).uri();
|
||||||
var context = VmContext.get(this);
|
var context = VmContext.get(this);
|
||||||
try {
|
try {
|
||||||
context.getSecurityManager().checkImportModule(currentModule.getUri(), importUri);
|
context.getSecurityManager().checkImportModule(currentModule.getUri(), importUri);
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ public class ReadGlobMemberBodyNode extends ExpressionNode {
|
|||||||
private Object readResource(VmObjectLike mapping, String path) {
|
private Object readResource(VmObjectLike mapping, String path) {
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
var globElements = (Map<String, ResolvedGlobElement>) mapping.getExtraStorage();
|
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);
|
var resource = VmContext.get(this).getResourceManager().read(resourceUri, this).orElse(null);
|
||||||
if (resource == null) {
|
if (resource == null) {
|
||||||
CompilerDirectives.transferToInterpreter();
|
CompilerDirectives.transferToInterpreter();
|
||||||
|
|||||||
@@ -114,7 +114,7 @@ public class VmImportAnalyzer {
|
|||||||
entry.stringValue());
|
entry.stringValue());
|
||||||
var globImports =
|
var globImports =
|
||||||
elements.values().stream()
|
elements.values().stream()
|
||||||
.map(ResolvedGlobElement::getUri)
|
.map(ResolvedGlobElement::uri)
|
||||||
.map(ImportGraph.Import::new)
|
.map(ImportGraph.Import::new)
|
||||||
.toList();
|
.toList();
|
||||||
result.addAll(globImports);
|
result.addAll(globImports);
|
||||||
|
|||||||
@@ -45,29 +45,12 @@ public final class GlobResolver {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final class ResolvedGlobElement {
|
public record ResolvedGlobElement(String path, URI uri, boolean isDirectory) {
|
||||||
private final String path;
|
|
||||||
|
|
||||||
private final URI uri;
|
|
||||||
private final boolean isDirectory;
|
|
||||||
|
|
||||||
public ResolvedGlobElement(String path, URI uri, boolean isDirectory) {
|
public ResolvedGlobElement(String path, URI uri, boolean isDirectory) {
|
||||||
this.path = path;
|
this.path = path;
|
||||||
this.uri = uri.normalize();
|
this.uri = uri.normalize();
|
||||||
this.isDirectory = isDirectory;
|
this.isDirectory = isDirectory;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getPath() {
|
|
||||||
return path;
|
|
||||||
}
|
|
||||||
|
|
||||||
public URI getUri() {
|
|
||||||
return uri;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isDirectory() {
|
|
||||||
return isDirectory;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final char NULL = 0;
|
private static final char NULL = 0;
|
||||||
@@ -434,15 +417,15 @@ public final class GlobResolver {
|
|||||||
listElementCallCount);
|
listElementCallCount);
|
||||||
for (var element : matchedElements) {
|
for (var element : matchedElements) {
|
||||||
if (isLeaf) {
|
if (isLeaf) {
|
||||||
result.put(element.getPath(), element);
|
result.put(element.path(), element);
|
||||||
} else if (element.isDirectory()) {
|
} else if (element.isDirectory()) {
|
||||||
resolveHierarchicalGlob(
|
resolveHierarchicalGlob(
|
||||||
securityManager,
|
securityManager,
|
||||||
reader,
|
reader,
|
||||||
globPatternParts,
|
globPatternParts,
|
||||||
idx + 1,
|
idx + 1,
|
||||||
element.getUri(),
|
element.uri(),
|
||||||
element.getPath(),
|
element.path(),
|
||||||
hasAbsoluteGlob,
|
hasAbsoluteGlob,
|
||||||
result,
|
result,
|
||||||
listElementCallCount);
|
listElementCallCount);
|
||||||
|
|||||||
@@ -48,15 +48,7 @@ public abstract class YamlResolver implements ScalarResolver {
|
|||||||
return Tag.STR;
|
return Tag.STR;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final class ResolverTuple {
|
private record ResolverTuple(Tag tag, Pattern regexp) {
|
||||||
private final Tag tag;
|
|
||||||
private final Pattern regexp;
|
|
||||||
|
|
||||||
ResolverTuple(Tag tag, Pattern regexp) {
|
|
||||||
this.tag = tag;
|
|
||||||
this.regexp = regexp;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "Tuple tag=" + tag + " regexp=" + regexp;
|
return "Tuple tag=" + tag + " regexp=" + regexp;
|
||||||
|
|||||||
Reference in New Issue
Block a user