Skip to content

Commit

Permalink
Signed-off-by: Heinrich Weichert <[email protected]>
Browse files Browse the repository at this point in the history
  • Loading branch information
heinrichWeichert committed Sep 27, 2023
1 parent bd76ce4 commit a57e45a
Showing 1 changed file with 21 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

import org.eclipse.core.resources.IFile;
Expand Down Expand Up @@ -71,6 +72,24 @@ public IXtextDocument setDocument(IXtextDocument document) {

protected static class Quickfix {

@Override
public int hashCode() {
return Objects.hash(description, label, result);
}

@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
Quickfix other = (Quickfix) obj;
return Objects.equals(description, other.description) && Objects.equals(label, other.label)
&& Objects.equals(result, other.result);
}

private final String label;

private final String description;
Expand All @@ -95,42 +114,6 @@ public String getResult() {
return result;
}

@Override
public int hashCode() {
int prime = 31;
int result = 1;
result = prime * result + ((label == null) ? 0 : label.hashCode());
result = prime * result + ((description == null) ? 0 : description.hashCode());
return prime * result + ((this.result == null) ? 0 : this.result.hashCode());
}

@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
AbstractQuickfixTest.Quickfix other = (AbstractQuickfixTest.Quickfix) obj;
if (label == null) {
if (other.label != null)
return false;
} else if (!label.equals(other.label))
return false;
if (description == null) {
if (other.description != null)
return false;
} else if (!description.equals(other.description))
return false;
if (result == null) {
if (other.result != null)
return false;
} else if (!result.equals(other.result))
return false;
return true;
}

@Override
public String toString() {
return "label: " + label + ", description: " + description + ", result: " + result;
Expand Down Expand Up @@ -193,7 +176,7 @@ protected XtextEditor openInEditor(IFile dslFile) {
try {
return openEditor(dslFile);
} catch (Exception e) {
throw new RuntimeException(e);
throw new IllegalStateException(e);
}
}

Expand Down Expand Up @@ -222,7 +205,7 @@ protected Issue getValidationIssue(IXtextDocument document, String issueCode) {
List<Issue> issueCandidates = document
.readOnly(state -> resourceValidator.validate(state, CheckMode.NORMAL_AND_FAST, CancelIndicator.NullImpl)) //
.stream() //
.filter(issue -> issue.getCode().equals(issueCode)) //
.filter(issue -> Objects.equals(issue.getCode(), issueCode)) //
.collect(Collectors.toList());
assertEquals("There should be one '" + issueCode + "' validation issue!", 1, issueCandidates.size());
return issueCandidates.get(0);
Expand Down

0 comments on commit a57e45a

Please sign in to comment.