List of usage examples for com.google.gwt.user.rebind SourceWriter print
void print(String s, Object... args);
From source file:com.colinalworth.gwt.websockets.rebind.ServerCreator.java
License:Apache License
/** * Writes out the method to use to invoke a server call. Mostly derived from RPC's way of building proxy methods * * @param logger/*from www . ja v a 2 s.c om*/ * @param context * @param sw * @param m */ private void printServerMethodBody(TreeLogger logger, GeneratorContext context, SourceWriter sw, JMethod m) { sw.println("%1$s {", m.getReadableDeclaration(false, true, true, true, true)); sw.indent(); sw.print("__sendMessage(\"%1$s\"", m.getName()); StringBuilder sb = new StringBuilder(); String callback = "null"; JParameter[] parameters = m.getParameters(); for (int i = 0; i < parameters.length; i++) { JParameter param = parameters[i]; if (i + 1 == parameters.length && param.getType().isInterface() != null && param.getType().isInterface().getQualifiedSourceName().equals(Callback.class.getName())) { callback = param.getName(); } else { sb.append(",\n").append(param.getName()); } } sw.print(","); sw.println(callback); sw.print(sb.toString()); sw.println(");"); sw.outdent(); sw.println("}"); }
From source file:com.google.gwt.testing.easygwtmock.rebind.MocksControlGenerator.java
License:Apache License
private void printFactoryMethod(SourceWriter out, JMethod methodToImplement, JClassType mockControlInterface, String classToCreate) {//from w w w.j a v a2s . co m 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("}"); }
From source file:com.google.gwt.testing.easygwtmock.rebind.MocksGenerator.java
License:Apache License
/** * Prints each constructor for the mock class, and a hidden init method. *//*from w w w . j ava2 s . c o m*/ private void printConstructors(SourceWriter out, String newClassName, JConstructor[] constructors) { if (constructors.length == 0) { // probably an interface out.print("public %s() {}", newClassName); } for (JConstructor constructor : constructors) { out.print("public %s(", newClassName); printMatchingParameters(out, constructor); out.println(") {"); out.indent(); printMatchingSuperCall(out, constructor); out.outdent(); out.println("}"); out.println(); } out.println("public %s __mockInit(MocksControlBase newValue) {", newClassName); out.indent(); out.println("this.mocksControl = newValue;"); out.println("return this;"); out.outdent(); out.println("}"); out.println(); }
From source file:org.eclipse.che.util.ExtensionRegistryGenerator.java
License:Open Source License
/** * Generate constructor with dependencies added into field * * @param className//from ww w .j a va 2 s.c om * @param extensions * @param sw * @throws UnableToCompleteException */ private void generateConstructor(String className, List<JClassType> extensions, SourceWriter sw) throws UnableToCompleteException { // constructor sw.indent(); sw.print("public %s()", className); sw.println("{"); sw.indent(); { for (JClassType extension : extensions) { sw.println("{"); sw.indent(); /* Array<DependencyDescription> deps = Collections.<DependencyDescription> createArray(); */ generateDependenciesForExtension(sw, extension); Extension annotation = extension.getAnnotation(Extension.class); /* extensions.put("ide.ext.demo", new ExtensionDescription("ide.ext.demo", "1.0.0", "Demo extension", deps, demoExtProvider)); */ // the class's fqn String extensionId = extension.getQualifiedSourceName(); sw.println("extensions.put(\"%s\", new ExtensionDescription(\"%s\",\"%s\",\"%s\",\"%s\",deps));", escape(extensionId), escape(extensionId), escape(annotation.version()), escape(annotation.title()), escape(annotation.description())); sw.outdent(); sw.println("}"); } } sw.outdent(); sw.println("}"); }