當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。