boolean replaceIncrementalSourceAst ( JsAst ast ) { CompilerInput oldInput = getInput ( ast . getInputId ( ) ) ; checkNotNull ( oldInput , "No input to replace: %s" , ast . getInputId ( ) . getIdName ( ) ) ; Node newRoot = checkNotNull ( ast . getAstRoot ( this ) ) ; Node oldRoot = oldInput . getAstRoot ( this ) ; oldRoot . replaceWith ( newRoot ) ; CompilerInput newInput = new CompilerInput ( ast ) ; putCompilerInput ( ast . getInputId ( ) , newInput ) ; JSModule module = oldInput . getModule ( ) ; if ( module != null ) { module . addAfter ( newInput , oldInput ) ; module . remove ( oldInput ) ; } // Verify the input id is set properly. checkState ( newInput . getInputId ( ) . equals ( oldInput . getInputId ( ) ) ) ; InputId inputIdOnAst = newInput . getAstRoot ( this ) . getInputId ( ) ; checkState ( newInput . getInputId ( ) . equals ( inputIdOnAst ) ) ; return true ; }
Replace a source input dynamically . Intended for incremental re - compilation .