Author: scabanovich
Date: 2011-10-05 13:07:37 -0400 (Wed, 05 Oct 2011)
New Revision: 35381
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.core/src/org/jboss/tools/cdi/seam/config/core/CDISeamConfigExtension.java
trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.core/src/org/jboss/tools/cdi/seam/config/core/CDISeamConfigPreferences.java
trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.core/src/org/jboss/tools/cdi/seam/config/core/validation/SeamConfigValidationMessages.java
trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.core/src/org/jboss/tools/cdi/seam/config/core/validation/messages.properties
Log:
JBIDE-9834
https://issues.jboss.org/browse/JBIDE-9834
Validation for configuring abstract types and types without bean constructors is added.
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.core/src/org/jboss/tools/cdi/seam/config/core/CDISeamConfigExtension.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.core/src/org/jboss/tools/cdi/seam/config/core/CDISeamConfigExtension.java 2011-10-05
17:02:22 UTC (rev 35380)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.core/src/org/jboss/tools/cdi/seam/config/core/CDISeamConfigExtension.java 2011-10-05
17:07:37 UTC (rev 35381)
@@ -31,6 +31,7 @@
import org.jboss.tools.cdi.core.extension.feature.IBuildParticipantFeature;
import org.jboss.tools.cdi.core.extension.feature.IValidatorFeature;
import org.jboss.tools.cdi.internal.core.impl.CDIProject;
+import org.jboss.tools.cdi.internal.core.impl.definition.TypeDefinition;
import org.jboss.tools.cdi.internal.core.scanner.FileSet;
import org.jboss.tools.cdi.internal.core.validation.CDICoreValidator;
import org.jboss.tools.cdi.seam.config.core.definition.ConfigTypeDefinition;
@@ -237,6 +238,20 @@
}
}
}
+ List<TypeDefinition> ds = def.getTypeDefinitions();
+ for (TypeDefinition d: ds) {
+ if(!d.hasBeanConstructor()) {
+ ConfigTypeDefinition cd = (ConfigTypeDefinition)d;
+ SAXNode n = cd.getConfig().getNode();
+ if(d.isAbstract()) {
+ String message = NLS.bind(SeamConfigValidationMessages.TYPE_IS_ABSTRACT,
cd.getParametedType().getSimpleName());
+ validator.addError(message,
CDISeamConfigPreferences.ABSTRACT_TYPE_IS_CONFIGURED_AS_BEAN, new
TextSourceReference(def.getFileObject(), file, n), file);
+ } else {
+ String message = NLS.bind(SeamConfigValidationMessages.NO_BEAN_CONSTRUCTOR,
cd.getParametedType().getSimpleName());
+ validator.addError(message, CDISeamConfigPreferences.BEAN_CONSTRUCTOR_IS_MISSING,
new TextSourceReference(def.getFileObject(), file, n), file);
+ }
+ }
+ }
}
}
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.core/src/org/jboss/tools/cdi/seam/config/core/CDISeamConfigPreferences.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.core/src/org/jboss/tools/cdi/seam/config/core/CDISeamConfigPreferences.java 2011-10-05
17:02:22 UTC (rev 35380)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.core/src/org/jboss/tools/cdi/seam/config/core/CDISeamConfigPreferences.java 2011-10-05
17:07:37 UTC (rev 35381)
@@ -17,6 +17,8 @@
public static final String ANNOTATION_EXPECTED =
INSTANCE.createSeverityOption("annotationExpected");
public static final String INLINE_BEAN_TYPE_MISMATCH =
INSTANCE.createSeverityOption("inlineBeanTypeMismatch");
+ public static final String ABSTRACT_TYPE_IS_CONFIGURED_AS_BEAN =
INSTANCE.createSeverityOption("abstractTypeIsConfiguredAsBean");
+ public static final String BEAN_CONSTRUCTOR_IS_MISSING =
INSTANCE.createSeverityOption("beanConstructorIsMissing");
public static CDISeamConfigPreferences getInstance() {
return INSTANCE;
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.core/src/org/jboss/tools/cdi/seam/config/core/validation/SeamConfigValidationMessages.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.core/src/org/jboss/tools/cdi/seam/config/core/validation/SeamConfigValidationMessages.java 2011-10-05
17:02:22 UTC (rev 35380)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.core/src/org/jboss/tools/cdi/seam/config/core/validation/SeamConfigValidationMessages.java 2011-10-05
17:07:37 UTC (rev 35381)
@@ -12,6 +12,8 @@
public static String UNRESOLVED_CONSTRUCTOR;
public static String ANNOTATION_EXPECTED;
public static String INLINE_BEAN_TYPE_MISMATCH;
+ public static String TYPE_IS_ABSTRACT;
+ public static String NO_BEAN_CONSTRUCTOR;
static {
NLS.initializeMessages(BUNDLE_NAME, SeamConfigValidationMessages.class);
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.core/src/org/jboss/tools/cdi/seam/config/core/validation/messages.properties
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.core/src/org/jboss/tools/cdi/seam/config/core/validation/messages.properties 2011-10-05
17:02:22 UTC (rev 35380)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.core/src/org/jboss/tools/cdi/seam/config/core/validation/messages.properties 2011-10-05
17:07:37 UTC (rev 35381)
@@ -3,4 +3,6 @@
UNRESOLVED_METHOD=Cannot resolve method in node {0}.
UNRESOLVED_CONSTRUCTOR=Cannot resolve constructor in type node {0}.
ANNOTATION_EXPECTED=Annotation types are only allowed here.
-INLINE_BEAN_TYPE_MISMATCH=Type mismatch: cannot convert from {0} to {1}
\ No newline at end of file
+INLINE_BEAN_TYPE_MISMATCH=Type mismatch: cannot convert from {0} to {1}.
+TYPE_IS_ABSTRACT=Abstract type {0} cannot be configured as a bean.
+NO_BEAN_CONSTRUCTOR=No bean constructor found for type {0}.
\ No newline at end of file