Author: scabanovich
Date: 2012-05-04 19:17:23 -0400 (Fri, 04 May 2012)
New Revision: 40810
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/BeansXmlValidationDelegate.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/CDIValidationMessages.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/messages.properties
Log:
JBIDE-11731
https://issues.jboss.org/browse/JBIDE-11731
Error message for beans.xml validation are modified.
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/BeansXmlValidationDelegate.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/BeansXmlValidationDelegate.java 2012-05-04
23:09:47 UTC (rev 40809)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/BeansXmlValidationDelegate.java 2012-05-04
23:17:23 UTC (rev 40810)
@@ -185,7 +185,7 @@
typepath = typepath + "/" + typeNode.getTypeName(); //$NON-NLS-1$
attr = typeValidator.getTypeElementName();
}
- IType type = getType(beansXml, typeNode,
typeValidator.getUnknownTypeErrorMessage(), typeValidator.getUnknownTypeErrorMessageId(),
typepath, attr);
+ IType type = getType(beansXml, typeNode, typeValidator, typepath, attr);
if(type!=null) {
if(!type.isBinary()) {
validator.getValidationContext().addLinkedCoreResource(CDICoreValidator.SHORT_ID,
beansXml.getFullPath().toOSString(), type.getPath(), false);
@@ -198,23 +198,14 @@
}
}
}
- if(!typeValidator.validateKindOfType(type)) {
+ String typeError = typeValidator.validateType(context, type);
+ if(typeError != null) {
IMarker marker = validator.addError(typeValidator.getIllegalTypeErrorMessage(),
CDIPreferences.ILLEGAL_TYPE_NAME_IN_BEANS_XML,
- new String[]{}, typeNode.getLength(), typeNode.getStartOffset(), beansXml,
typeValidator.getIllegalTypeErrorMessageId());
+ new String[]{typeNode.getTypeName()}, typeNode.getLength(),
typeNode.getStartOffset(), beansXml, typeValidator.getIllegalTypeErrorMessageId());
if(marker != null) bindMarkerToModel(marker, typepath,
typeValidator.getTypeElementName());
- } else if(type.isBinary()) {
- if(!typeValidator.validateBinaryType(type)) {
- IMarker marker = validator.addError(typeValidator.getIllegalTypeErrorMessage(),
CDIPreferences.ILLEGAL_TYPE_NAME_IN_BEANS_XML,
- new String[]{}, typeNode.getLength(), typeNode.getStartOffset(), beansXml,
typeValidator.getIllegalTypeErrorMessageId());
- if(marker != null) bindMarkerToModel(marker, typepath,
typeValidator.getTypeElementName());
+ if(type.isBinary()) {
+ continue;
}
- continue;
- } else {
- if(!typeValidator.validateSourceType(context, type)) {
- IMarker marker = validator.addError(typeValidator.getIllegalTypeErrorMessage(),
CDIPreferences.ILLEGAL_TYPE_NAME_IN_BEANS_XML,
- new String[]{}, typeNode.getLength(), typeNode.getStartOffset(), beansXml,
typeValidator.getIllegalTypeErrorMessageId());
- if(marker != null) bindMarkerToModel(marker, typepath,
typeValidator.getTypeElementName());
- }
}
TypeNode node = uniqueTypes.get(typeNode.getTypeName());
if(node!=null) {
@@ -266,23 +257,29 @@
return null;
}
- private IType getType(IFile beansXml, TypeNode node, String errorMessage, int
errorMessageId, String xmodelpath, String attr) {
+ private IType getType(IFile beansXml, TypeNode node, TypeValidator typeValidator, String
xmodelpath, String attr) {
IType type = null;
- if(node.getTypeName()!=null) {
+ String typeName = node.getTypeName();
+ if(typeName!=null && typeName.trim().length() > 0) {
try {
IJavaProject javaProject = getJavaProject(beansXml);
if(javaProject!=null) {
- type = EclipseJavaUtil.findType(javaProject, node.getTypeName());
+ type = EclipseJavaUtil.findType(javaProject, typeName);
}
} catch (JavaModelException e) {
CDICorePlugin.getDefault().logError(e);
return null;
}
+ } else {
+ IMarker marker = validator.addError(typeValidator.getEmptyTypeErrorMessage(),
CDIPreferences.ILLEGAL_TYPE_NAME_IN_BEANS_XML,
+ new String[]{node.getTypeName()}, node.getLength(), node.getStartOffset(), beansXml,
typeValidator.getUnknownTypeErrorMessageId());
+ bindMarkerToModel(marker, xmodelpath, attr);
+ return null;
}
if(type==null) {
addLinkedResourcesForUnknownType(beansXml, node.getTypeName());
- IMarker marker = validator.addError(errorMessage,
CDIPreferences.ILLEGAL_TYPE_NAME_IN_BEANS_XML,
- new String[]{}, node.getLength(), node.getStartOffset(), beansXml, errorMessageId);
+ IMarker marker = validator.addError(typeValidator.getUnknownTypeErrorMessage(),
CDIPreferences.ILLEGAL_TYPE_NAME_IN_BEANS_XML,
+ new String[]{node.getTypeName()}, node.getLength(), node.getStartOffset(), beansXml,
typeValidator.getUnknownTypeErrorMessageId());
bindMarkerToModel(marker, xmodelpath, attr);
}
return type;
@@ -414,22 +411,14 @@
private static interface TypeValidator {
- boolean validateSourceType(CDICoreValidator.CDIValidationContext context, IType type);
+ String validateType(CDICoreValidator.CDIValidationContext context, IType type) throws
JavaModelException;
- boolean validateBinaryType(IType type) throws JavaModelException;
-
- /**
- * Validates if the type represens class/annotation/...
- * @param type
- * @return
- * @throws JavaModelException
- */
- boolean validateKindOfType(IType type) throws JavaModelException;
-
String getTypeElementName();
String getParrentElementname();
+ String getEmptyTypeErrorMessage();
+
String getUnknownTypeErrorMessage();
int getUnknownTypeErrorMessageId();
@@ -447,6 +436,28 @@
return "class"; //$NON-NLS-1$
}
+ public String validateType(CDICoreValidator.CDIValidationContext context, IType type)
throws JavaModelException {
+ if(!validateKindOfType(type)) {
+ return getIllegalTypeErrorMessage();
+ }
+ if(type.isBinary()) {
+ if(!validateBinaryType(type)) {
+ return getIllegalTypeErrorMessage();
+ }
+ } else if(!validateSourceType(context, type)) {
+ return getIllegalTypeErrorMessage();
+ }
+ return null;
+ }
+
+ abstract public boolean validateSourceType(CDICoreValidator.CDIValidationContext
context, IType type);
+
+ /**
+ * Validates if the type represens class/annotation/...
+ * @param type
+ * @return
+ * @throws JavaModelException
+ */
public boolean validateKindOfType(IType type) throws JavaModelException {
return type.isClass();
}
@@ -475,6 +486,10 @@
return "alternatives"; //$NON-NLS-1$
}
+ public String getEmptyTypeErrorMessage() {
+ return CDIValidationMessages.EMPTY_ALTERNATIVE_BEAN_CLASS_NAME;
+ }
+
public String getUnknownTypeErrorMessage() {
return CDIValidationMessages.UNKNOWN_ALTERNATIVE_BEAN_CLASS_NAME;
}
@@ -522,6 +537,10 @@
return "alternatives"; //$NON-NLS-1$
}
+ public String getEmptyTypeErrorMessage() {
+ return CDIValidationMessages.EMPTY_ALTERNATIVE_ANNOTATION_NAME;
+ }
+
public String getUnknownTypeErrorMessage() {
return CDIValidationMessages.UNKNOWN_ALTERNATIVE_ANNOTATION_NAME;
}
@@ -559,6 +578,10 @@
return "decorators"; //$NON-NLS-1$
}
+ public String getEmptyTypeErrorMessage() {
+ return CDIValidationMessages.EMPTY_DECORATOR_BEAN_CLASS_NAME;
+ }
+
public String getUnknownTypeErrorMessage() {
return CDIValidationMessages.UNKNOWN_DECORATOR_BEAN_CLASS_NAME;
}
@@ -596,6 +619,10 @@
return "interceptors"; //$NON-NLS-1$
}
+ public String getEmptyTypeErrorMessage() {
+ return CDIValidationMessages.EMPTY_INTERCEPTOR_CLASS_NAME;
+ }
+
public String getUnknownTypeErrorMessage() {
return CDIValidationMessages.UNKNOWN_INTERCEPTOR_CLASS_NAME;
}
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/CDIValidationMessages.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/CDIValidationMessages.java 2012-05-04
23:09:47 UTC (rev 40809)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/CDIValidationMessages.java 2012-05-04
23:17:23 UTC (rev 40810)
@@ -137,14 +137,18 @@
public static String ILLEGAL_INJECTING_USERTRANSACTION_TYPE;
public static String ILLEGAL_INJECTING_INJECTIONPOINT_TYPE;
public static String ILLEGAL_QUALIFIER_IN_STEREOTYPE;
+ public static String EMPTY_ALTERNATIVE_BEAN_CLASS_NAME;
public static String UNKNOWN_ALTERNATIVE_BEAN_CLASS_NAME;
public static String ILLEGAL_ALTERNATIVE_BEAN_CLASS;
+ public static String EMPTY_ALTERNATIVE_ANNOTATION_NAME;
public static String UNKNOWN_ALTERNATIVE_ANNOTATION_NAME;
public static String ILLEGAL_ALTERNATIVE_ANNOTATION;
public static String DUPLICATE_ALTERNATIVE_TYPE;
+ public static String EMPTY_DECORATOR_BEAN_CLASS_NAME;
public static String UNKNOWN_DECORATOR_BEAN_CLASS_NAME;
public static String ILLEGAL_DECORATOR_BEAN_CLASS;
public static String DUPLICATE_DECORATOR_CLASS;
+ public static String EMPTY_INTERCEPTOR_CLASS_NAME;
public static String UNKNOWN_INTERCEPTOR_CLASS_NAME;
public static String ILLEGAL_INTERCEPTOR_CLASS;
public static String DUPLICATE_INTERCEPTOR_CLASS;
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/messages.properties
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/messages.properties 2012-05-04
23:09:47 UTC (rev 40809)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/messages.properties 2012-05-04
23:17:23 UTC (rev 40810)
@@ -119,16 +119,20 @@
#Beans.xml
-UNKNOWN_ALTERNATIVE_BEAN_CLASS_NAME=There is no class with the specified name [JSR-299
�5.1.1]
-ILLEGAL_ALTERNATIVE_BEAN_CLASS=<class> element must specify the name of an
alternative bean class [JSR-299 �5.1.1]
-UNKNOWN_ALTERNATIVE_ANNOTATION_NAME=There is no annotation with the specified name
[JSR-299 �5.1.1]
-ILLEGAL_ALTERNATIVE_ANNOTATION=<stereotype> element must specify the name of an
@Alternative stereotype annotation [JSR-299 �5.1.1]
+EMPTY_ALTERNATIVE_BEAN_CLASS_NAME=<class> element must specify the name of an
alternative bean class [JSR-299 �5.1.1]
+UNKNOWN_ALTERNATIVE_BEAN_CLASS_NAME=There is no class "{0}" [JSR-299 �5.1.1]
+ILLEGAL_ALTERNATIVE_BEAN_CLASS="{0}" is not an alternative bean class [JSR-299
�5.1.1]
+EMPTY_ALTERNATIVE_ANNOTATION_NAME=<stereotype> element must specify the name of an
@Alternative stereotype annotation [JSR-299 �5.1.1]
+UNKNOWN_ALTERNATIVE_ANNOTATION_NAME=There is no annotation "{0}" [JSR-299
�5.1.1]
+ILLEGAL_ALTERNATIVE_ANNOTATION= "{0}" is not @Alternative stereotype annotation
[JSR-299 �5.1.1]
DUPLICATE_ALTERNATIVE_TYPE=The same type cannot be listed more than once under the
<alternatives> element [JSR-299 �5.1.1]
-UNKNOWN_DECORATOR_BEAN_CLASS_NAME=There is no class with the specified name [JSR-299
�8.2]
-ILLEGAL_DECORATOR_BEAN_CLASS=<class> element must specify the name of a decorator
bean class [JSR-299 �8.2]
+EMPTY_DECORATOR_BEAN_CLASS_NAME=<class> element must specify the name of a
decorator bean class [JSR-299 �8.2]
+UNKNOWN_DECORATOR_BEAN_CLASS_NAME=There is no class "{0}" [JSR-299 �8.2]
+ILLEGAL_DECORATOR_BEAN_CLASS="{0}" is not a decorator bean class [JSR-299
�8.2]
DUPLICATE_DECORATOR_CLASS=The same class cannot be listed more then once under the
<decorators> element [JSR-299 �8.2]
-UNKNOWN_INTERCEPTOR_CLASS_NAME=There is no class with the specified name [JSR-299 �9.4]
-ILLEGAL_INTERCEPTOR_CLASS=<class> element must specify the name of an interceptor
class [JSR-299 �9.4]
+EMPTY_INTERCEPTOR_CLASS_NAME=<class> element must specify the name of an
interceptor class [JSR-299 �9.4]
+UNKNOWN_INTERCEPTOR_CLASS_NAME=There is no class "{0}" [JSR-299 �9.4]
+ILLEGAL_INTERCEPTOR_CLASS="{0}" is not an interceptor class [JSR-299 �9.4]
DUPLICATE_INTERCEPTOR_CLASS=The same class cannot be listed more then once under the
<interceptors> element [JSR-299 �9.4]
#Messages for Progress Monitor