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


Java GeneratorContext类代码示例

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


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

示例1: configure

import com.google.gwt.core.ext.GeneratorContext; //导入依赖的package包/类
@Override
protected void configure() {
  install(new ResolutionModule());
  install(new OutputModule());

  bind(TreeLogger.class).toInstance(logger);
  bind(GeneratorContext.class).toInstance(ctx);
  bind(new TypeLiteral<Class<? extends Ginjector>>(){})
      .annotatedWith(GinjectorInterfaceType.class)
      .toInstance(ginjectorInterface);
  bind(GinjectorBindings.class).annotatedWith(RootBindings.class)
      .to(GinjectorBindings.class).in(Singleton.class);
  bind(BindingIndex.class)
      .to(Key.get(GinjectorBindings.class, RootBindings.class))
      .in(Singleton.class);
  install(new FactoryModuleBuilder()
      .build(GuiceElementVisitor.GuiceElementVisitorFactory.class));
  bind(new TypeLiteral<Set<Class<? extends GinModule>>>(){})
      .annotatedWith(ModuleClasses.class)
      .toInstance(moduleClasses);
  bind(BindingFactory.class).to(BindingFactoryImpl.class);
  install(new FactoryModuleBuilder()
      .build(SourceWriteUtil.Factory.class));
}
 
开发者ID:google-code-export,项目名称:google-gin,代码行数:25,代码来源:GinjectorGeneratorModule.java

示例2: getInjectionMap

import com.google.gwt.core.ext.GeneratorContext; //导入依赖的package包/类
protected static GwtInjectionMap getInjectionMap(TreeLogger logger, GeneratorContext ctx){
  //we still have to synchronize because we're passing state through a field.
  GwtInjectionMap map = injectionThreadlocal.get();
  if (map == null)//only synchronize if we have to.
  synchronized (Thread.currentThread()) {//synchro on the lock the threadlocal needs
    //we have to double checked lock because we can't override ThreadLocal#initialValue,
    //as we need the generator context :/
    map = injectionThreadlocal.get();
    if (map != null)
      return map;
    map = new GwtInjectionMap(logger, ctx);
    injectionThreadlocal.set(map);
    //TODO: clean up leaky threadlocals...
  }
  return map;
}
 
开发者ID:WeTheInternet,项目名称:xapi,代码行数:17,代码来源:AbstractInjectionGenerator.java

示例3: generateOnce

import com.google.gwt.core.ext.GeneratorContext; //导入依赖的package包/类
private void generateOnce(PrintWriter printWriter, TreeLogger logger,
    GeneratorContext generatorContext, JClassType componentJsType, ClassName componentTypeName)
throws UnableToCompleteException
{
    String templateContent =
        getTemplateContent(generatorContext.getResourcesOracle(), logger, componentTypeName);

    LocalComponents localComponents = new LocalComponents();
    findLocalComponentsForComponent(localComponents,
        componentJsType.getSuperclass(),
        generatorContext.getTypeOracle());

    TemplateParserContext templateParserContext =
        new TemplateParserContext(componentTypeName, localComponents);
    registerFieldsAndMethodsInContext(templateParserContext, componentJsType);

    TemplateParserResult templateParserResult =
        new TemplateParser(logger).parseHtmlTemplate(templateContent, templateParserContext);

    createTemplateImpl(generatorContext,
        logger,
        printWriter,
        componentTypeName,
        templateParserResult);
}
 
开发者ID:Axellience,项目名称:vue-gwt,代码行数:26,代码来源:TemplateGwtGenerator.java

示例4: generate

import com.google.gwt.core.ext.GeneratorContext; //导入依赖的package包/类
@Override public String generate(TreeLogger logger, GeneratorContext context, String typeName) throws UnableToCompleteException {	
String result = null;
try {
	String version = findVersion(logger, context);
	JClassType classType = context.getTypeOracle().getType(typeName);
	String packageName = packageNameFrom(classType);
	String simpleName = simpleNameFrom(classType);
	result = packageName + '.' + simpleName;
	SourceWriter source = getSourceWriter(logger, context, classType); 
	if(source != null) { //? Otherwise, work needs to be done.
	    source.println();
	    source.println("private String value;");
	    source.println();
	    source.println("public " + simpleName + "() {");
	    populateInstanceFactory(logger, context, typeName, source, version);
	    source.println("}");
	    source.println();
	    source.println("@Override");
	    source.println("public String getValue() {");
	    source.println(" return value;");
	    source.println("}");
	    source.println(); source.commit(logger);
	    //emitVersionArtifact(logger, context, version);
    }
} catch (NotFoundException nfe) {
    logger.log(Type.ERROR, "Could not find extension point type '" + typeName + "'!", nfe);
    throw new UnableToCompleteException();
} 
return result;
  }
 
