Skip to content

Commit

Permalink
Introduce GLOB_KEY constant
Browse files Browse the repository at this point in the history
  • Loading branch information
dnestoro committed May 10, 2024
1 parent efc7e1f commit 0167958
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ public static InputStream openStream(URI uri) throws IOException {
public static final String NAME_KEY = "name";
public static final String TYPE_KEY = "type";
public static final String MODULE_KEY = "module";
public static final String GLOB_KEY = "module";
private final Map<String, Set<String>> seenUnknownAttributesByType = new HashMap<>();
private final boolean strictSchema;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,18 +172,18 @@ private void parsePatternEntry(Object data, BiConsumer<C, String> resourceRegist
}

private void parseGlobEntry(Object data, GlobPatternConsumer<C, String, String> resourceRegistry) {
EconomicMap<String, Object> glob = asMap(data, "Elements of 'globs' list must be a glob descriptor objects");
checkAttributes(glob, "resource and resource bundle descriptor object", Collections.singletonList("glob"), List.of(CONDITIONAL_KEY, MODULE_KEY));
TypeResult<C> resolvedConfigurationCondition = conditionResolver.resolveCondition(parseCondition(glob));
EconomicMap<String, Object> globObject = asMap(data, "Elements of 'globs' list must be a glob descriptor objects");
checkAttributes(globObject, "resource and resource bundle descriptor object", Collections.singletonList(GLOB_KEY), List.of(CONDITIONAL_KEY, MODULE_KEY));
TypeResult<C> resolvedConfigurationCondition = conditionResolver.resolveCondition(parseCondition(globObject));
if (!resolvedConfigurationCondition.isPresent()) {
return;
}

Object moduleObject = glob.get(MODULE_KEY);
Object moduleObject = globObject.get(MODULE_KEY);
String module = moduleObject == null ? "" : asString(moduleObject);

Object valueObject = glob.get("glob");
String value = asString(valueObject, "glob");
Object valueObject = globObject.get(GLOB_KEY);
String value = asString(valueObject, GLOB_KEY);
resourceRegistry.accept(resolvedConfigurationCondition.get(), module, value);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

package com.oracle.svm.hosted;

import static com.oracle.svm.core.configure.ConfigurationFiles.Options.TreatAllReachableConditionsAsReached;
import static com.oracle.svm.core.jdk.Resources.RESOURCES_INTERNAL_PATH_SEPARATOR;

import java.io.IOException;
Expand Down Expand Up @@ -534,15 +535,14 @@ public List<ConfigurationCondition> isIncluded(Module module, String resourceNam
}

private List<ConfigurationCondition> getConditionsFromGlobTrie(Module module, String resourceName) {
// TODO append / if it is a directory
String pattern = GlobUtils.transformToTriePath(resourceName, module == null ? "" : module.getName());
List<String> types = CompressedGlobTrie.getAdditionalContentIfMatched(ImageSingletons.lookup(GlobTrieNode.class), pattern);
if (types == null) {
return Collections.emptyList();
}

return types.stream()
.map(UnresolvedConfigurationCondition::create)
.map(type -> UnresolvedConfigurationCondition.create(type, TreatAllReachableConditionsAsReached.getValue()))
.map(conditionResolver::resolveCondition)
.map(TypeResult::get)
.toList();
Expand Down

0 comments on commit 0167958

Please sign in to comment.