use of com.google.javascript.jscomp.modules.ModuleMetadataMap.ModuleMetadata in project closure-compiler by google.
the class GatherModuleMetadataTest method testGoogProvideWithGoogDeclaredInOtherFile.
@Test
public void testGoogProvideWithGoogDeclaredInOtherFile() {
// Closure's base.js declare the global goog. It should be ignored when scanning the provide'd
// file. Only local variables named goog should cause the pass to back off.
testSame(srcs("var goog;", "goog.provide('my.provide');"));
assertThat(metadataMap().getModulesByGoogNamespace().keySet()).containsExactly("my.provide");
ModuleMetadata m = metadataMap().getModulesByGoogNamespace().get("my.provide");
assertThat(m.googNamespaces()).containsExactly("my.provide");
assertThat(m.isGoogProvide()).isTrue();
}
use of com.google.javascript.jscomp.modules.ModuleMetadataMap.ModuleMetadata in project closure-compiler by google.
the class GatherModuleMetadataTest method testRequiredClosureNamespaces.
@Test
public void testRequiredClosureNamespaces() {
testSame("goog.require('my.Type');");
ModuleMetadata m = metadataMap().getModulesByPath().get("testcode");
assertThat(m.stronglyRequiredGoogNamespaces()).containsExactly("my.Type");
}
use of com.google.javascript.jscomp.modules.ModuleMetadataMap.ModuleMetadata in project closure-compiler by google.
the class GatherModuleMetadataTest method testBundleGoogLoadModuleAndProvides.
@Test
public void testBundleGoogLoadModuleAndProvides() {
testSame(lines("goog.provide('some.provide');", "", "goog.provide('some.other.provide');", "", "goog.loadModule(function(exports) {", " goog.module('multiple.calls.c0');", " return exports;", "});", "", "goog.loadModule(function(exports) {", " goog.module('multiple.calls.c1');", " return exports;", "});"));
assertThat(metadataMap().getModulesByGoogNamespace().keySet()).containsExactly("some.provide", "some.other.provide", "multiple.calls.c0", "multiple.calls.c1");
ModuleMetadata m = metadataMap().getModulesByGoogNamespace().get("multiple.calls.c0");
assertThat(m.googNamespaces()).containsExactly("multiple.calls.c0");
assertThat(m.isNonLegacyGoogModule()).isTrue();
assertThat(m.path()).isNull();
assertThat(m.usesClosure()).isTrue();
m = metadataMap().getModulesByGoogNamespace().get("multiple.calls.c1");
assertThat(m.googNamespaces()).containsExactly("multiple.calls.c1");
assertThat(m.isNonLegacyGoogModule()).isTrue();
assertThat(m.path()).isNull();
assertThat(m.usesClosure()).isTrue();
m = metadataMap().getModulesByPath().get("testcode");
assertThat(m.googNamespaces()).containsExactly("some.provide", "some.other.provide");
assertThat(m.isGoogProvide()).isTrue();
assertThat(m.usesClosure()).isTrue();
}
use of com.google.javascript.jscomp.modules.ModuleMetadataMap.ModuleMetadata in project closure-compiler by google.
the class ModuleMapCreator method create.
private ModuleMap create() {
unresolvedModules.clear();
unresolvedModulesByClosureNamespace.clear();
// goog.loadModule calls.
for (ModuleMetadata moduleMetadata : moduleMetadataMap.getAllModuleMetadata()) {
process(moduleMetadata);
}
return resolve();
}
use of com.google.javascript.jscomp.modules.ModuleMetadataMap.ModuleMetadata in project closure-compiler by google.
the class GlobalNamespaceTest method googModuleLevelNamesAreCaptured.
@Test
public void googModuleLevelNamesAreCaptured() {
GlobalNamespace namespace = parseAndGatherModuleData("goog.module('m'); const x = 0;");
ModuleMetadata metadata = lastCompiler.getModuleMetadataMap().getModulesByGoogNamespace().get("m");
Name x = namespace.getNameFromModule(metadata, "x");
assertThat(x).isNotNull();
assertThat(x.getDeclaration()).isNotNull();
}
Aggregations