### Eclipse Workspace Patch 1.0
#P org.jboss.tools.cdi.core
Index: src/org/jboss/tools/cdi/internal/core/validation/BeansXmlValidationDelegate.java
===================================================================
--- src/org/jboss/tools/cdi/internal/core/validation/BeansXmlValidationDelegate.java	(revision 39150)
+++ src/org/jboss/tools/cdi/internal/core/validation/BeansXmlValidationDelegate.java	(working copy)
@@ -21,6 +21,7 @@
 
 import org.eclipse.core.resources.IFile;
 import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IMarker;
 import org.eclipse.core.resources.IProject;
 import org.eclipse.core.resources.IResource;
 import org.eclipse.core.runtime.CoreException;
@@ -46,6 +47,7 @@
 import org.jboss.tools.cdi.core.IStereotype;
 import org.jboss.tools.cdi.core.preferences.CDIPreferences;
 import org.jboss.tools.common.EclipseUtil;
+import org.jboss.tools.common.model.XModelObject;
 import org.jboss.tools.common.model.util.EclipseJavaUtil;
 import org.jboss.tools.common.model.util.EclipseResourceUtil;
 import org.w3c.dom.Element;
@@ -97,6 +99,9 @@
 	}
 
 	public void validateBeansXml(CDICoreValidator.CDIValidationContext context, IFile beansXml) {
+		XModelObject f = EclipseResourceUtil.createObjectForResource(beansXml);
+		String xmodelpath = (f == null) ? "" : f.getPath();
+
 		IModelManager manager = StructuredModelManager.getModelManager();
 		if(manager == null) {
 			// this may happen if plug-in org.eclipse.wst.sse.core 
@@ -120,7 +125,7 @@
 				 *  - If the same type is listed twice under the <alternatives> element, the container automatically detects the problem and
 				 *    treats it as a deployment problem.
 				 */
-				validateTypeBeanForBeansXml(context, getAlternativeClassValidator(), document, beansXml);
+				validateTypeBeanForBeansXml(context, getAlternativeClassValidator(), document, beansXml, xmodelpath + "/Alternatives"); //$NON-NLS-1$
 
 				/*
 				 * 5.1.1. Declaring selected alternatives for a bean archive
@@ -130,7 +135,7 @@
 				 *  - If the same type is listed twice under the <alternatives> element, the container automatically detects the problem and
 				 *    treats it as a deployment problem. 
 				 */
-				validateTypeBeanForBeansXml(context, getAlternativeStereotypeValidator(), document,	beansXml);
+				validateTypeBeanForBeansXml(context, getAlternativeStereotypeValidator(), document,	beansXml, xmodelpath + "/Alternatives"); //$NON-NLS-1$
 
 				/*
 				 * 8.2. Decorator enablement and ordering
@@ -140,7 +145,7 @@
 				 *  - If the same class is listed twice under the <decorators> element, the container automatically detects the problem and
 				 *    treats it as a deployment problem.
 				 */
-				validateTypeBeanForBeansXml(context, getDecoratorTypeValidator(), document, beansXml);
+				validateTypeBeanForBeansXml(context, getDecoratorTypeValidator(), document, beansXml, xmodelpath + "/Decorators"); //$NON-NLS-1$
 
 				/*
 				 * 9.4. Interceptor enablement and ordering
@@ -150,7 +155,7 @@
 				 *  - If the same class is listed twice under the <interceptors> element, the container automatically detects the problem and treats it as
 				 *    a deployment problem.
 				 */
-				validateTypeBeanForBeansXml(context, getInterceptorTypeValidator(), document, beansXml);
+				validateTypeBeanForBeansXml(context, getInterceptorTypeValidator(), document, beansXml, xmodelpath + "/Interceptors"); //$NON-NLS-1$
 			}
 		} catch (CoreException e) {
 			CDICorePlugin.getDefault().logError(e);
@@ -163,7 +168,7 @@
 		}
 	}
 
