diff --git a/processor/src/main/java/com/tickaroo/tikxml/processor/scanning/DefaultAnnotationDetector.kt b/processor/src/main/java/com/tickaroo/tikxml/processor/scanning/DefaultAnnotationDetector.kt index f4140d7..27d0bc3 100644 --- a/processor/src/main/java/com/tickaroo/tikxml/processor/scanning/DefaultAnnotationDetector.kt +++ b/processor/src/main/java/com/tickaroo/tikxml/processor/scanning/DefaultAnnotationDetector.kt @@ -358,12 +358,6 @@ open class DefaultAnnotationDetector(protected val elementUtils: Elements, prote namingMap.remove(elementNameMatcher.xmlElementName) } namingMap[xmlElementName] = PolymorphicTypeElementNameMatcher(xmlElementName, typeElement.asType()) - - if (element.getSurroundingClassQualifiedName().endsWith("CompanyConstructor")) { - messager.printMessage( - Diagnostic.Kind.WARNING, "Test2 -> ${namingMap.entries.joinToString()} " - ) - } } } diff --git a/processor/src/main/java/com/tickaroo/tikxml/processor/xml/XmlElement.kt b/processor/src/main/java/com/tickaroo/tikxml/processor/xml/XmlElement.kt index 1697bf1..01ab5e6 100644 --- a/processor/src/main/java/com/tickaroo/tikxml/processor/xml/XmlElement.kt +++ b/processor/src/main/java/com/tickaroo/tikxml/processor/xml/XmlElement.kt @@ -123,8 +123,17 @@ interface XmlElement { } else { // Conflict val variableField = toInsert.element - throw ProcessingException(variableField, - "Conflict: $toInsert is in conflict with $existingElement. Maybe both have the same xml name '${toInsert.name}' (you can change that via annotations) or @${Path::class.simpleName} is causing this conflict.") + if (toInsert is PolymorphicSubstitutionField || toInsert is PolymorphicSubstitutionListField) { + throw ProcessingException( + variableField, + "Conflict: $toInsert is in conflict with $existingElement. Maybe both have the same xml name or type or @${Path::class.simpleName} is causing this conflict." + ) + } else { + throw ProcessingException( + variableField, + "Conflict: $toInsert is in conflict with $existingElement. Maybe both have the same xml name '${toInsert.name}' (you can change that via annotations) or @${Path::class.simpleName} is causing this conflict." + ) + } } } else { diff --git a/processor/src/test/java/com/tickaroo/tikxml/processor/scanning/AnnotationScannerTest.kt b/processor/src/test/java/com/tickaroo/tikxml/processor/scanning/AnnotationScannerTest.kt index cce74de..3fa1968 100644 --- a/processor/src/test/java/com/tickaroo/tikxml/processor/scanning/AnnotationScannerTest.kt +++ b/processor/src/test/java/com/tickaroo/tikxml/processor/scanning/AnnotationScannerTest.kt @@ -593,7 +593,6 @@ class AnnotationScannerTest { " @${ElementNameMatcher::class.qualifiedName}(name=\"b\", type=B.class) ", " })", " Root element;", - "", " @${Element::class.qualifiedName}(name=\"a\")", " Root a;", " @${Xml::class.qualifiedName}", @@ -608,7 +607,7 @@ class AnnotationScannerTest { .that(componentFile).processedWith(XmlProcessor()) .failsToCompile() .withErrorContaining( - "Conflict: field 'a' in class test.PolymorphicElement is in conflict with field 'element' in class test.PolymorphicElement. Maybe both have the same xml name 'a' (you can change that via annotations) or @${Path::class.simpleName} is causing this conflict.") + "Conflict: field 'a' in class test.PolymorphicElement is in conflict with field 'element' in class test.PolymorphicElement. Maybe both have the same xml name or type or @${Path::class.simpleName} is causing this conflict.") } @Test @@ -667,7 +666,7 @@ class AnnotationScannerTest { .that(componentFile).processedWith(XmlProcessor()) .failsToCompile() .withErrorContaining( - "Conflict: field 'element' in class test.PolymorphicElement is in conflict with test.PolymorphicElement. Maybe both have the same xml name 'b' (you can change that via annotations) or @${Path::class.simpleName} is causing this conflict.") + "Conflict: field 'element' in class test.PolymorphicElement is in conflict with test.PolymorphicElement. Maybe both have the same xml name or type or @${Path::class.simpleName} is causing this conflict.") } /// LIST TESTS @@ -727,7 +726,7 @@ class AnnotationScannerTest { val componentFile = JavaFileObjects.forSourceLines("test.PolymorphicElement", "package test;", "@${Xml::class.qualifiedName}", - "class PolymorphicElement {", + "class PolymorphicElement{", " @${Element::class.qualifiedName} ( typesByElement = {", " @${ElementNameMatcher::class.qualifiedName}(name=\"a\", type=A.class),", " @${ElementNameMatcher::class.qualifiedName}(name=\"b\", type=B.class)", @@ -804,7 +803,7 @@ class AnnotationScannerTest { .processedWith(XmlProcessor()) .failsToCompile() .withErrorContaining( - "Conflict: field 'a' in class test.PolymorphicElement is in conflict with field 'element' in class test.PolymorphicElement. Maybe both have the same xml name 'a' (you can change that via annotations) or @${Path::class.simpleName} is causing this conflict.") + "Conflict: field 'a' in class test.PolymorphicElement is in conflict with field 'element' in class test.PolymorphicElement. Maybe both have the same xml name or type or @${Path::class.simpleName} is causing this conflict.") } @Test @@ -832,7 +831,7 @@ class AnnotationScannerTest { .that(componentFile).processedWith(XmlProcessor()) .failsToCompile() .withErrorContaining( - "Conflict: field 'a' in class test.PolymorphicElement is in conflict with field 'element' in class test.PolymorphicElement. Maybe both have the same xml name 'a' (you can change that via annotations) or @${Path::class.java.simpleName} is causing this conflict.") + "Conflict: field 'a' in class test.PolymorphicElement is in conflict with field 'element' in class test.PolymorphicElement. Maybe both have the same xml name or type or @${Path::class.simpleName} is causing this conflict.") } @Test @@ -942,7 +941,7 @@ class AnnotationScannerTest { .that(componentFile).processedWith(XmlProcessor()) .failsToCompile() .withErrorContaining( - "Conflict: field 'element' in class test.PolymorphicElement is in conflict with test.PolymorphicElement. Maybe both have the same xml name 'a' (you can change that via annotations) or @${Path::class.simpleName} is causing this conflict.") + "Conflict: field 'element' in class test.PolymorphicElement is in conflict with test.PolymorphicElement. Maybe both have the same xml name or type or @${Path::class.simpleName} is causing this conflict.") } @Test @@ -969,7 +968,7 @@ class AnnotationScannerTest { .that(componentFile).processedWith(XmlProcessor()) .failsToCompile() .withErrorContaining( - "Conflict: field 'element' in class test.PolymorphicElement is in conflict with test.PolymorphicElement. Maybe both have the same xml name 'a' (you can change that via annotations) or @${Path::class.simpleName} is causing this conflict.") + "Conflict: field 'element' in class test.PolymorphicElement is in conflict with test.PolymorphicElement. Maybe both have the same xml name or type or @${Path::class.simpleName} is causing this conflict.") } @Test