List of usage examples for com.google.gwt.user.rebind SourceWriter outdent
void outdent();
From source file:com.gwtent.gen.aop.AOPCreator.java
License:Apache License
private void overrideMethods(SourceWriter source, JClassType classType) { for (MethodCache cache : methodCaches) { String ivnValueName = getIvnValueName(cache.getSourceMethod()); source.println(cache.getSourceMethod().toString()); source.println("{"); source.indent();//from w w w . ja va 2 s. c o m source.println( "if (" + ivnValueName + ".getCurrentInterceptor() instanceof MethodInterceptorFinalAdapter){"); if (GenUtils.checkIfReturnVoid(cache.getSourceMethod())) { source.println(" super." + cache.getSourceMethod().getName() + "(" + GenUtils.getParamNames(cache.getSourceMethod()) + ");"); source.println(" return;"); } else source.println(" return super." + cache.getSourceMethod().getName() + "(" + GenUtils.getParamNames(cache.getSourceMethod()) + ");"); source.println("}"); source.println(); source.println( "Object[] args = new Object[]{" + GenUtils.getParamNames(cache.getSourceMethod()) + "};"); source.println(ivnValueName + ".reset(args);"); source.println("try {"); if (GenUtils.checkIfReturnVoid(cache.getSourceMethod())) { source.println(" " + ivnValueName + ".proceed();"); source.println(" return;"); } else source.println(" return (" + cache.getSourceMethod().getReturnType().getQualifiedSourceName() + ") " + ivnValueName + ".proceed();"); source.println("} catch (Throwable e) {"); source.println(" throw new AspectException(e);"); source.println("}"); source.outdent(); source.println("}"); } }
From source file:com.gwtent.gen.aop.AOPCreator.java
License:Apache License
private void createMethodInvocationChain(SourceWriter source) { source.println("private MethodInvocationLinkedAdapter createMethodInvocationChain(Method method) {"); source.indent();//from w w w . j a v a 2 s . c om source.println("List<MethodInterceptor> interceptors = new ArrayList<MethodInterceptor>();"); source.println("for (Method adviceMethod : InterceptorMap.interceptors.get(method)){"); source.println(" interceptors.add(AdviceInstanceProvider.INSTANCE.getInstance(adviceMethod));"); source.println("}"); source.println("interceptors.add(new MethodInterceptorFinalAdapter());"); source.println("return new MethodInvocationLinkedAdapter(method, this, interceptors);"); source.outdent(); source.println("}"); }
From source file:com.gwtent.gen.LogableSourceCreator.java
License:Apache License
public String generate() throws UnableToCompleteException { JClassType classType;//from w w w . j a v a 2s . c o m 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(); } }
From source file:com.gwtent.gen.reflection.ReflectAllInOneCreator.java
License:Apache License
@Override public void createSource(SourceWriter source, JClassType classType) { //ClassType -->> the interface name created automatically Map<JClassType, String> typeNameMap = new HashMap<JClassType, String>(); genAllClasses(source, typeNameMap);/*from ww w . j a va2s .c o m*/ // source.println("public " + getSimpleUnitName(classType) + "(){"); // source.indent(); // // for (String classname : allGeneratedClassNames){ // source.println("new " + classname + "();"); // } // source.outdent(); // source.println("}"); source.println("public com.gwtent.reflection.client.Type doGetType(String name) {"); source.indent(); //source.println("com.gwtent.reflection.client.Type resultType = super.doGetType(name);"); //source.println("if (resultType != null) {return resultType;}"); for (JClassType type : typeNameMap.keySet()) { source.println("if (name.equals( \"" + type.getQualifiedSourceName() + "\")){return GWT.create(" + typeNameMap.get(type) + ".class);}"); } source.println(); source.println("return null;"); source.outdent(); source.print("}"); }
From source file:com.gwtent.gen.reflection.SourceVisitor.java
License:Apache License
@Override protected void createSource(SourceWriter source, JClassType classType) { source.println("public " + getSimpleUnitName(classType) + "(){"); source.indent();// ww w .j av a2 s. c om 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("}"); }
From source file:com.gwtplatform.dispatch.rebind.VelocityGenerator.java
License:Apache License
@Override public String generate(TreeLogger treeLogger, GeneratorContext generatorContext, String typeName) throws UnableToCompleteException { logger = new Logger(treeLogger); typeOracle = generatorContext.getTypeOracle(); type = getType(typeName);//from w ww.j ava 2 s. c om PrintWriter printWriter = tryCreatePrintWriter(generatorContext); if (printWriter == null) { return typeName + SUFFIX; } injector = Guice.createInjector(new RebindModule(logger, generatorContext)); serializerProviderGenerator = injector.getInstance(SerializerProviderGenerator.class); generatorFactory = injector.getInstance(GeneratorFactory.class); registerPrimitiveTypes(); generateRestServices(); generateRestGinModule(); generateSerializerProvider(); ClassSourceFileComposerFactory composer = initComposer(); SourceWriter sourceWriter = composer.createSourceWriter(generatorContext, printWriter); sourceWriter.indent(); sourceWriter.println("@Override"); sourceWriter.println("public void onModuleLoad() {}"); sourceWriter.outdent(); sourceWriter.commit(treeLogger); return typeName + SUFFIX; }
From source file:com.gwtplatform.mvp.rebind.ApplicationControllerGenerator.java
License:Apache License
private void writeInit(SourceWriter sw, String generatorName, JClassType preBootstrapper, JClassType bootstrapper) {/*from w w w . j a v a2 s. c om*/ sw.println(OVERRIDE); sw.println(INJECT_METHOD); sw.indent(); if (preBootstrapper != null) { sw.println(ONPREBOOTSTRAP, preBootstrapper.getSimpleSourceName()); sw.println(); sw.println(SCHEDULE_DEFERRED_1); sw.indent(); sw.println(OVERRIDE); sw.println(SCHEDULE_DEFERRED_2); sw.indent(); } sw.println(String.format(DELAYED_BIND, DelayedBindRegistry.class.getSimpleName(), generatorName)); sw.println(); sw.println(String.format(ONBOOTSTRAP, generatorName, bootstrapper.getSimpleSourceName())); sw.outdent(); sw.println("}"); if (preBootstrapper != null) { sw.outdent(); sw.println("});"); sw.outdent(); sw.println("}"); } sw.println(OVERRIDE); sw.println(ONMODULE_LOAD); sw.indent(); sw.println(INIT); sw.outdent(); sw.println("}"); }
From source file:com.gwtplatform.mvp.rebind.NonLeafTabContentProxyOutputter.java
License:Apache License
private void writeGetTabDataInternalMethod(SourceWriter writer) throws UnableToCompleteException { if (tabLabel != null) { // Simple string tab label writer.println();/* w w w .j a v a2s. c om*/ writer.println("protected TabData getTabDataInternal(" + ginjectorInspector.getGinjectorClassName() + " ginjector) {"); writer.indent(); writer.println("return new TabDataBasic(\"" + tabLabel + "\", " + tabPriority + ");"); writer.outdent(); writer.println("}"); } else { tabInfoMethod.writeGetTabDataInternalMethod(writer); } }
From source file:com.gwtplatform.mvp.rebind.PresenterTitleMethod.java
License:Apache License
private void writeProxyMethodStaticReturningString(SourceWriter writer) { writer.println();//from w ww . j a v a 2 s. co m writer.println("protected void getPlaceTitle(GetPlaceTitleEvent event) {"); writer.indent(); writer.print("String title = " + presenterInspector.getPresenterClassName() + "."); writePresenterMethodCall(writer); writer.println(); writer.println("event.getHandler().onSetPlaceTitle( title );"); writer.outdent(); writer.println("}"); }
From source file:com.gwtplatform.mvp.rebind.PresenterTitleMethod.java
License:Apache License
private void writeProxyMethodNonStaticReturnString(SourceWriter writer) { writer.println();/*from ww w .j a v a 2 s . com*/ writer.println("protected void getPlaceTitle(final GetPlaceTitleEvent event) {"); writer.indent(); writer.println("getPresenter( new NotifyingAsyncCallback<" + presenterInspector.getPresenterClassName() + ">(getEventBus()){"); writer.indent(); writer.indent(); writer.println("public void success(" + presenterInspector.getPresenterClassName() + " p ) {"); writer.indent(); writer.print("String title = p."); writePresenterMethodCall(writer); writer.println(); writer.println("event.getHandler().onSetPlaceTitle( title );"); writer.outdent(); writer.println(" }"); writer.println("public void failure(Throwable t) { event.getHandler().onSetPlaceTitle(null); }"); writer.outdent(); writer.println("} );"); writer.outdent(); writer.println("}"); }