system/src/sc/layer/LayeredSystem.java
public void addAllTypeDeclarations(String typeName, ArrayList<Object> res, boolean openAllLayers, boolean openTypes) {
      Object typeObj;
      if (openTypes)
         typeObj = getSrcTypeDeclaration(typeName, null, true, false, true, openAllLayers ? Layer.ANY_INACTIVE_LAYER : Layer.ANY_OPEN_INACTIVE_LAYER, false);
      else
         typeObj = getCachedTypeDeclaration(typeName, null, null, false, false, openAllLayers ? Layer.ANY_INACTIVE_LAYER : Layer.ANY_OPEN_INACTIVE_LAYER, false);
      if (typeObj != null)
         res.add(typeObj);
      else {
         if (!openTypes) {
            SrcEntry srcEnt = getSrcFileFromTypeName(typeName, true, null, true, null, openAllLayers ? Layer.ANY_INACTIVE_LAYER : Layer.ANY_OPEN_INACTIVE_LAYER, false);
            if (srcEnt != null)
               res.add(srcEnt);
         }

         Layer layer = getLayerByDirName(typeName);
         if (layer != null)
             res.add(layer.model.getModelTypeDeclaration());
         else {
            layer = !openAllLayers ? lookupInactiveLayer(typeName, true, true) :
                                     getInactiveLayer(typeName.replace('.', '/'), openAllLayers, true, true, true);
            if (layer != null && layer.model != null)
               res.add(layer.model.getModelTypeDeclaration());
         }
      }
      /*
      if (peerSystems != null) {
         for (LayeredSystem peerSys:peerSystems) {
            typeObj = peerSys.getSrcTypeDeclaration(typeName, null, true, false, true, Layer.ANY_LAYER, false);
            if (typeObj != null) {
               res.add(typeObj);
            }
         }
      }
      */
      if (typeIndexProcessMap != null) {
         for (Map.Entry<String, SysTypeIndex> indexEnt : typeIndexProcessMap.entrySet()) {
            SysTypeIndex sysIndex = indexEnt.getValue();
            ArrayList<TypeIndexEntry> typeIndexEntries = sysIndex.getTypeIndexes(typeName);
            if (typeIndexEntries != null) {
               for (TypeIndexEntry typeIndexEntry : typeIndexEntries) {
                  Layer layer = openAllLayers ? getInactiveLayerByPath(typeIndexEntry.layerName, null, openAllLayers, true) : lookupInactiveLayer(typeIndexEntry.layerName, true, true);
                  if (layer != null && (!layer.closed || openAllLayers)) {
                     LayeredSystem layerSys = layer.layeredSystem;
                     Object newTypeObj;
                     if (openTypes) {
                        newTypeObj = layerSys.getSrcTypeDeclaration(typeName, layer.getNextLayer(), true, false, true, layer, false);
                     }
                     else {
                        newTypeObj = layerSys.getCachedTypeDeclaration(typeName, null, null, false, false, openAllLayers ? Layer.ANY_INACTIVE_LAYER : Layer.ANY_OPEN_INACTIVE_LAYER, false);
                        if (newTypeObj == null) {
                           SrcEntry srcEnt = layer.getSrcEntryForType(typeName);
                           //SrcEntry srcEnt = layerSys.getSrcFileFromTypeName(typeName, true, null, true, null);
                           if (srcEnt != null)
                              newTypeObj = srcEnt;
                           else {
                              Layer indexLayer = getAllIndexLayer(typeIndexEntry.layerName);
                              if (indexLayer != null) {
                                 String layerPackage = indexLayer.packagePrefix;
                                 if (layerPackage == null)
                                    layerPackage = "";
                                 if (typeName.startsWith(layerPackage) && typeName.length() > layerPackage.length() + 1)  {
                                    String relFileName = layerPackage.length() == 0 ? typeName : typeName.substring(layerPackage.length()+1);
                                    relFileName = FileUtil.addExtension(relFileName.replace('.',FileUtil.FILE_SEPARATOR_CHAR), FileUtil.getExtension(typeIndexEntry.fileName));
                                    newTypeObj = new SrcEntry(indexLayer, typeIndexEntry.fileName, relFileName);
                                 }
                              }
                           }
                        }
                     }
                     if (newTypeObj != null)
                        res.add(newTypeObj);
                  }
                  else {
                     boolean found = false;
                     for (Object resEnt:res) {
                        if (typeIndexEntry.sameType(resEnt)) {
                           found = true;
                           break;
                        }
                     }
                     if (!found)
                        res.add(typeIndexEntry);
                  }
               }
            }
         }
      }
   }
/**
    * For the IDE specifically. when open types is true, returns TypeDeclaration or TypeIndexEntry instances. When openTypes is false,
    * rather than reading the file, it will return the SrcEntry if the file is not already in the cache.
    */