-	private void validateTypeBeanForBeansXml(CDICoreValidator.CDIValidationContext context, TypeValidator typeValidator, IDOMDocument document, IFile beansXml) {
+	private void validateTypeBeanForBeansXml(CDICoreValidator.CDIValidationContext context, TypeValidator typeValidator, IDOMDocument document, IFile beansXml, String xmodelpath) {
 		try {
 			NodeList parentNodeList = document.getElementsByTagName(typeValidator.getParrentElementname());
 			for (int i = 0; i < parentNodeList.getLength(); i++) {
@@ -172,7 +177,13 @@
 					List<TypeNode> typeNodes = getTypeElements((Element)parentNode, typeValidator.getTypeElementName());
 					Map<String, TypeNode> uniqueTypes = new HashMap<String, TypeNode>();
 					for (TypeNode typeNode : typeNodes) {
-						IType type = getType(beansXml, typeNode, typeValidator.getUnknownTypeErrorMessage(), typeValidator.getUnknownTypeErrorMessageId());
+						String typepath = xmodelpath;
+						String attr = null;
+						if(typeNode.getTypeName().length() > 0) {
+							typepath = typepath + "/" + typeNode.getTypeName();
+							attr = typeValidator.getTypeElementName();
+						}
+						IType type = getType(beansXml, typeNode, typeValidator.getUnknownTypeErrorMessage(), typeValidator.getUnknownTypeErrorMessageId(), typepath, attr);
 						if(type!=null) {
 							if(!type.isBinary()) {
 								validator.getValidationContext().addLinkedCoreResource(CDICoreValidator.SHORT_ID, beansXml.getFullPath().toOSString(), type.getPath(), false);
@@ -186,29 +197,42 @@
 								}
 							}
 							if(!typeValidator.validateKindOfType(type)) {
-								validator.addError(typeValidator.getIllegalTypeErrorMessage(), CDIPreferences.ILLEGAL_TYPE_NAME_IN_BEANS_XML,
+								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());
 							} else if(type.isBinary()) {
 								if(!typeValidator.validateBinaryType(type)) {
-									validator.addError(typeValidator.getIllegalTypeErrorMessage(), CDIPreferences.ILLEGAL_TYPE_NAME_IN_BEANS_XML,
+									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());
 								}
 								continue;
 							} else {
 								if(!typeValidator.validateSourceType(context, type)) {
-									validator.addError(typeValidator.getIllegalTypeErrorMessage(), CDIPreferences.ILLEGAL_TYPE_NAME_IN_BEANS_XML,
+									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) {
 								if(!node.isMarkedAsDuplicated()) {
-									validator.addError(typeValidator.getDuplicateTypeErrorMessage(), CDIPreferences.DUPLICATE_TYPE_IN_BEANS_XML,
+									IMarker marker = validator.addError(typeValidator.getDuplicateTypeErrorMessage(), CDIPreferences.DUPLICATE_TYPE_IN_BEANS_XML,
 											new String[]{}, node.getLength(), node.getStartOffset(), beansXml);
+									if(marker != null) bindMarkerToModel(marker, typepath, typeValidator.getTypeElementName());
 								}
 								node.setMarkedAsDuplicated(true);
-								validator.addError(typeValidator.getDuplicateTypeErrorMessage(), CDIPreferences.DUPLICATE_TYPE_IN_BEANS_XML,
+								typeNode.setMarkedAsDuplicated(true);
+								typeNode.setDuplicationIndex(node.getDuplicationIndex() + 1);
+								IMarker marker = validator.addError(typeValidator.getDuplicateTypeErrorMessage(), CDIPreferences.DUPLICATE_TYPE_IN_BEANS_XML,
 										new String[]{}, typeNode.getLength(), typeNode.getStartOffset(), beansXml);
+								if(marker != null) {
+									int di = typeNode.getDuplicationIndex();
+									if(di > 0) {
+										typepath += "__duplicate" + di; //$NON-NLS-1$
+									}
+									bindMarkerToModel(marker, typepath, typeValidator.getTypeElementName());
+								}
 							}
 							uniqueTypes.put(typeNode.getTypeName(), typeNode);
 						}
@@ -240,7 +264,7 @@
 		return null;
 	}
 
-	private IType getType(IFile beansXml, TypeNode node, String errorMessage, int errorMessageId) {
+	private IType getType(IFile beansXml, TypeNode node, String errorMessage, int errorMessageId, String xmodelpath, String attr) {
 		IType type = null;
 		if(node.getTypeName()!=null) {
 			try {
@@ -255,12 +279,27 @@
 		}
 		if(type==null) {
 			addLinkedResourcesForUnknownType(beansXml, node.getTypeName());
-			validator.addError(errorMessage, CDIPreferences.ILLEGAL_TYPE_NAME_IN_BEANS_XML,
+			IMarker marker = validator.addError(errorMessage, CDIPreferences.ILLEGAL_TYPE_NAME_IN_BEANS_XML,
 					new String[]{}, node.getLength(), node.getStartOffset(), beansXml, errorMessageId);
+			bindMarkerToModel(marker, xmodelpath, attr);
 		}
 		return type;
 	}
 
+	private void bindMarkerToModel(IMarker marker, String path, String attribute) {
+		try {
+			if(marker!=null) {
+				marker.setAttribute("path", path); //$NON-NLS-1$
+				if(attribute != null) {
+					marker.setAttribute("attribute", attribute); //$NON-NLS-1$
+				}
+			}
+		} catch(CoreException e) {
+			CDICorePlugin.getDefault().logError(e);
+		}
+		
+	}
+
 	private void addLinkedResourcesForUnknownType(IFile beansXml, String typeName) {
 		if(typeName!=null && typeName.trim().length()>0) {
 			IStatus status = JavaConventions.validateJavaTypeName(typeName, CompilerOptions.VERSION_1_7, CompilerOptions.VERSION_1_7);
@@ -318,6 +357,7 @@
 		private int length;
 		private String typeName;
 		private boolean markedAsDuplicated;
+		private int duplicationIndex = 0;
 
 		public TypeNode(int startOffset, int length, String typeName) {
 			this.startOffset = startOffset;
@@ -356,6 +396,14 @@
 		public void setMarkedAsDuplicated(boolean markedAsDuplicated) {
 			this.markedAsDuplicated = markedAsDuplicated;
 		}
+	
+		public int getDuplicationIndex() {
+			return duplicationIndex;
+		}
+
+		public void setDuplicationIndex(int i) {
+			duplicationIndex = i;
+		}
 	}
 
 	private static interface TypeValidator {
#P org.jboss.tools.common.model
Index: src/org/jboss/tools/common/model/markers/XMarkerManager.java
===================================================================
--- src/org/jboss/tools/common/model/markers/XMarkerManager.java	(revision 39150)
+++ src/org/jboss/tools/common/model/markers/XMarkerManager.java	(working copy)
@@ -314,9 +314,13 @@
 			return null;
 		}
 		if(ms == null) return null;
+		String pathInFile = object.getPath().substring(f.getPath().length());
 		for (int i = 0; i < ms.length; i++) {
 			XModelObject o = object;
 			String path = ms[i].getAttribute("path", null); //$NON-NLS-1$
+			if(path != null && !path.endsWith(pathInFile)) {
+				continue;
+			}
 			o = (path == null) ? o : o.getModel().getByPath(path);
 			if(o == null) continue;
 			String attr = ms[i].getAttribute("attribute", null); //$NON-NLS-1$
