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 - Support tags in search and replace patterns
Summary: Support tags in search and replace patterns
Status: NEW
Alias: None
Product: java
Classification: Unclassified
Component: Source (show other bugs)
Version: 8.1
Hardware: PC Linux
: P3 normal (vote)
Assignee: apireviews
URL:
Keywords: API, API_REVIEW_FAST
Depends on:
Blocks: 246059
  Show dependency tree
 
Reported: 2014-08-20 14:52 UTC by Svata Dedic
Modified: 2014-08-21 07:00 UTC (History)
3 users (show)

See Also:
Issue Type: TASK
Exception Reporter:


Attachments
Proposed changes (52.76 KB, patch)
2014-08-21 06:59 UTC, Svata Dedic
Details | Diff

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