For the IDE specifically. when open types is true, returns TypeDeclaration or TypeIndexEntry instances. When openTypes is false,
rather than reading the file, it will return the SrcEntry if the file is not already in the cache.
For the IDE specifically . when open types is true returns TypeDeclaration or TypeIndexEntry instances . When openTypes is false rather than reading the file it will return the SrcEntry if the file is not already in the cache .
public void addAllTypeDeclarations(String typeName, ArrayList<Object> res, boolean openAllLayers, boolean openTypes) {
      Object typeObj;
      if (openTypes)
         typeObj = getSrcTypeDeclaration(typeName, null, true, false, true, openAllLayers ? Layer.ANY_INACTIVE_LAYER : Layer.ANY_OPEN_INACTIVE_LAYER, false);
      else
         typeObj = getCachedTypeDeclaration(typeName, null, null, false, false, openAllLayers ? Layer.ANY_INACTIVE_LAYER : Layer.ANY_OPEN_INACTIVE_LAYER, false);
      if (typeObj != null)
         res.add(typeObj);
      else {
         if (!openTypes) {
            SrcEntry srcEnt = getSrcFileFromTypeName(typeName, true, null, true, null, openAllLayers ? Layer.ANY_INACTIVE_LAYER : Layer.ANY_OPEN_INACTIVE_LAYER, false);
            if (srcEnt != null)
               res.add(srcEnt);
         }
         Layer layer = getLayerByDirName(typeName);
         if (layer != null)
             res.add(layer.model.getModelTypeDeclaration());
         else {
            layer = !openAllLayers ? lookupInactiveLayer(typeName, true, true) :
                                     getInactiveLayer(typeName.replace('.', '/'), openAllLayers, true, true, true);
            if (layer != null && layer.model != null)
               res.add(layer.model.getModelTypeDeclaration());
         }
      }
      /*
      if (peerSystems != null) {
         for (LayeredSystem peerSys:peerSystems) {
            typeObj = peerSys.getSrcTypeDeclaration(typeName, null, true, false, true, Layer.ANY_LAYER, false);
            if (typeObj != null) {
               res.add(typeObj);
            }
         }
      }
      */
      if (typeIndexProcessMap != null) {
         for (Map.Entry<String, SysTypeIndex> indexEnt : typeIndexProcessMap.entrySet()) {
            SysTypeIndex sysIndex = indexEnt.getValue();
            ArrayList<TypeIndexEntry> typeIndexEntries = sysIndex.getTypeIndexes(typeName);
            if (typeIndexEntries != null) {
               for (TypeIndexEntry typeIndexEntry : typeIndexEntries) {
                  Layer layer = openAllLayers ? getInactiveLayerByPath(typeIndexEntry.layerName, null, openAllLayers, true) : lookupInactiveLayer(typeIndexEntry.layerName, true, true);
                  if (layer != null && (!layer.closed || openAllLayers)) {
                     LayeredSystem layerSys = layer.layeredSystem;
                     Object newTypeObj;
                     if (openTypes) {
                        newTypeObj = layerSys.getSrcTypeDeclaration(typeName, layer.getNextLayer(), true, false, true, layer, false);
                     }
                     else {
                        newTypeObj = layerSys.getCachedTypeDeclaration(typeName, null, null, false, false, openAllLayers ? Layer.ANY_INACTIVE_LAYER : Layer.ANY_OPEN_INACTIVE_LAYER, false);
                        if (newTypeObj == null) {
                           SrcEntry srcEnt = layer.getSrcEntryForType(typeName);
                           if (srcEnt != null)
                              newTypeObj = srcEnt;
                           else {
                              Layer indexLayer = getAllIndexLayer(typeIndexEntry.layerName);
                              if (indexLayer != null) {
                                 String layerPackage = indexLayer.packagePrefix;
                                 if (layerPackage == null)
                                    layerPackage = "";
                                 if (typeName.startsWith(layerPackage) && typeName.length() > layerPackage.length() + 1)  {
                                    String relFileName = layerPackage.length() == 0 ? typeName : typeName.substring(layerPackage.length()+1);
                                    relFileName = FileUtil.addExtension(relFileName.replace('.',FileUtil.FILE_SEPARATOR_CHAR), FileUtil.getExtension(typeIndexEntry.fileName));
                                    newTypeObj = new SrcEntry(indexLayer, typeIndexEntry.fileName, relFileName);
                                 }
                              }
                           }
                        }
                     }
                     if (newTypeObj != null)
                        res.add(newTypeObj);
                  }
                  else {
                     boolean found = false;
                     for (Object resEnt:res) {
                        if (typeIndexEntry.sameType(resEnt)) {
                           found = true;
                           break;
                        }
                     }
                     if (!found)
                        res.add(typeIndexEntry);
                  }
               }
            }
         }
      }
   }