开发者ID:TOMOTON,项目名称:gwt-dagger2,代码行数:31,代码来源:VersionGenerator.java

示例5: findVersion

import com.google.gwt.core.ext.GeneratorContext; //导入依赖的package包/类
@SuppressWarnings("resource")
private String findVersion(TreeLogger logger, GeneratorContext context) throws UnableToCompleteException {
   	String result = "0.0.0-DEV";
   	Scanner scanner = null;
   	try {
		URL location = Version.class.getClassLoader().getResource("VERSION");
		scanner = new Scanner(location.openStream(), "UTF-8").useDelimiter("\\A");
		result = scanner.next();
	} catch (IOException ioe) {
	    logger.log(Type.ERROR, "Could not determine build version!", ioe);
	    throw new UnableToCompleteException();
	} finally {
		try { scanner.close(); } catch (Exception ignore) {}
	}
   	return result;
   }
 
开发者ID:TOMOTON,项目名称:gwt-dagger2,代码行数:17,代码来源:VersionGenerator.java

示例6: findReflectedClasses

import com.google.gwt.core.ext.GeneratorContext; //导入依赖的package包/类
protected Set<JType> findReflectedClasses(final GeneratorContext context, final TypeOracle typeOracle,
        final TreeLogger logger) throws UnableToCompleteException {
    final Set<JType> types = new HashSet<JType>();
    final Set<String> uediInterfaceNames = getUediInterfaceNames();
    final Set<JClassType> uediInterfaces = new HashSet<JClassType>();
    final String rootPackage = getRootPackage(context, logger);

    for (final JPackage jPackage : typeOracle.getPackages()) {
        for (final JClassType jType : jPackage.getTypes()) {
            if (uediInterfaceNames.contains(jType.getQualifiedSourceName())) {
                uediInterfaces.add(jType);
            } else if (jType.isClass() != null && jType.isInterface() == null && !jType.isClass().isAbstract()
                    && jType.getQualifiedSourceName().startsWith(rootPackage)) {
                types.add(jType);
            }
        }
    }
    if (uediInterfaces.size() < uediInterfaceNames.size()) {
        logger.log(Type.ERROR, "UEDIT: Unable to find UEDI interfaces in classpath. Aborting.");
        throw new UnableToCompleteException();
    }
    return filter(types, uediInterfaces);
}
 
开发者ID:czyzby,项目名称:uedi,代码行数:24,代码来源:ReflectionPoolGenerator.java

示例7: GinjectorBindingsOutputter

import com.google.gwt.core.ext.GeneratorContext; //导入依赖的package包/类
@Inject
GinjectorBindingsOutputter(GeneratorContext ctx,
    ErrorManager errorManager,
    GinjectorFragmentOutputter.Factory fragmentOutputterFactory,
    FragmentPackageName.Factory fragmentPackageNameFactory,
    GinjectorNameGenerator ginjectorNameGenerator,
    TreeLogger logger,
    MethodCallUtil methodCallUtil,
    ReachabilityAnalyzer reachabilityAnalyzer,
    SourceWriteUtil.Factory sourceWriteUtilFactory) {

  this.ctx = ctx;
  this.errorManager = errorManager;
  this.fragmentOutputterFactory = fragmentOutputterFactory;
  this.fragmentPackageNameFactory = fragmentPackageNameFactory;
  this.ginjectorNameGenerator = ginjectorNameGenerator;
  this.logger = logger;
  this.methodCallUtil = methodCallUtil;
  this.reachabilityAnalyzer = reachabilityAnalyzer;
  this.sourceWriteUtilFactory = sourceWriteUtilFactory;
}
 
开发者ID:google-code-export,项目名称:google-gin,代码行数:22,代码来源:GinjectorBindingsOutputter.java

示例8: createModule

