本文整理汇总了Java中com.google.gwt.user.rebind.SourceWriter.commit方法的典型用法代码示例。如果您正苦于以下问题:Java SourceWriter.commit方法的具体用法?Java SourceWriter.commit怎么用?Java SourceWriter.commit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.gwt.user.rebind.SourceWriter
的用法示例。
在下文中一共展示了SourceWriter.commit方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: generate
import com.google.gwt.user.rebind.SourceWriter; //导入方法依赖的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;
}
示例2: createModule
import com.google.gwt.user.rebind.SourceWriter; //导入方法依赖的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;
}
示例3: generateDataProxyFastJSOClasses
import com.google.gwt.user.rebind.SourceWriter; //导入方法依赖的package包/类
void generateDataProxyFastJSOClasses()
{
for( JType type : dataProxyFastFactories )
{
String jsoPackage = getDataProxyFastImplPackageName( type );
String jsoSimpleClassName = getDataProxyFastImplSimpleName( type );
PrintWriter pw2 = context.tryCreate( logger, jsoPackage, jsoSimpleClassName );
if( pw2 == null )
continue;
ClassSourceFileComposerFactory cf2 = new ClassSourceFileComposerFactory( jsoPackage, jsoSimpleClassName );
cf2.addImport( "fr.lteconsulting.hexa.client.comm.GenericJSO" );
cf2.addImport( "com.google.gwt.core.client.JavaScriptObject" );
cf2.addImport( "com.google.gwt.core.client.GWT" );
cf2.addImport( "fr.lteconsulting.hexa.client.tools.HexaTools" );
cf2.addImplementedInterface( type.getParameterizedQualifiedSourceName() );
cf2.setSuperclass( "GenericJSO" );
SourceWriter sw2 = cf2.createSourceWriter( context, pw2 );
generateDataProxyFastJSOImpl( jsoSimpleClassName, type, sw2, logger );
sw2.commit( logger );
}
}
示例4: create
import com.google.gwt.user.rebind.SourceWriter; //导入方法依赖的package包/类
public String create(TreeLogger logger, GeneratorContext context) {
PrintWriter printWriter = context.tryCreate(logger, this.packageName, this.viewProxySimpleName);
if (printWriter == null) {
return this.viewProxyQualifiedName;
}
SourceWriter srcWriter = this.getSourceWriter(printWriter, context);
srcWriter.indent();
this.generateProxy(logger, srcWriter);
srcWriter.println();
this.generateTokenPrefixes(logger, srcWriter);
srcWriter.println();
if (this.placeTokenizerClass == null) {
this.generateInternalTokenizer(logger, srcWriter);
} else {
this.generateDelegateTokenizer(logger, srcWriter);
}
this.generateActivityFactory(logger, srcWriter);
srcWriter.outdent();
srcWriter.commit(logger);
return this.viewProxyQualifiedName;
}
示例5: create
import com.google.gwt.user.rebind.SourceWriter; //导入方法依赖的package包/类
public String create(TreeLogger logger, GeneratorContext context) throws UnableToCompleteException, NotFoundException {
PrintWriter printWriter = this.getPrintWriter(logger, context);
if (printWriter == null) {
return this.proxyModelQualifiedName;
}
this.serializerTypeName = this.createSerializer(logger, context);
this.collectImports();
SourceWriter srcWriter = this.getSourceWriter(printWriter, context);
srcWriter.indent();
srcWriter.println();
this.generateSerializer(srcWriter);
srcWriter.println();
this.generateServiceImplementation(logger, srcWriter);
this.generateServiceImplementationWithCallback(logger, srcWriter);
srcWriter.outdent();
srcWriter.commit(logger);
return this.proxyModelQualifiedName;
}
示例6: create
import com.google.gwt.user.rebind.SourceWriter; //导入方法依赖的package包/类
public String create(TreeLogger logger, GeneratorContext context) {
PrintWriter writer = context.tryCreate(logger, this.packageName, this.proxyName);
if (writer == null) {
return this.proxyQualifiedName;
}
SourceWriter srcWriter = this.getSourceWriter(writer, context);
srcWriter.indent();
this.doCreate(logger, context, srcWriter);
srcWriter.outdent();
srcWriter.commit(logger);
return this.proxyQualifiedName;
}
示例7: create
import com.google.gwt.user.rebind.SourceWriter; //导入方法依赖的package包/类
public String create(TreeLogger logger, GeneratorContext context) {
PrintWriter printWriter = this.getPrintWriter(logger, context);
if (printWriter == null) {
return this.proxyModelQualifiedName;
}
this.collectImports();
SourceWriter srcWriter = this.getSourceWriter(printWriter, context);
srcWriter.indent();
srcWriter.println();
this.generateCreateService(srcWriter);
srcWriter.println();
this.generateServiceImplementation(logger, srcWriter);
this.generateServiceImplementationWithCallback(srcWriter);
srcWriter.outdent();
srcWriter.commit(logger);
return this.proxyModelQualifiedName;
}
示例8: generate
import com.google.gwt.user.rebind.SourceWriter; //导入方法依赖的package包/类
public String generate() throws UnableToCompleteException{
JClassType classType;
try {
logger.log(Type.DEBUG, "Start generate UNIT for " + typeName + " in " + this.getClass().getName());
Calendar start = Calendar.getInstance();
classType = typeOracle.getType(typeName);
if (genExclusion(classType)){
return null;
}
SourceWriter source = getSourceWriter(classType, isUseLog(), 6);
if ((source != null)) {
source.indent();
createSource(source, classType);
source.outdent();
source.commit(logger);
}
logger.log(Type.DEBUG, "Code commited, Unit name: " + getUnitName(classType) + " Time:" + (start.getTimeInMillis() - Calendar.getInstance().getTimeInMillis()));
return getUnitName(classType);
} catch (Throwable e) {
this.logger.log(Type.ERROR, e.getMessage(), e);
throw new UnableToCompleteException();
}
}
示例9: write
import com.google.gwt.user.rebind.SourceWriter; //导入方法依赖的package包/类
/**
* Writes the Ginjector class for the given bindings object, and all its
* package-specific fragments.
*/
void write(GinjectorBindings bindings) throws UnableToCompleteException {
TypeLiteral<?> ginjectorInterface = bindings.getGinjectorInterface();
String implClassName = ginjectorNameGenerator.getClassName(bindings);
if (implClassName.contains(".")) {
errorManager.logError("Internal error: the injector class name \"%s\" contains a full stop.",
implClassName);
}
String packageName = ReflectUtil.getUserPackageName(TypeLiteral.get(bindings.getModule()));
PrintWriter printWriter = ctx.tryCreate(logger, packageName, implClassName);
if (printWriter == null) {
// We already created this Ginjector.
return;
}
ClassSourceFileComposerFactory composerFactory = new ClassSourceFileComposerFactory(packageName,
implClassName);
SourceWriter writer = composerFactory.createSourceWriter(ctx, printWriter);
FragmentMap fragments = new FragmentMap(bindings, packageName, implClassName,
fragmentOutputterFactory);
outputBindings(bindings, fragments, writer);
errorManager.checkForError();
fragments.commitAll();
writer.commit(logger);
}
示例10: generate
import com.google.gwt.user.rebind.SourceWriter; //导入方法依赖的package包/类
@Override
public String generate(TreeLogger logger, GeneratorContext context, String typeName)
throws UnableToCompleteException {
JClassType requestedType = context.getTypeOracle().findType(typeName);
String packageName = requestedType.getPackage().getName();
String requestedName = requestedType.getSimpleSourceName();
String newClassName = requestedName + "Impl";
String moduleName = createModule(logger, context, requestedType, packageName, requestedName);
String ginjectorName =
createGinjector(logger, context, packageName, requestedName, newClassName, moduleName);
ClassSourceFileComposerFactory composerFactory =
new ClassSourceFileComposerFactory(packageName, newClassName);
composerFactory.setSuperclass(requestedType.getQualifiedSourceName());
composerFactory.addImport(GWT.class.getCanonicalName());
SourceWriter writer = composerFactory
.createSourceWriter(context, context.tryCreate(logger, packageName, newClassName));
writer.println("public void initialize() {");
writer.indent();
writer.println(
"((" + ginjectorName + ") GWT.create(" + ginjectorName + ".class)).injectMembers(this);");
writer.outdent();
writer.println("}");
writer.commit(logger);
return packageName + "." + newClassName;
}
示例11: createGinjector
import com.google.gwt.user.rebind.SourceWriter; //导入方法依赖的package包/类
private String createGinjector(TreeLogger logger, GeneratorContext context, String packageName,
String requestedName, String newClassName, String moduleName) {
String ginjectorName = requestedName + "Ginjector";
ClassSourceFileComposerFactory ginjectorFactory =
new ClassSourceFileComposerFactory(packageName, ginjectorName);
ginjectorFactory.makeInterface();
ginjectorFactory.addImplementedInterface(Ginjector.class.getCanonicalName());
ginjectorFactory.addImport(GinModules.class.getCanonicalName());
ginjectorFactory.addAnnotationDeclaration("@GinModules(" + moduleName + ".class)");
SourceWriter ginjectorWriter = ginjectorFactory.createSourceWriter(context,
context.tryCreate(logger, packageName, ginjectorName));
ginjectorWriter.println("void injectMembers(" + newClassName + " obj);");
ginjectorWriter.commit(logger);
return ginjectorName;
}
示例12: writeInterface
import com.google.gwt.user.rebind.SourceWriter; //导入方法依赖的package包/类
/**
* Write an Empty Interface implementing
* {@link de.knightsoftnet.validators.client.impl.GwtSpecificValidator} with Generic parameter of
* the bean type.
*/
private void writeInterface(final GeneratorContext context, final TreeLogger logger,
final BeanHelper bean) {
final PrintWriter pw = context.tryCreate(logger, bean.getPackage(), bean.getValidatorName());
if (pw != null) {
final TreeLogger interfaceLogger = logger.branch(TreeLogger.TRACE,
"Creating the interface for " + bean.getFullyQualifiedValidatorName());
final ClassSourceFileComposerFactory factory =
new ClassSourceFileComposerFactory(bean.getPackage(), bean.getValidatorName());
factory.addImplementedInterface(
GwtSpecificValidator.class.getCanonicalName() + " <" + bean.getTypeCanonicalName() + ">");
factory.addImport(GWT.class.getCanonicalName());
factory.makeInterface();
final SourceWriter sw = factory.createSourceWriter(context, pw);
// static MyValidator INSTANCE = GWT.create(MyValidator.class);
sw.print("static ");
sw.print(bean.getValidatorName());
sw.print(" INSTANCE = GWT.create(");
sw.print(bean.getValidatorName());
sw.println(".class);");
sw.commit(interfaceLogger);
pw.close();
}
}
示例13: create
import com.google.gwt.user.rebind.SourceWriter; //导入方法依赖的package包/类
/**
* create logger.
*
* @return qualified name
* @throws UnableToCompleteException if fails
*/
public final String create() throws UnableToCompleteException {
final SourceWriter sourceWriter = this.getSourceWriter(this.logger, this.context);
if (sourceWriter != null) {
this.writeClassBody(sourceWriter);
sourceWriter.commit(this.logger);
}
return this.getQualifiedName();
}
示例14: createDummyClass
import com.google.gwt.user.rebind.SourceWriter; //导入方法依赖的package包/类
private String createDummyClass (TreeLogger logger, GeneratorContext context) {
String packageName = "com.badlogic.gdx.backends.gwt.preloader";
String className = "PreloaderBundleImpl";
ClassSourceFileComposerFactory composer = new ClassSourceFileComposerFactory(packageName, className);
composer.addImplementedInterface(packageName + ".PreloaderBundle");
PrintWriter printWriter = context.tryCreate(logger, packageName, className);
if (printWriter == null) {
return packageName + "." + className;
}
SourceWriter sourceWriter = composer.createSourceWriter(context, printWriter);
sourceWriter.commit(logger);
return packageName + "." + className;
}
示例15: createProxy
import com.google.gwt.user.rebind.SourceWriter; //导入方法依赖的package包/类
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);
}