Best way to search for instances of a string in Eclipse
I am trying to find where a particular variable is being set. Is it possible to search through a set of project source files to find all the possible spots a certain variable might be getting set?
The search in the drop-down menu is a bit confusing to use. After I enter a search I happen to be looking at, and I know it is there, when I do a search from the root of the file system, it tells me that the string is not there :)
Is this a common newbie issue? I j开发者_如何学Cust recently started using Eclipse and could just be missing something simple :)
Thanks, Alex
Select the field where it is declared, then ctrl+shift+H to open the search dialog. The "Java Search" tab should be selected with the Search string populated with your field name, including package. In "Search For" select "Field" and in "Limit To" select "Write accesses" That will show you everywhere that field is assigned.
Here's a screenshot of the search dialog.
I believe the default mapping is Ctrl Shift G. Highlight the variable and do Ctrl Shift G it will find all references of that variable.
Be careful, it will not just do assignments, so you might be getting more data than you want.
精彩评论