system/src/sc/layer/SysTypeIndex.java
public void addModifiedTypesOfType(String processIdent, LayeredSystem sys, BodyTypeDeclaration type, boolean before, TreeSet<String> checkedTypes, ArrayList<BodyTypeDeclaration> res) {
      refreshReverseTypeIndex(sys);

      Layer typeLayer = type.getLayer();
      String typeName = type.getFullTypeName();
      ArrayList<TypeIndexEntry> indexEntries = inactiveTypeIndex.modifyTypeIndex.get(typeName);
      int layerIx = -1;

      // First find the current type in the list we've indexed.
      if (indexEntries != null) {
         checkedTypes.add(processIdent);
         int idxPos = 0;
         for (TypeIndexEntry idx:indexEntries) {
            if (idx.layerName != null && typeLayer != null && idx.layerName.equals(typeLayer.getLayerName()) && StringUtil.equalStrings(processIdent, idx.processIdent)) {
               layerIx = idxPos;
               break;
            }
            idxPos++;
         }

         if (layerIx == -1) {
            // Since we search each layered system for each type, we may just not find this type in this layered system so add no entries from it.
            return;
         }

         // Now add each successive entry - those are the possible modifiers.
         for (int i = before ? 0 : layerIx + 1; i < (before ? layerIx : indexEntries.size()); i++) {
            TypeIndexEntry modTypeIndexEntry = indexEntries.get(i);

            // TODO: add a mode which creates stub type declarations when the type has not been loaded so we do not have to parse so much code in this operation.
            // we can use the replaced logic to swap in the new one once it's fetched and/or just populate this one when we need to by parsing it's file.

            // Make sure the index entry matches this process before we go and add it.
            if (StringUtil.equalStrings(modTypeIndexEntry.processIdent, processIdent)) {
               //Layer modLayer = sys.getActiveOrInactiveLayerByPath(modTypeIndexEntry.layerName, null, false, true, true);
               Layer modLayer = sys.getInactiveLayerByPath(modTypeIndexEntry.layerName, null, false, true);
               if (modLayer == null) {
                  System.err.println("*** Warning unable to find modifying layer: " + modTypeIndexEntry.layerName + " - skipping index entyr");
               } else {
                  // The modLayer may not be in the right system but perhaps we've created that system to lookup this layer.  If so, get the right system
                  // and use it
                  Layer typeLayerInSystem;
                  if (!modLayer.layeredSystem.getProcessIdent().equals(processIdent)) {
                     LayeredSystem peerSys = sys.getPeerLayeredSystem(processIdent);
                     if (peerSys == null)
                        continue;
                     modLayer = typeLayerInSystem = peerSys.getSameLayerFromRemote(modLayer);
                     if (modLayer == null || modLayer == Layer.ANY_INACTIVE_LAYER)
                        continue;
                  }
                  else
                     typeLayerInSystem = sys.getInactiveLayerByPath(type.getLayer().getLayerName(), null, false, true);
                  if (typeLayerInSystem != null) {
                     Layer peerLayer = typeLayerInSystem.layeredSystem == modLayer.layeredSystem ? typeLayerInSystem : modLayer.layeredSystem.getSameLayerFromRemote(typeLayerInSystem);
                     if (peerLayer != null) {
                        TypeDeclaration modType = (TypeDeclaration) modLayer.layeredSystem.getSrcTypeDeclaration(typeName, modLayer.getNextLayer(), true, false, true, peerLayer, type.isLayerType || type.isLayerComponent());
                        if (modType != null && modType.getLayer() != null) {
                           if (modType.getLayer().getLayerPosition() > peerLayer.getLayerPosition())
                              res.add(modType);
                        }
                     }
                  } else
                     System.err.println("*** Unable to map layer name from system to the other");
               }
            }
         }
      }
   }
/** Adds the TypeDeclarations of any matching types.  The LayeredSystem passed may be the system or the main system so be careful to use the system from the layer to retrieve the type. */
Adds the TypeDeclarations of any matching types.  The LayeredSystem passed may be the system or the main system so be careful to use the system from the layer to retrieve the type.
Adds the TypeDeclarations of any matching types . The LayeredSystem passed may be the system or the main system so be careful to use the system from the layer to retrieve the type .
public void addModifiedTypesOfType(String processIdent, LayeredSystem sys, BodyTypeDeclaration type, boolean before, TreeSet<String> checkedTypes, ArrayList<BodyTypeDeclaration> res) {
      refreshReverseTypeIndex(sys);
      Layer typeLayer = type.getLayer();
      String typeName = type.getFullTypeName();
      ArrayList<TypeIndexEntry> indexEntries = inactiveTypeIndex.modifyTypeIndex.get(typeName);
      int layerIx = -1;
      if (indexEntries != null) {
         checkedTypes.add(processIdent);
         int idxPos = 0;
         for (TypeIndexEntry idx:indexEntries) {
            if (idx.layerName != null && typeLayer != null && idx.layerName.equals(typeLayer.getLayerName()) && StringUtil.equalStrings(processIdent, idx.processIdent)) {
               layerIx = idxPos;
               break;
            }
            idxPos++;
         }
         if (layerIx == -1) {
            return;
         }
         for (int i = before ? 0 : layerIx + 1; i < (before ? layerIx : indexEntries.size()); i++) {
            TypeIndexEntry modTypeIndexEntry = indexEntries.get(i);
            if (StringUtil.equalStrings(modTypeIndexEntry.processIdent, processIdent)) {
               Layer modLayer = sys.getInactiveLayerByPath(modTypeIndexEntry.layerName, null, false, true);
               if (modLayer == null) {
                  System.err.println("*** Warning unable to find modifying layer: " + modTypeIndexEntry.layerName + " - skipping index entyr");
               } else {
                  Layer typeLayerInSystem;
                  if (!modLayer.layeredSystem.getProcessIdent().equals(processIdent)) {
                     LayeredSystem peerSys = sys.getPeerLayeredSystem(processIdent);
                     if (peerSys == null)
                        continue;
                     modLayer = typeLayerInSystem = peerSys.getSameLayerFromRemote(modLayer);
                     if (modLayer == null || modLayer == Layer.ANY_INACTIVE_LAYER)
                        continue;
                  }
                  else
                     typeLayerInSystem = sys.getInactiveLayerByPath(type.getLayer().getLayerName(), null, false, true);
                  if (typeLayerInSystem != null) {
                     Layer peerLayer = typeLayerInSystem.layeredSystem == modLayer.layeredSystem ? typeLayerInSystem : modLayer.layeredSystem.getSameLayerFromRemote(typeLayerInSystem);
                     if (peerLayer != null) {
                        TypeDeclaration modType = (TypeDeclaration) modLayer.layeredSystem.getSrcTypeDeclaration(typeName, modLayer.getNextLayer(), true, false, true, peerLayer, type.isLayerType || type.isLayerComponent());
                        if (modType != null && modType.getLayer() != null) {
                           if (modType.getLayer().getLayerPosition() > peerLayer.getLayerPosition())
                              res.add(modType);
                        }
                     }
                  } else
                     System.err.println("*** Unable to map layer name from system to the other");
               }
            }
         }
      }
   }
