public void testExternsLifting1() throws Exception { String code = "/** @externs */ function f() {}"; test(new String[] {code}, new String[] {}); assertEquals(2, lastCompiler.getExternsForTesting().size()); CompilerInput extern = lastCompiler.getExternsForTesting().get(1); assertNull(extern.getModule()); assertTrue(extern.isExtern()); assertEquals(code, extern.getCode()); assertEquals(1, lastCompiler.getInputsForTesting().size()); CompilerInput input = lastCompiler.getInputsForTesting().get(0); assertNotNull(input.getModule()); assertFalse(input.isExtern()); assertEquals("", input.getCode()); }
private void addInstaller(Node sourceNode, String function) { // Find the module InputId inputId = sourceNode.getInputId(); CompilerInput input = inputId != null ? compiler.getInput(inputId) : null; JSModule module = input != null ? input.getModule() : null; InjectedInstaller injected = new InjectedInstaller(module, function); if (installers.add(injected)) { changed = true; Node installer = compiler.parseSyntheticCode(function).removeChildren(); installer.useSourceInfoIfMissingFromForTree(sourceNode); Node enclosingScript = NodeUtil.getEnclosingScript(sourceNode); enclosingScript.addChildrenToFront(installer); } }
JSModule getRefModule(ReferenceCollectingCallback.Reference ref) { CompilerInput input = compiler.getInput(ref.getInputId()); return input == null ? null : input.getModule(); }
/** Gets the current input module. */ public JSModule getModule() { CompilerInput input = getInput(); return input == null ? null : input.getModule(); }