From 63a121b159da4867f115a5d99a972ba85c260faf Mon Sep 17 00:00:00 2001 From: aclement Date: Thu, 11 May 2006 07:25:50 +0000 Subject: 134471 - incremental structure model repair code overhaul - full equals support for when mungers are compared and we care about slocs. --- .../compiler/lookup/EclipseSourceLocation.java | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'org.aspectj.ajdt.core') diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseSourceLocation.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseSourceLocation.java index dd5de8cad..9091f4603 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseSourceLocation.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseSourceLocation.java @@ -136,4 +136,26 @@ public class EclipseSourceLocation implements ISourceLocation { if (getOffset()>=0) { sb.append("::").append(getOffset()); } return sb.toString(); } + + private volatile int hashCode = -1; + public int hashCode() { + if (hashCode == -1) { + int result = 17; + // other parts important? + result = 37*result + getLine(); + result = 37*result + getOffset(); + result = 37*result + (filename==null?0:filename.hashCode()); + hashCode = result; + } + return hashCode; + } + + public boolean equals(Object other) { + if (! (other instanceof EclipseSourceLocation)) return super.equals(other); + EclipseSourceLocation o = (EclipseSourceLocation) other; + return + getLine()==o.getLine() && + getOffset()==o.getOffset() && + ((filename==null)?(o.filename==null):o.filename.equals(filename)); + } } -- cgit v1.2.3