Bug 344557

Summary: ASTMatcher comparing Long variables declares differences
Product: [Eclipse Project] JDT Reporter: Johannes Tietje <johannes.tietje>
Component: CoreAssignee: Olivier Thomann <Olivier_Thomann>
Status: VERIFIED WONTFIX QA Contact:
Severity: normal    
Priority: P3 CC: amj87.iitr, Olivier_Thomann
Version: 3.7   
Target Milestone: 3.7 RC1   
Hardware: PC   
OS: Linux   
Whiteboard:
Attachments:
Description Flags
Test project to reproduce the bug. none

Description Johannes Tietje CLA 2011-05-03 08:11:33 EDT
Build Identifier: 20100917-0705

When comparing two classes with Long class variables, the ASTMatcher produces a difference, where the values "1l" and "1L" are syntactically, but not semantically, different.

Reproducible: Always
Comment 1 Johannes Tietje CLA 2011-05-03 08:12:04 EDT
Created attachment 194563 [details]
Test project to reproduce the bug.
Comment 2 Olivier Thomann CLA 2011-05-05 11:57:10 EDT
You should replace your ASTMatcher with your own implementation if you want to match 1l with 1L.
Something like this would work:

ASTMatcher matcher = new ASTMatcher(true) {
	@Override
	public boolean match(NumberLiteral node, Object other) {
		if (!(other instanceof NumberLiteral)) {
			return false;
		}
		NumberLiteral o = (NumberLiteral) other;
		return safeEquals(
			node.getToken().toLowerCase(),
			o.getToken().toLowerCase());
	}
};

By default, the ASTMatcher is matching 1:1. So only identical nodes are reported as matching.
For example, 0x01 doesn't match with 1.

Closing as WONTFIX.
Let me know if you have any questions.
Comment 3 Ayushman Jain CLA 2011-05-13 04:15:48 EDT
Verified for 3.7RC1.