Java Reference
In-Depth Information
Regular analysis of your code will improve the maintainability and clarity of your
source tree. Historically, however, the problem with any sort of design mainte-
nance phase has been its negative impact on the development cycle, in terms of
both time and accuracy. Having to manually update code structures and correct
all the affected references not only takes time, but also is prone to errors. With
IDEA , refactoring your program's design is a snap.
9.1 Analyzing your code
Whether during debugging, architectural review, or design improvement, code
analysis is easier when you use IDEA 's analysis tools. IDEA can help you under-
stand your code's structure and the relationship between your classes. In this sec-
tion, we'll discuss how to track down your dependencies, use the structure view to
look through your code, and work through the code hierarchy.
9.1.1
Tracking down dependencies
An important part of understanding your code is having the knowledge of what
depends on what . Where is this method being called from? What classes are using
this constant? IDEA has a number of features that help answer these questions
and track down how and where your code is being used.
Finding all usages of a class, method, field, or parameter
The Search | Find Usages ( Alt+F7 ) and Search | Find Usages in File ( Ctrl+F7 )
commands locate all the references to the current class, method, field, variable,
or parameter. The difference between the two commands is that Find Usages
searches the entire project, whereas Find Usages in File is limited to searching
the file you're currently editing. Both commands are also available from the con-
text menu in the editor.
Depending on whether you're searching usages on a class, method, field, or
parameter, there are a number of different search options to select from the
search dialog, as shown in figure 9.1. The exact options available depend on the
type of symbol you're searching on and whether it's part of a library or local mod-
ule. Here's what the options do:
Skip results tab with one usage takes effect when only a single reference to
your current symbol exists. In this case, your cursor moves immediately to
that usage rather than displaying the sole usage in the results list.
 
 
 
 
 
 
 
 
 
Search WWH ::




Custom Search