Category Image Making Sense of Java CodeSense in XCode 1.5


The long-awaited Code Sense finally arrives in XCode released in Aug 2004. Here are my notes on what I had to do to make it work after I installed XCode 1.5 on top of XCode 1.2/OS X 10.2.4/WO 5.2.3

In summary follow these steps to success:
* Check Java installation and make sure CurrentJDK is linked to 1.4.2
* Install XCode 1.5
* Install Java 1.4.2 Developer Package
* Unjar Java Docs
* Prepare Java Classes for Code Sense
* Fix the WO documentation support as per XCode 1.5 release notes
* Turn On CodeSense
* Finally Use CodeSense

Check Your Java 1.4.2 Installation
# First, cd into the Java Versions directory
% cd /System/Library/Frameworks/JavaVM.framework/Versions

# Then list contents
% ls -al

# the output should look something like this:
total 16
drwxr-xr-x 10 root wheel 340 24 Sep 2003 .
drwxr-xr-x 10 root wheel 340 10 Aug 17:19 ..
drwxr-xr-x 3 root wheel 102 10 Jan 2004 1.2
drwxr-xr-x 3 root wheel 102 10 Jan 2004 1.3
drwxr-xr-x 8 root wheel 272 24 Sep 2003 1.3.1
drwxr-xr-x 4 root wheel 136 6 Dec 2003 1.4.1
drwxr-xr-x 8 root wheel 272 10 Jan 2004 1.4.2
drwxr-xr-x 5 root wheel 170 10 Jan 2004 A
lrwxr-xr-x 1 root wheel 1 10 Aug 17:19 Current -> A
lrwxr-xr-x 1 root wheel 5 10 Aug 16:18 CurrentJDK -> 1.4.2

# If the CurrentJDK points to 1.4.2 (as shown here since I fixed it yesterday), then you are OK. If 1.4.1 exists (which it should not since 1.4.2 installer was supposed to replace it!) and if CurrentJDK -> 1.4.1, then you need to fix the symbolic link using this command
%sudo ln -fhsv 1.4.2 CurrentJDK

Install XCode 1.5
Download XCode 1.5 from connect.apple.com, BACKUP your development Mac, and then install XCode 1.5. Do not open it yet.

Install Java 1.4.2 Developer Package
Download Java 1.4.2 Developer from connect.apple.com and install it

Unjar Java Docs
Run this script form the command line
/Developer/Documentation/Java/scripts/unjarJavaDocumentation.sh

Prepare Java Classes for Code Sense
The objective is to put the XXX.pbxindex for the appropriate "pre-cooked" project index in this folder
~/Library/Application Support/Apple/Developer Tools/Index Templates

The WebObjects HTML App index template is named JavaWebObjectsAppIndex.pbxindex and contains the files shown here:



With XCode, open the file:
/Developer/Extras/Xcode\ Index\ Templates/JavaWebObjectsAppIndex

Next select Window/Activity Viewer menu. You will see indexing progress.

Check that all the jar files in the project are NOT red font. If red, it means Xcode cannot find them. In that case, Get Info on the file and use Choose to find it and correct the absolute path.

Leave the JavaWebObjectsAppIndex project open until Activity Viewer indicates that indexing is complete.

When complete close it and copy the folder JavaWebObjectsAppIndex.pbxindex inside in ./build/JavaWebObjectsAppIndex.build/ to
~/Library/Application Support/Apple/Developer Tools/Index Templates

Repeat this process for any other Index Templates that you want code sense functionality for.

Finally, ENABLE codesense by setting this user-specific default from the command line

% defaults write com.apple.Xcode PBXCodeSenseEnableIndexTemplates YES

Fix the WO documentation support as per XCode 1.5 release notes
Open XCode and READ the RELEASE NOTES, especially the WebObjects related notes at the bottom!

Follow the instructions for fixing WebObjects Help Documentation as shown in the release notes and expanded here:
1) Create a soft link to the WebObjects documentation in the ADC Reference Library. To do so, run the command:
% sudo ln -s "/Developer/Documentation/WebObjects" "/Developer/ADC Reference Library"
2) Open /Developer/ADC Reference Library/documentation/Help/Developer Help Viewer/MacOSXDeveloper.pbHelpIndexerList and add this line to the XML:
/Developer/Documentation/WebObjects
# This can be done by opening the file with pico
% cd /Developer/ADC\ Reference\ Library/documentation/Help/Developer\ Help\ Viewer/
% sudo pico MacOSXDeveloper.pbHelpIndexerList
# Then add the value as a string member (highlighted below) of the XML array so that the contents of the file look like this:

3) Re-index the documentation. To do so, run the command:
sudo /Developer/Tools/pbhelpindexer -o "/Developer/ADC Reference Library/documentation/Help/Developer Help Viewer/"
This may take a a couple of minutes!
4) Restart Xcode.
Turn On CodeSense
Open XCode Preferences
Click on Navigation pane and set up desired options, for example:



Finally Use CodeSense

1) Start typing a variable name



2) Entering a period shows all fields/methods



3) Typing letters filters the list (use up/down arrows and/or tab to choose)




Troubleshooting:
So you find that CodeSense is not finding your newly created methods? ... usually caused by syntax mistakes and an index that is not up to date. Just save your files and Build, fixing any errors and reBuilding until you have no more java errors. Code Sense should now find all methods.


</HTMLCode>

Posted: Tuesday - August 10, 2004 at 04:39 PM        


Published by