Skip to content

Commit

Permalink
Unify XMLErrorReporter/DefaultSAXParser classes and show errors
Browse files Browse the repository at this point in the history
  • Loading branch information
HannesWell committed Aug 13, 2023
1 parent daecf47 commit 7b86df0
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 514 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@
import org.eclipse.core.runtime.jobs.ISchedulingRule;
import org.eclipse.core.runtime.jobs.MultiRule;
import org.eclipse.osgi.util.NLS;
import org.eclipse.pde.internal.core.builders.DefaultSAXParser;
import org.eclipse.pde.internal.core.builders.PDEBuilderHelper;
import org.eclipse.pde.internal.core.builders.PDEMarkerFactory;
import org.eclipse.pde.internal.ds.core.Activator;
import org.eclipse.pde.internal.ds.core.Messages;

Expand Down Expand Up @@ -130,7 +132,7 @@ protected IProject[] build(int kind, Map<String, String> args, IProgressMonitor
@Override
protected void clean(IProgressMonitor monitor) throws CoreException {
// bug 426874 - delete markers set and files created
getProject().deleteMarkers(DSMarkerFactory.MARKER_ID, true, IResource.DEPTH_INFINITE);
getProject().deleteMarkers(PDEMarkerFactory.MARKER_ID, true, IResource.DEPTH_INFINITE);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jface.text.Document;
import org.eclipse.osgi.util.NLS;
import org.eclipse.pde.internal.core.builders.PDEMarkerFactory;
import org.eclipse.pde.internal.core.builders.XMLErrorReporter;
import org.eclipse.pde.internal.core.text.IDocumentElementNode;
import org.eclipse.pde.internal.core.util.CoreUtility;
import org.eclipse.pde.internal.ds.core.Activator;
Expand Down Expand Up @@ -56,7 +58,7 @@ public DSErrorReporter(IFile file) {
}

@Override
public void validateContent(IProgressMonitor monitor) {
public void validate(IProgressMonitor monitor) {

try {
Document textDocument = CoreUtility.getTextDocument(fFile
Expand Down Expand Up @@ -93,7 +95,7 @@ private void reportIllegalAttributeValue(Element element, Attr attr) {
String message = NLS.bind(Messages.DSErrorReporter_attrValue, attr
.getValue(), attr.getName());
report(message, getLine(element, attr.getName()), ERROR,
DSMarkerFactory.CAT_OTHER);
PDEMarkerFactory.CAT_OTHER);
}

private void validateReferenceElements(IDSReference[] references) {
Expand Down Expand Up @@ -147,7 +149,7 @@ private void reportInvalidTarget(Element element, String target) {
.getAttribute(IDSConstants.ATTRIBUTE_REFERENCE_NAME);
String message = NLS.bind(Messages.DSErrorReporter_invalidTarget, name,
target);
report(message, getLine(element), ERROR, DSMarkerFactory.CAT_OTHER);
report(message, getLine(element), ERROR, PDEMarkerFactory.CAT_OTHER);
}

private void validateReferenceElementNames(Hashtable<String, String> referencedNames,
Expand All @@ -171,7 +173,7 @@ private void reportDuplicateReferenceElementName(Element element,
Messages.DSErrorReporter_duplicateReferenceName, name);
report(message,
getLine(element, IDSConstants.ATTRIBUTE_REFERENCE_NAME), ERROR,
DSMarkerFactory.CAT_OTHER);
PDEMarkerFactory.CAT_OTHER);
}

private void validateReferencePolicy(Element element) {
Expand Down Expand Up @@ -203,7 +205,7 @@ private void reportIllegalPolicy(Element element, String policy) {
Attr attr = element
.getAttributeNode(IDSConstants.ATTRIBUTE_REFERENCE_POLICY);
report(message, getLine(element, attr.getName()), ERROR,
DSMarkerFactory.CAT_OTHER);
PDEMarkerFactory.CAT_OTHER);
}

private void validateReferenceCardinality(Element element) {
Expand Down Expand Up @@ -242,7 +244,7 @@ private void reportIllegalCardinality(Element element, String cardinality) {
if (attr == null || attr.getValue() == null || attr.getName() == null)
return;
report(message, getLine(element, attr.getName()), ERROR,
DSMarkerFactory.CAT_OTHER);
PDEMarkerFactory.CAT_OTHER);
}

private void validatePropertiesElements(IDSProperties[] propertiesElements) {
Expand All @@ -261,7 +263,7 @@ private void validatePropertiesElements(IDSProperties[] propertiesElements) {
.bind(
Messages.DSErrorReporter_cannotFindProperties,
properties.getEntry()), getLine(element), WARNING,
DSMarkerFactory.CAT_OTHER);
PDEMarkerFactory.CAT_OTHER);
}
}

Expand Down Expand Up @@ -368,7 +370,7 @@ private void reportPropertyTypeCastException(Element element, String value,
String message = NLS.bind(
Messages.DSErrorReporter_propertyTypeCastException,
new String[] { value, type });
report(message, getLine(element), WARNING, DSMarkerFactory.CAT_OTHER);
report(message, getLine(element), WARNING, PDEMarkerFactory.CAT_OTHER);
}

/**
Expand Down Expand Up @@ -409,7 +411,7 @@ private void validatePropertyAttrValueAndBody(Element element,
private void reportEmptyPropertyValue(Element element, String propertyName) {
String message = NLS.bind(Messages.DSErrorReporter_emptyPropertyValue,
propertyName);
report(message, getLine(element), WARNING, DSMarkerFactory.CAT_OTHER);
report(message, getLine(element), WARNING, PDEMarkerFactory.CAT_OTHER);

}

Expand All @@ -418,7 +420,7 @@ private void reportSingleAndMultiplePropertyValues(Element element,
String message = NLS.bind(
Messages.DSErrorReporter_singleAndMultipleAttrValue,
propertyName, value);
report(message, getLine(element), WARNING, DSMarkerFactory.CAT_OTHER);
report(message, getLine(element), WARNING, PDEMarkerFactory.CAT_OTHER);
}

private void validatePropertyTypes(Element element) {
Expand Down Expand Up @@ -485,7 +487,7 @@ private void reportMissingRequiredAttribute(Element element,
String attName, int severity) {
String message = NLS.bind(Messages.DSErrorReporter_requiredAttribute,
attName, element.getNodeName());
report(message, getLine(element), severity, DSMarkerFactory.CAT_OTHER);
report(message, getLine(element), severity, PDEMarkerFactory.CAT_OTHER);
}

/**
Expand All @@ -507,7 +509,7 @@ private void reportJavaTypeNotFound(String elementConstant,
Element element = (Element) elementsByTagName.item(index);
report(NLS.bind(Messages.DSErrorReporter_cannotFindJavaType, resource,
attributeConstant), getLine(element), WARNING,
DSMarkerFactory.CAT_OTHER);
PDEMarkerFactory.CAT_OTHER);
}

private void validateComponentElement(IDSComponent component) {
Expand All @@ -518,7 +520,7 @@ private void validateComponentElement(IDSComponent component) {
report(NLS.bind(Messages.DSErrorReporter_requiredElement,
IDSConstants.ELEMENT_IMPLEMENTATION),
getLine(getDocumentRoot()), ERROR,
DSMarkerFactory.CAT_OTHER);
PDEMarkerFactory.CAT_OTHER);
}

// validate boolean values
Expand Down Expand Up @@ -556,7 +558,7 @@ private void validateConfigurationPolicyAttribute(Element element,
report(
Messages.DSErrorReporter_invalidConfigurationPolicyValue,
getLine(element), WARNING,
DSMarkerFactory.CAT_OTHER);
PDEMarkerFactory.CAT_OTHER);
}
}
}
Expand Down Expand Up @@ -589,13 +591,13 @@ private void validateImmediateAttribute(Element element,

private void reportInvalidImmediateFactory(Element element) {
report(Messages.DSErrorReporter_invalidImmediateValueFactory,
getLine(element), WARNING, DSMarkerFactory.CAT_OTHER);
getLine(element), WARNING, PDEMarkerFactory.CAT_OTHER);

}

private void reportInvalidImmediate(Element element) {
report(Messages.DSErrorReporter_invalidImmediateValue,
getLine(element), WARNING, DSMarkerFactory.CAT_OTHER);
getLine(element), WARNING, PDEMarkerFactory.CAT_OTHER);
}

private void validateEmpty(Element element, Attr attr) {
Expand All @@ -612,7 +614,7 @@ private void reportIllegalEmptyAttributeValue(Element element, Attr attr) {
String message = NLS.bind(Messages.DSErrorReporter_emptyAttrValue, attr
.getName());
report(message, getLine(element, attr.getName()), ERROR,
DSMarkerFactory.CAT_OTHER);
PDEMarkerFactory.CAT_OTHER);
}

private void validateServiceElement(IDSService service) {
Expand All @@ -635,7 +637,7 @@ private void validateServiceElement(IDSService service) {

private void reportEmptyService(Element element) {
report(Messages.DSErrorReporter_illegalEmptyService, getLine(element),
ERROR, DSMarkerFactory.CAT_OTHER);
ERROR, PDEMarkerFactory.CAT_OTHER);
}

private void validateServiceFactory(Element element, IDSService service) {
Expand All @@ -658,14 +660,14 @@ private void validateServiceFactory(Element element, IDSService service) {

private void reportIllegalServiceFactory_Immediate(Element element) {
report(Messages.DSErrorReporter_illegalServiceFactory_Immediate,
getLine(element), ERROR, DSMarkerFactory.CAT_OTHER);
getLine(element), ERROR, PDEMarkerFactory.CAT_OTHER);


}

private void reportIllegalServiceFactory(Element element) {
report(Messages.DSErrorReporter_illegalServiceFactory,
getLine(element), ERROR, DSMarkerFactory.CAT_OTHER);
getLine(element), ERROR, PDEMarkerFactory.CAT_OTHER);
}

private void validateProvideElement(IDSProvide[] providedServices) {
Expand Down Expand Up @@ -702,7 +704,7 @@ private void validateDuplicateInterface(Hashtable<String, String> providedInterf
String message = NLS.bind(
Messages.DSErrorReporter_duplicatedInterface, interface1);
report(message, getLine(element), WARNING,
DSMarkerFactory.CAT_OTHER);
PDEMarkerFactory.CAT_OTHER);
} else {
providedInterfaces.put(interface1, interface1);
}
Expand Down

This file was deleted.

This file was deleted.

Loading

0 comments on commit 7b86df0

Please sign in to comment.