system/src/sc/lang/java/Statement.java
public void addToFileLineIndex(GenFileLineIndex idx, int rootStartGenLine) {
      if (isLineStatement()) {
         ISrcStatement srcStatement = getSrcStatement(null);
         if (srcStatement != null && srcStatement != this) {
            ISemanticNode srcRoot = srcStatement.getRootNode();
            if (srcRoot instanceof JavaModel) {
               JavaModel srcModel = (JavaModel) srcRoot;
               IParseNode pn = getParseNode();
               if (pn == null) {
                  System.out.println("*** Attempt to add statement to genLine index with no parse-node - ~/.stratacode/modelCache is corrupt?");
                  return;
               }
               int startGenOffset = pn.getStartIndex();
               if (startGenOffset == -1) {
                  System.out.println("*** Attempt to add statement to genLine index with a parse-node that's missing a startIndex");
                  return;
               }
               int startGenLine;
               if (rootStartGenLine == -1) {
                  // There are two ways to build the line index... incrementally or absolute.  This genFileLineIndex variable is only set when we are using absolute but -1 signals incremental
                  if (idx == null || idx.genFileLineIndex == null)
                     throw new IllegalArgumentException("*** Error - genFileLineIndex not initialized but rootStartGenLine is passed as -1");
                  startGenLine = idx.genFileLineIndex.getLineForOffset(startGenOffset);
               }
               else {
                  CharSequence cur = idx.currentStatement;
                  startGenLine = rootStartGenLine + ParseUtil.countCodeLinesInNode(cur, startGenOffset+1);
               }
               int numGenLines = getNumStatementLines();
               if (numGenLines > 0)
                  numGenLines--;
               int endGenLine = startGenLine + numGenLines;

               addMappingForSrcStatement(idx, srcModel, srcStatement, startGenLine, endGenLine);
            }
            else {
               System.err.println("*** Unrecognized root node for src statement in generated model");
            }
         }
         // else - these statements are not generated with the fromStatement set - break here to improve the registration
      }
      if (this instanceof IBlockStatement) {
         List<Statement> blockSts = ((IBlockStatement) this).getBlockStatements();
         if (blockSts != null) {
            for (Statement blockSt:blockSts) {
               blockSt.addToFileLineIndex(idx, rootStartGenLine);
            }
         }
      }
      else if (this instanceof IStatementWrapper) {
         Statement wrappedSt = ((IStatementWrapper) this).getWrappedStatement();
         if (wrappedSt != null)
            wrappedSt.addToFileLineIndex(idx, rootStartGenLine);
      }
      else if (this instanceof IBlockStatementWrapper) {
         BlockStatement bst = ((IBlockStatementWrapper) this).getWrappedBlockStatement();
         if (bst != null)
            bst.addToFileLineIndex(idx, rootStartGenLine);
      }
      // NewExpression and TypeDeclaration
      else if (this instanceof IClassBodyStatement) {
         List<Statement> sts = ((IClassBodyStatement) this).getBodyStatements();
         if (sts != null) {
            for (Statement st:sts)
               st.addToFileLineIndex(idx, rootStartGenLine);
         }
      }
   }
/**
    * Adds this statement to the generated file line index.  If you pass in rootStartGenLen = -1, the generated source file is used
    * to compute the line number using this parse-node's offset into that file.  If you pass in a positive value, we count the lines
    * in "currentStatement" of the index up until the parse-node's offset.  You can use this mode to incrementally generate an index,
    * even when there's no complete transformed model for the entire file (such as with generating JS).  In that case, we have a generated
    * model for each statement and are manually adding statements to the file, so we need to compute the line numbers relative to this "currentStatement"
    * - i.e. the root statement.
    */
