[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [Dltk-dev] equals() in AST nodes
|
There is an issue with equals.
Consider the following statement:
int i=2;
int j=0;
switch (i) {
case 2:
j=1;
break;
case 2:
j=2;
break;
}
One of our users wanted us to do semantic checking to determine if the
second case statement was "equal" (equivalent) to the first. If so, we
should flag it as a duplicate. Thus, I wanted to use ASTNode.equals to
check for the duplicate node. Unfortunately, equals fails since each
node includes the start position within the buffer - and those aren't
equal.
It would be useful to have a method that could be used to indicate the
everything but position was equal. I'm not sure what such a method
should be called.
Chuck
On Jun 10, 2009, at 9:28 AM, Michael Spector wrote:
Hi All,
Is there any reason to have equals() methods in basic AST nodes
implemented in DLTK core?
I guess it ASTNode should have the following to disallow weird and
useless implementations of equals() in class hierarchy:
public final boolean equals(Object obj) {
return this == obj;
}
public final int hashCode() {
return super.hashCode();
}
What do you think?
Thanks,
Michael
<ATT00001.c>