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 246587

Summary: Support tags in search and replace patterns
Product: java Reporter: Svata Dedic <sdedic>
Component: SourceAssignee: apireviews <apireviews>
Status: NEW ---    
Severity: normal CC: dbalek, sdedic, tzezula
Priority: P3 Keywords: API, API_REVIEW_FAST
Version: 8.1   
Hardware: PC   
OS: Linux   
Issue Type: TASK Exception Reporter:
Bug Depends on:    
Bug Blocks: 246059    
Attachments: Proposed changes

Description Svata Dedic 2014-08-20 14:52:13 UTC
Please see defect #246059, the 'lock' case in comment #1. The Lock hint is defined by a pattern and the fix is also driven by pattern (template). The bad thing is that {} in the search pattern is not associated with {} in the fix template, and so comments are not transferred, but (after additional bugs were fixed) migrated upwards the tree and will end up completely outside the compound statement.

The proposed API change allows to name certain trees in the search pattern. The matcher in java.source module then records TreePaths that correspond to the named pattern trees in the Occurrence structure.

The Hint infrastructure is then able to pass that information to hints, so individual hint implementations may use the named TreePaths for e.g. navigation inside the original source, so they can better pinpoint interesting places of the matching text.

Other usage, important for fixing #246059, is that JavaFixUtilities.rewriteFix, which works based on code templates can use the same named tree syntax to associate tree matches from Occurrence with trees of the newly generated code - this allows java.source generator to transfer comments and possibly whitespace more consistently.
Comment 1 Svata Dedic 2014-08-21 06:59:09 UTC
Created attachment 148805 [details]
Proposed changes