system/src/sc/lang/java/BodyTypeDeclaration.java
public BodyTypeDeclaration refreshNode() {
      JavaModel myModel = getJavaModel();
      if (myModel == null)
         return this;
      // Or we can look our replacement up...
      if (isLayerType()) {
         JavaModel layerModel = myModel.layeredSystem.getAnnotatedLayerModel(getTypeName().replace(".", "/"), null);
         if (layerModel != null)
            return layerModel.getModelTypeDeclaration();
         return this;
      }

      if (removed) { // For live types we have a ref to the replacement
         if (replacedByType == null)
            return null;
         return replacedByType.refreshNode();
      }
      LayeredSystem sys = myModel.getLayeredSystem();
      if (sys == null)
         return this;
      JavaModel newModel = (JavaModel) sys.getAnnotatedModel(myModel.getSrcFile());
      if (newModel == myModel)
         return this;
      if (newModel == null)
         newModel = myModel;

      // First see if we can find this new type as part of the new model since that's the most accurate way to refresh the type
      String innerTypeName = getInnerTypeName();
      Object res = newModel.getTypeDeclaration(innerTypeName);
      if (res instanceof BodyTypeDeclaration)
         return (BodyTypeDeclaration) res;

      // Otherwise, we can try to find this type by name using the ref layer
      Layer newModelLayer = newModel.getLayer();
      res = newModel.layeredSystem.getSrcTypeDeclaration(getFullTypeName(), newModelLayer == null ? null : newModelLayer.getNextLayer(), true, false, false, newModelLayer, newModel.isLayerModel);
      if (res instanceof TypeDeclaration) {
         TypeDeclaration newType = (TypeDeclaration) res;
         Layer newTypeLayer = newType.getLayer();
         Layer thisLayer = getLayer();
         // We might switch from an inactive layer to an active layer, or maybe the layers themselves were reloaded?
         if (newTypeLayer != null && (thisLayer == null || newTypeLayer.getLayerName().equals(thisLayer.getLayerName())))
            return (TypeDeclaration) res;
         return this;
      }
      displayError("Type removed: ", getFullTypeName(), " for ");
      // TODO - remove for debugging
      res = newModel.layeredSystem.getSrcTypeDeclaration(getFullTypeName(), null, true,  false, false, newModel.layer, newModel.isLayerModel);
      return null;
   }
/**
    * This method is used by the IDE when it wants to convert this type declaration (which it might find in a reference) with the
    * version of this type managed in the IDE.  It uses the getAnnotatedModel method to find the right model, then looks for this
    * type in that layered system (since we know by then that the model in that system is annotated .
    */
This method is used by the IDE when it wants to convert this type declaration (which it might find in a reference) with the
version of this type managed in the IDE.  It uses the getAnnotatedModel method to find the right model, then looks for this
type in that layered system (since we know by then that the model in that system is annotated .
This method is used by the IDE when it wants to convert this type declaration ( which it might find in a reference ) with the version of this type managed in the IDE . It uses the getAnnotatedModel method to find the right model then looks for this type in that layered system ( since we know by then that the model in that system is annotated .
public BodyTypeDeclaration refreshNode() {
      JavaModel myModel = getJavaModel();
      if (myModel == null)
         return this;
      if (isLayerType()) {
         JavaModel layerModel = myModel.layeredSystem.getAnnotatedLayerModel(getTypeName().replace(".", "/"), null);
         if (layerModel != null)
            return layerModel.getModelTypeDeclaration();
         return this;
      }
      if (removed) { 
         if (replacedByType == null)
            return null;
         return replacedByType.refreshNode();
      }
      LayeredSystem sys = myModel.getLayeredSystem();
      if (sys == null)
         return this;
      JavaModel newModel = (JavaModel) sys.getAnnotatedModel(myModel.getSrcFile());
      if (newModel == myModel)
         return this;
      if (newModel == null)
         newModel = myModel;
      String innerTypeName = getInnerTypeName();
      Object res = newModel.getTypeDeclaration(innerTypeName);
      if (res instanceof BodyTypeDeclaration)
         return (BodyTypeDeclaration) res;
      Layer newModelLayer = newModel.getLayer();
      res = newModel.layeredSystem.getSrcTypeDeclaration(getFullTypeName(), newModelLayer == null ? null : newModelLayer.getNextLayer(), true, false, false, newModelLayer, newModel.isLayerModel);
      if (res instanceof TypeDeclaration) {
         TypeDeclaration newType = (TypeDeclaration) res;
         Layer newTypeLayer = newType.getLayer();
         Layer thisLayer = getLayer();
         if (newTypeLayer != null && (thisLayer == null || newTypeLayer.getLayerName().equals(thisLayer.getLayerName())))
            return (TypeDeclaration) res;
         return this;
      }
      displayError("Type removed: ", getFullTypeName(), " for ");
      res = newModel.layeredSystem.getSrcTypeDeclaration(getFullTypeName(), null, true,  false, false, newModel.layer, newModel.isLayerModel);
      return null;
   }
public BodyTypeDeclaration refreshNode ( ) { JavaModel myModel = getJavaModel ( ) ; if ( myModel == null ) return this ; if ( isLayerType ( ) ) { JavaModel layerModel = myModel . layeredSystem . getAnnotatedLayerModel ( getTypeName ( ) . replace ( "." , "/" ) , null ) ; if ( layerModel != null ) return layerModel . getModelTypeDeclaration ( ) ; return this ; } if ( removed ) { if ( replacedByType == null ) return null ; return replacedByType . refreshNode ( ) ; } LayeredSystem sys = myModel . getLayeredSystem ( ) ; if ( sys == null ) return this ; JavaModel newModel = ( JavaModel ) sys . getAnnotatedModel ( myModel . getSrcFile ( ) ) ; if ( newModel == myModel ) return this ; if ( newModel == null ) newModel = myModel ; String innerTypeName = getInnerTypeName ( ) ; Object res = newModel . getTypeDeclaration ( innerTypeName ) ; if ( res instanceof BodyTypeDeclaration ) return ( BodyTypeDeclaration ) res ; Layer newModelLayer = newModel . getLayer ( ) ; res = newModel . layeredSystem . getSrcTypeDeclaration ( getFullTypeName ( ) , newModelLayer == null ? null : newModelLayer . getNextLayer ( ) , true , false , false , newModelLayer , newModel . isLayerModel ) ; if ( res instanceof TypeDeclaration ) { TypeDeclaration newType = ( TypeDeclaration ) res ; Layer newTypeLayer = newType . getLayer ( ) ; Layer thisLayer = getLayer ( ) ; if ( newTypeLayer != null && ( thisLayer == null || newTypeLayer . getLayerName ( ) . equals ( thisLayer . getLayerName ( ) ) ) ) return ( TypeDeclaration ) res ; return this ; } displayError ( "Type removed: " , getFullTypeName ( ) , " for " ) ; res = newModel . layeredSystem . getSrcTypeDeclaration ( getFullTypeName ( ) , null , true , false , false , newModel . layer , newModel . isLayerModel ) ; return null ; }
This method is used by the IDE when it wants to convert this type declaration (which it might find in a reference) with the
 version of this type managed in the IDE.
This method is used by the IDE when it wants to convert this type declaration ( which it might find in a reference ) with the version of this type managed in the IDE .
// Or we can look our replacement up... // For live types we have a ref to the replacement // First see if we can find this new type as part of the new model since that's the most accurate way to refresh the type // Otherwise, we can try to find this type by name using the ref layer // We might switch from an inactive layer to an active layer, or maybe the layers themselves were reloaded? // TODO - remove for debugging