public void addModifiedTypesOfType ( String processIdent , LayeredSystem sys , BodyTypeDeclaration type , boolean before , TreeSet < String > checkedTypes , ArrayList < BodyTypeDeclaration > res ) { refreshReverseTypeIndex ( sys ) ; Layer typeLayer = type . getLayer ( ) ; String typeName = type . getFullTypeName ( ) ; ArrayList < TypeIndexEntry > indexEntries = inactiveTypeIndex . modifyTypeIndex . get ( typeName ) ; int layerIx = - 1 ; if ( indexEntries != null ) { checkedTypes . add ( processIdent ) ; int idxPos = 0 ; for ( TypeIndexEntry idx : indexEntries ) { if ( idx . layerName != null && typeLayer != null && idx . layerName . equals ( typeLayer . getLayerName ( ) ) && StringUtil . equalStrings ( processIdent , idx . processIdent ) ) { layerIx = idxPos ; break ; } idxPos ++ ; } if ( layerIx == - 1 ) { return ; } for ( int i = before ? 0 : layerIx + 1 ; i < ( before ? layerIx : indexEntries . size ( ) ) ; i ++ ) { TypeIndexEntry modTypeIndexEntry = indexEntries . get ( i ) ; if ( StringUtil . equalStrings ( modTypeIndexEntry . processIdent , processIdent ) ) { Layer modLayer = sys . getInactiveLayerByPath ( modTypeIndexEntry . layerName , null , false , true ) ; if ( modLayer == null ) { System . err . println ( "*** Warning unable to find modifying layer: " + modTypeIndexEntry . layerName + " - skipping index entyr" ) ; } else { Layer typeLayerInSystem ; if ( ! modLayer . layeredSystem . getProcessIdent ( ) . equals ( processIdent ) ) { LayeredSystem peerSys = sys . getPeerLayeredSystem ( processIdent ) ; if ( peerSys == null ) continue ; modLayer = typeLayerInSystem = peerSys . getSameLayerFromRemote ( modLayer ) ; if ( modLayer == null || modLayer == Layer . ANY_INACTIVE_LAYER ) continue ; } else typeLayerInSystem = sys . getInactiveLayerByPath ( type . getLayer ( ) . getLayerName ( ) , null , false , true ) ; if ( typeLayerInSystem != null ) { Layer peerLayer = typeLayerInSystem . layeredSystem == modLayer . layeredSystem ? typeLayerInSystem : modLayer . layeredSystem . getSameLayerFromRemote ( typeLayerInSystem ) ; if ( peerLayer != null ) { TypeDeclaration modType = ( TypeDeclaration ) modLayer . layeredSystem . getSrcTypeDeclaration ( typeName , modLayer . getNextLayer ( ) , true , false , true , peerLayer , type . isLayerType || type . isLayerComponent ( ) ) ; if ( modType != null && modType . getLayer ( ) != null ) { if ( modType . getLayer ( ) . getLayerPosition ( ) > peerLayer . getLayerPosition ( ) ) res . add ( modType ) ; } } } else System . err . println ( "*** Unable to map layer name from system to the other" ) ; } } } } }
Adds the TypeDeclarations of any matching types.
Adds the TypeDeclarations of any matching types .
// First find the current type in the list we've indexed. // Since we search each layered system for each type, we may just not find this type in this layered system so add no entries from it. // Now add each successive entry - those are the possible modifiers. // TODO: add a mode which creates stub type declarations when the type has not been loaded so we do not have to parse so much code in this operation. // we can use the replaced logic to swap in the new one once it's fetched and/or just populate this one when we need to by parsing it's file. // Make sure the index entry matches this process before we go and add it. //Layer modLayer = sys.getActiveOrInactiveLayerByPath(modTypeIndexEntry.layerName, null, false, true, true); // The modLayer may not be in the right system but perhaps we've created that system to lookup this layer.  If so, get the right system // and use it