0

Is there a way of searching only the code and not the comments in the code in Eclipse?

So, I'm looking up the source code for say, a certain identifier or a method name to trace where it is declared/used.

I'm using "Find/Replace" with ^F. but, I want it to search the text only in the source code and skip all the comments.

1
  • Are we talking about Java source code? Commented Nov 22, 2013 at 9:55

2 Answers 2

1

If you want to search for proper references (uses/declarations), use Shift-Ctrl-G. This will search for all references to the symbol in your workspace. If you want more detailed control, use the Search dialog (Ctrl-H). There you can do wildcard searches for things like any type which begins with Package in a given working set, or a specified set of resources. Note that this is not a free text search, this actually searches the Java AST, so it will not trigger on text in comments.

If you want to search inside comments, you can use the "File Search" tab in the Search dialog.

Sign up to request clarification or add additional context in comments.

2 Comments

well - maybe they'll do it in the next version. all it takes is a good all search plainly ignoring the comments. without wandering about the "perfectly-friendly" menus of Eclipse.
I don't understand your objection. What exactly do you want to search for, and how does the existing search functions fail to do what you want?
0

Use the References item in the contextual menu.

4 Comments

probably because it's not answering.
But that's the way to search for references to identifiers: select it, right-click, and choose References over the desired scope.
Note: If you have turned off Use reduced search menu in the Java Preferences then the context menu contains a Search item rather than References.
Shift-Ctrl-G will do the same thing without opening a context menu.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.