system/src/sc/lang/sc/ModifyDeclaration.java
public BodyTypeDeclaration replaceHiddenType(BodyTypeDeclaration parent) {
      if (hiddenByType == null) {
         if (parent != null)
            setParentNode(parent);
         if (!isStarted())
            ParseUtil.initAndStartComponent(this);

         String nextType = typeName;
         String rest;
         ClassDeclaration subClass;
         BodyTypeDeclaration nextParent = getEnclosingType(), theRoot = null;

         // If this is a root level A.b.c, it's just a way to refer to a child node via the root node.
         if (nextParent == null) {
            return this;
         }

         BodyTypeDeclaration currentModType;
         BodyTypeDeclaration subType;
         do {
            // Need to handle the "a.b" types here - we create class a extends modType.a {  class b extends modType.a.b here }
            int dotIx = nextType.indexOf(".");
            if (dotIx != -1) {
               rest = nextType.substring(dotIx+1);
               nextType = nextType.substring(0, dotIx);
               int startIx = 0;
               int upCt;
               // Count number of "."s in the current name, including the one we stripped off
               for (upCt = 1; (startIx = nextType.indexOf('.', startIx)) != -1; upCt++)
                  ;
               currentModType = modifyTypeDecl;
               for (int up = 0; up < upCt; up++) {
                  if (currentModType == null) {
                     // Should not get here
                     System.err.println("*** Unable to resolve parent type for complex modify: " + typeName);
                     return this;
                  }
                  currentModType = currentModType.getEnclosingType();
               }
            }
            else {
               rest = null;
               currentModType = modifyTypeDecl;
            }
            if (currentModType == null) {
               System.err.println("*** Can't find mod type for type transform: " + typeName);
               return this;
            }

            if (nextParent == null) {
               System.err.println("*** Can't find next parent type for type transform: " + typeName);
               return this;
            }

            subType = null;
            // CheckbaseType is true here - we'll need to create a modify if there's another type.  If it comes from
            // the extends type, that's the "modifyInherited" case.
            Object innerTypeObj = nextParent.getInnerType(nextType, null, true, false, false, false);
            if (innerTypeObj != this && innerTypeObj instanceof BodyTypeDeclaration) {
               subType = (BodyTypeDeclaration) innerTypeObj;
            }

            if (subType == null) {
               // Did not find an existing subType so create a new one
               subClass = new ClassDeclaration();
               subClass.typeName = nextType;
               subClass.setProperty("extendsType", ClassType.create(ModelUtil.getTypeName(currentModType)));
               subClass.operator = currentModType.getDeclarationType() == DeclarationType.OBJECT ? "object" : "class";
               if (theRoot == null) {
                  theRoot = subClass;
               }
               else {
                  nextParent.addBodyStatement(subClass);
               }
               subType = subClass;
            }
            else {
               // If we inherit a definition, need to create the implied ModifyDeclaration to map from this type
               // to the next
               if (subType.getEnclosingType() != nextParent) {
                  subType = new ModifyDeclaration();
                  subType.typeName = nextType;
                  nextParent.addBodyStatement(subType);
               }
               if (theRoot == null)
                  theRoot = subType;
            }
            nextParent = subType;

            nextType = rest;
         } while (rest != null);
         BodyTypeDeclaration parentType = getEnclosingType();
         parentType.addToHiddenBody(theRoot, false);
         hiddenByRoot = theRoot;
         hiddenByType = subType;
      }
      return hiddenByType;
   }
/** gets rid of the "a.b" shortcut types - creates a if necessary */
gets rid of the "a.b" shortcut types - creates a if necessary
gets rid of the " a . b " shortcut types - creates a if necessary
public BodyTypeDeclaration replaceHiddenType(BodyTypeDeclaration parent) {
      if (hiddenByType == null) {
         if (parent != null)
            setParentNode(parent);
         if (!isStarted())
            ParseUtil.initAndStartComponent(this);
         String nextType = typeName;
         String rest;
         ClassDeclaration subClass;
         BodyTypeDeclaration nextParent = getEnclosingType(), theRoot = null;
         if (nextParent == null) {
            return this;
         }
         BodyTypeDeclaration currentModType;
         BodyTypeDeclaration subType;
         do {
            int dotIx = nextType.indexOf(".");
            if (dotIx != -1) {
               rest = nextType.substring(dotIx+1);
               nextType = nextType.substring(0, dotIx);
               int startIx = 0;
               int upCt;
               for (upCt = 1; (startIx = nextType.indexOf('.', startIx)) != -1; upCt++)
                  ;
               currentModType = modifyTypeDecl;
               for (int up = 0; up < upCt; up++) {
                  if (currentModType == null) {
                     System.err.println("*** Unable to resolve parent type for complex modify: " + typeName);
                     return this;
                  }
                  currentModType = currentModType.getEnclosingType();
               }
            }
            else {
               rest = null;
               currentModType = modifyTypeDecl;
            }
            if (currentModType == null) {
               System.err.println("*** Can't find mod type for type transform: " + typeName);
               return this;
            }
            if (nextParent == null) {
               System.err.println("*** Can't find next parent type for type transform: " + typeName);
               return this;
            }
            subType = null;
            Object innerTypeObj = nextParent.getInnerType(nextType, null, true, false, false, false);
            if (innerTypeObj != this && innerTypeObj instanceof BodyTypeDeclaration) {
               subType = (BodyTypeDeclaration) innerTypeObj;
            }
            if (subType == null) {
               subClass = new ClassDeclaration();
               subClass.typeName = nextType;
               subClass.setProperty("extendsType", ClassType.create(ModelUtil.getTypeName(currentModType)));
               subClass.operator = currentModType.getDeclarationType() == DeclarationType.OBJECT ? "object" : "class";
               if (theRoot == null) {
                  theRoot = subClass;
               }
               else {
                  nextParent.addBodyStatement(subClass);
               }
               subType = subClass;
            }
            else {
               if (subType.getEnclosingType() != nextParent) {
                  subType = new ModifyDeclaration();
                  subType.typeName = nextType;
                  nextParent.addBodyStatement(subType);
               }
               if (theRoot == null)
                  theRoot = subType;
            }
            nextParent = subType;
            nextType = rest;
         } while (rest != null);
         BodyTypeDeclaration parentType = getEnclosingType();
         parentType.addToHiddenBody(theRoot, false);
         hiddenByRoot = theRoot;
         hiddenByType = subType;
      }
      return hiddenByType;
   }
public BodyTypeDeclaration replaceHiddenType ( BodyTypeDeclaration parent ) { if ( hiddenByType == null ) { if ( parent != null ) setParentNode ( parent ) ; if ( ! isStarted ( ) ) ParseUtil . initAndStartComponent ( this ) ; String nextType = typeName ; String rest ; ClassDeclaration subClass ; BodyTypeDeclaration nextParent = getEnclosingType ( ) , theRoot = null ; if ( nextParent == null ) { return this ; } BodyTypeDeclaration currentModType ; BodyTypeDeclaration subType ; do { int dotIx = nextType . indexOf ( "." ) ; if ( dotIx != - 1 ) { rest = nextType . substring ( dotIx + 1 ) ; nextType = nextType . substring ( 0 , dotIx ) ; int startIx = 0 ; int upCt ; for ( upCt = 1 ; ( startIx = nextType . indexOf ( '.' , startIx ) ) != - 1 ; upCt ++ ) ; currentModType = modifyTypeDecl ; for ( int up = 0 ; up < upCt ; up ++ ) { if ( currentModType == null ) { System . err . println ( "*** Unable to resolve parent type for complex modify: " + typeName ) ; return this ; } currentModType = currentModType . getEnclosingType ( ) ; } } else { rest = null ; currentModType = modifyTypeDecl ; } if ( currentModType == null ) { System . err . println ( "*** Can't find mod type for type transform: " + typeName ) ; return this ; } if ( nextParent == null ) { System . err . println ( "*** Can't find next parent type for type transform: " + typeName ) ; return this ; } subType = null ; Object innerTypeObj = nextParent . getInnerType ( nextType , null , true , false , false , false ) ; if ( innerTypeObj != this && innerTypeObj instanceof BodyTypeDeclaration ) { subType = ( BodyTypeDeclaration ) innerTypeObj ; } if ( subType == null ) { subClass = new ClassDeclaration ( ) ; subClass . typeName = nextType ; subClass . setProperty ( "extendsType" , ClassType . create ( ModelUtil . getTypeName ( currentModType ) ) ) ; subClass . operator = currentModType . getDeclarationType ( ) == DeclarationType . OBJECT ? "object" : "class" ; if ( theRoot == null ) { theRoot = subClass ; } else { nextParent . addBodyStatement ( subClass ) ; } subType = subClass ; } else { if ( subType . getEnclosingType ( ) != nextParent ) { subType = new ModifyDeclaration ( ) ; subType . typeName = nextType ; nextParent . addBodyStatement ( subType ) ; } if ( theRoot == null ) theRoot = subType ; } nextParent = subType ; nextType = rest ; } while ( rest != null ) ; BodyTypeDeclaration parentType = getEnclosingType ( ) ; parentType . addToHiddenBody ( theRoot , false ) ; hiddenByRoot = theRoot ; hiddenByType = subType ; } return hiddenByType ; }
gets rid of the "a.b" shortcut types - creates a if necessary
gets rid of the " a . b " shortcut types - creates a if necessary
// If this is a root level A.b.c, it's just a way to refer to a child node via the root node. // Need to handle the "a.b" types here - we create class a extends modType.a {  class b extends modType.a.b here } // Count number of "."s in the current name, including the one we stripped off // Should not get here // CheckbaseType is true here - we'll need to create a modify if there's another type.  If it comes from // the extends type, that's the "modifyInherited" case. // Did not find an existing subType so create a new one // If we inherit a definition, need to create the implied ModifyDeclaration to map from this type // to the next