use of org.eclipse.wst.html.core.internal.contentmodel.HTMLPropertyDeclaration in project webtools.sourceediting by eclipse.
the class LibraryTagsCompletionProposalComputer method validModelQueryNode.
/**
* @see org.eclipse.wst.html.ui.internal.contentassist.HTMLTagsCompletionProposalComputer#validModelQueryNode(org.eclipse.wst.xml.core.internal.contentmodel.CMNode)
*/
protected boolean validModelQueryNode(CMNode node) {
boolean isValid = false;
// unwrap
if (node instanceof CMNodeWrapper) {
node = ((CMNodeWrapper) node).getOriginNode();
}
// determine if is valid
if (node instanceof HTMLPropertyDeclaration) {
HTMLPropertyDeclaration propDec = (HTMLPropertyDeclaration) node;
isValid = propDec.isJSP();
} else if (node.supports(TLDElementDeclaration.IS_LIBRARY_TAG)) {
Boolean isLibraryTag = (Boolean) node.getProperty(TLDElementDeclaration.IS_LIBRARY_TAG);
isValid = isLibraryTag != null && isLibraryTag.booleanValue();
}
return isValid;
}
use of org.eclipse.wst.html.core.internal.contentmodel.HTMLPropertyDeclaration in project webtools.sourceediting by eclipse.
the class HTMLTagsCompletionProposalComputer method validModelQueryNode.
/**
* <p>Filter out all {@link CMNode}s except those specific to HTML documents</p>
*
* @see org.eclipse.wst.xml.ui.internal.contentassist.AbstractXMLModelQueryCompletionProposalComputer#validModelQueryNode(org.eclipse.wst.xml.core.internal.contentmodel.CMNode)
*/
protected boolean validModelQueryNode(CMNode node) {
boolean isValid = false;
// $NON-NLS-1$
Object cmdoc = node.getProperty("CMDocument");
if (cmdoc instanceof CMNode) {
String name = ((CMNode) cmdoc).getNodeName();
// $NON-NLS-1$ //$NON-NLS-2$
isValid = name != null && name.endsWith(".dtd") && name.indexOf("html") != -1;
} else if (node.supports(HTMLAttributeDeclaration.IS_HTML)) {
Boolean isHTML = (Boolean) node.getProperty(HTMLAttributeDeclaration.IS_HTML);
isValid = isHTML == null || isHTML.booleanValue();
} else if (node instanceof HTMLPropertyDeclaration) {
HTMLPropertyDeclaration propDec = (HTMLPropertyDeclaration) node;
isValid = !propDec.isJSP();
} else if (node instanceof CMAttributeDeclaration || node instanceof CMElementDeclarationImpl) {
isValid = true;
} else if (node instanceof CMElementDeclaration) {
Boolean isXHTML = ((Boolean) node.getProperty(HTMLCMProperties.IS_XHTML));
isValid = isXHTML != null && isXHTML.booleanValue();
}
// Do not propose obsolete tags, regardless
if (isValid && node.supports(HTMLCMProperties.IS_OBSOLETE)) {
Boolean isObsolete = ((Boolean) node.getProperty(HTMLCMProperties.IS_OBSOLETE));
isValid = !(isObsolete != null && isObsolete.booleanValue());
}
return isValid;
}
use of org.eclipse.wst.html.core.internal.contentmodel.HTMLPropertyDeclaration in project webtools.sourceediting by eclipse.
the class HTMLModelParserAdapter method isEndTagOmissible.
public boolean isEndTagOmissible(Element element) {
CMElementDeclaration dec = CMNodeUtil.getElementDeclaration(element);
if (dec == null || !(dec instanceof HTMLPropertyDeclaration))
return false;
int type = ((HTMLPropertyDeclaration) dec).getOmitType();
return type == HTMLElementDeclaration.OMIT_BOTH || type == HTMLElementDeclaration.OMIT_END || type == HTMLElementDeclaration.OMIT_END_DEFAULT || type == HTMLElementDeclaration.OMIT_END_MUST;
}
use of org.eclipse.wst.html.core.internal.contentmodel.HTMLPropertyDeclaration in project webtools.sourceediting by eclipse.
the class SyntaxValidator method validateTags.
private void validateTags(ElementInfo info) {
if (info.hasStartTag()) {
if (!info.target.isStartTagClosed()) {
// Mark the whole START tag as an error segment.
Segment errorSeg = new Segment(info.startTag);
report(UNCLOSED_TAG_ERROR, errorSeg, info.target);
}
} else {
if (info.hasEndTag()) {
if (info.decl != null) {
// else determine if end tag is omissible
if (info.isXHTML) {
Segment errorSeg = FMUtil.getSegment(info.target, FMUtil.SEG_END_TAG_NAME);
report(MISSING_START_TAG_ERROR, errorSeg, info.target);
} else {
// determine if the end tag is omissible
boolean canOmitStartTag = false;
if (info.decl instanceof HTMLPropertyDeclaration) {
int omitType = ((HTMLPropertyDeclaration) info.decl).getOmitType();
canOmitStartTag = omitType == HTMLElementDeclaration.OMIT_BOTH;
}
if (!canOmitStartTag && !info.target.hasChildNodes()) {
if (info.target.isContainer()) {
// Set the error mark to the start of the element.
Segment errorSeg = FMUtil.getSegment(info.target, FMUtil.SEG_END_TAG);
report(MISSING_START_TAG_ERROR, errorSeg, info.target);
} else {
// Mark the whole END tag as an error segment.
Segment errorSeg = new Segment(info.endTag);
report(UNNECESSARY_END_TAG_ERROR, errorSeg, info.target);
}
}
}
}
}
}
if (info.hasEndTag()) {
if (!info.target.isClosed()) {
// Set the whole END tag as error segment.
Segment errorSeg = new Segment(info.endTag);
report(UNCLOSED_END_TAG_ERROR, errorSeg, info.target);
}
} else {
if (info.isXHTML) {
// XHTML
// if editor closed during validation this could be null
IStructuredDocumentRegion structRegion = info.target.getStartStructuredDocumentRegion();
if (!info.target.isEmptyTag() && structRegion != null && DOMRegionContext.XML_TAG_OPEN.equals(structRegion.getFirstRegion().getType())) {
/*
* https://bugs.eclipse.org/bugs/show_bug.cgi?id=248963 :
* report empty tags not written as such, but only when
* they follow actual XML/HTML syntax
*/
if (isEmptyContent(info.decl)) {
// EMPTY element should be written in <.../> form
Segment errorSeg = FMUtil.getSegment(info.target, FMUtil.SEG_START_TAG);
report(INVALID_EMPTY_ELEMENT_TAG, errorSeg, info.target);
} else {
// end tag is required.
Segment errorSeg = FMUtil.getSegment(info.target, FMUtil.SEG_START_TAG);
report(MISSING_END_TAG_ERROR, errorSeg, info.target);
}
}
} else {
// HTML
if (info.hasStartTag()) {
if (info.decl != null && CMUtil.isHTML(info.decl) && !info.target.isEmptyTag() && !CMUtil.isEndTagOmissible(info.decl) && DOMRegionContext.XML_TAG_OPEN.equals(info.startTag.getFirstRegion().getType())) {
// Set the error mark to the end of the element.
Segment errorSeg = FMUtil.getSegment(info.target, FMUtil.SEG_START_TAG);
report(MISSING_END_TAG_ERROR, errorSeg, info.target);
}
}
}
}
}
Aggregations