use of com.google.gwt.user.rebind.ClassSourceFileComposerFactory in project rstudio by rstudio.
the class MenuEmitter method generate.
public String generate() throws UnableToCompleteException {
String className = bundleType_.getSimpleSourceName() + "__Menu_" + menuId_;
PrintWriter printWriter = context_.tryCreate(logger_, packageName_, className);
if (printWriter == null)
return null;
ClassSourceFileComposerFactory factory = new ClassSourceFileComposerFactory(packageName_, className);
factory.addImport("org.rstudio.core.client.Debug");
factory.addImport("org.rstudio.core.client.command.MenuCallback");
SourceWriter writer = factory.createSourceWriter(context_, printWriter);
emitFields(writer);
emitConstructor(writer, className);
emitMethod(writer);
writer.outdent();
writer.println("}");
context_.commit(logger_, printWriter);
return packageName_ + "." + className;
}
use of com.google.gwt.user.rebind.ClassSourceFileComposerFactory in project rstudio by rstudio.
the class JavaScriptSerializerGenerator method generate.
@Override
public String generate(TreeLogger logger, GeneratorContext context, String typeName) throws UnableToCompleteException {
TypeOracle oracle = context.getTypeOracle();
List<JClassType> classes = new ArrayList<JClassType>();
// locate all the types annotated with JavaScriptSerializable
for (JClassType classType : oracle.getTypes()) {
if (isAnnotatedSerializable(classType))
classes.add(classType);
}
ClassSourceFileComposerFactory sourceFile = new ClassSourceFileComposerFactory(genPackageName, genClassName);
sourceFile.addImplementedInterface(JavaScriptSerializer.class.getCanonicalName());
sourceFile.addImport("com.google.gwt.core.client.JavaScriptObject");
sourceFile.addImport("org.rstudio.core.client.js.JsObject;");
PrintWriter printWriter = context.tryCreate(logger, genPackageName, genClassName);
if (printWriter != null) {
SourceWriter sourceWriter = sourceFile.createSourceWriter(context, printWriter);
sourceWriter.println(genClassName + "() {");
sourceWriter.println("}");
printSerializers(classes, sourceWriter);
printDeserializers(classes, sourceWriter);
sourceWriter.commit(logger);
}
return sourceFile.getCreatedClassName();
}
use of com.google.gwt.user.rebind.ClassSourceFileComposerFactory in project libgdx by libgdx.
the class ReflectionCacheSourceCreator method createProxy.
private void createProxy(JClassType type) {
ClassSourceFileComposerFactory composer = new ClassSourceFileComposerFactory(type.getPackage().getName(), type.getSimpleSourceName() + "Proxy");
PrintWriter printWriter = context.tryCreate(logger, packageName, simpleName);
if (printWriter == null) {
return;
}
SourceWriter writer = composer.createSourceWriter(context, printWriter);
writer.commit(logger);
}
use of com.google.gwt.user.rebind.ClassSourceFileComposerFactory in project libgdx by libgdx.
the class ReflectionCacheSourceCreator method create.
public String create() {
ClassSourceFileComposerFactory composer = new ClassSourceFileComposerFactory(packageName, simpleName);
composer.addImplementedInterface("com.badlogic.gwtref.client.IReflectionCache");
imports(composer);
PrintWriter printWriter = context.tryCreate(logger, packageName, simpleName);
if (printWriter == null) {
return packageName + "." + simpleName;
}
sw = composer.createSourceWriter(context, printWriter);
generateLookups();
forNameC();
newArrayC();
getArrayLengthT();
getArrayElementT();
setArrayElementT();
getF();
setF();
invokeM();
sw.commit(logger);
createProxy(type);
return packageName + "." + simpleName;
}
use of com.google.gwt.user.rebind.ClassSourceFileComposerFactory in project gerrit by GerritCodeReview.
the class PluginGenerator method generate.
@Override
public String generate(TreeLogger logger, GeneratorContext context, String typeName) throws UnableToCompleteException {
// The TypeOracle knows about all types in the type system
TypeOracle typeOracle = context.getTypeOracle();
// Get a reference to the type that the generator should implement
JClassType sourceType = typeOracle.findType(typeName);
// Ensure that the requested type exists
if (sourceType == null) {
logger.log(TreeLogger.ERROR, "Could not find requested typeName", null);
throw new UnableToCompleteException();
}
// Make sure the Gadget type is correctly defined
validateType(logger, sourceType);
// Pick a name for the generated class to not conflict.
String generatedSimpleSourceName = sourceType.getSimpleSourceName() + "PluginImpl";
// Begin writing the generated source.
ClassSourceFileComposerFactory f = new ClassSourceFileComposerFactory(sourceType.getPackage().getName(), generatedSimpleSourceName);
f.addImport(GWT.class.getName());
f.setSuperclass(typeName);
// All source gets written through this Writer
PrintWriter out = context.tryCreate(logger, sourceType.getPackage().getName(), generatedSimpleSourceName);
// If an implementation already exists, we don't need to do any work
if (out != null) {
// We really use a SourceWriter since it's convenient
SourceWriter sw = f.createSourceWriter(context, out);
sw.commit(logger);
}
return f.getCreatedClassName();
}
Aggregations