use of org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQuery in project webtools.sourceediting by eclipse.
the class CMUtil method getDeclaration.
/**
* You cannot always retrieve HTMLElementDeclaration via an Element instance.
* Because, it occasionally a JSP custom tag. -- 9/7/2001
*/
public static CMElementDeclaration getDeclaration(Element target) {
Document doc = target.getOwnerDocument();
ModelQuery query = ModelQueryUtil.getModelQuery(doc);
return query.getCMElementDeclaration(target);
}
use of org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQuery in project webtools.sourceediting by eclipse.
the class HMQUtil method getAncestorDeclarations.
private static Collection getAncestorDeclarations(Element target) {
Vector ancestors = new Vector();
Document doc = target.getOwnerDocument();
ModelQuery query = ModelQueryUtil.getModelQuery(doc);
CMElementDeclaration decl = query.getCMElementDeclaration(target);
ancestors.add(decl);
Element parent = getParent(target);
while (parent != null) {
decl = query.getCMElementDeclaration(parent);
if (decl != null)
ancestors.add(decl);
parent = getParent(parent);
}
return ancestors;
}
use of org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQuery in project webtools.sourceediting by eclipse.
the class AbstractBreakpointProvider method isCustomTagRegion.
private static boolean isCustomTagRegion(IndexedRegion node) {
if (node instanceof Element) {
Element xmlElement = (Element) node;
ModelQuery mq = ModelQueryUtil.getModelQuery(xmlElement.getOwnerDocument());
CMElementDeclaration decl = mq.getCMElementDeclaration(xmlElement);
if (decl instanceof CMNodeWrapper) {
CMNode cmNode = ((CMNodeWrapper) decl).getOriginNode();
return cmNode instanceof TLDElementDeclaration;
}
}
return false;
}
use of org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQuery in project webtools.sourceediting by eclipse.
the class JSPModelQueryImpl method getEmbeddedModelQuery.
// ISSUE: shouldn't this be private?
protected ModelQuery getEmbeddedModelQuery(Node node) {
ModelQuery embeddedModelQuery = null;
if (node instanceof INodeNotifier) {
Node ownerNode = node.getOwnerDocument();
if (ownerNode == null) {
// then must be the document itself
ownerNode = node;
}
PageDirectiveAdapter pageDirectiveAdapter = (PageDirectiveAdapter) ((INodeNotifier) ownerNode).getAdapterFor(PageDirectiveAdapter.class);
if (pageDirectiveAdapter != null) {
String effectiveContentType = null;
ModelQuery potentialModelQueryObject = null;
String familyId = pageDirectiveAdapter.getEmbeddedType().getFamilyId();
if (ContentTypeFamilyForHTML.HTML_FAMILY.equals(familyId)) {
effectiveContentType = "text/html";
} else {
effectiveContentType = pageDirectiveAdapter.getContentType();
}
potentialModelQueryObject = (ModelQuery) embeddedModelQueries.get(effectiveContentType);
if (potentialModelQueryObject == null) {
ModelQueryAdapter embeddedAdapter = (ModelQueryAdapter) pageDirectiveAdapter.adapt((INodeNotifier) node, ModelQueryAdapter.class);
if (embeddedAdapter != null) {
// we will cache one model query per content type
embeddedModelQuery = embeddedAdapter.getModelQuery();
embeddedModelQueries.put(effectiveContentType, embeddedModelQuery);
}
} else {
embeddedModelQuery = potentialModelQueryObject;
}
}
}
return embeddedModelQuery;
}
use of org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQuery in project webtools.sourceediting by eclipse.
the class JSPActionValidator method processDirective.
private void processDirective(IReporter reporter, IFile file, IStructuredModel model, IStructuredDocumentRegion documentRegion) {
IndexedRegion ir = model.getIndexedRegion(documentRegion.getStartOffset());
if (ir instanceof IDOMElement) {
IDOMElement element = (IDOMElement) ir;
ModelQuery query = ModelQueryUtil.getModelQuery(model);
if (query != null) {
CMElementDeclaration cmElement = query.getCMElementDeclaration(element);
if (cmElement != null) {
CMNamedNodeMap cmAttributes = null;
CMNamedNodeMapImpl allAttributes = new CMNamedNodeMapImpl();
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, cmElement, cmAttributes, reporter, file, model.getStructuredDocument(), documentRegion);
// missing required attributes
if (!foundjspattribute && fSeverityMissingRequiredAttribute != ValidationMessage.IGNORE)
checkRequiredAttributes(element, cmAttributes, reporter, file, model.getStructuredDocument(), documentRegion);
if (fSeverityNonEmptyInlineTag != ValidationMessage.IGNORE)
checkNonEmptyInlineTag(element, cmElement, reporter, file, model.getStructuredDocument());
}
}
}
}
Aggregations