system/src/sc/lang/java/ModelStream.java
public Object resolveType(String currentPackage, String typeName, boolean create, TypeDeclaration fromType) {
      if (CTypeUtil.getClassName(typeName).equals(SyncLayer.GLOBAL_TYPE_NAME)) {
         if (globalType == null) {
            globalModel = new JavaModel();
            globalType = ClassDeclaration.create("class", SyncLayer.GLOBAL_TYPE_NAME, null);
            Layer buildLayer = system == null ? null : system.buildLayer;
            globalModel.setLayeredSystem(system);
            globalModel.setLayer(buildLayer);
            globalModel.addSrcFile(new SrcEntry(buildLayer, SyncLayer.GLOBAL_TYPE_NAME, SyncLayer.GLOBAL_TYPE_NAME));
            globalType.setParentNode(globalModel);
            globalModel.addTypeDeclaration(globalType);
         }
         return globalType;
      }
      TypeDeclaration lastType = lastTypeForName.get(typeName);
      if (lastType == null && currentPackage != null)
         lastType = lastTypeForName.get(CTypeUtil.prefixPath(currentPackage, typeName));
      if (lastType != null) {
         if (fromType != null)
            lastTypeForName.put(typeName, fromType);
         return lastType;
      }
      Object inst = resolveObject(currentPackage, typeName, create, false);
      if (inst != null) {
         Object type;
         // TODO: remove this special case for TypeDeclarations - because those represent classes in the system, they got messed up in the logic below but that's fixed now with the ClientTypeDeclaration wrapper
         if (typeName.startsWith("sc_type_")) {
            if (DynUtil.isType(inst))
               return inst.getClass();
            else
               type = DynUtil.getType(inst);
         }
         else
            type = DynUtil.getType(inst);
         if (type != null && fromType != null) {
            lastTypeForName.put(typeName, fromType);
         }
         String typeTypeName = DynUtil.getTypeName(type, false);
         Object newType = system == null ? PTypeUtil.findType(typeTypeName) : system.getRuntimeTypeDeclaration(typeTypeName);
         if (newType != null)
            type = newType;
         if (type == null && currentPackage != null) {
            String packageTypeName = CTypeUtil.prefixPath(currentPackage, typeTypeName);
            newType = system == null ? PTypeUtil.findType(packageTypeName) : system.getRuntimeTypeDeclaration(packageTypeName);
            if (newType != null)
               type = newType;
         }
         return type;
      }
      VariableDefinition varDef = resolveFieldWithName(currentPackage, typeName);
      if (varDef != null)
         return varDef.getTypeDeclaration();
      return null;
   }
/** Returns the type of the object with the given name - for compile time checks */
Returns the type of the object with the given name - for compile time checks
Returns the type of the object with the given name - for compile time checks
public Object resolveType(String currentPackage, String typeName, boolean create, TypeDeclaration fromType) {
      if (CTypeUtil.getClassName(typeName).equals(SyncLayer.GLOBAL_TYPE_NAME)) {
         if (globalType == null) {
            globalModel = new JavaModel();
            globalType = ClassDeclaration.create("class", SyncLayer.GLOBAL_TYPE_NAME, null);
            Layer buildLayer = system == null ? null : system.buildLayer;
            globalModel.setLayeredSystem(system);
            globalModel.setLayer(buildLayer);
            globalModel.addSrcFile(new SrcEntry(buildLayer, SyncLayer.GLOBAL_TYPE_NAME, SyncLayer.GLOBAL_TYPE_NAME));
            globalType.setParentNode(globalModel);
            globalModel.addTypeDeclaration(globalType);
         }
         return globalType;
      }
      TypeDeclaration lastType = lastTypeForName.get(typeName);
      if (lastType == null && currentPackage != null)
         lastType = lastTypeForName.get(CTypeUtil.prefixPath(currentPackage, typeName));
      if (lastType != null) {
         if (fromType != null)
            lastTypeForName.put(typeName, fromType);
         return lastType;
      }
      Object inst = resolveObject(currentPackage, typeName, create, false);
      if (inst != null) {
         Object type;
         if (typeName.startsWith("sc_type_")) {
            if (DynUtil.isType(inst))
               return inst.getClass();
            else
               type = DynUtil.getType(inst);
         }
         else
            type = DynUtil.getType(inst);
         if (type != null && fromType != null) {
            lastTypeForName.put(typeName, fromType);
         }
         String typeTypeName = DynUtil.getTypeName(type, false);
         Object newType = system == null ? PTypeUtil.findType(typeTypeName) : system.getRuntimeTypeDeclaration(typeTypeName);
         if (newType != null)
            type = newType;
         if (type == null && currentPackage != null) {
            String packageTypeName = CTypeUtil.prefixPath(currentPackage, typeTypeName);
            newType = system == null ? PTypeUtil.findType(packageTypeName) : system.getRuntimeTypeDeclaration(packageTypeName);
            if (newType != null)
               type = newType;
         }
         return type;
      }
      VariableDefinition varDef = resolveFieldWithName(currentPackage, typeName);
      if (varDef != null)
         return varDef.getTypeDeclaration();
      return null;
   }
