if (typeConsApp == null || typeConsApp.isFunctionType()) {
return null;
}
// Check visibility of the type.. (should we do this?)
Perspective perspective = getValueNodeBuilderHelper().getPerspective();
if (perspective.getTypeConstructor(typeConsApp.getName()) == null) {
return null;
}
if (dataConstructor == null) {
// No data constructor provided - we have to pick one, and create a default value.
// If the perspective's working module has changed, the typeExprToNodeMap is no longer valid.
if (perspective.getWorkingModule() != workingModule) {
workingModule = perspective.getWorkingModule();
typeExprToNodeMap.clear();
}
// TODOEL: ~HACK - we use the string-ified value as a key because we want it equals() in the map.
String typeExprString = typeExpr.toString();
// First, check if we've previously created a value node for this expression.
if (typeExprToNodeMap.containsKey(typeExprString)) {
// We've already found a value node for this type, so just return it.
// If we're currently in the process of finding a value node for it, then this
// will end up returning null. That's ok since it indicates to the caller that
// there is a cycle.
DataConstructorValueNode valueNode = typeExprToNodeMap.get(typeExprString);
return valueNode != null ? valueNode.copyValueNode(typeExpr) : null;
} else {
// Add a signal that we are building a value node for this type.
typeExprToNodeMap.put(typeExprString, null);
}
// Iterate over the visible data constructors.
DataConstructor[] dataConsArray = perspective.getDataConstructorsForType(typeConsApp.getName());
if (dataConsArray != null) {
for (final DataConstructor element : dataConsArray) {