本文整理汇总了Java中com.google.gwt.user.rebind.SourceWriter类的典型用法代码示例。如果您正苦于以下问题:Java SourceWriter类的具体用法?Java SourceWriter怎么用?Java SourceWriter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SourceWriter类属于com.google.gwt.user.rebind包,在下文中一共展示了SourceWriter类的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: printFactoryMethod
import com.google.gwt.user.rebind.SourceWriter; //导入依赖的package包/类
private void printFactoryMethod(SourceWriter out, JMethod methodToImplement,
JClassType mockControlInterface, String classToCreate) {
out.println("%s {", methodToImplement.getReadableDeclaration(false, false, false, false, true));
out.indent();
if (isNiceMock(methodToImplement, mockControlInterface)) {
out.print("return this.setToNice(new %s(", classToCreate);
printMatchingParameters(out, methodToImplement);
out.println(").__mockInit(this));");
} else {
out.print("return new %s(", classToCreate);
printMatchingParameters(out, methodToImplement);
out.println(").__mockInit(this);");
}
out.outdent();
out.println("}");
}
示例3: printMatchingParameters
import com.google.gwt.user.rebind.SourceWriter; //导入依赖的package包/类
private void printMatchingParameters(SourceWriter out, JMethod methodToImplement) {
JParameter[] params = methodToImplement.getParameters();
for (int i = 0; i < params.length; i++) {
if (i > 0) {
out.print(", ");
}
out.print(params[i].getName());
}
}
示例4: printMatchingSuperCall
import com.google.gwt.user.rebind.SourceWriter; //导入依赖的package包/类
private void printMatchingSuperCall(SourceWriter out, JConstructor constructorToCall) {
if (constructorToCall.getParameters().length == 0) {
return; // will be added automatically
}
out.print("super(");
JParameter[] params = constructorToCall.getParameters();
for (int i = 0; i < params.length; i++) {
if (i > 0) {
out.print(", ");
}
out.print(params[i].getName());
}
out.println(");");
}
示例5: doGetSourceWriter
import com.google.gwt.user.rebind.SourceWriter; //导入依赖的package包/类
@Override
protected SourceWriter doGetSourceWriter(JClassType classType) {
String packageName = classType.getPackage().getName();
String simpleName = getSimpleUnitName(classType);
ClassSourceFileComposerFactory composer = new ClassSourceFileComposerFactory(
packageName, simpleName);
composer.setSuperclass(TypeOracleImpl.class.getCanonicalName());
composer.addImport("org.lirazs.gbackbone.reflection.client.*");
composer.addImport("java.util.*");
composer.addImport(classType.getPackage().getName() + ".*");
PrintWriter printWriter = context.tryCreate(logger, packageName, simpleName);
if (printWriter == null) {
return null;
} else {
SourceWriter sw = composer.createSourceWriter(context, printWriter);
return sw;
}
}
示例6: createSource
import com.google.gwt.user.rebind.SourceWriter; //导入依赖的package包/类
@Override
protected void createSource(SourceWriter source, JClassType classType) {
source.println("public " + getSimpleUnitName(classType) + "(){");
source.indent();
List<JClassType> types = allReflectionClasses();
for(JClassType type : types){
ReflectionProxyGenerator gen = new ReflectionProxyGenerator();
try {
String classname = gen.generate(this.logger, context, type.getQualifiedSourceName());
source.println("new " + classname + "();");
} catch (UnableToCompleteException e) {
throw new CheckedExceptionWrapper(e);
}
}
source.outdent();
source.println("}");
}
示例7: addClassAnnotation
import com.google.gwt.user.rebind.SourceWriter; //导入依赖的package包/类
protected void addClassAnnotation(JClassType classType,
SourceWriter source) {
source.println();
source.println("protected void addAnnotations(){");
source.indent();
if (this.reflectable.classAnnotations()) {
Annotation[] annotations = AnnotationsHelper
.getAnnotations(classType);
GeneratorHelper.addAnnotations_AnnotationImpl(this.typeOracle,
"this", source, annotations, logger);
}
source.outdent();
source.println("}");
}
示例8: addAnnotations_AnnotationImpl
import com.google.gwt.user.rebind.SourceWriter; //导入依赖的package包/类
public static void addAnnotations_AnnotationImpl(TypeOracle typeOracle,
String dest, SourceWriter source, Annotation[] annotations, TreeLogger logger){
if (annotations.length <= 0)
return;
for (Annotation annotation : annotations) {
JClassType classType = typeOracle.findType(ReflectionUtils.getQualifiedSourceName(annotation.annotationType()));
if (classType != null){
source.print(dest + ".addAnnotation(" + createAnnotationValues(typeOracle, annotation, logger) + ");");
}else{
logger.log(Type.ERROR, "Annotation (" + ReflectionUtils.getQualifiedSourceName(annotation.annotationType()) + ") not exists in compiled client source code, please ensure this class is exists and included in your module(.gwt.xml) file. GWTENT reflection process will ignore it and continue. ");
}
}
}
示例9: generateGetExtensionsMethod
import com.google.gwt.user.rebind.SourceWriter; //导入依赖的package包/类
/**
* Generate the code for {@link ExtensionRegistry#getExtensionDescriptions()}
*
* @param sw
*/
private void generateGetExtensionsMethod(SourceWriter sw) {
/*
@Override
public StringMap<ExtensionDescription> getExtensionDescriptions()
{
return extensions;
}
*/
sw.println("@Override");
sw.println("public Map<String, ExtensionDescription> getExtensionDescriptions()");
sw.println("{");
sw.indent();
sw.println("return extensions;");
sw.outdent();
sw.println("}");
}
示例10: GinjectorFragmentContext
import com.google.gwt.user.rebind.SourceWriter; //导入依赖的package包/类
@Inject
public GinjectorFragmentContext(
ErrorManager errorManager,
FragmentPackageName.Factory fragmentPackageNameFactory,
GinjectorNameGenerator ginjectorNameGenerator,
SourceWriteUtil.Factory sourceWriteUtilFactory,
@Assisted GinjectorBindings bindings,
@Assisted FragmentPackageName fragmentPackageName,
@Assisted SourceWriter sourceWriter) {
this.bindings = bindings;
this.errorManager = errorManager;
this.fragmentPackageName = fragmentPackageName;
this.fragmentPackageNameFactory = fragmentPackageNameFactory;
this.ginjectorNameGenerator = ginjectorNameGenerator;
this.sourceWriteUtil = sourceWriteUtilFactory.create(bindings);
this.sourceWriter = sourceWriter;
}
示例11: writeBindingContext
import com.google.gwt.user.rebind.SourceWriter; //导入依赖的package包/类
/**
* Writes out a binding context, followed by a newline.
*
* <p>Binding contexts may contain newlines; this routine translates those for
* the SourceWriter to ensure that indents, Javadoc comments, etc are handled
* properly.
*/
public void writeBindingContext(SourceWriter writer, Context context) {
// Avoid a trailing \n -- the GWT class source file composer will output an
// ugly extra newline if we do that.
String text = context.toString();
boolean first = true;
for (String line : text.split("\n")) {
if (first) {
first = false;
} else {
writer.println();
}
// Indent the line relative to its current location. writer.indent()
// won't work, since it does the wrong thing in Javadoc.
writer.print(" ");
writer.print(line);
}
}
示例12: 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;
}
示例13: writePresent
import com.google.gwt.user.rebind.SourceWriter; //导入依赖的package包/类
@Override
public void writePresent(SourceWriter srcWriter) {
srcWriter
.println("final HandlerRegistrationCollection mayStopRegistrations = new HandlerRegistrationCollection();");
for (JMethod mayStopMethod : this.presenterMethods) {
srcWriter.println("mayStopRegistrations.add(EventBus.get()"
+ ".addHandlerToSource(MayStopActivityEvent.TYPE, place, new MayStopActivityEvent.Handler() {");
srcWriter.indent();
srcWriter.println("@Override public void onMayStopActivity(MayStopActivityEvent event) {");
srcWriter.indent();
srcWriter.println("if (event.getMessage() == null) { event.setMessage(%s.this.%s()); }", this.injectorName,
mayStopMethod.getName());
srcWriter.outdent();
srcWriter.outdent();
srcWriter.println("}}));");
}
srcWriter.println("mayStopRegistrations.add(EventBus.get()"
+ ".addHandlerToSource(StopActivityEvent.TYPE, place, new StopActivityEvent.Handler() {");
srcWriter.indent();
srcWriter.println("@Override public void onStopActivity(StopActivityEvent event) {");
srcWriter.indent();
srcWriter.println("mayStopRegistrations.removeHandler();");
srcWriter.outdent();
srcWriter.outdent();
srcWriter.println("}}));");
}
示例14: writeExpandDefaultAndValidateClassGroups
import com.google.gwt.user.rebind.SourceWriter; //导入依赖的package包/类
private void writeExpandDefaultAndValidateClassGroups(final SourceWriter sw)
throws UnableToCompleteException {
// public <T> void expandDefaultAndValidateClassGroups(
sw.println("public <T> void expandDefaultAndValidateClassGroups(");
// GwtValidationContext<T> context, BeanType object,
// Set<ConstraintViolation<T>> violations, Group... groups) {
sw.indent();
sw.indent();
sw.println("GwtValidationContext<T> context,");
sw.println(this.beanHelper.getTypeCanonicalName() + " object,");
sw.println("Set<ConstraintViolation<T>> violations,");
sw.println("Group... groups) {");
sw.outdent();
this.writeExpandDefaultAndValidate(sw, Stage.OBJECT);
// }
sw.outdent();
sw.println("}");
}
示例15: writeExpandDefaultAndValidatePropertyGroups
import com.google.gwt.user.rebind.SourceWriter; //导入依赖的package包/类
private void writeExpandDefaultAndValidatePropertyGroups(final SourceWriter sw)
throws UnableToCompleteException {
// public <T> void expandDefaultAndValidatePropertyGroups(
sw.println("public <T> void expandDefaultAndValidatePropertyGroups(");
// GwtValidationContext<T> context, BeanType object, String propertyName,
// Set<ConstraintViolation<T>> violations, Group... groups) {
sw.indent();
sw.indent();
sw.println("GwtValidationContext<T> context,");
sw.println(this.beanHelper.getTypeCanonicalName() + " object,");
sw.println("String propertyName,");
sw.println("Set<ConstraintViolation<T>> violations,");
sw.println("Group... groups) {");
sw.outdent();
this.writeExpandDefaultAndValidate(sw, Stage.PROPERTY);
// }
sw.outdent();
sw.println("}");
}