use of com.google.javascript.jscomp.modules.ModuleMetadataMap.ModuleMetadata in project closure-compiler by google.
the class GlobalNamespaceTest method googModuleLevelQualifiedNamesAreCaptured.
@Test
public void googModuleLevelQualifiedNamesAreCaptured() {
GlobalNamespace namespace = parseAndGatherModuleData("goog.module('m'); class Foo {} Foo.Bar = 0;");
ModuleMetadata metadata = lastCompiler.getModuleMetadataMap().getModulesByGoogNamespace().get("m");
Name x = namespace.getNameFromModule(metadata, "Foo.Bar");
assertThat(x).isNotNull();
assertThat(x.getDeclaration()).isNotNull();
}
use of com.google.javascript.jscomp.modules.ModuleMetadataMap.ModuleMetadata in project closure-compiler by google.
the class GlobalNamespaceTest method googLoadModule_containsExportsPropertyAssignments.
@Test
public void googLoadModule_containsExportsPropertyAssignments() {
GlobalNamespace namespace = parseAndGatherModuleData(lines("goog.loadModule(function(exports) {", " goog.module('m');", " exports.Foo = class {};", " return exports;", "});"));
ModuleMetadata metadata = lastCompiler.getModuleMetadataMap().getModulesByGoogNamespace().get("m");
Name exportsFoo = namespace.getNameFromModule(metadata, "exports.Foo");
assertThat(exportsFoo.getGlobalSets()).isEqualTo(1);
}
use of com.google.javascript.jscomp.modules.ModuleMetadataMap.ModuleMetadata in project closure-compiler by google.
the class GlobalNamespaceTest method googLoadModule_containsExports.
@Test
public void googLoadModule_containsExports() {
GlobalNamespace namespace = parseAndGatherModuleData(lines("goog.loadModule(function(exports) {", " goog.module('m');", " const x = 0;", " return exports;", "});"));
ModuleMetadata metadata = lastCompiler.getModuleMetadataMap().getModulesByGoogNamespace().get("m");
Name exports = namespace.getNameFromModule(metadata, "exports");
assertThat(exports.getGlobalSets()).isEqualTo(0);
}
use of com.google.javascript.jscomp.modules.ModuleMetadataMap.ModuleMetadata in project closure-compiler by google.
the class TypedScopeCreator method containingGoogModuleIdOf.
@Nullable
static String containingGoogModuleIdOf(TypedScope scope) {
Module module = scope.getModule();
if (module == null) {
TypedScope parent = scope.getParent();
return (parent != null) ? containingGoogModuleIdOf(parent) : null;
}
// Stop recursing once we've hit a module scope.
ModuleMetadata metadata = module.metadata();
checkState(metadata.isModule(), metadata);
/**
* This module may not have a goog.module/goog.declareModuleId. Also don't crash if it's
* malformed with multiple module IDs.
*/
return Iterables.getFirst(metadata.googNamespaces(), null);
}
use of com.google.javascript.jscomp.modules.ModuleMetadataMap.ModuleMetadata in project closure-compiler by google.
the class PolymerBehaviorExtractor method resolveGoogModuleGet.
private ResolveBehaviorNameResult resolveGoogModuleGet(String moduleNamespace) {
ModuleMetadata closureModule = moduleMetadataMap.getModulesByGoogNamespace().get(moduleNamespace);
if (closureModule == null) {
// Invalid goog.module.get() call.
return FAILED_RESOLVE_RESULT;
} else if (closureModule.isGoogProvide()) {
return resolveBehaviorName(moduleNamespace, null);
}
checkState(closureModule.isGoogModule(), closureModule);
return resolveBehaviorName(GOOG_MODULE_EXPORTS, closureModule);
}
Aggregations