[218143] ModelQuery use not pervasive enough
diff --git a/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/validation/JSPActionValidator.java b/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/validation/JSPActionValidator.java
index f53a3e2..612375d 100644
--- a/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/validation/JSPActionValidator.java
+++ b/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/validation/JSPActionValidator.java
@@ -38,6 +38,8 @@
import org.eclipse.wst.xml.core.internal.contentmodel.CMAttributeDeclaration;
import org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration;
import org.eclipse.wst.xml.core.internal.contentmodel.CMNamedNodeMap;
+import org.eclipse.wst.xml.core.internal.contentmodel.CMNode;
+import org.eclipse.wst.xml.core.internal.contentmodel.basic.CMNamedNodeMapImpl;
import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQuery;
import org.eclipse.wst.xml.core.internal.modelquery.ModelQueryUtil;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMAttr;
@@ -244,6 +246,18 @@
CMElementDeclaration cmElement = query.getCMElementDeclaration(element);
if (cmElement != null) {
CMNamedNodeMap cmAttributes = cmElement.getAttributes();
+
+ CMNamedNodeMapImpl allAttributes = new CMNamedNodeMapImpl(cmAttributes);
+ if (cmElement != null) {
+ List nodes = query.getAvailableContent(element, cmElement, ModelQuery.INCLUDE_ATTRIBUTES);
+ for (int k = 0; k < nodes.size(); k++) {
+ CMNode cmnode = (CMNode) nodes.get(k);
+ if (cmnode.getNodeType() == CMNode.ATTRIBUTE_DECLARATION) {
+ allAttributes.put(cmnode);
+ }
+ }
+ }
+ cmAttributes = allAttributes;
boolean foundjspattribute = checkUnknownAttributes(element, cmAttributes, reporter, file, model.getStructuredDocument(), documentRegion);
// required attributes could be hidden in jsp regions in
diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/validate/HTMLAttributeValidator.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/validate/HTMLAttributeValidator.java
index 82b2e8a..bea9cc8 100644
--- a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/validate/HTMLAttributeValidator.java
+++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/validate/HTMLAttributeValidator.java
@@ -12,6 +12,8 @@
+import java.util.List;
+
import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion;
import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionContainer;
@@ -20,6 +22,10 @@
import org.eclipse.wst.xml.core.internal.contentmodel.CMDataType;
import org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration;
import org.eclipse.wst.xml.core.internal.contentmodel.CMNamedNodeMap;
+import org.eclipse.wst.xml.core.internal.contentmodel.CMNode;
+import org.eclipse.wst.xml.core.internal.contentmodel.basic.CMNamedNodeMapImpl;
+import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQuery;
+import org.eclipse.wst.xml.core.internal.modelquery.ModelQueryUtil;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMAttr;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
@@ -90,6 +96,16 @@
return;
CMNamedNodeMap declarations = edec.getAttributes();
+ CMNamedNodeMapImpl allAttributes = new CMNamedNodeMapImpl(declarations);
+ List nodes = ModelQueryUtil.getModelQuery(target.getOwnerDocument()).getAvailableContent((Element) node, edec, ModelQuery.INCLUDE_ATTRIBUTES);
+ for (int k = 0; k < nodes.size(); k++) {
+ CMNode cmnode = (CMNode) nodes.get(k);
+ if (cmnode.getNodeType() == CMNode.ATTRIBUTE_DECLARATION) {
+ allAttributes.put(cmnode);
+ }
+ }
+ declarations = allAttributes;
+
NamedNodeMap attrs = target.getAttributes();
for (int i = 0; i < attrs.getLength(); i++) {
int rgnType = REGION_NAME;
diff --git a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/internal/modelqueryimpl/ModelQueryExtensionManagerImpl.java b/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/internal/modelqueryimpl/ModelQueryExtensionManagerImpl.java
index a9a29ae..72c28fd 100644
--- a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/internal/modelqueryimpl/ModelQueryExtensionManagerImpl.java
+++ b/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/internal/modelqueryimpl/ModelQueryExtensionManagerImpl.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2002, 2006 IBM Corporation and others.
+ * Copyright (c) 2002, 2008 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -20,6 +20,7 @@
import org.eclipse.wst.xml.core.internal.contentmodel.CMDocument;
import org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration;
import org.eclipse.wst.xml.core.internal.contentmodel.CMNode;
+import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQuery;
import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.extension.ModelQueryExtension;
import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.extension.ModelQueryExtensionManager;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
@@ -61,30 +62,43 @@
public void filterAvailableElementContent(List cmnodes, Element element, CMElementDeclaration ed)
{
+ filterAvailableElementContent(cmnodes, element, ed, ModelQuery.INCLUDE_CHILD_NODES);
+ }
+
+ public void filterAvailableElementContent(List cmnodes, Element element, CMElementDeclaration ed, int includeOptions)
+ {
String contentTypeId = getContentTypeId(element);
String parentNamespace = element.getNamespaceURI();
List modelQueryExtensions = modelQueryExtensionRegistry.getApplicableExtensions(contentTypeId, parentNamespace);
-
- for (Iterator j = cmnodes.iterator(); j.hasNext(); )
- {
- CMNode cmNode = (CMNode)j.next();
- String namespace = getNamespace(cmNode);
- String name = cmNode.getNodeName();
-
- boolean include = true;
- for(int k = 0; k < modelQueryExtensions.size() && include; k++) {
+ if((includeOptions & ModelQuery.INCLUDE_CHILD_NODES) > 0)
+ {
+ for (Iterator j = cmnodes.iterator(); j.hasNext(); )
{
- ModelQueryExtension extension = (ModelQueryExtension)modelQueryExtensions.get(k);
- include = extension.isApplicableChildElement(element, namespace, name);
- if (!include)
- {
- // remove the cmNode from the list
- j.remove();
+ CMNode cmNode = (CMNode)j.next();
+ String namespace = getNamespace(cmNode);
+ String name = cmNode.getNodeName();
+
+ boolean include = true;
+ for(int k = 0; k < modelQueryExtensions.size() && include; k++) {
+ {
+ ModelQueryExtension extension = (ModelQueryExtension)modelQueryExtensions.get(k);
+ include = extension.isApplicableChildElement(element, namespace, name);
+ if (!include)
+ {
+ // remove the cmNode from the list
+ j.remove();
+ }
}
}
}
}
+ // add MQE-provided content
+ for(int k = 0; k < modelQueryExtensions.size(); k++)
+ {
+ ModelQueryExtension extension = (ModelQueryExtension)modelQueryExtensions.get(k);
+ cmnodes.addAll(Arrays.asList(extension.getAvailableElementContent(element, parentNamespace, includeOptions)));
+ }
}
private String getNamespace(CMNode cmNode)
diff --git a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/modelquery/extension/ModelQueryExtension.java b/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/modelquery/extension/ModelQueryExtension.java
index 6d5870d..000a432 100644
--- a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/modelquery/extension/ModelQueryExtension.java
+++ b/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/modelquery/extension/ModelQueryExtension.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2002, 2006 IBM Corporation and others.
+ * Copyright (c) 2002, 2008 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -12,12 +12,14 @@
*******************************************************************************/
package org.eclipse.wst.xml.core.internal.contentmodel.modelquery.extension;
+import org.eclipse.wst.xml.core.internal.contentmodel.CMNode;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
public abstract class ModelQueryExtension
{
protected static final String[] EMPTY_STRING_ARRAY = {};
+ protected static final CMNode[] EMPTY_CMNODE_ARRAY = {};
public String[] getAttributeValues(Element ownerElement, String namespace, String name)
{
@@ -33,4 +35,9 @@
{
return true;
}
+
+ public CMNode[] getAvailableElementContent(Element parentElement, String namespace, int includeOptions)
+ {
+ return EMPTY_CMNODE_ARRAY;
+ }
}
diff --git a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/modelquery/extension/ModelQueryExtensionManager.java b/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/modelquery/extension/ModelQueryExtensionManager.java
index 1a41a3f..31c440f 100644
--- a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/modelquery/extension/ModelQueryExtensionManager.java
+++ b/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/modelquery/extension/ModelQueryExtensionManager.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2002, 2006 IBM Corporation and others.
+ * Copyright (c) 2002, 2008 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -25,4 +25,6 @@
List getDataTypeValues(Element element, CMNode cmNode);
void filterAvailableElementContent(List availableContent, Element element, CMElementDeclaration ed);
+
+ void filterAvailableElementContent(List availableContent, Element element, CMElementDeclaration ed, int includeOptions);
}
diff --git a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/modelqueryimpl/ModelQueryImpl.java b/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/modelqueryimpl/ModelQueryImpl.java
index a93d565..436d8ff 100644
--- a/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/modelqueryimpl/ModelQueryImpl.java
+++ b/bundles/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/modelqueryimpl/ModelQueryImpl.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2002, 2006 IBM Corporation and others.
+ * Copyright (c) 2002, 2008 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -309,7 +309,7 @@
List list = visitor.computeAvailableContent(includeOptions);
if (extensionManager != null)
{
- extensionManager.filterAvailableElementContent(list, element, ed);
+ extensionManager.filterAvailableElementContent(list, element, ed, includeOptions);
}
return list;
}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/AttrImpl.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/AttrImpl.java
index bc39339..cf2e968 100644
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/AttrImpl.java
+++ b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/AttrImpl.java
@@ -18,6 +18,7 @@
import java.util.Iterator;
+import java.util.List;
import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
@@ -26,6 +27,10 @@
import org.eclipse.wst.xml.core.internal.contentmodel.CMAttributeDeclaration;
import org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration;
import org.eclipse.wst.xml.core.internal.contentmodel.CMNamedNodeMap;
+import org.eclipse.wst.xml.core.internal.contentmodel.CMNode;
+import org.eclipse.wst.xml.core.internal.contentmodel.basic.CMNamedNodeMapImpl;
+import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQuery;
+import org.eclipse.wst.xml.core.internal.modelquery.ModelQueryUtil;
import org.eclipse.wst.xml.core.internal.provisional.IXMLCharEntity;
import org.eclipse.wst.xml.core.internal.provisional.IXMLNamespace;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMAttr;
@@ -93,6 +98,17 @@
if (elementDecl == null)
return null;
CMNamedNodeMap attributes = elementDecl.getAttributes();
+ CMNamedNodeMapImpl allAttributes = new CMNamedNodeMapImpl(attributes);
+ List nodes = ModelQueryUtil.getModelQuery(getOwnerDocument()).getAvailableContent(getOwnerElement(), elementDecl, ModelQuery.INCLUDE_ATTRIBUTES);
+ for (int k = 0; k < nodes.size(); k++) {
+ CMNode cmnode = (CMNode) nodes.get(k);
+ if (cmnode.getNodeType() == CMNode.ATTRIBUTE_DECLARATION) {
+ allAttributes.put(cmnode);
+ }
+ }
+ attributes = allAttributes;
+
+
if (attributes == null)
return null;
return (CMAttributeDeclaration) attributes.getNamedItem(getName());
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/preferences/XMLCorePreferenceNames.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/preferences/XMLCorePreferenceNames.java
index 7e5b13e..63f2dde 100644
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/preferences/XMLCorePreferenceNames.java
+++ b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/preferences/XMLCorePreferenceNames.java
@@ -138,6 +138,7 @@
* <p>
* Value is of type <code>Boolean</code>.
* </p>
+ * @deprecated - no longer used
*/
public static final String CONVERT_EOL_CODES = "convertEOLCodes";//$NON-NLS-1$
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/AbstractContentAssistProcessor.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/AbstractContentAssistProcessor.java
index ee417bc..6cdccd9 100644
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/AbstractContentAssistProcessor.java
+++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/AbstractContentAssistProcessor.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2001, 2007 IBM Corporation and others.
+ * Copyright (c) 2001, 2008 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -49,6 +49,7 @@
import org.eclipse.wst.xml.core.internal.contentmodel.CMNamedNodeMap;
import org.eclipse.wst.xml.core.internal.contentmodel.CMNode;
import org.eclipse.wst.xml.core.internal.contentmodel.CMNodeList;
+import org.eclipse.wst.xml.core.internal.contentmodel.basic.CMNamedNodeMapImpl;
import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQuery;
import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQueryAction;
import org.eclipse.wst.xml.core.internal.contentmodel.util.DOMNamespaceHelper;
@@ -127,6 +128,19 @@
CMElementDeclaration elementDecl = getCMElementDeclaration(node);
if (elementDecl != null) {
CMNamedNodeMap attributes = elementDecl.getAttributes();
+
+ CMNamedNodeMapImpl allAttributes = new CMNamedNodeMapImpl(attributes);
+ if (node.getNodeType() == Node.ELEMENT_NODE) {
+ List nodes = ModelQueryUtil.getModelQuery(node.getOwnerDocument()).getAvailableContent((Element) node, elementDecl, ModelQuery.INCLUDE_ATTRIBUTES);
+ for (int k = 0; k < nodes.size(); k++) {
+ CMNode cmnode = (CMNode) nodes.get(k);
+ if (cmnode.getNodeType() == CMNode.ATTRIBUTE_DECLARATION) {
+ allAttributes.put(cmnode);
+ }
+ }
+ }
+ attributes = allAttributes;
+
String matchString = contentAssistRequest.getMatchString();
// check whether an attribute really exists for the replacement
@@ -246,6 +260,19 @@
// declaration for the attribute otherwise
if (elementDecl != null) {
CMNamedNodeMap attributes = elementDecl.getAttributes();
+
+ CMNamedNodeMapImpl allAttributes = new CMNamedNodeMapImpl(attributes);
+ if (node.getNodeType() == Node.ELEMENT_NODE) {
+ List nodes = ModelQueryUtil.getModelQuery(node.getOwnerDocument()).getAvailableContent((Element) node, elementDecl, ModelQuery.INCLUDE_ATTRIBUTES);
+ for (int k = 0; k < nodes.size(); k++) {
+ CMNode cmnode = (CMNode) nodes.get(k);
+ if (cmnode.getNodeType() == CMNode.ATTRIBUTE_DECLARATION) {
+ allAttributes.put(cmnode);
+ }
+ }
+ }
+ attributes = allAttributes;
+
String noprefixName = DOMNamespaceHelper.getUnprefixedName(attributeName);
if (attributes != null) {
attrDecl = (CMAttributeDeclaration) attributes.getNamedItem(noprefixName);
@@ -1133,6 +1160,17 @@
if (beginsWith(cmnodeName, elementMatchString)) {
if (cmnode.getNodeType() == CMNode.ELEMENT_DECLARATION) {
cmattrMap = ((CMElementDeclaration) cmnode).getAttributes();
+
+ CMNamedNodeMapImpl allAttributes = new CMNamedNodeMapImpl(cmattrMap);
+ List nodes = ModelQueryUtil.getModelQuery(node.getOwnerDocument()).getAvailableContent((Element) node, (CMElementDeclaration) cmnode, ModelQuery.INCLUDE_ATTRIBUTES);
+ for (int k = 0; k < nodes.size(); k++) {
+ CMNode adnode = (CMNode) nodes.get(k);
+ if (adnode.getNodeType() == CMNode.ATTRIBUTE_DECLARATION) {
+ allAttributes.put(adnode);
+ }
+ }
+ cmattrMap = allAttributes;
+
// iterate possible attributes from a cmnode in
// proposal list
for (int k = 0; (cmattrMap != null) && (k < cmattrMap.getLength()); k++) {
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/AttributeContextInformationProvider.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/AttributeContextInformationProvider.java
index b005237..f0e9052 100644
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/AttributeContextInformationProvider.java
+++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/AttributeContextInformationProvider.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2001, 2006 IBM Corporation and others.
+ * Copyright (c) 2001, 2008 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -31,6 +31,9 @@
import org.eclipse.wst.xml.core.internal.contentmodel.CMNamedNodeMap;
import org.eclipse.wst.xml.core.internal.contentmodel.CMNode;
import org.eclipse.wst.xml.core.internal.contentmodel.CMNodeList;
+import org.eclipse.wst.xml.core.internal.contentmodel.basic.CMNamedNodeMapImpl;
+import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQuery;
+import org.eclipse.wst.xml.core.internal.modelquery.ModelQueryUtil;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext;
import org.w3c.dom.Element;
@@ -121,6 +124,16 @@
if (decl != null) {
CMNamedNodeMap attributes = decl.getAttributes();
+ CMNamedNodeMapImpl allAttributes = new CMNamedNodeMapImpl(attributes);
+ List nodes = ModelQueryUtil.getModelQuery(node.getOwnerDocument()).getAvailableContent((Element) node, decl, ModelQuery.INCLUDE_ATTRIBUTES);
+ for (int k = 0; k < nodes.size(); k++) {
+ CMNode cmnode = (CMNode) nodes.get(k);
+ if (cmnode.getNodeType() == CMNode.ATTRIBUTE_DECLARATION) {
+ allAttributes.put(cmnode);
+ }
+ }
+ attributes = allAttributes;
+
String attrContextString = node.getNodeName();
StringBuffer attrInfo = new StringBuffer(" "); //$NON-NLS-1$
String name = ""; //$NON-NLS-1$
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/correction/QuickAssistProcessorXML.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/correction/QuickAssistProcessorXML.java
index 92acbe4..328db8d 100644
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/correction/QuickAssistProcessorXML.java
+++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/correction/QuickAssistProcessorXML.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2001, 2007 IBM Corporation and others.
+ * Copyright (c) 2001, 2008 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -26,6 +26,8 @@
import org.eclipse.wst.xml.core.internal.contentmodel.CMAttributeDeclaration;
import org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration;
import org.eclipse.wst.xml.core.internal.contentmodel.CMNamedNodeMap;
+import org.eclipse.wst.xml.core.internal.contentmodel.CMNode;
+import org.eclipse.wst.xml.core.internal.contentmodel.basic.CMNamedNodeMapImpl;
import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQuery;
import org.eclipse.wst.xml.core.internal.modelquery.ModelQueryUtil;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
@@ -151,6 +153,17 @@
CMElementDeclaration elementDecl = modelQuery.getCMElementDeclaration((Element) node);
if (elementDecl != null) {
CMNamedNodeMap attrMap = elementDecl.getAttributes();
+
+ CMNamedNodeMapImpl allAttributes = new CMNamedNodeMapImpl(attrMap);
+ List nodes = ModelQueryUtil.getModelQuery(node.getOwnerDocument()).getAvailableContent((Element)node, elementDecl, ModelQuery.INCLUDE_ATTRIBUTES);
+ for (int k = 0; k < nodes.size(); k++) {
+ CMNode cmnode = (CMNode) nodes.get(k);
+ if (cmnode.getNodeType() == CMNode.ATTRIBUTE_DECLARATION) {
+ allAttributes.put(cmnode);
+ }
+ }
+ attrMap = allAttributes;
+
Iterator it = attrMap.iterator();
CMAttributeDeclaration attr = null;
while (it.hasNext()) {
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/correction/XMLQuickAssistProcessor.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/correction/XMLQuickAssistProcessor.java
index 33b65f7..4649e94 100644
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/correction/XMLQuickAssistProcessor.java
+++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/correction/XMLQuickAssistProcessor.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007 IBM Corporation and others.
+ * Copyright (c) 2007, 2008 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -29,6 +29,8 @@
import org.eclipse.wst.xml.core.internal.contentmodel.CMAttributeDeclaration;
import org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration;
import org.eclipse.wst.xml.core.internal.contentmodel.CMNamedNodeMap;
+import org.eclipse.wst.xml.core.internal.contentmodel.CMNode;
+import org.eclipse.wst.xml.core.internal.contentmodel.basic.CMNamedNodeMapImpl;
import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQuery;
import org.eclipse.wst.xml.core.internal.modelquery.ModelQueryUtil;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
@@ -137,6 +139,17 @@
CMElementDeclaration elementDecl = modelQuery.getCMElementDeclaration((Element) node);
if (elementDecl != null) {
CMNamedNodeMap attrMap = elementDecl.getAttributes();
+
+ CMNamedNodeMapImpl allAttributes = new CMNamedNodeMapImpl(attrMap);
+ List nodes = ModelQueryUtil.getModelQuery(node.getOwnerDocument()).getAvailableContent((Element) node, elementDecl, ModelQuery.INCLUDE_ATTRIBUTES);
+ for (int k = 0; k < nodes.size(); k++) {
+ CMNode cmnode = (CMNode) nodes.get(k);
+ if (cmnode.getNodeType() == CMNode.ATTRIBUTE_DECLARATION) {
+ allAttributes.put(cmnode);
+ }
+ }
+ attrMap = allAttributes;
+
Iterator it = attrMap.iterator();
CMAttributeDeclaration attr = null;
while (it.hasNext()) {
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/hyperlink/XMLHyperlinkDetector.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/hyperlink/XMLHyperlinkDetector.java
index ee4f913..3b00c0c 100644
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/hyperlink/XMLHyperlinkDetector.java
+++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/hyperlink/XMLHyperlinkDetector.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2007 IBM Corporation and others.
+ * Copyright (c) 2006, 2008 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -35,6 +35,9 @@
import org.eclipse.wst.xml.core.internal.contentmodel.CMAttributeDeclaration;
import org.eclipse.wst.xml.core.internal.contentmodel.CMDataType;
import org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration;
+import org.eclipse.wst.xml.core.internal.contentmodel.CMNamedNodeMap;
+import org.eclipse.wst.xml.core.internal.contentmodel.CMNode;
+import org.eclipse.wst.xml.core.internal.contentmodel.basic.CMNamedNodeMapImpl;
import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQuery;
import org.eclipse.wst.xml.core.internal.contentmodel.util.DOMNamespaceHelper;
import org.eclipse.wst.xml.core.internal.modelquery.ModelQueryUtil;
@@ -490,7 +493,18 @@
// determine if attribute value is of type URI
if (cmElement != null) {
- CMAttributeDeclaration attrDecl = (CMAttributeDeclaration) cmElement.getAttributes().getNamedItem(attrName);
+ CMNamedNodeMap attrDecls = cmElement.getAttributes();
+ CMNamedNodeMapImpl allAttributes = new CMNamedNodeMapImpl(attrDecls);
+ List nodes = ModelQueryUtil.getModelQuery(attr.getOwnerDocument()).getAvailableContent(attr.getOwnerElement(), cmElement, ModelQuery.INCLUDE_ATTRIBUTES);
+ for (int k = 0; k < nodes.size(); k++) {
+ CMNode cmnode = (CMNode) nodes.get(k);
+ if (cmnode.getNodeType() == CMNode.ATTRIBUTE_DECLARATION) {
+ allAttributes.put(cmnode);
+ }
+ }
+ attrDecls = allAttributes;
+
+ CMAttributeDeclaration attrDecl = (CMAttributeDeclaration) attrDecls.getNamedItem(attrName);
if ((attrDecl != null) && (attrDecl.getAttrType() != null) && (CMDataType.URI.equals(attrDecl.getAttrType().getDataTypeName()))) {
return true;
}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/properties/XMLPropertySource.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/properties/XMLPropertySource.java
index 26e2ae4..3f8ce7f 100644
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/properties/XMLPropertySource.java
+++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/properties/XMLPropertySource.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2001, 2006 IBM Corporation and others.
+ * Copyright (c) 2001, 2008 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -30,6 +30,8 @@
import org.eclipse.wst.xml.core.internal.contentmodel.CMDataType;
import org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration;
import org.eclipse.wst.xml.core.internal.contentmodel.CMNamedNodeMap;
+import org.eclipse.wst.xml.core.internal.contentmodel.CMNode;
+import org.eclipse.wst.xml.core.internal.contentmodel.basic.CMNamedNodeMapImpl;
import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQuery;
import org.eclipse.wst.xml.core.internal.contentmodel.util.DOMNamespaceHelper;
import org.eclipse.wst.xml.core.internal.document.DocumentTypeAdapter;
@@ -249,7 +251,7 @@
// the displayName MUST be set
EnumeratedStringPropertyDescriptor descriptor = new EnumeratedStringPropertyDescriptor(attrDecl.getNodeName(), attrDecl.getNodeName(), _getValidFixedStrings(attrDecl, helper));
descriptor.setCategory(getCategory(attrDecl));
- descriptor.setDescription(DOMNamespaceHelper.computeName(attrDecl,fNode,null));
+ descriptor.setDescription(DOMNamespaceHelper.computeName(attrDecl, fNode, null));
return descriptor;
}
@@ -287,6 +289,15 @@
CMElementDeclaration ed = getDeclaration();
if (ed != null) {
attrMap = ed.getAttributes();
+ CMNamedNodeMapImpl allAttributes = new CMNamedNodeMapImpl(attrMap);
+ List nodes = ModelQueryUtil.getModelQuery(fNode.getOwnerDocument()).getAvailableContent((Element) fNode, ed, ModelQuery.INCLUDE_ATTRIBUTES);
+ for (int k = 0; k < nodes.size(); k++) {
+ CMNode cmnode = (CMNode) nodes.get(k);
+ if (cmnode.getNodeType() == CMNode.ATTRIBUTE_DECLARATION) {
+ allAttributes.put(cmnode);
+ }
+ }
+ attrMap = allAttributes;
}
List descriptorList = new ArrayList();
@@ -345,12 +356,32 @@
if (!names.contains(attrName)) {
IPropertyDescriptor holdDescriptor = createPropertyDescriptor(attrDecl);
if (holdDescriptor != null) {
+ names.add(attrName);
descriptorList.add(holdDescriptor);
}
}
}
}
+ // add MQE-based descriptors
+ if (ed != null && fNode.getNodeType() == Node.ELEMENT_NODE) {
+ List nodes = ModelQueryUtil.getModelQuery(fNode.getOwnerDocument()).getAvailableContent((Element) fNode, ed, ModelQuery.INCLUDE_ATTRIBUTES);
+ for (int i = 0; i < nodes.size(); i++) {
+ CMNode node = (CMNode) nodes.get(i);
+ if (node.getNodeType() == CMNode.ATTRIBUTE_DECLARATION) {
+ attrDecl = (CMAttributeDeclaration) node;
+ String attrName = DOMNamespaceHelper.computeName(attrDecl, fNode, null);
+ if (!names.contains(attrName)) {
+ IPropertyDescriptor holdDescriptor = createPropertyDescriptor(attrDecl);
+ if (holdDescriptor != null) {
+ descriptorList.add(holdDescriptor);
+ }
+ }
+ }
+ }
+ }
+
+
IPropertyDescriptor[] descriptors = new IPropertyDescriptor[descriptorList.size()];
for (int i = 0; i < descriptors.length; i++) {
descriptors[i] = (IPropertyDescriptor) descriptorList.get(i);
@@ -359,7 +390,7 @@
}
private IPropertyDescriptor createTextPropertyDescriptor(CMAttributeDeclaration attrDecl) {
- String attrName = DOMNamespaceHelper.computeName(attrDecl,fNode,null);
+ String attrName = DOMNamespaceHelper.computeName(attrDecl, fNode, null);
TextPropertyDescriptor descriptor = new TextPropertyDescriptor(attrName, attrName);
descriptor.setCategory(getCategory(attrDecl));
descriptor.setDescription(attrName);
@@ -477,6 +508,15 @@
CMElementDeclaration ed = getDeclaration();
if (ed != null) {
attrDecls = ed.getAttributes();
+ CMNamedNodeMapImpl allAttributes = new CMNamedNodeMapImpl(attrDecls);
+ List nodes = ModelQueryUtil.getModelQuery(fNode.getOwnerDocument()).getAvailableContent((Element) fNode, ed, ModelQuery.INCLUDE_ATTRIBUTES);
+ for (int k = 0; k < nodes.size(); k++) {
+ CMNode cmnode = (CMNode) nodes.get(k);
+ if (cmnode.getNodeType() == CMNode.ATTRIBUTE_DECLARATION) {
+ allAttributes.put(cmnode);
+ }
+ }
+ attrDecls = allAttributes;
}
if (attrDecls != null) {
@@ -543,6 +583,15 @@
CMElementDeclaration ed = getDeclaration();
if (ed != null) {
attrDecls = ed.getAttributes();
+ CMNamedNodeMapImpl allAttributes = new CMNamedNodeMapImpl(attrDecls);
+ List nodes = ModelQueryUtil.getModelQuery(fNode.getOwnerDocument()).getAvailableContent((Element) fNode, ed, ModelQuery.INCLUDE_ATTRIBUTES);
+ for (int k = 0; k < nodes.size(); k++) {
+ CMNode cmnode = (CMNode) nodes.get(k);
+ if (cmnode.getNodeType() == CMNode.ATTRIBUTE_DECLARATION) {
+ allAttributes.put(cmnode);
+ }
+ }
+ attrDecls = allAttributes;
}
NamedNodeMap attrMap = fNode.getAttributes();
@@ -654,6 +703,15 @@
CMNamedNodeMap attrMap = null;
if (ed != null) {
attrMap = ed.getAttributes();
+ CMNamedNodeMapImpl allAttributes = new CMNamedNodeMapImpl(attrMap);
+ List nodes = ModelQueryUtil.getModelQuery(fNode.getOwnerDocument()).getAvailableContent((Element) fNode, ed, ModelQuery.INCLUDE_ATTRIBUTES);
+ for (int k = 0; k < nodes.size(); k++) {
+ CMNode cmnode = (CMNode) nodes.get(k);
+ if (cmnode.getNodeType() == CMNode.ATTRIBUTE_DECLARATION) {
+ allAttributes.put(cmnode);
+ }
+ }
+ attrMap = allAttributes;
}
// Update exiting descriptors; not added to the final list here
if (attrMap != null) {
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/taginfo/XMLTagInfoHoverProcessor.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/taginfo/XMLTagInfoHoverProcessor.java
index 41c3f64..47276fc 100644
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/taginfo/XMLTagInfoHoverProcessor.java
+++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/taginfo/XMLTagInfoHoverProcessor.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2001, 2006 IBM Corporation and others.
+ * Copyright (c) 2001, 2008 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -14,6 +14,8 @@
+import java.util.List;
+
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.ITextViewer;
@@ -30,6 +32,7 @@
import org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration;
import org.eclipse.wst.xml.core.internal.contentmodel.CMNamedNodeMap;
import org.eclipse.wst.xml.core.internal.contentmodel.CMNode;
+import org.eclipse.wst.xml.core.internal.contentmodel.basic.CMNamedNodeMapImpl;
import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQuery;
import org.eclipse.wst.xml.core.internal.contentmodel.util.DOMNamespaceHelper;
import org.eclipse.wst.xml.core.internal.modelquery.ModelQueryUtil;
@@ -116,7 +119,7 @@
protected String computeTagAttNameHelp(IDOMNode xmlnode, IDOMNode parentNode, IStructuredDocumentRegion flatNode, ITextRegion region) {
CMElementDeclaration elementDecl = getCMElementDeclaration(xmlnode);
String attName = flatNode.getText(region);
- CMAttributeDeclaration attDecl = getCMAttributeDeclaration(elementDecl, attName);
+ CMAttributeDeclaration attDecl = getCMAttributeDeclaration(xmlnode, elementDecl, attName);
return getAdditionalInfo(elementDecl, attDecl);
}
@@ -129,7 +132,7 @@
ITextRegion attrNameRegion = getAttrNameRegion(xmlnode, region);
String attName = flatNode.getText(attrNameRegion);
- CMAttributeDeclaration attDecl = getCMAttributeDeclaration(elementDecl, attName);
+ CMAttributeDeclaration attDecl = getCMAttributeDeclaration(xmlnode, elementDecl, attName);
return getAdditionalInfo(elementDecl, attDecl);
}
@@ -194,11 +197,22 @@
* Retreives CMAttributeDeclaration indicated by attribute name within
* elementDecl
*/
- protected CMAttributeDeclaration getCMAttributeDeclaration(CMElementDeclaration elementDecl, String attName) {
+ protected CMAttributeDeclaration getCMAttributeDeclaration(IDOMNode node, CMElementDeclaration elementDecl, String attName) {
CMAttributeDeclaration attrDecl = null;
if (elementDecl != null) {
CMNamedNodeMap attributes = elementDecl.getAttributes();
+
+ CMNamedNodeMapImpl allAttributes = new CMNamedNodeMapImpl(attributes);
+ List nodes = ModelQueryUtil.getModelQuery(node.getOwnerDocument()).getAvailableContent((Element) node, elementDecl, ModelQuery.INCLUDE_ATTRIBUTES);
+ for (int k = 0; k < nodes.size(); k++) {
+ CMNode cmnode = (CMNode) nodes.get(k);
+ if (cmnode.getNodeType() == CMNode.ATTRIBUTE_DECLARATION) {
+ allAttributes.put(cmnode);
+ }
+ }
+ attributes = allAttributes;
+
String noprefixName = DOMNamespaceHelper.getUnprefixedName(attName);
if (attributes != null) {
attrDecl = (CMAttributeDeclaration) attributes.getNamedItem(noprefixName);
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/views/contentoutline/XMLContentOutlineConfiguration.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/views/contentoutline/XMLContentOutlineConfiguration.java
index c684216..9359ae9 100644
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/views/contentoutline/XMLContentOutlineConfiguration.java
+++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/views/contentoutline/XMLContentOutlineConfiguration.java
@@ -12,6 +12,8 @@
*******************************************************************************/
package org.eclipse.wst.xml.ui.views.contentoutline;
+import java.util.List;
+
import org.eclipse.core.runtime.IPath;
import org.eclipse.jface.action.IContributionItem;
import org.eclipse.jface.action.IMenuListener;
@@ -47,6 +49,9 @@
import org.eclipse.wst.xml.core.internal.contentmodel.CMAttributeDeclaration;
import org.eclipse.wst.xml.core.internal.contentmodel.CMDataType;
import org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration;
+import org.eclipse.wst.xml.core.internal.contentmodel.CMNamedNodeMap;
+import org.eclipse.wst.xml.core.internal.contentmodel.CMNode;
+import org.eclipse.wst.xml.core.internal.contentmodel.basic.CMNamedNodeMapImpl;
import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQuery;
import org.eclipse.wst.xml.core.internal.modelquery.ModelQueryUtil;
import org.eclipse.wst.xml.ui.internal.XMLUIMessages;
@@ -136,7 +141,19 @@
while ((i < attributes.getLength()) && (idTypedAttribute == null)) {
Node attr = attributes.item(i);
String attrName = attr.getNodeName();
- CMAttributeDeclaration attrDecl = (CMAttributeDeclaration) elementDecl.getAttributes().getNamedItem(attrName);
+ CMNamedNodeMap attributeDeclarationMap = elementDecl.getAttributes();
+
+ CMNamedNodeMapImpl allAttributes = new CMNamedNodeMapImpl(attributeDeclarationMap);
+ List nodes = ModelQueryUtil.getModelQuery(node.getOwnerDocument()).getAvailableContent(element, elementDecl, ModelQuery.INCLUDE_ATTRIBUTES);
+ for (int k = 0; k < nodes.size(); k++) {
+ CMNode cmnode = (CMNode) nodes.get(k);
+ if (cmnode.getNodeType() == CMNode.ATTRIBUTE_DECLARATION) {
+ allAttributes.put(cmnode);
+ }
+ }
+ attributeDeclarationMap = allAttributes;
+
+ CMAttributeDeclaration attrDecl = (CMAttributeDeclaration) attributeDeclarationMap.getNamedItem(attrName);
if (attrDecl != null) {
if ((attrDecl.getAttrType() != null) && (CMDataType.ID.equals(attrDecl.getAttrType().getDataTypeName()))) {
idTypedAttribute = attr;