Skip to content
Snippets Groups Projects
Commit 8eec1cf4 authored by René Schöne's avatar René Schöne
Browse files

Fix property resolving.

parent d8d3e817
No related branches found
No related tags found
No related merge requests found
...@@ -189,7 +189,7 @@ aspect Navigation { ...@@ -189,7 +189,7 @@ aspect Navigation {
return Optional.of(instance); return Optional.of(instance);
} }
} }
return Optional.empty(); return getResourceRequirement().resolveInstance(name);
} }
syn Optional<Instance> ResourceRequirement.resolveInstance(String name) { syn Optional<Instance> ResourceRequirement.resolveInstance(String name) {
...@@ -281,27 +281,41 @@ aspect Navigation { ...@@ -281,27 +281,41 @@ aspect Navigation {
} }
} }
} }
// if no component instance has been found, look for a resource instance // if no component instance has been found, look for a resource instance
ResourceRequirement currentRequirement = null; ResourceRequirement currentRequirement = null;
Instance currentInstance = null; Instance currentInstance = null;
// first resolve the instance
Optional<Instance> hwInstance;
// resolve all names but the last (which is a property)
for (int currentName = 0; currentName < qn.getNumName() - 1; currentName++) { for (int currentName = 0; currentName < qn.getNumName() - 1; currentName++) {
if (currentRequirement == null) { if (currentRequirement == null) {
currentRequirement = getResourceRequirement(); hwInstance = resolveInstance(instanceName);
// TODO this has to be extended if the one resource requirement there is has more than one instance if (!hwInstance.isPresent()) {
currentInstance = getResourceRequirement().getInstance(0); // instance can not be resolved -> bad
} else { logger.error("Could not resolve first instance {}", instanceName);
for (ResourceRequirement newResourceRequirement : currentRequirement.getResourceRequirementList()) return null;
for (Instance instance : newResourceRequirement.getInstanceList()) {
if (instance.name().equals(qn.getName(currentName).getName())) {
currentRequirement = newResourceRequirement;
currentInstance = instance;
} }
currentInstance = hwInstance.get();
currentRequirement = currentInstance.containingResourceRequirement();
} else {
hwInstance = currentRequirement.resolveInstance(qn.getName(currentName).getName());
if (!hwInstance.isPresent()) {
// instance can not be resolved -> bad
logger.error("Could not resolve {}th instance {}", currentName, qn.getName(currentName).getName());
return null;
} }
currentInstance = hwInstance.get();
currentRequirement = currentInstance.containingResourceRequirement();
} }
} }
// now, currentRequirement refers to the final resource type // now, currentRequirement refers to the final resource type
return new PropertyResourceDesignator(currentInstance.createRef(), currentRequirement.getResourceTypeRef().getRef().resolveProperty(qn.getName(qn.getNumName()-1).getName()).get().createRef()); Optional<Property> resolvedProperty = currentRequirement.getResourceTypeRef().getRef().resolveProperty(qn.getName(qn.getNumName() - 1).getName());
if (resolvedProperty.isPresent()) {
return new PropertyResourceDesignator(currentInstance.createRef(), resolvedProperty.get().createRef());
}
logger.error("Could not resolve property {}", qn);
return null;
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment