system/src/sc/lang/java/NewExpression.java
private void initAnonId() {
      LayeredSystem sys = getLayeredSystem();

      // First assign the anonId before we get into things so that if any children start creating anonymous types which
      // ends up copying around NewExpressions, we have a consistent anonId for the original and the copy.
      // NOTE: Now that we call initAnonymousType in start() no matter what, we are not doing the NeedsAnonymousConversion check
      // Why are we initializing the anonymous type if we are not transforming them to JS?
      if (anonId == -1 && classBody != null && sys != null /* && sys.getNeedsAnonymousConversion()*/) {
         BodyTypeDeclaration enclType = getEnclosingType();
         if (enclType != null) {
            // Need to create this up front so we can return it in getEnclosingType for any children of the class body
            // They will get added later in initAnonymousType
            // Though note that also this class overrides the findX methods to look in the body of the new expr so
            // maybe we do not need to do this afterall?   Right now it's a mix of both approaches.
            anonType = new AnonClassDeclaration();
            anonId = enclType.allocateAnonId();
            if (enclType.typeName.equals("EditorModel"))
               System.out.println("*** init setting anonId for: " + typeIdentifier + ": " + anonId);
            anonType.typeName = ANON_TYPE_PREFIX + anonId;
            anonType.operator = "class";
            anonType.newExpr = this;

            enclType.addToHiddenBody(anonType, true);
         }
      }
   }
/* TODO: remove this method Previously we needed a first-pass to just initialize the type and the id without copying over the members.
    * We would do this step during 'init' and then during 'start' we'd finish creating the type.  Because we init
    * all body members in a layer before we've assembled the layers into one, we can't allocate the anonIds until
    * the start phase.  So this method can probably be removed.
    */
remove this method Previously we needed a first-pass to just initialize the type and the id without copying over the members.
remove this method Previously we needed a first - pass to just initialize the type and the id without copying over the members .
private void initAnonId() {
      LayeredSystem sys = getLayeredSystem();
      if (anonId == -1 && classBody != null && sys != null /* && sys.getNeedsAnonymousConversion()*/) {
         BodyTypeDeclaration enclType = getEnclosingType();
         if (enclType != null) {
            anonType = new AnonClassDeclaration();
            anonId = enclType.allocateAnonId();
            if (enclType.typeName.equals("EditorModel"))
               System.out.println("*** init setting anonId for: " + typeIdentifier + ": " + anonId);
            anonType.typeName = ANON_TYPE_PREFIX + anonId;
            anonType.operator = "class";
            anonType.newExpr = this;
            enclType.addToHiddenBody(anonType, true);
         }
      }
   }
private void initAnonId ( ) { LayeredSystem sys = getLayeredSystem ( ) ; if ( anonId == - 1 && classBody != null && sys != null /* && sys.getNeedsAnonymousConversion()*/ ) { BodyTypeDeclaration enclType = getEnclosingType ( ) ; if ( enclType != null ) { anonType = new AnonClassDeclaration ( ) ; anonId = enclType . allocateAnonId ( ) ; if ( enclType . typeName . equals ( "EditorModel" ) ) System . out . println ( "*** init setting anonId for: " + typeIdentifier + ": " + anonId ) ; anonType . typeName = ANON_TYPE_PREFIX + anonId ; anonType . operator = "class" ; anonType . newExpr = this ; enclType . addToHiddenBody ( anonType , true ) ; } } }
TODO: remove this method Previously we needed a first-pass to just initialize the type and the id without copying over the members.
TODO : remove this method Previously we needed a first - pass to just initialize the type and the id without copying over the members .
// First assign the anonId before we get into things so that if any children start creating anonymous types which // ends up copying around NewExpressions, we have a consistent anonId for the original and the copy. // NOTE: Now that we call initAnonymousType in start() no matter what, we are not doing the NeedsAnonymousConversion check // Why are we initializing the anonymous type if we are not transforming them to JS? // Need to create this up front so we can return it in getEnclosingType for any children of the class body // They will get added later in initAnonymousType // Though note that also this class overrides the findX methods to look in the body of the new expr so // maybe we do not need to do this afterall?   Right now it's a mix of both approaches.