List of usage examples for com.google.gwt.user.rebind SourceWriter println
void println();
From source file:io.reinert.requestor.rebind.JsonGwtJacksonGenerator.java
License:Apache License
@Override public String generate(TreeLogger logger, GeneratorContext ctx, String typeName) throws UnableToCompleteException { TypeOracle typeOracle = ctx.getTypeOracle(); assert typeOracle != null; JClassType intfType = typeOracle.findType(typeName); if (intfType == null) { logger.log(TreeLogger.ERROR, "Unable to find metadata for type '" + typeName + "'", null); throw new UnableToCompleteException(); }//from w w w. j av a 2 s. com if (intfType.isInterface() == null) { logger.log(TreeLogger.ERROR, intfType.getQualifiedSourceName() + " is not an interface", null); throw new UnableToCompleteException(); } // TODO: check if type was already generated and reuse it TreeLogger typeLogger = logger.branch(TreeLogger.ALL, "Generating Json SerDes powered by Gwt Jackson...", null); final SourceWriter sourceWriter = getSourceWriter(typeLogger, ctx, intfType); if (sourceWriter != null) { sourceWriter.println(); final ArrayList<String> serdes = new ArrayList<String>(); for (JClassType type : typeOracle.getTypes()) { Json annotation = type.getAnnotation(Json.class); if (annotation != null) { serdes.add(generateSerdes(sourceWriter, type, annotation)); } } generateFields(sourceWriter); generateConstructor(sourceWriter, serdes); generateMethods(sourceWriter); sourceWriter.commit(typeLogger); } return typeName + "Impl"; }
From source file:org.cruxframework.crux.core.rebind.rpc.CruxProxyCreator.java
License:Apache License
/** * @param srcWriter// w ww .j av a2s . c o m */ private void generateProxyWrapperEndMethod(SourceWriter srcWriter) { srcWriter.println(); srcWriter.println("private void __endMethodCall(String methodDesc, boolean unblocksScreen){"); srcWriter.indent(); srcWriter.println("Boolean isProcessing = __syncProcessingMethods.remove(methodDesc);"); srcWriter.println("if (isProcessing != null && !isProcessing){"); srcWriter.indent(); srcWriter.println("if (unblocksScreen) Screen.unblockToUser();"); srcWriter.println("setServiceEntryPoint(__baseEntrypoint);"); srcWriter.outdent(); srcWriter.println("}"); srcWriter.outdent(); srcWriter.println("}"); }
From source file:org.cruxframework.crux.core.rebind.rpc.CruxProxyCreator.java
License:Apache License
/** * @param srcWriter//from w ww . j a v a 2s.co m * @param asyncMethod * @param asyncReturnType * @return */ private List<JParameter> generateProxyWrapperMethodDeclaration(SourceWriter srcWriter, JMethod asyncMethod, JType asyncReturnType) { srcWriter.println(); srcWriter.print("public "); srcWriter.print(asyncReturnType.getQualifiedSourceName()); srcWriter.print(" "); srcWriter.print(asyncMethod.getName() + "("); boolean needsComma = false; List<JParameter> parameters = new ArrayList<JParameter>(); JParameter[] asyncParams = asyncMethod.getParameters(); for (int i = 0; i < asyncParams.length; ++i) { JParameter param = asyncParams[i]; if (needsComma) { srcWriter.print(", "); } else { needsComma = true; } JType paramType = param.getType(); if (i == (asyncParams.length - 1)) { srcWriter.print("final "); } srcWriter.print(paramType.getQualifiedSourceName()); srcWriter.print(" "); String paramName = param.getName(); parameters.add(param); srcWriter.print(paramName); } srcWriter.println(") {"); srcWriter.indent(); return parameters; }
From source file:org.cruxframework.crux.core.rebind.rpc.CruxProxyCreator.java
License:Apache License
/** * @param srcWriter//from w ww . j av a 2 s. c o m */ private void generateProxyWrapperStartMethod(SourceWriter srcWriter) { srcWriter.println(); srcWriter.println("private boolean __startMethodCall(String methodDesc, boolean blocksScreen){"); srcWriter.indent(); srcWriter.println("boolean ret = !__syncProcessingMethods.containsKey(methodDesc);"); srcWriter.println("if (ret){"); srcWriter.indent(); srcWriter.println("__syncProcessingMethods.put(methodDesc, true);"); srcWriter.println("if (blocksScreen) Screen.blockToUser();"); srcWriter.outdent(); srcWriter.println("}"); srcWriter.println("return ret;"); srcWriter.outdent(); srcWriter.println("}"); }
From source file:org.cruxframework.crux.core.rebind.rpc.CruxProxyCreator.java
License:Apache License
/** * @param srcWriter/* w ww.j av a 2 s. co m*/ */ private void generateProxyWrapperUpdateTokenMethod(SourceWriter srcWriter) { srcWriter.println(); srcWriter.println("private void __updateMethodToken(String methodDesc, String token){"); srcWriter.indent(); srcWriter.println("__syncProcessingMethods.put(methodDesc, false);"); srcWriter.println("if (this.__hasParameters){"); srcWriter.indent(); srcWriter.println("super.setServiceEntryPoint(__baseEntrypoint + \"&" + CruxSynchronizerTokenService.CRUX_SYNC_TOKEN_PARAM + "=\" + token);"); srcWriter.outdent(); srcWriter.println("}else{"); srcWriter.indent(); srcWriter.println("super.setServiceEntryPoint(__baseEntrypoint + \"?" + CruxSynchronizerTokenService.CRUX_SYNC_TOKEN_PARAM + "=\" + token);"); srcWriter.outdent(); srcWriter.println("}"); srcWriter.outdent(); srcWriter.println("}"); }
From source file:org.cruxframework.crux.core.rebind.rpc.CruxProxyCreator.java
License:Apache License
/** * @param srcWriter/*from w w w. ja v a 2 s .c o m*/ */ private void generateSetServiceEntryPointMethod(SourceWriter srcWriter) { srcWriter.println(); srcWriter.println("public void setServiceEntryPoint(String entryPoint){"); srcWriter.indent(); srcWriter.println("__baseEntrypoint = entryPoint;"); srcWriter.println("super.setServiceEntryPoint(entryPoint);"); srcWriter.outdent(); srcWriter.println("}"); }