diff options
Diffstat (limited to 'client-compiler')
-rw-r--r-- | client-compiler/src/main/java/com/vaadin/server/widgetsetutils/metadata/RendererVisitor.java | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/client-compiler/src/main/java/com/vaadin/server/widgetsetutils/metadata/RendererVisitor.java b/client-compiler/src/main/java/com/vaadin/server/widgetsetutils/metadata/RendererVisitor.java index 2e54d00aab..8b645aa492 100644 --- a/client-compiler/src/main/java/com/vaadin/server/widgetsetutils/metadata/RendererVisitor.java +++ b/client-compiler/src/main/java/com/vaadin/server/widgetsetutils/metadata/RendererVisitor.java @@ -22,8 +22,11 @@ import com.google.gwt.core.ext.typeinfo.JClassType; import com.google.gwt.core.ext.typeinfo.JMethod; import com.google.gwt.core.ext.typeinfo.JParameterizedType; import com.google.gwt.core.ext.typeinfo.JType; +import com.google.gwt.core.ext.typeinfo.NotFoundException; import com.vaadin.client.connectors.AbstractRendererConnector; +import elemental.json.JsonValue; + /** * Generates type data for renderer connectors. * <ul> @@ -86,12 +89,33 @@ public class RendererVisitor extends TypeVisitor { JType presentationType = getPresentationType(type, logger); bundle.setPresentationType(type, presentationType); - bundle.setNeedsSerialize(presentationType); + if (!hasCustomDecodeMethod(type, logger)) { + bundle.setNeedsSerialize(presentationType); + } logger.log(Type.DEBUG, "Presentation type of " + type + " is " + presentationType); } + private static boolean hasCustomDecodeMethod(JClassType type, + TreeLogger logger) throws UnableToCompleteException { + try { + JMethod decodeMethod = ConnectorBundle.findInheritedMethod(type, + "decode", + type.getOracle().getType(JsonValue.class.getName())); + if (decodeMethod == null) { + throw new NotFoundException(); + } + + return !decodeMethod.getEnclosingType().getQualifiedSourceName() + .equals(AbstractRendererConnector.class.getName()); + } catch (NotFoundException e) { + logger.log(Type.ERROR, "Can't find decode method for renderer " + + type, e); + throw new UnableToCompleteException(); + } + } + private static JType getPresentationType(JClassType type, TreeLogger logger) throws UnableToCompleteException { JClassType originalType = type; |