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


Java SourceWriter类代码示例

本文整理汇总了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;
  }
 
开发者ID:TOMOTON,项目名称:gwt-dagger2,代码行数:31,代码来源:VersionGenerator.java

示例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("}");
}
 
开发者ID:google,项目名称:easy-gwt-mock,代码行数:17,代码来源:MocksControlGenerator.java

示例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());
  }
}
 
开发者ID:google,项目名称:easy-gwt-mock,代码行数:10,代码来源:MocksControlGenerator.java

示例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(");");
}
 
开发者ID:google,项目名称:easy-gwt-mock,代码行数:17,代码来源:MocksGenerator.java

示例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;
	}
}
 
开发者ID:liraz,项目名称:gwt-backbone,代码行数:20,代码来源:SourceVisitor.java

示例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("}");
}
 
开发者ID:liraz,项目名称:gwt-backbone,代码行数:21,代码来源:SourceVisitor.java

示例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("}");
}
 
开发者ID:liraz,项目名称:gwt-backbone,代码行数:18,代码来源:ReflectionCreator.java

示例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. ");
  	}
   }
}
 
开发者ID:liraz,项目名称:gwt-backbone,代码行数:17,代码来源:GeneratorHelper.java

示例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("}");
}
 
开发者ID:eclipse,项目名称:che,代码行数:26,代码来源:ExtensionRegistryGenerator.java

示例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;
}
 
开发者ID:google-code-export,项目名称:google-gin,代码行数:19,代码来源:GinjectorFragmentContext.java

示例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);
  }
}
 
开发者ID:google-code-export,项目名称:google-gin,代码行数:25,代码来源:SourceWriteUtil.java

示例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;
}
 
开发者ID:google-code-export,项目名称:google-gin,代码行数:25,代码来源:FrameworkGenerator.java

示例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("}}));");
}
 
开发者ID:Putnami,项目名称:putnami-web-toolkit,代码行数:27,代码来源:InjectMayStopActivityCreator.java

示例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("}");
}
 
开发者ID:ManfredTremmel,项目名称:gwt-bean-validators,代码行数:22,代码来源:GwtSpecificValidatorCreator.java

示例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("}");
}
 
开发者ID:ManfredTremmel,项目名称:gwt-bean-validators,代码行数:23,代码来源:GwtSpecificValidatorCreator.java


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