system/src/sc/lang/java/TransformUtil.java
public static void appendIndentIfNecessary(SemanticNodeList node) {
      if (node == null)
         return;
      if (node.size() == 0) {
         IParseNode listPN = node.getParseNode();
         if (listPN instanceof ParentParseNode) {
            ParentParseNode listPPN = (ParentParseNode) listPN;
            if (listPPN.children != null && listPPN.children.size() > 0) {
               Object symbolPN = listPPN.children.get(0);
               if (symbolPN instanceof ParentParseNode) {
                  ParentParseNode symbolPPN = (ParentParseNode) symbolPN;
                  if (symbolPPN.children != null && symbolPPN.children.size() == 2) {
                     Object spacePN = symbolPPN.children.get(1);
                     if (spacePN instanceof ParentParseNode) {
                        ParentParseNode spacePPN = (ParentParseNode) spacePN;
                        if (spacePPN.children != null && spacePPN.children.size() == 1) {
                           Object spaceChild = spacePPN.children.get(0);
                           if (spaceChild == null || spaceChild.toString().equals("\n"))
                              spacePPN.children.set(0, "\n" + FormatContext.INDENT_STR);
                        }
                     }
                  }
               }
            }
         }
         return;
      }
      int lastIx = node.size() - 1;
      appendIndentIfNecessary(node, lastIx);
   }
/**
    * This is a bit of a tricky situation.  When we are adding a new language construct, if the construct was
    * parsed, it will not add indentation properly to the first node.  We will not format the previous node
    * in that case and it is responsible for inserting the indent for the next node.  In this case, we just need
    * to stick in indentation.  But if the previous node is generated, we can just skip that.
    */
This is a bit of a tricky situation.  When we are adding a new language construct, if the construct was
parsed, it will not add indentation properly to the first node.  We will not format the previous node
in that case and it is responsible for inserting the indent for the next node.  In this case, we just need
to stick in indentation.  But if the previous node is generated, we can just skip that.
This is a bit of a tricky situation . When we are adding a new language construct if the construct was parsed it will not add indentation properly to the first node . We will not format the previous node in that case and it is responsible for inserting the indent for the next node . In this case we just need to stick in indentation . But if the previous node is generated we can just skip that .
public static void appendIndentIfNecessary(SemanticNodeList node) {
      if (node == null)
         return;
      if (node.size() == 0) {
         IParseNode listPN = node.getParseNode();
         if (listPN instanceof ParentParseNode) {
            ParentParseNode listPPN = (ParentParseNode) listPN;
            if (listPPN.children != null && listPPN.children.size() > 0) {
               Object symbolPN = listPPN.children.get(0);
               if (symbolPN instanceof ParentParseNode) {
                  ParentParseNode symbolPPN = (ParentParseNode) symbolPN;
                  if (symbolPPN.children != null && symbolPPN.children.size() == 2) {
                     Object spacePN = symbolPPN.children.get(1);
                     if (spacePN instanceof ParentParseNode) {
                        ParentParseNode spacePPN = (ParentParseNode) spacePN;
                        if (spacePPN.children != null && spacePPN.children.size() == 1) {
                           Object spaceChild = spacePPN.children.get(0);
                           if (spaceChild == null || spaceChild.toString().equals("\n"))
                              spacePPN.children.set(0, "\n" + FormatContext.INDENT_STR);
                        }
                     }
                  }
               }
            }
         }
         return;
      }
      int lastIx = node.size() - 1;
      appendIndentIfNecessary(node, lastIx);
   }
public static void appendIndentIfNecessary ( SemanticNodeList node ) { if ( node == null ) return ; if ( node . size ( ) == 0 ) { IParseNode listPN = node . getParseNode ( ) ; if ( listPN instanceof ParentParseNode ) { ParentParseNode listPPN = ( ParentParseNode ) listPN ; if ( listPPN . children != null && listPPN . children . size ( ) > 0 ) { Object symbolPN = listPPN . children . get ( 0 ) ; if ( symbolPN instanceof ParentParseNode ) { ParentParseNode symbolPPN = ( ParentParseNode ) symbolPN ; if ( symbolPPN . children != null && symbolPPN . children . size ( ) == 2 ) { Object spacePN = symbolPPN . children . get ( 1 ) ; if ( spacePN instanceof ParentParseNode ) { ParentParseNode spacePPN = ( ParentParseNode ) spacePN ; if ( spacePPN . children != null && spacePPN . children . size ( ) == 1 ) { Object spaceChild = spacePPN . children . get ( 0 ) ; if ( spaceChild == null || spaceChild . toString ( ) . equals ( "\n" ) ) spacePPN . children . set ( 0 , "\n" + FormatContext . INDENT_STR ) ; } } } } } } return ; } int lastIx = node . size ( ) - 1 ; appendIndentIfNecessary ( node , lastIx ) ; }
This is a bit of a tricky situation.
This is a bit of a tricky situation .