You can compare various combinations of program elements (projects, packages, classes, interfaces, and methods) that are in the workspace and in the repository. When you compare program elements, the results are displayed in a comparison results window.
Comparing Program Elements That Are Both in the Workspace
You can compare any two program elements in the workspace, provided they are the same
program element type (that is, you can compare two projects, but not a project and a
package). To compare two program elements that are both in the workspace:
Comparing Program Element Editions with Editions In the Repository
You can also compare the following combinations of program elements:
See Comparing Editions of a Program Element for more information on working with the Comparison Results window when two editions have been compared.
Working with Comparison Results
Note: The following information applies to comparing two program elements that are both in the workspace. For information on comparing editions of the same element, see Comparing Editions of a Program Element.
From the Comparison Results window, you can do the following tasks:
The Differences pane lists all the difference between the two program elements and their contained elements, in a tree view. Beside each program element is a description of what the difference is: changed source code, changed comment, changed declaration, added element, or deleted element. The element on the right is being compared to the element on the left, so "Added method" for example, means that the class on the right contains a method that the class on the left does not contain.
Stepping through Differences
When you select an item in the Differences list, the source for the two program elements
that contain the difference is shown in the Source panes, with the difference highlighted.
To move to the next difference click the Next Difference button . To return to the previous
difference, click the Previous Difference button
.
Ignoring Differences
There may be some differences you want excluded from the list of differences.
To have a difference ignored, select it and click the Ignore
button . To show
ignored differences, click the Show Ignored Items button so that it is in
the down position
. Ignore differences will have parentheses
around them in the Differences list. To hide the ignored differences, click the Show
Ignored Items button so that it is in the up position
.
Modifying Program Element Source
The Source panes in the Comparison Results window are the same as those
elsewhere; you can edit the code and save it. There is code assist support
(type Ctrl+Spacebar to get help with type and field names). To save changes, select Save
from the pane's pop-up menu.
Merging the Contents of the Compared Elements
You can change the source code of one of the program elements by merging into it
the contents of the other program element, either by replacing a single difference in the
code, or by replacing the entire program element. The following menu actions help
with merging differences:
Menu Option | What It Does |
Replace with Alternative (in Source pane pop-up menus) | Select an item in the Differences list. If the difference is changed source code or declaration, the corresponding code will be highlighted in each of the Source panes. Then select this option in the Right-Hand Source pane pop-up menu to replace the the highlighted code with the highlighted code in the Left-Hand Source pane. Alternatively, select this option in the Left-Hand Source pane pop-up menu to replace the highlighted code with the highlighted code in the Right-Hand Source pane. |
Load Left (in the Differences pane pop-up menu) | Replaces the contents of the program element in the Right-Hand Source pane with the contents in the Left-Hand Source pane. If there is no corresponding program element in the Left-Hand Source pane, then it deletes the program element in the Right-Hand Source pane. |
Load Right (in the Differences pane pop-up menu) | Replaces the contents of the program element in the Left-Hand Source pane with the contents in the Right-Hand Source pane. If there is no corresponding program element in the Right-Hand Source pane, then it deletes the program element in the Left-Hand source pane. |
These menu options are available only if the merge can be done.
Projects and Other Program Elements
Comparing Editions of a Program Element
Merging Editions of a Class or Interface