From 41481a1834c98ae620fc6e1e7d2f1c72e40aba2e Mon Sep 17 00:00:00 2001 From: Steven Looman Date: Fri, 1 Sep 2023 09:12:46 +0200 Subject: [PATCH] Fix build --- .../nl/ramsolutions/sw/magik/Location.java | 33 +++++++++++++++++++ .../java/nl/ramsolutions/sw/magik/Range.java | 33 +++++++++++++++++++ 2 files changed, 66 insertions(+) diff --git a/magik-squid/src/main/java/nl/ramsolutions/sw/magik/Location.java b/magik-squid/src/main/java/nl/ramsolutions/sw/magik/Location.java index 06bdde91..f1ef15f0 100644 --- a/magik-squid/src/main/java/nl/ramsolutions/sw/magik/Location.java +++ b/magik-squid/src/main/java/nl/ramsolutions/sw/magik/Location.java @@ -6,6 +6,7 @@ import java.net.URI; import java.nio.file.Path; import java.util.Comparator; +import java.util.Objects; /** * Location within a file. @@ -103,4 +104,36 @@ public Path getPath() { return Path.of(this.uri); } + @Override + public String toString() { + return String.format( + "%s@%s(%s, %s)", + this.getClass().getName(), Integer.toHexString(this.hashCode()), + this.getUri(), this.getRange()); + } + + @Override + public int hashCode() { + return Objects.hash(this.uri, this.range); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + + if (obj == null) { + return false; + } + + if (this.getClass() != obj.getClass()) { + return false; + } + + final Location other = (Location) obj; + return Objects.equals(this.uri, other.uri) + && Objects.equals(this.range, other.range); + } + } diff --git a/magik-squid/src/main/java/nl/ramsolutions/sw/magik/Range.java b/magik-squid/src/main/java/nl/ramsolutions/sw/magik/Range.java index b8a9231c..a1035673 100644 --- a/magik-squid/src/main/java/nl/ramsolutions/sw/magik/Range.java +++ b/magik-squid/src/main/java/nl/ramsolutions/sw/magik/Range.java @@ -2,6 +2,7 @@ import com.sonar.sslr.api.AstNode; import com.sonar.sslr.api.Token; +import java.util.Objects; /** * Range containing a start position and an end position. @@ -46,4 +47,36 @@ public static Range fromTree(final AstNode node) { return new Range(startPosition, endPosition); } + @Override + public String toString() { + return String.format( + "%s@%s(%s, %s)", + this.getClass().getName(), Integer.toHexString(this.hashCode()), + this.getStartPosition(), this.getEndPosition()); + } + + @Override + public int hashCode() { + return Objects.hash(this.startPosition, this.endPosition); + } + + @Override + public boolean equals(final Object obj) { + if (this == obj) { + return true; + } + + if (obj == null) { + return false; + } + + if (this.getClass() != obj.getClass()) { + return false; + } + + final Range other = (Range) obj; + return Objects.equals(this.startPosition, other.startPosition) + && Objects.equals(this.endPosition, other.endPosition); + } + }