当前位置: 首页>>代码示例>>Java>>正文


Java TypedScope类代码示例

本文整理汇总了Java中com.google.javascript.jscomp.TypedScope的典型用法代码示例。如果您正苦于以下问题:Java TypedScope类的具体用法?Java TypedScope怎么用?Java TypedScope使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


TypedScope类属于com.google.javascript.jscomp包,在下文中一共展示了TypedScope类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: visitTopScope

import com.google.javascript.jscomp.TypedScope; //导入依赖的package包/类
@Override
protected boolean visitTopScope(TypedScope scope) {
  Type globalJavaType = createGlobalJavaType(packagePrefix);

  if (!getContext().getExternDependencyFiles().isEmpty()) {
    // We don't add the global type to the dependency mapping file so we cannot use that
    // information to decide if there is already a global scope defined in the dependencies.
    // It's simply safe to assume that if there are dependencies, a global scope is already
    // defined. If the current sources define function/variable on the global scope, a specific
    // extension type will be created for the global scope.
    globalJavaType.setExtern(true);
  }

  getJavaTypeRegistry().registerJavaGlobalType(globalJavaType, scope.getTypeOfThis());
  getContext().getJavaProgram().addType(globalJavaType);
  // push the current java type to be able to create an extension type later.
  super.pushCurrentJavaType(globalJavaType);

  return true;
}
 
开发者ID:google,项目名称:jsinterop-generator,代码行数:21,代码来源:TypeCollector.java

示例2: generateJavaProgram

import com.google.javascript.jscomp.TypedScope; //导入依赖的package包/类
private Program generateJavaProgram() {
  List<SourceFile> allSources =
      ImmutableList.<SourceFile>builder()
          .addAll(options.getDependencies())
          .addAll(options.getSources())
          .build();

  compiler.compile(new ArrayList<>(), allSources, createCompilerOptions());

  GenerationContext ctx =
      GenerationContext.builder()
          .compiler(compiler)
          .sourceFiles(options.getSources())
          .externDependencyFiles(options.getDependencies())
          // TODO(b/36178451): set the map in the context directly
          .javaProgram(new Program(readKeyValueFiles(options.getDependencyMappingFiles())))
          .typeRegistry(new ClosureTypeRegistry())
          .nameMapping(readKeyValueFiles(options.getNameMappingFiles()))
          .build();

  TypedScope topScope = compiler.getTopScope();

  new TypeCollector(ctx, options.getPackagePrefix(), options.getExtensionTypePrefix())
      .accept(topScope);

  new AnonymousTypeCollector(ctx).accept(topScope);

  new MemberCollector(ctx).accept(topScope);

  new EnumMemberCollector(ctx).accept(topScope);

  new InheritanceVisitor(ctx).accept(topScope);

  new TypeParameterCollector(ctx).accept(topScope);

  return ctx.getJavaProgram();
}
 
开发者ID:google,项目名称:jsinterop-generator,代码行数:38,代码来源:ClosureJsInteropGenerator.java

示例3: accept

import com.google.javascript.jscomp.TypedScope; //导入依赖的package包/类
@Override
public void accept(TypedScope scope) {
  super.accept(scope);

  checkState(
      parameterNameMapping.isEmpty(), "Unused parameter name mapping: %s", parameterNameMapping);
}
 
开发者ID:google,项目名称:jsinterop-generator,代码行数:8,代码来源:MemberCollector.java

示例4: accept

import com.google.javascript.jscomp.TypedScope; //导入依赖的package包/类
public void accept(TypedScope scope) {
  pushCurrentJavaType(scope.getTypeOfThis());
  if (visitTopScope(scope)) {
    for (TypedVar symbol : scope.getVarIterable()) {
      if (isDefinedInExternFiles(symbol) && isNotNamespaced(symbol)) {
        accept(symbol, true);
      }
    }
  }
  popCurrentJavaType();
}
 
开发者ID:google,项目名称:jsinterop-generator,代码行数:12,代码来源:AbstractClosureVisitor.java

示例5: visitTopScope

import com.google.javascript.jscomp.TypedScope; //导入依赖的package包/类
protected boolean visitTopScope(TypedScope scope) {
  return true;
}
 
开发者ID:google,项目名称:jsinterop-generator,代码行数:4,代码来源:AbstractClosureVisitor.java

示例6: processReservedSymbols

import com.google.javascript.jscomp.TypedScope; //导入依赖的package包/类
/**
 * Reserved words are problematic because they cannot be used as var declarations, but are valid
 * properties. For example:
 *
 * <pre>
 * var switch = 0;  // parses badly in JS.
 * foo.switch = 0;  // ok.
 * </pre>
 *
 * This means that closure code is allowed to goog.provide('ng.components.switch'), which cannot
 * trivially translate in TS to:
 *
 * <pre>
 * namespace ng.components {
 *   var switch : ...;
 * }
 * </pre>
 *
 * Instead, go one step higher and generate:
 *
 * <pre>
 * namespace ng {
 *   var components : {switch: ..., };
 * }
 * </pre>
 *
 * This turns a namespace into a property of its parent namespace. Note: this violates the
 * invariant that generated namespaces are 1-1 with getNamespace of goog.provides.
 */
private void processReservedSymbols(TreeSet<String> provides, TypedScope topScope) {
  Set<String> collapsedNamespaces = new TreeSet<>();
  for (String reservedProvide : provides) {
    if (RESERVED_JS_WORDS.contains(getUnqualifiedName(reservedProvide))) {
      String namespace = getNamespace(reservedProvide);
      if (collapsedNamespaces.contains(namespace)) continue;
      collapsedNamespaces.add(namespace);
      Set<String> properties = getSubNamespace(provides, namespace);
      emitNamespaceBegin(getNamespace(namespace));
      emit("var");
      emit(getUnqualifiedName(namespace));
      emit(": {");
      Iterator<String> bundledIt = properties.iterator();
      while (bundledIt.hasNext()) {
        emit(getUnqualifiedName(bundledIt.next()));
        emit(":");
        TypedVar var = topScope.getOwnSlot(reservedProvide);
        if (var != null) {
          TreeWalker walker = new TreeWalker(compiler.getTypeRegistry(), provides, false, false);
          walker.visitType(var.getType());
        } else {
          emit("any");
        }
        if (bundledIt.hasNext()) emit(",");
      }
      emit("};");
      emitBreak();
      emitNamespaceEnd();
      for (String property : properties) {
        // Assume that all symbols that are siblings of the reserved word are default exports.
        declareModule(property, true, property, true);
      }
    }
  }
  // Remove the symbols that we have emitted above.
  Iterator<String> it = provides.iterator();
  while (it.hasNext()) {
    if (collapsedNamespaces.contains(getNamespace(it.next()))) it.remove();
  }
}
 
开发者ID:angular,项目名称:clutz,代码行数:70,代码来源:DeclarationGenerator.java


注:本文中的com.google.javascript.jscomp.TypedScope类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。