Attach any IDE code templates to this page, pending adding them to Subversion.
Eclipse formatters
- OCAPJavaCodeFormat.xml - Java code formatter for Eclipse: in Subversion
- OCAPCCodeFormat.xml - C code formatter for Eclipse: in Subversion
Eclipse templates
- EclipseOCAPCodeTemplate.xml - Java code templates for Eclipse: attached
To apply the code formatters and templates:
- Download the Eclipse-specific attachment
- Access the Eclipse preferences window (Window/preferences on Windows)
- Navigate the tree on the left to the Java code templates preference pane (Java, Code Style, Code Templates)
- Click the 'Import...' button
- Select the EclipseOCAPCodeTemplate.xml file and open
- Click the 'Apply' button
- Navigate the tree on the left to the Java code formatter preference pane (Java, Code Style, Formatter)
- Click the 'Import...' button
- Select the OCAPJavaCodeFormat.xml file and open
- Click the 'Apply' button
- Navigate the tree on the left to the C code formatter preference pane (C/C++, Code Style)
- Click the 'Import...' button
- Select the OCAPCCodeFormat.xml file and open
- Click the 'Apply' button
- Press OK to close the preferences window
In Eclipse, Ctrl-Shift-F will reformat the current file.
Using Eclipse templates in IntelliJ IDEA
- Install Eclipse 3.2 or greater (Eclipse executable will actually perform the formatting)
- Create or modify an existing project to use project-specific formatting and template settings
- Define at least one project in Eclipse
- Follow instructions above for importing the code templates and formatter configuration, with one additional step before performing the import:
- Select the 'Configure Project specific settings' link on the right, select the project (for both the formatter and code templates import processes) and then import settings
- Install the External Code Formatter plugin
- In IDEA, access the Settings window
- Select Plugins
- Select the 'available' tab
- Right-click on External Code Formatter and select 'Download and Install'
- Restart IDEA
- Modify the External Code Formatter settings
- In IDEA, access the Settings window
- Select External Code Formatter
- On Windows, it should be sufficient to select 'Use the eclipse code formatter' and provide the path to eclipsec.exe and the above-configured project's org.eclipse.jdt.core.prefs file
- On Mac, use a custom formatter for *.java
- Specify the commands for reformatting
- /Applications/eclipse/Eclipse.app/Contents/MacOS/eclipse -nosplash -application org.eclipse.jdt.core.JavaCodeFormatter -verbose -config ~/workspace/myproject/.settings/org.eclipse.jdt.core.prefs %FILE or FILES or DIRECTORY%
- (Change the path to the eclipse binary and the project settings path as needed)
In IDEA, Alt-Apple-L will prompt to reformat