import com.google.gwt.core.ext.GeneratorContext; //导入依赖的package包/类
private String createModule(TreeLogger logger, GeneratorContext context, JClassType requestedType,
    String packageName, String requestedName) {
  String moduleName = requestedName + "Module";
  ClassSourceFileComposerFactory moduleFactory =
      new ClassSourceFileComposerFactory(packageName, moduleName);
  moduleFactory.setSuperclass(AbstractGinModule.class.getCanonicalName());
  moduleFactory.addImport(Names.class.getCanonicalName());
  SourceWriter moduleWriter = moduleFactory.createSourceWriter(context,
      context.tryCreate(logger, packageName, moduleName));

  moduleWriter.println("public void configure() {");
  moduleWriter.indent();
  for (JMethod method : requestedType.getMethods()) {
    if (method.getName().startsWith("set")) {
      String name = method.getParameters()[0].getAnnotation(Named.class).value();
      moduleWriter.println("bindConstant().annotatedWith(Names.named(\"" + name + "\")).to(\""
          + Math.pow(Integer.parseInt(name), 2) + "\");");
    }
  }
  moduleWriter.outdent();
  moduleWriter.println("}");
  moduleWriter.commit(logger);
  return moduleName;
}
 
开发者ID:google-code-export,项目名称:google-gin,代码行数:25,代码来源:FrameworkGenerator.java

示例9: getTestCases

import com.google.gwt.core.ext.GeneratorContext; //导入依赖的package包/类
public static List<TestCase> getTestCases(TreeLogger logger, GeneratorContext context)
        throws UnableToCompleteException {
    if (DEBUG) logger = logger.branch(TreeLogger.WARN, "Getting test cases", null, null);
    TypeOracle oracle = context.getTypeOracle();
    JClassType jsTestCaseClass = oracle.findType(JsTestCase.class.getName());

    List<TestCase> testCases = new ArrayList<TestCase>();

    for (JClassType classType : oracle.getTypes()) {
        if (classType.equals(jsTestCaseClass) || !classType.isAssignableTo(jsTestCaseClass)) {
            continue;
        }

        if (classType.getEnclosingType() != null) {
            if (DEBUG) logger.log(TreeLogger.WARN, "Skipping nested class: " +
                    classType.getEnclosingType().getName() + "." + classType.getName());
            continue;
        }

        if (DEBUG) logger.log(TreeLogger.WARN, "Found class: " + classType.getName());
        testCases.add(new TestCase(classType, findTests(logger, context, classType)));
    }
    return testCases;
}
 
开发者ID:chromium,项目名称:dom-distiller,代码行数:25,代码来源:JsTestEntryGenerator.java

示例10: findTests

import com.google.gwt.core.ext.GeneratorContext; //导入依赖的package包/类
public static List<JMethod> findTests(
        TreeLogger logger, GeneratorContext context, JClassType classType)
        throws UnableToCompleteException {
    if (DEBUG) logger = logger.branch(TreeLogger.WARN,
            "Finding tests for class: " + classType.getName());

    List<JMethod> tests = new ArrayList<JMethod>();
    for (JMethod method : classType.getMethods()) {
        if (method.getName().startsWith("test")) {
            if (DEBUG) logger.log(TreeLogger.WARN, "Found test: " + method.getName());
            verifyTestSignature(logger, classType, method);
            tests.add(method);
        }
    }
    return tests;
}
 
开发者ID:chromium,项目名称:dom-distiller,代码行数:17,代码来源:JsTestEntryGenerator.java

示例11: getAllInstantiableClassesByThisfactory

import com.google.gwt.core.ext.GeneratorContext; //导入依赖的package包/类
/**
 * Filter all classes visible to GWT client side and return only those deemed instantiable
 * through the factory class we are generating (that is EntityInputFactoryImpl).
 * <p>
 * Allowing all classes to be instantiable would potentially generate too huge class method
 * perhaps even too huge to compile. There must be some sub-selection. Classes can be filtered
 * based on marker interface, or class annotation see {@link JClassType#getAnnotation(Class)},
 * or some regex matching based on package or class name.
 * 
 * @param context
 * @return Filter all classes visible to GWT client side and return only those deemed
 *         instantiable
 */
private List<JClassType> getAllInstantiableClassesByThisfactory(GeneratorContext context) {
  TypeOracle oracle = context.getTypeOracle();
  JClassType markerInterface1 = oracle.findType(IEntityInput.class.getName());
  JClassType markerInterface2 = oracle.findType(Entity.class.getName());
  List<JClassType> allInstantiableClasses = new LinkedList<JClassType>();

  for (JClassType classType : oracle.getTypes()) {
    if (!classType.equals(markerInterface1) && classType.isAssignableTo(markerInterface1)) {
      allInstantiableClasses.add(classType);
    }
    else if (!classType.equals(markerInterface2) && classType.isAssignableTo(markerInterface2)) {
      allInstantiableClasses.add(classType);
    }
  }

  return allInstantiableClasses;
}
 
