This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 239119 - CopyFinders and Matchers should support extra parenthesis and commutative ops
Summary: CopyFinders and Matchers should support extra parenthesis and commutative ops
Status: NEW
Alias: None
Product: java
Classification: Unclassified
Component: Source (show other bugs)
Version: 8.0
Hardware: PC Linux
: P2 normal (vote)
Assignee: Svata Dedic
URL:
Keywords:
Depends on:
Blocks: 234089
  Show dependency tree
 
Reported: 2013-12-04 16:04 UTC by Svata Dedic
Modified: 2013-12-10 22:47 UTC (History)
1 user (show)

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Svata Dedic 2013-12-04 16:04:09 UTC
If searching for a Tree-based match, the target may use extra parenthesis for aesthetical reasons, which do not influence the actual semantics. 
The CopyFinder should (optionally) support such situation and match a tree that differs only in meaningless parenthesis.

Likewise for commutative operations, variable on either side should match.

Some operations are not strictly commutative, but can be flipped provided that operator changes, i.e. x >= y is equivalent to y <= x. 

In the case of integer literals (or compile-time constant references) the above is also requivalent to x > (y - 1) etc.

Allowing such equivalent matches would allow to code less triggers for hints and potentially find more duplicates of tree fragments.