public Object resolveType ( String currentPackage , String typeName , boolean create , TypeDeclaration fromType ) { if ( CTypeUtil . getClassName ( typeName ) . equals ( SyncLayer . GLOBAL_TYPE_NAME ) ) { if ( globalType == null ) { globalModel = new JavaModel ( ) ; globalType = ClassDeclaration . create ( "class" , SyncLayer . GLOBAL_TYPE_NAME , null ) ; Layer buildLayer = system == null ? null : system . buildLayer ; globalModel . setLayeredSystem ( system ) ; globalModel . setLayer ( buildLayer ) ; globalModel . addSrcFile ( new SrcEntry ( buildLayer , SyncLayer . GLOBAL_TYPE_NAME , SyncLayer . GLOBAL_TYPE_NAME ) ) ; globalType . setParentNode ( globalModel ) ; globalModel . addTypeDeclaration ( globalType ) ; } return globalType ; } TypeDeclaration lastType = lastTypeForName . get ( typeName ) ; if ( lastType == null && currentPackage != null ) lastType = lastTypeForName . get ( CTypeUtil . prefixPath ( currentPackage , typeName ) ) ; if ( lastType != null ) { if ( fromType != null ) lastTypeForName . put ( typeName , fromType ) ; return lastType ; } Object inst = resolveObject ( currentPackage , typeName , create , false ) ; if ( inst != null ) { Object type ; if ( typeName . startsWith ( "sc_type_" ) ) { if ( DynUtil . isType ( inst ) ) return inst . getClass ( ) ; else type = DynUtil . getType ( inst ) ; } else type = DynUtil . getType ( inst ) ; if ( type != null && fromType != null ) { lastTypeForName . put ( typeName , fromType ) ; } String typeTypeName = DynUtil . getTypeName ( type , false ) ; Object newType = system == null ? PTypeUtil . findType ( typeTypeName ) : system . getRuntimeTypeDeclaration ( typeTypeName ) ; if ( newType != null ) type = newType ; if ( type == null && currentPackage != null ) { String packageTypeName = CTypeUtil . prefixPath ( currentPackage , typeTypeName ) ; newType = system == null ? PTypeUtil . findType ( packageTypeName ) : system . getRuntimeTypeDeclaration ( packageTypeName ) ; if ( newType != null ) type = newType ; } return type ; } VariableDefinition varDef = resolveFieldWithName ( currentPackage , typeName ) ; if ( varDef != null ) return varDef . getTypeDeclaration ( ) ; return null ; }
Returns the type of the object with the given name - for compile time checks
Returns the type of the object with the given name - for compile time checks
// TODO: remove this special case for TypeDeclarations - because those represent classes in the system, they got messed up in the logic below but that's fixed now with the ClientTypeDeclaration wrapper