Example #1
0
 /**
  * Creates two big maps that associate names to their entities.
  *
  * @param anchor a scope to start scanning from
  */
 private void collectEntitiesByName(Scope<? extends Entity> anchor) {
   // Go through the aggregates
   for (ContainedConnection<? extends Entity, Aggregate> connection : anchor.getAggregates()) {
     collectContained(connection);
     // - descend
     Aggregate aggregate = connection.getContained();
     collectEntitiesByName(aggregate.getScope());
   }
   // Go through aliases
   for (ContainedConnection<? extends Entity, Alias> connection : anchor.getAliass()) {
     collectContained(connection);
   }
   // Go through enumerated types
   for (ContainedConnection<? extends Entity, sourceanalysis.Enum> connection :
       anchor.getEnums()) {
     collectContained(connection);
   }
   // Even go through constant data members
   for (ContainedConnection<? extends Entity, Field> connection : anchor.getFields()) {
     Field field = connection.getContained();
     try {
       Type type = field.getType();
       if (type.isFlat() && type.isConst() && type.getBaseType() instanceof Primitive)
         collectContained(connection);
     } catch (MissingInformationException e) {
       // Fields with no type are ignored
     }
   }
   // Look in inner namespace scopes
   for (ContainedConnection<? extends Entity, Namespace> connection : anchor.getNamespaces()) {
     // - descend
     Namespace namespace = connection.getContained();
     collectEntitiesByName(namespace.getScope());
   }
 }
Example #2
0
 /**
  * Attempts repair of a type expression using knowledge gathered from the collection in the two
  * name maps. This includes filling missing cross-references by fulfilling the references using
  * the maps.
  *
  * @param type original type expression
  * @param origin specifies the context in which this type expression occurs (class or namespace)
  * @return Type repaired type expression
  */
 public Type repairType(Type type, Entity origin) {
   try {
     return Type.transformType(type, new OrphanTypeRepair(origin));
   } catch (InappropriateKindException e) {
     System.err.println("*** WARNING: inconsistent type expression " + type);
     return type;
   }
 }
Example #3
0
 /**
  * Examines type, checking if there is a reason to suspect that type as one that requires repair.
  * A type may require repair if any of the base entities involved are "hanging", that is, have no
  * container. Since all the entities in the program database are contained in the global
  * namespace, at least, entity name might have to be resolved.
  *
  * @param type type expression
  * @return boolean <b>true</b> for suspicious types
  */
 public boolean isSuspicious(Type type) {
   // Check root of type
   Type.TypeNode root = type.getRootNode();
   if (root == null) return false;
   else return isSuspicious(root);
 }