system/src/sc/layer/LayeredSystem.java
private Object initModelForBuild(SrcEntry toGenEnt, Layer genLayer, boolean incrCompile, BuildState bd, BuildPhase phase, String defaultReason) {
      Object modelObj;
      IFileProcessor proc = getFileProcessorForSrcEnt(toGenEnt, phase, false);
      if (proc == null)
         return null; // possibly not processed in this phase
      if (proc.getProducesTypes()) {
         // We may have already parsed and initialized this component from a reference.
         TypeDeclaration cachedType = getCachedTypeDeclaration(proc.getPrependLayerPackage() ? toGenEnt.getTypeName() : toGenEnt.getRelTypeName(), toGenEnt.layer.getNextLayer(), null, false, false, null, false);
         // Make sure it's from the right layer
         if (cachedType != null && cachedType.getLayer() == toGenEnt.layer)
            modelObj = cachedType;
         else
            modelObj = null;
      }
      else
         modelObj = null;

      if (modelObj == null) {
         ILanguageModel langModel = getLanguageModel(toGenEnt);
         // Checking the model cache again for those cases where there are no types involved and the model was cloned from another runtime (faster than reparsing it again)
         modelObj = langModel;
         if (modelObj instanceof JavaModel) {
            JavaModel tempModel = (JavaModel) modelObj;
            if (tempModel.getLayer() != toGenEnt.layer)
               System.err.println("*** Mismatching layers in started model");
         }
         if (modelObj == null) {
            if (options.verbose) {
               String procReason = "";
               if (incrCompile) {
                  SrcEntry depEnt = bd.dependentFilesChanged.get(toGenEnt);
                  procReason = depEnt == null ? (bd.modifiedFiles.contains(toGenEnt) ? ": source file changed" : defaultReason) : ": dependent file changed: " + depEnt;
               }
               verbose("Preparing " + toGenEnt + procReason + ", runtime: " + getRuntimeName());
            }

            modelObj = parseSrcType(toGenEnt, genLayer.getNextLayer(), false, true);
            //modelObj = parseSrcType(toGenEnt, null);
         }
         else {
            if (!langModel.isInitialized())
               ParseUtil.initComponent(langModel);
            if (!langModel.isAdded())
               addNewModel(langModel, genLayer.getNextLayer(), null, null, langModel instanceof JavaModel && ((JavaModel) langModel).isLayerModel, false);

            verbose("Preparing from model cache " + toGenEnt + ", runtime: " + getRuntimeName());
         }
      }
      // Parsed it and there was an error
      else if (modelObj == INVALID_TYPE_DECLARATION_SENTINEL || modelObj == IFileProcessor.FILE_OVERRIDDEN_SENTINEL)
         return modelObj;
      else {
         TypeDeclaration modelType = (TypeDeclaration) modelObj;

         JavaModel model = modelType.getJavaModel();
         model.dependenciesChanged();
         modelObj = model;
         // If we are not starting anything, we won't be resolving the errors
         if (options.verbose && !modelType.isStarted()) {
            String modelTypeName = modelType.getFullTypeName();
            // This happens now that we build previous layers, put their classes in so they are there for the next layer
            //if (!model.getLayer().annotationLayer && !genLayer.layerUniqueName.equals("sc") && getClass(modelTypeName) != null)
            //   System.err.println("*** Warning - generated type: " + modelTypeName + " exists in the system classpath ");
            verbose("Preparing from cache " + toGenEnt);
         }
      }

      return modelObj;
   }
/** Takes a srcEntry - a src file in a layer and parses the file and starts the component as needed.  The defaultReason is used to debug why this model is started.  Ordinarily this is because
    * a dependent file has changed, or the file was modified but if neither of these cases is true, the caller can provide a more specific reason. */
