use of org.eclipse.wst.validation.internal.operations.LocalizedMessage in project webtools.sourceediting by eclipse.
the class MarkupValidator method checkStartingSpaceForPI.
private void checkStartingSpaceForPI(IStructuredDocumentRegion structuredDocumentRegion, IReporter reporter) {
if (structuredDocumentRegion.isDeleted()) {
return;
}
IStructuredDocumentRegion prev = structuredDocumentRegion.getPrevious();
if ((prev != null) && prev.getStartOffset() == 0) {
if (prev.getType() == DOMRegionContext.XML_CONTENT) {
String messageText = XMLCoreMessages.ReconcileStepForMarkup_5;
int start = prev.getStartOffset();
int length = prev.getLength();
LocalizedMessage message = new LocalizedMessage(getPluginPreference().getInt(XMLCorePreferenceNames.WHITESPACE_AT_START), messageText);
message.setOffset(start);
message.setLength(length);
message.setLineNo(getLineNumber(start));
getAnnotationMsg(reporter, ProblemIDsXML.SpacesBeforePI, message, null, length);
// Position p = new Position(start, length);
//
// ReconcileAnnotationKey key =
// createKey(structuredDocumentRegion, getScope());
// TemporaryAnnotation annotation = new TemporaryAnnotation(p,
// SEVERITY_SYNTAX_ERROR, message, key,
// ProblemIDsXML.SpacesBeforePI);
// results.add(annotation);
}
}
}
use of org.eclipse.wst.validation.internal.operations.LocalizedMessage in project webtools.sourceediting by eclipse.
the class MarkupValidator method checkAttributesInEndTag.
private void checkAttributesInEndTag(IStructuredDocumentRegion structuredDocumentRegion, IReporter reporter) {
if (structuredDocumentRegion.isDeleted()) {
return;
}
ITextRegionList textRegions = structuredDocumentRegion.getRegions();
int errorCount = 0;
int start = structuredDocumentRegion.getEndOffset();
int end = structuredDocumentRegion.getEndOffset();
for (int i = 0; (i < textRegions.size()) && (errorCount < ELEMENT_ERROR_LIMIT) && !structuredDocumentRegion.isDeleted(); i++) {
ITextRegion textRegion = textRegions.get(i);
if ((textRegion.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_NAME) || (textRegion.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_EQUALS) || (textRegion.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE)) {
if (start > structuredDocumentRegion.getStartOffset(textRegion)) {
start = structuredDocumentRegion.getStartOffset(textRegion);
}
end = structuredDocumentRegion.getEndOffset(textRegion);
errorCount++;
}
}
// create one error for all attributes in the end tag
if (errorCount > 0) {
// Position p = new Position(start, end - start);
String messageText = XMLCoreMessages.End_tag_has_attributes;
LocalizedMessage message = new LocalizedMessage(getPluginPreference().getInt(XMLCorePreferenceNames.END_TAG_WITH_ATTRIBUTES), messageText);
message.setOffset(start);
message.setLength(end - start);
message.setLineNo(getLineNumber(start));
getAnnotationMsg(reporter, ProblemIDsXML.AttrsInEndTag, message, null, end - start);
}
}
use of org.eclipse.wst.validation.internal.operations.LocalizedMessage in project webtools.sourceediting by eclipse.
the class MarkupValidator method checkEmptyTag.
private void checkEmptyTag(IStructuredDocumentRegion structuredDocumentRegion, IReporter reporter) {
if (structuredDocumentRegion.isDeleted()) {
return;
}
// navigate to name
ITextRegionList regions = structuredDocumentRegion.getRegions();
if (regions.size() == 2) {
// missing name region
if ((regions.get(0).getType() == DOMRegionContext.XML_TAG_OPEN) && (regions.get(1).getType() == DOMRegionContext.XML_TAG_CLOSE)) {
String messageText = XMLCoreMessages.ReconcileStepForMarkup_3;
int start = structuredDocumentRegion.getStartOffset();
int length = structuredDocumentRegion.getLength();
int lineNo = getLineNumber(start);
LocalizedMessage message = new LocalizedMessage(getPluginPreference().getInt(XMLCorePreferenceNames.MISSING_TAG_NAME), messageText);
message.setOffset(start);
message.setLength(length);
message.setLineNo(lineNo);
getAnnotationMsg(reporter, ProblemIDsXML.EmptyTag, message, null, length);
}
}
}
use of org.eclipse.wst.validation.internal.operations.LocalizedMessage in project webtools.sourceediting by eclipse.
the class MarkupValidator method addAttributeError.
private void addAttributeError(String messageText, String attributeValueText, int start, int length, int problemId, IStructuredDocumentRegion sdRegion, IReporter reporter, int messageSeverity) {
if (sdRegion.isDeleted()) {
return;
}
int lineNo = getLineNumber(start);
LocalizedMessage message = new LocalizedMessage(messageSeverity, messageText);
message.setOffset(start);
message.setLength(length);
message.setLineNo(lineNo);
getAnnotationMsg(reporter, problemId, message, attributeValueText, length);
}
use of org.eclipse.wst.validation.internal.operations.LocalizedMessage in project webtools.sourceediting by eclipse.
the class MarkupValidator method checkNoNamespaceInPI.
private void checkNoNamespaceInPI(IStructuredDocumentRegion structuredDocumentRegion, IReporter reporter) {
if (structuredDocumentRegion.isDeleted()) {
return;
}
// navigate to name
ITextRegionList regions = structuredDocumentRegion.getRegions();
ITextRegion r = null;
int errorCount = 0;
for (int i = 0; (i < regions.size()) && (errorCount < ELEMENT_ERROR_LIMIT) && !structuredDocumentRegion.isDeleted(); i++) {
r = regions.get(i);
if (r.getType() == DOMRegionContext.XML_TAG_NAME) {
String piText = structuredDocumentRegion.getText(r);
// $NON-NLS-1$
int index = piText.indexOf(":");
if (index != -1) {
String messageText = XMLCoreMessages.ReconcileStepForMarkup_4;
int start = structuredDocumentRegion.getStartOffset(r) + index;
int length = piText.trim().length() - index;
LocalizedMessage message = new LocalizedMessage(getPluginPreference().getInt(XMLCorePreferenceNames.NAMESPACE_IN_PI_TARGET), messageText);
message.setOffset(start);
message.setLength(length);
message.setLineNo(getLineNumber(start));
getAnnotationMsg(reporter, ProblemIDsXML.NamespaceInPI, message, null, length);
errorCount++;
}
}
}
}
Aggregations