Skip to content

Commit

Permalink
Fix build
Browse files Browse the repository at this point in the history
  • Loading branch information
StevenLooman committed Sep 1, 2023
1 parent 62edad4 commit 41481a1
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 0 deletions.
33 changes: 33 additions & 0 deletions magik-squid/src/main/java/nl/ramsolutions/sw/magik/Location.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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);
}

}
33 changes: 33 additions & 0 deletions magik-squid/src/main/java/nl/ramsolutions/sw/magik/Range.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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);
}

}

0 comments on commit 41481a1

Please sign in to comment.