Takes a srcEntry - a src file in a layer and parses the file and starts the component as needed.  The defaultReason is used to debug why this model is started.  Ordinarily this is because
a dependent file has changed, or the file was modified but if neither of these cases is true, the caller can provide a more specific reason.
Takes a srcEntry - a src file in a layer and parses the file and starts the component as needed . The defaultReason is used to debug why this model is started . Ordinarily this is because a dependent file has changed or the file was modified but if neither of these cases is true the caller can provide a more specific reason .
private Object initModelForBuild(SrcEntry toGenEnt, Layer genLayer, boolean incrCompile, BuildState bd, BuildPhase phase, String defaultReason) {
      Object modelObj;
      IFileProcessor proc = getFileProcessorForSrcEnt(toGenEnt, phase, false);
      if (proc == null)
         return null; 
      if (proc.getProducesTypes()) {
         TypeDeclaration cachedType = getCachedTypeDeclaration(proc.getPrependLayerPackage() ? toGenEnt.getTypeName() : toGenEnt.getRelTypeName(), toGenEnt.layer.getNextLayer(), null, false, false, null, false);
         if (cachedType != null && cachedType.getLayer() == toGenEnt.layer)
            modelObj = cachedType;
         else
            modelObj = null;
      }
      else
         modelObj = null;
      if (modelObj == null) {
         ILanguageModel langModel = getLanguageModel(toGenEnt);
         modelObj = langModel;
         if (modelObj instanceof JavaModel) {
            JavaModel tempModel = (JavaModel) modelObj;
            if (tempModel.getLayer() != toGenEnt.layer)
               System.err.println("*** Mismatching layers in started model");
         }
         if (modelObj == null) {
            if (options.verbose) {
               String procReason = "";
               if (incrCompile) {
                  SrcEntry depEnt = bd.dependentFilesChanged.get(toGenEnt);
                  procReason = depEnt == null ? (bd.modifiedFiles.contains(toGenEnt) ? ": source file changed" : defaultReason) : ": dependent file changed: " + depEnt;
               }
               verbose("Preparing " + toGenEnt + procReason + ", runtime: " + getRuntimeName());
            }
            modelObj = parseSrcType(toGenEnt, genLayer.getNextLayer(), false, true);
         }
         else {
            if (!langModel.isInitialized())
               ParseUtil.initComponent(langModel);
            if (!langModel.isAdded())
               addNewModel(langModel, genLayer.getNextLayer(), null, null, langModel instanceof JavaModel && ((JavaModel) langModel).isLayerModel, false);
            verbose("Preparing from model cache " + toGenEnt + ", runtime: " + getRuntimeName());
         }
      }
      else if (modelObj == INVALID_TYPE_DECLARATION_SENTINEL || modelObj == IFileProcessor.FILE_OVERRIDDEN_SENTINEL)
         return modelObj;
      else {
         TypeDeclaration modelType = (TypeDeclaration) modelObj;
         JavaModel model = modelType.getJavaModel();
         model.dependenciesChanged();
         modelObj = model;
         if (options.verbose && !modelType.isStarted()) {
            String modelTypeName = modelType.getFullTypeName();
            verbose("Preparing from cache " + toGenEnt);
         }
      }
      return modelObj;
   }
private Object initModelForBuild ( SrcEntry toGenEnt , Layer genLayer , boolean incrCompile , BuildState bd , BuildPhase phase , String defaultReason ) { Object modelObj ; IFileProcessor proc = getFileProcessorForSrcEnt ( toGenEnt , phase , false ) ; if ( proc == null ) return null ; if ( proc . getProducesTypes ( ) ) { TypeDeclaration cachedType = getCachedTypeDeclaration ( proc . getPrependLayerPackage ( ) ? toGenEnt . getTypeName ( ) : toGenEnt . getRelTypeName ( ) , toGenEnt . layer . getNextLayer ( ) , null , false , false , null , false ) ; if ( cachedType != null && cachedType . getLayer ( ) == toGenEnt . layer ) modelObj = cachedType ; else modelObj = null ; } else modelObj = null ; if ( modelObj == null ) { ILanguageModel langModel = getLanguageModel ( toGenEnt ) ; modelObj = langModel ; if ( modelObj instanceof JavaModel ) { JavaModel tempModel = ( JavaModel ) modelObj ; if ( tempModel . getLayer ( ) != toGenEnt . layer ) System . err . println ( "*** Mismatching layers in started model" ) ; } if ( modelObj == null ) { if ( options . verbose ) { String procReason = "" ; if ( incrCompile ) { SrcEntry depEnt = bd . dependentFilesChanged . get ( toGenEnt ) ; procReason = depEnt == null ? ( bd . modifiedFiles . contains ( toGenEnt ) ? ": source file changed" : defaultReason ) : ": dependent file changed: " + depEnt ; } verbose ( "Preparing " + toGenEnt + procReason + ", runtime: " + getRuntimeName ( ) ) ; } modelObj = parseSrcType ( toGenEnt , genLayer . getNextLayer ( ) , false , true ) ; } else { if ( ! langModel . isInitialized ( ) ) ParseUtil . initComponent ( langModel ) ; if ( ! langModel . isAdded ( ) ) addNewModel ( langModel , genLayer . getNextLayer ( ) , null , null , langModel instanceof JavaModel && ( ( JavaModel ) langModel ) . isLayerModel , false ) ; verbose ( "Preparing from model cache " + toGenEnt + ", runtime: " + getRuntimeName ( ) ) ; } } else if ( modelObj == INVALID_TYPE_DECLARATION_SENTINEL || modelObj == IFileProcessor . FILE_OVERRIDDEN_SENTINEL ) return modelObj ; else { TypeDeclaration modelType = ( TypeDeclaration ) modelObj ; JavaModel model = modelType . getJavaModel ( ) ; model . dependenciesChanged ( ) ; modelObj = model ; if ( options . verbose && ! modelType . isStarted ( ) ) { String modelTypeName = modelType . getFullTypeName ( ) ; verbose ( "Preparing from cache " + toGenEnt ) ; } } return modelObj ; }
Takes a srcEntry - a src file in a layer and parses the file and starts the component as needed.
Takes a srcEntry - a src file in a layer and parses the file and starts the component as needed .
// possibly not processed in this phase // We may have already parsed and initialized this component from a reference. // Make sure it's from the right layer // Checking the model cache again for those cases where there are no types involved and the model was cloned from another runtime (faster than reparsing it again) //modelObj = parseSrcType(toGenEnt, null); // Parsed it and there was an error // If we are not starting anything, we won't be resolving the errors // This happens now that we build previous layers, put their classes in so they are there for the next layer //if (!model.getLayer().annotationLayer && !genLayer.layerUniqueName.equals("sc") && getClass(modelTypeName) != null) //   System.err.println("*** Warning - generated type: " + modelTypeName + " exists in the system classpath ");