Adds this statement to the generated file line index.  If you pass in rootStartGenLen = -1, the generated source file is used
to compute the line number using this parse-node's offset into that file.  If you pass in a positive value, we count the lines
in "currentStatement" of the index up until the parse-node's offset.  You can use this mode to incrementally generate an index,
even when there's no complete transformed model for the entire file (such as with generating JS).  In that case, we have a generated
model for each statement and are manually adding statements to the file, so we need to compute the line numbers relative to this "currentStatement"
- i.e. the root statement.
Adds this statement to the generated file line index . If you pass in rootStartGenLen = - 1 the generated source file is used to compute the line number using this parse - node ' s offset into that file . If you pass in a positive value we count the lines in " currentStatement " of the index up until the parse - node ' s offset . You can use this mode to incrementally generate an index even when there ' s no complete transformed model for the entire file ( such as with generating JS ) . In that case we have a generated model for each statement and are manually adding statements to the file so we need to compute the line numbers relative to this " currentStatement " - i . e . the root statement .
public void addToFileLineIndex(GenFileLineIndex idx, int rootStartGenLine) {
      if (isLineStatement()) {
         ISrcStatement srcStatement = getSrcStatement(null);
         if (srcStatement != null && srcStatement != this) {
            ISemanticNode srcRoot = srcStatement.getRootNode();
            if (srcRoot instanceof JavaModel) {
               JavaModel srcModel = (JavaModel) srcRoot;
               IParseNode pn = getParseNode();
               if (pn == null) {
                  System.out.println("*** Attempt to add statement to genLine index with no parse-node - ~/.stratacode/modelCache is corrupt?");
                  return;
               }
               int startGenOffset = pn.getStartIndex();
               if (startGenOffset == -1) {
                  System.out.println("*** Attempt to add statement to genLine index with a parse-node that's missing a startIndex");
                  return;
               }
               int startGenLine;
               if (rootStartGenLine == -1) {
                  if (idx == null || idx.genFileLineIndex == null)
                     throw new IllegalArgumentException("*** Error - genFileLineIndex not initialized but rootStartGenLine is passed as -1");
                  startGenLine = idx.genFileLineIndex.getLineForOffset(startGenOffset);
               }
               else {
                  CharSequence cur = idx.currentStatement;
                  startGenLine = rootStartGenLine + ParseUtil.countCodeLinesInNode(cur, startGenOffset+1);
               }
               int numGenLines = getNumStatementLines();
               if (numGenLines > 0)
                  numGenLines--;
               int endGenLine = startGenLine + numGenLines;
               addMappingForSrcStatement(idx, srcModel, srcStatement, startGenLine, endGenLine);
            }
            else {
               System.err.println("*** Unrecognized root node for src statement in generated model");
            }
         }
      }
      if (this instanceof IBlockStatement) {
         List<Statement> blockSts = ((IBlockStatement) this).getBlockStatements();
         if (blockSts != null) {
            for (Statement blockSt:blockSts) {
               blockSt.addToFileLineIndex(idx, rootStartGenLine);
            }
         }
      }
      else if (this instanceof IStatementWrapper) {
         Statement wrappedSt = ((IStatementWrapper) this).getWrappedStatement();
         if (wrappedSt != null)
            wrappedSt.addToFileLineIndex(idx, rootStartGenLine);
      }
      else if (this instanceof IBlockStatementWrapper) {
         BlockStatement bst = ((IBlockStatementWrapper) this).getWrappedBlockStatement();
         if (bst != null)
            bst.addToFileLineIndex(idx, rootStartGenLine);
      }
      else if (this instanceof IClassBodyStatement) {
         List<Statement> sts = ((IClassBodyStatement) this).getBodyStatements();
         if (sts != null) {
            for (Statement st:sts)
               st.addToFileLineIndex(idx, rootStartGenLine);
         }
      }
   }
public void addToFileLineIndex ( GenFileLineIndex idx , int rootStartGenLine ) { if ( isLineStatement ( ) ) { ISrcStatement srcStatement = getSrcStatement ( null ) ; if ( srcStatement != null && srcStatement != this ) { ISemanticNode srcRoot = srcStatement . getRootNode ( ) ; if ( srcRoot instanceof JavaModel ) { JavaModel srcModel = ( JavaModel ) srcRoot ; IParseNode pn = getParseNode ( ) ; if ( pn == null ) { System . out . println ( "*** Attempt to add statement to genLine index with no parse-node - ~/.stratacode/modelCache is corrupt?" ) ; return ; } int startGenOffset = pn . getStartIndex ( ) ; if ( startGenOffset == - 1 ) { System . out . println ( "*** Attempt to add statement to genLine index with a parse-node that's missing a startIndex" ) ; return ; } int startGenLine ; if ( rootStartGenLine == - 1 ) { if ( idx == null || idx . genFileLineIndex == null ) throw new IllegalArgumentException ( "*** Error - genFileLineIndex not initialized but rootStartGenLine is passed as -1" ) ; startGenLine = idx . genFileLineIndex . getLineForOffset ( startGenOffset ) ; } else { CharSequence cur = idx . currentStatement ; startGenLine = rootStartGenLine + ParseUtil . countCodeLinesInNode ( cur , startGenOffset + 1 ) ; } int numGenLines = getNumStatementLines ( ) ; if ( numGenLines > 0 ) numGenLines -- ; int endGenLine = startGenLine + numGenLines ; addMappingForSrcStatement ( idx , srcModel , srcStatement , startGenLine , endGenLine ) ; } else { System . err . println ( "*** Unrecognized root node for src statement in generated model" ) ; } } } if ( this instanceof IBlockStatement ) { List < Statement > blockSts = ( ( IBlockStatement ) this ) . getBlockStatements ( ) ; if ( blockSts != null ) { for ( Statement blockSt : blockSts ) { blockSt . addToFileLineIndex ( idx , rootStartGenLine ) ; } } } else if ( this instanceof IStatementWrapper ) { Statement wrappedSt = ( ( IStatementWrapper ) this ) . getWrappedStatement ( ) ; if ( wrappedSt != null ) wrappedSt . addToFileLineIndex ( idx , rootStartGenLine ) ; } else if ( this instanceof IBlockStatementWrapper ) { BlockStatement bst = ( ( IBlockStatementWrapper ) this ) . getWrappedBlockStatement ( ) ; if ( bst != null ) bst . addToFileLineIndex ( idx , rootStartGenLine ) ; } else if ( this instanceof IClassBodyStatement ) { List < Statement > sts = ( ( IClassBodyStatement ) this ) . getBodyStatements ( ) ; if ( sts != null ) { for ( Statement st : sts ) st . addToFileLineIndex ( idx , rootStartGenLine ) ; } } }
Adds this statement to the generated file line index.
Adds this statement to the generated file line index .
// There are two ways to build the line index... incrementally or absolute.  This genFileLineIndex variable is only set when we are using absolute but -1 signals incremental // else - these statements are not generated with the fromStatement set - break here to improve the registration // NewExpression and TypeDeclaration