Object[] args = {tagName};
String messageText = NLS.bind(XMLUIMessages.Missing_end_tag_, args);
int lineNumber = getLineNumber(start);
IMessage message = new LocalizedMessage(SEVERITY_MISSING_END_TAG , messageText);
message.setOffset(start);
message.setLength(length);
message.setLineNo(lineNumber);
if (reporter instanceof IncrementalReporter) {
Object[] additionalFixInfo = getStartEndFixInfo(xmlNode, tagName, r);
MarkupQuickAssistProcessor processor = new MarkupQuickAssistProcessor();
processor.setProblemId(ProblemIDsXML.MissingEndTag);
processor.setAdditionalFixInfo(additionalFixInfo);
message.setAttribute(QUICKASSISTPROCESSOR, processor);
AnnotationInfo info = new AnnotationInfo(message);
((IncrementalReporter) reporter).addAnnotationInfo(this, info);
}
else {
reporter.addMessage(this, message);
}
}
}
}
else {
IStructuredDocumentRegion startRegion = xmlNode.getStartStructuredDocumentRegion();
if (startRegion == null || startRegion.isDeleted()) {
// analyze the tag (check self closing)
ITextRegionList regions = endRegion.getRegions();
ITextRegion r = null;
int start = sdRegion.getStart();
int length = sdRegion.getTextLength();
for (int i = 0; i < regions.size(); i++) {
r = regions.get(i);
if (r.getType() == DOMRegionContext.XML_TAG_NAME) {
tagName = sdRegion.getText(r);
start = sdRegion.getStartOffset(r);
length = r.getTextLength();
}
}
if (tagName != null) {
Object[] args = {tagName};
String messageText = NLS.bind(XMLUIMessages.Missing_start_tag_, args);
int lineNumber = getLineNumber(start);
IMessage message = new LocalizedMessage(SEVERITY_MISSING_START_TAG, messageText);
message.setOffset(start);
message.setLength(length);
message.setLineNo(lineNumber);
if (reporter instanceof IncrementalReporter) {
Object[] additionalFixInfo = getStartEndFixInfo(xmlNode, tagName, r);
MarkupQuickAssistProcessor processor = new MarkupQuickAssistProcessor();
processor.setProblemId(ProblemIDsXML.MissingStartTag);
processor.setAdditionalFixInfo(additionalFixInfo);
message.setAttribute(QUICKASSISTPROCESSOR, processor);
AnnotationInfo info = new AnnotationInfo(message);
((IncrementalReporter) reporter).addAnnotationInfo(this, info);
}
else {
reporter.addMessage(this, message);
}
}
}
}
}
/*
* Check for an end tag that has no start tag
*/
else {
IStructuredDocumentRegion startRegion = xmlNode.getStartStructuredDocumentRegion();
if (startRegion == null) {
IStructuredDocumentRegion endRegion = xmlNode.getEndStructuredDocumentRegion();
if (!endRegion.isDeleted()) {
// get name
ITextRegionList regions = endRegion.getRegions();
ITextRegion r = null;
for (int i = 0; i < regions.size(); i++) {
r = regions.get(i);
if (r.getType() == DOMRegionContext.XML_TAG_NAME) {
tagName = sdRegion.getText(r);
}
}
if (!selfClosed && (tagName != null)) {
String messageText = XMLUIMessages.Indicate_no_grammar_specified_severities_error;
int start = sdRegion.getStart();
int lineNumber = getLineNumber(start);
// SEVERITY_STRUCTURE == IMessage.HIGH_SEVERITY
IMessage message = new LocalizedMessage(IMessage.HIGH_SEVERITY, messageText);
message.setOffset(start);
message.setLength(sdRegion.getTextLength());
message.setLineNo(lineNumber);
reporter.addMessage(this, message);
}
}
}