List of usage examples for com.google.gwt.core.ext TreeLogger ALL
Type ALL
To view the source code for com.google.gwt.core.ext TreeLogger ALL.
Click Source Link
From source file:io.reinert.requestor.rebind.JsonAutoBeanGenerator.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(); }// w w w .jav a2 s.c om 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 AutoBeans...", null); final SourceWriter sourceWriter = getSourceWriter(typeLogger, ctx, intfType); if (sourceWriter != null) { sourceWriter.println(); ArrayDeque<JClassType> annotatedTypes = new ArrayDeque<JClassType>(); ArrayList<Json> jsonAnnotations = new ArrayList<Json>(); final ArrayDeque<String> allTypesAndWrappers = new ArrayDeque<String>(); for (JClassType type : typeOracle.getTypes()) { Json annotation = type.getAnnotation(Json.class); if (annotation != null && type.isInterface() != null) { annotatedTypes.add(type); jsonAnnotations.add(annotation); final String listWrapperTypeName = generateListWrapperInterface(sourceWriter, type); sourceWriter.println(); final String setWrapperTypeName = generateSetWrapperInterface(sourceWriter, type); sourceWriter.println(); // Add current type name for single de/serialization allTypesAndWrappers.add(type.getQualifiedSourceName()); allTypesAndWrappers.add(listWrapperTypeName); allTypesAndWrappers.add(setWrapperTypeName); } } final ArrayDeque<String> serdesFields = new ArrayDeque<String>(); final ArrayDeque<String> providerFields = new ArrayDeque<String>(); if (!allTypesAndWrappers.isEmpty()) { generateFactoryInterface(sourceWriter, allTypesAndWrappers); sourceWriter.println(); generateFactoryField(sourceWriter); sourceWriter.println(); int i = 0; for (JClassType annotatedType : annotatedTypes) { final String providerFieldName = generateProviderField(sourceWriter, annotatedType); providerFields.add(providerFieldName); final String serdesFieldName = generateSerdesClassAndField(logger, typeOracle, sourceWriter, annotatedType, jsonAnnotations.get(i++)); serdesFields.add(serdesFieldName); } } generateFields(sourceWriter); generateConstructor(sourceWriter, serdesFields, providerFields); generateMethods(sourceWriter); sourceWriter.commit(typeLogger); } return typeName + "Impl"; }
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 ww w. java 2s . c om*/ 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.turbogwt.net.http.rebind.JsonSerdesGenerator.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 www.ja v a 2s . co m*/ if (intfType.isInterface() == null) { logger.log(TreeLogger.ERROR, intfType.getQualifiedSourceName() + " is not an interface", null); throw new UnableToCompleteException(); } TreeLogger typeLogger = logger.branch(TreeLogger.ALL, "Generating SerDes powered by Gwt Jackson...", null); final SourceWriter sourceWriter = getSourceWriter(typeLogger, ctx, intfType); if (sourceWriter != null) { sourceWriter.println(); final ArrayList<String> serdes = new ArrayList<>(); 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); generateIteratorMethod(sourceWriter); sourceWriter.commit(typeLogger); } return typeName + "Impl"; }