summaryrefslogtreecommitdiffstats
path: root/client-compiler
diff options
context:
space:
mode:
authorLeif Åstrand <leif@vaadin.com>2012-08-16 20:16:29 +0300
committerLeif Åstrand <leif@vaadin.com>2012-08-20 08:55:25 +0300
commit80cc4976fc7f7931d75f3b31dde6da168936f01f (patch)
tree7f88979d47a9eae7f3b1c496cb5918c048a45bfa /client-compiler
parent95411dc8c260fc5dcd548f11a8de50a2b8bb9770 (diff)
downloadvaadin-framework-80cc4976fc7f7931d75f3b31dde6da168936f01f.tar.gz
vaadin-framework-80cc4976fc7f7931d75f3b31dde6da168936f01f.zip
Abort widgetset compile for conflicting @Connect mappings (#9343)
Diffstat (limited to 'client-compiler')
-rw-r--r--client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/WidgetMapGenerator.java30
1 files changed, 27 insertions, 3 deletions
diff --git a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/WidgetMapGenerator.java b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/WidgetMapGenerator.java
index dae6f2821e..1f5b301802 100644
--- a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/WidgetMapGenerator.java
+++ b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/WidgetMapGenerator.java
@@ -23,6 +23,7 @@ import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
+import java.util.Map;
import java.util.TreeSet;
import com.google.gwt.core.ext.Generator;
@@ -116,8 +117,10 @@ public class WidgetMapGenerator extends Generator {
* Logger object
* @param context
* Generator context
+ * @throws UnableToCompleteException
*/
- private void generateClass(TreeLogger logger, GeneratorContext context) {
+ private void generateClass(TreeLogger logger, GeneratorContext context)
+ throws UnableToCompleteException {
// get print writer that receives the source code
PrintWriter printWriter = null;
printWriter = context.tryCreate(logger, packageName, className);
@@ -147,7 +150,7 @@ public class WidgetMapGenerator extends Generator {
logConnectors(logger, context, connectors);
// generator constructor source code
- generateImplementationDetector(sourceWriter, connectors);
+ generateImplementationDetector(logger, sourceWriter, connectors);
generateInstantiatorMethod(sourceWriter, connectors);
// close generated class
sourceWriter.outdent();
@@ -369,13 +372,18 @@ public class WidgetMapGenerator extends Generator {
/**
*
+ * @param logger
+ * logger to print messages to
* @param sourceWriter
* Source writer to output source code
* @param paintablesHavingWidgetAnnotation
+ * @throws UnableToCompleteException
*/
private void generateImplementationDetector(
+ TreeLogger logger,
SourceWriter sourceWriter,
- Collection<Class<? extends ServerConnector>> paintablesHavingWidgetAnnotation) {
+ Collection<Class<? extends ServerConnector>> paintablesHavingWidgetAnnotation)
+ throws UnableToCompleteException {
sourceWriter
.println("public Class<? extends "
+ serverConnectorClassName
@@ -385,8 +393,24 @@ public class WidgetMapGenerator extends Generator {
sourceWriter
.println("fullyQualifiedName = fullyQualifiedName.intern();");
+ // Keep track of encountered mappings to detect conflicts
+ Map<Class<? extends ClientConnector>, Class<? extends ServerConnector>> mappings = new HashMap<Class<? extends ClientConnector>, Class<? extends ServerConnector>>();
+
for (Class<? extends ServerConnector> connectorClass : paintablesHavingWidgetAnnotation) {
Class<? extends ClientConnector> clientConnectorClass = getClientConnectorClass(connectorClass);
+
+ // Check for conflicts
+ Class<? extends ServerConnector> prevousMapping = mappings.put(
+ clientConnectorClass, connectorClass);
+ if (prevousMapping != null) {
+ logger.log(Type.ERROR,
+ "Both " + connectorClass.getName() + " and "
+ + prevousMapping.getName()
+ + " have @Connect referring to "
+ + clientConnectorClass.getName() + ".");
+ throw new UnableToCompleteException();
+ }
+
sourceWriter.print("if ( fullyQualifiedName == \"");
sourceWriter.print(clientConnectorClass.getName());
sourceWriter.print("\" ) { ensureInstantiator("