Browse Source

134471 - incremental structure model repair code overhaul - full equals support for when mungers are compared and we care about slocs.

tags/V1_5_2rc1
aclement 18 years ago
parent
commit
63a121b159

+ 22
- 0
org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseSourceLocation.java View File

@@ -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));
}
}

Loading…
Cancel
Save