开发者ID:KnowledgeCaptureAndDiscovery,项目名称:ontosoft,代码行数:31,代码来源:EntityGenerator.java

示例12: checkEventBus

import com.google.gwt.core.ext.GeneratorContext; //导入依赖的package包/类
private boolean checkEventBus(TreeLogger logger,
                              GeneratorContext ctx) {

  long lastTimeGenerated = ctx.getCachedGeneratorResult()
                              .getTimeGenerated();

  JClassType sourceType = ctx.getTypeOracle()
                             .findType(EventBusElement.class.getName());
  if (sourceType == null) {
    logger.log(TreeLogger.TRACE,
               "Found previously dependent type that's no longer present: " + EventBusElement.class.getName());
    return false;
  }
  assert sourceType instanceof JRealClassType;
  JRealClassType realClass = (JRealClassType) sourceType;
  if (realClass == null || realClass.getLastModifiedTime() > lastTimeGenerated) {
    return false;
  }

  return true;
}
 
开发者ID:mvp4g,项目名称:mvp4g,代码行数:22,代码来源:Mvp4gGenerator.java

示例13: checkModule

import com.google.gwt.core.ext.GeneratorContext; //导入依赖的package包/类
private boolean checkModule(TreeLogger logger,
                            GeneratorContext ctx,
                            JClassType module) {

  long lastTimeGenerated = ctx.getCachedGeneratorResult()
                              .getTimeGenerated();

  if (module == null) {
    logger.log(TreeLogger.TRACE,
               "Found previously dependent type that's no longer present: " + Mvp4gModule.class.getName());
    return false;
  }
  assert module instanceof JRealClassType;
  JRealClassType realClass = (JRealClassType) module;
  if (realClass == null || realClass.getLastModifiedTime() > lastTimeGenerated) {
    return false;
  }

  return true;
}
 
开发者ID:mvp4g,项目名称:mvp4g,代码行数:21,代码来源:Mvp4gGenerator.java

示例14: checkSet

import com.google.gwt.core.ext.GeneratorContext; //导入依赖的package包/类
private boolean checkSet(TreeLogger logger,
                         GeneratorContext ctx,
                         Set<? extends Mvp4gElement> setOfElements) {

  long lastTimeGenerated = ctx.getCachedGeneratorResult()
                              .getTimeGenerated();

  for (Mvp4gElement element : setOfElements) {
    JClassType sourceType = ctx.getTypeOracle()
                               .findType(element.getProperty("class"));
    if (sourceType == null) {
      logger.log(TreeLogger.TRACE,
                 "Found previously dependent type that's no longer present: " + element.getProperty("class"));
      return false;
    }
    assert sourceType instanceof JRealClassType;
    JRealClassType realClass = (JRealClassType) sourceType;
    if (realClass == null || realClass.getLastModifiedTime() > lastTimeGenerated) {
      return false;
    }
  }
  return true;
}
 
开发者ID:mvp4g,项目名称:mvp4g,代码行数:24,代码来源:Mvp4gGenerator.java

示例15: generate

import com.google.gwt.core.ext.GeneratorContext; //导入依赖的package包/类
@Override
public String generate(final TreeLogger logger, final GeneratorContext context,
    final String typeName) throws UnableToCompleteException {
  final TypeOracle typeOracle = context.getTypeOracle();
  assert typeOracle != null;

  final JClassType validatorType = this.findType(logger, typeOracle, typeName);
  final JClassType genericType = this.findType(logger, typeOracle, Validator.class.getName());
  final JClassType gwtSpecificType =
      this.findType(logger, typeOracle, GwtSpecificValidator.class.getName());

  if (validatorType.isAssignableTo(genericType)) {
    return this.generateGenericValidator(logger, context, validatorType);
  } else if (validatorType.isAssignableTo(gwtSpecificType)) {
    return this.generateGwtSpecificValidator(logger, context, validatorType);
  } else {
    logger.log(TreeLogger.ERROR,
        "type is not a ValidatorGenerator or GwtSpecificValidatorGenerator: '" + typeName + "'",
        null);
    throw new UnableToCompleteException();
  }
}
 
开发者ID:ManfredTremmel,项目名称:gwt-bean-validators,代码行数:23,代码来源:ValidatorGenerator.java


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