public void addAllTypeDeclarations ( String typeName , ArrayList < Object > res , boolean openAllLayers , boolean openTypes ) { Object typeObj ; if ( openTypes ) typeObj = getSrcTypeDeclaration ( typeName , null , true , false , true , openAllLayers ? Layer . ANY_INACTIVE_LAYER : Layer . ANY_OPEN_INACTIVE_LAYER , false ) ; else typeObj = getCachedTypeDeclaration ( typeName , null , null , false , false , openAllLayers ? Layer . ANY_INACTIVE_LAYER : Layer . ANY_OPEN_INACTIVE_LAYER , false ) ; if ( typeObj != null ) res . add ( typeObj ) ; else { if ( ! openTypes ) { SrcEntry srcEnt = getSrcFileFromTypeName ( typeName , true , null , true , null , openAllLayers ? Layer . ANY_INACTIVE_LAYER : Layer . ANY_OPEN_INACTIVE_LAYER , false ) ; if ( srcEnt != null ) res . add ( srcEnt ) ; } Layer layer = getLayerByDirName ( typeName ) ; if ( layer != null ) res . add ( layer . model . getModelTypeDeclaration ( ) ) ; else { layer = ! openAllLayers ? lookupInactiveLayer ( typeName , true , true ) : getInactiveLayer ( typeName . replace ( '.' , '/' ) , openAllLayers , true , true , true ) ; if ( layer != null && layer . model != null ) res . add ( layer . model . getModelTypeDeclaration ( ) ) ; } } /*
      if (peerSystems != null) {
         for (LayeredSystem peerSys:peerSystems) {
            typeObj = peerSys.getSrcTypeDeclaration(typeName, null, true, false, true, Layer.ANY_LAYER, false);
            if (typeObj != null) {
               res.add(typeObj);
            }
         }
      }
      */ if ( typeIndexProcessMap != null ) { for ( Map . Entry < String , SysTypeIndex > indexEnt : typeIndexProcessMap . entrySet ( ) ) { SysTypeIndex sysIndex = indexEnt . getValue ( ) ; ArrayList < TypeIndexEntry > typeIndexEntries = sysIndex . getTypeIndexes ( typeName ) ; if ( typeIndexEntries != null ) { for ( TypeIndexEntry typeIndexEntry : typeIndexEntries ) { Layer layer = openAllLayers ? getInactiveLayerByPath ( typeIndexEntry . layerName , null , openAllLayers , true ) : lookupInactiveLayer ( typeIndexEntry . layerName , true , true ) ; if ( layer != null && ( ! layer . closed || openAllLayers ) ) { LayeredSystem layerSys = layer . layeredSystem ; Object newTypeObj ; if ( openTypes ) { newTypeObj = layerSys . getSrcTypeDeclaration ( typeName , layer . getNextLayer ( ) , true , false , true , layer , false ) ; } else { newTypeObj = layerSys . getCachedTypeDeclaration ( typeName , null , null , false , false , openAllLayers ? Layer . ANY_INACTIVE_LAYER : Layer . ANY_OPEN_INACTIVE_LAYER , false ) ; if ( newTypeObj == null ) { SrcEntry srcEnt = layer . getSrcEntryForType ( typeName ) ; if ( srcEnt != null ) newTypeObj = srcEnt ; else { Layer indexLayer = getAllIndexLayer ( typeIndexEntry . layerName ) ; if ( indexLayer != null ) { String layerPackage = indexLayer . packagePrefix ; if ( layerPackage == null ) layerPackage = "" ; if ( typeName . startsWith ( layerPackage ) && typeName . length ( ) > layerPackage . length ( ) + 1 ) { String relFileName = layerPackage . length ( ) == 0 ? typeName : typeName . substring ( layerPackage . length ( ) + 1 ) ; relFileName = FileUtil . addExtension ( relFileName . replace ( '.' , FileUtil . FILE_SEPARATOR_CHAR ) , FileUtil . getExtension ( typeIndexEntry . fileName ) ) ; newTypeObj = new SrcEntry ( indexLayer , typeIndexEntry . fileName , relFileName ) ; } } } } } if ( newTypeObj != null ) res . add ( newTypeObj ) ; } else { boolean found = false ; for ( Object resEnt : res ) { if ( typeIndexEntry . sameType ( resEnt ) ) { found = true ; break ; } } if ( ! found ) res . add ( typeIndexEntry ) ; } } } } } }
For the IDE specifically.
For the IDE specifically .
//SrcEntry srcEnt = layerSys.getSrcFileFromTypeName(typeName, true, null, true, null);