Bug 344557 - ASTMatcher comparing Long variables declares differences
Summary: ASTMatcher comparing Long variables declares differences
Status: VERIFIED WONTFIX
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.7   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: 3.7 RC1   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-05-03 08:11 EDT by Johannes Tietje CLA
Modified: 2011-05-13 04:15 EDT (History)
2 users (show)

See Also:


Attachments
Test project to reproduce the bug. (6.67 KB, application/zip)
2011-05-03 08:12 EDT, Johannes Tietje CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
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.