Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 

Eclipse Java Development User Guide
Previous Page Home Next Page

Searching the workbench

In this section, you will search the workbench for Java elements.

In the Search dialog, you can perform file, text or Java searches. Java searches operate on the structure of the code. File searches operate on the files by name and/or text content. Java searches are faster, since there is an underlying indexing structure for the code structure. Text searches allow you to find matches inside comments and strings.

Performing a Java search from the workbench

  1. In the Java perspective, click the Search (Search) button in the workbench toolbar or use Search > Java... from the menu bar.
  2. If it is not already selected, select the Java Search tab.
  3. In the Search string field, type runTest. In the Search For area, select Method, and in the Limit To area, select References.
    Verify that the Scope is set to Workspace.

    Java Search dialog

    Then click Search. While searching you may click Cancel at any time to stop the search. Partial results will be shown.
  4. In the Java perspective, the Search view shows the search results.

    Search results view

    Use the Show Next Match (Show Next Match) and Show Previous Match (Show Previous Match) buttons to navigate to each match. If the file in which the match was found is not currently open, it is opened in an editor.
  5. When you navigate to a search match using the Search view buttons, the file opens in the editor at the position of the match. Search matches are tagged with a search marker in the rulers.

    Editor with Search marker

Searching from a Java view

Java searches can also be performed from specific views, including the Outline, Hierarchy view and the Package Explorer view.

  1. In the Package Explorer view, double-click junit.framework.Assert.java to open it in an editor.
  2. In the Outline view, select the fail(String) method, and from its context menu, select References > Workspace.

    Search context menu in Outline view

Searching from an editor

From the Package Explorer view, open junit.framework.TestCase.java. In the editor, select the class name TestCase and from the context menu, select References > Workspace.

Search context menu in editor

Continuing a search from the search view

The Search Results view shows the results for the TestCase search. Select a search result and open the context menu. You can continue searching the selected element's references and declarations.

Search context menu in Search results view

If you want to follow multiple levels of method calls, you can also use Navigate > Open Call Hierarchy.

Performing a file search

  1. In the Java perspective, click the Search button in the workbench toolbar or select Search > File from the menu bar.
  2. If it is not already selected, select the File Search tab.
  3. In the Containing text field, type TestCase. Make sure that the File name patterns field is set to *.java. The Scope should be set to Workspace. Then click Search.

    File search tab

  4. To find all files of a given file name pattern, leave the Containing Text field empty.

Viewing previous search results

In the Search Results view, click the arrow next to the Previous Search Results toolbar button to see a menu containing the list of the most recent searches. You can choose items from this menu to view previous searches.  The list can be cleared by choosing Clear History.

Previous search results menu

The Previous Search Results button will display a dialog with the list of all previous searches from the current session.

Previous search results dialog

Selecting a previous search from this dialog will let you view that search.

Related concepts

Java search

Related reference

Refactoring actions
Refactoring wizard
Java preferences


 
 
  Published under the terms of the Eclipse Public License Version 1.0 ("EPL") Design by Interspire