Skip to content

Commit

Permalink
Delete previous validation errors if there are none
Browse files Browse the repository at this point in the history
Currently if one fixes all validation errors (or disables the validator)
the old errors stay permanently.

This deletes all markers if there are currently no errors or validators.
  • Loading branch information
Christoph Läubrich authored and laeubi committed Jun 2, 2024
1 parent 6fafba6 commit 803758c
Showing 1 changed file with 18 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,16 +68,23 @@ private MarkerFactory() {
public static void validationErrorOnStepDefinition(final IResource resource,
Map<Integer, String> errors, boolean persistent) {
if (errors == null || errors.isEmpty()) {
mark(resource, new IMarkerBuilder() {

@Override
public void build() throws CoreException {
deleteStepValidationErrors(resource);
}



});
return;
}

mark(resource, new IMarkerBuilder() {
@Override
public void build() throws CoreException {
IMarker[] markers = resource.findMarkers(STEPDEF_VALIDATION_ERROR, true, IResource.DEPTH_INFINITE);
for (IMarker marker : markers) {
marker.delete();
}
deleteStepValidationErrors(resource);
for (Entry<Integer, String> entry : errors.entrySet()) {
IMarker marker = resource.createMarker(STEPDEF_VALIDATION_ERROR);
marker.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_ERROR);
Expand All @@ -94,6 +101,13 @@ public void syntaxErrorOnStepDefinition(IResource stepDefinitionResource, Except
syntaxErrorOnStepDefinition(stepDefinitionResource, e, 0);
}

private static void deleteStepValidationErrors(final IResource resource) throws CoreException {
IMarker[] markers = resource.findMarkers(STEPDEF_VALIDATION_ERROR, true, IResource.DEPTH_INFINITE);
for (IMarker marker : markers) {
marker.delete();
}
}

// public void unmatchedStep(final IDocument gherkinDocument, final GherkinStepWrapper gherkinStepWrapper) {
//
// final IResource gherkinFile = gherkinStepWrapper.getSource();
Expand Down

0 comments on commit 803758c

Please sign in to comment.