code: 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;
    }
docs: Replace a source input dynamically. Intended for incremental
  re-compilation.
  
  If the new source input doesn't parse, then keep the old input
  in the AST and return false.
  
  @return Whether the new AST was attached successfully.