Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#2808: Fix possible NPE in AbstractQuickFixTest #2809

Merged
merged 1 commit into from
Sep 29, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -97,11 +98,7 @@ public String getResult() {

@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());
return Objects.hash(description, label, result);
}

@Override
Expand All @@ -112,25 +109,11 @@ public boolean equals(Object obj) {
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;
Quickfix other = (Quickfix) obj;
return Objects.equals(description, other.description) && Objects.equals(label, other.label)
&& Objects.equals(result, other.result);
}

@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)) //
imhotep82 marked this conversation as resolved.
Show resolved Hide resolved
.collect(Collectors.toList());
assertEquals("There should be one '" + issueCode + "' validation issue!", 1, issueCandidates.size());
return issueCandidates.get(0);
Expand Down