Bookmarkable link

Documenting, but not defining the code style in use

Overview

At present, the definitive Wicket Code Style may be considered to be that defined by the /trunk/jdk-1.4/wicket/.settings/org.eclipse.jdt.core.prefs file, which is all well & good as long as you're using Eclipse! At present, as all the main committers appear to use that IDE, this hasn't a big problem, but this page attempts to document the main points to help those using alternative formatters.

Note - the intention here is to act as an aid for any developers interested in replicating the Wicket Code Style in something other than Eclipse, in order to help with supplying patches, etc. Even with IDEA (and as anyone with IDEA will see, I've only mentioned about 1/2 the settings available), you're almost certainly not going to be able to 100% replicate the Eclipse formatter, as there are too many 'edge cases', even when JavaDoc formatting is disabled. (That's a whole can of worms in itself...)

Java Style

General - Tabs and Indents

Option

Value

Description

Use Tabs or Spaces

Tabs

Smart Tabs

(tick)

Inserts tabs for indentation and reformatting but the fine alignment to a necessary column is done using spaces. Otherwise, only tabs are used.

Tab Size

4

Number of spaces included within a tab

Indent

4

Number of spaces to insert for each indent level

Continuation indent

8

Number of spaces to insert in case of a construct break to be inserted at the next line

Right Margin (columns)

120

Column to wrap at

Alignment & Braces

Class declaration

On next line

 

Method declaration

On next line

 

Other

On next line

 

Special 'else if' treatment

(tick)

i.e., keep on same line

Indent 'case' from 'switch'

(tick)

 

Place 'else' on new line

(tick)

 

Blank Lines

Keep Blank Lines

In declarations

0

Maximum number of blank lines that will be kept before class or method declarations after reformatting

In code

0

Maximum number of blank lines that will be kept among items within classes or methods after reformatting

Before '}'

0

Maximum number of blank lines that will be kept before the closing code block brace after reformatting

Blank Lines

Before package statement

0

After package statement

1

Before imports

1

After imports

1

Around class

1

Around field

0

Around method

1

After class header

0

Spaces

Before Parentheses

Method call parentheses

(error)

Method declaration parentheses

(error)

'if' parentheses

(tick)

'while' parentheses

(tick)

'for' parentheses

(tick)

'catch' parentheses

(tick)

'switch' parentheses

(error)

'synchronized' parentheses

(error)

Annotation parentheses

(error)

Around operators

All operators

(tick)

Before left brace ({)

All left braces

(tick)

Within Parentheses

All parentheses

(error)

Within Ternary Operator

i.e. a ? b : c;

Before '?'

(tick)

After '?'

(tick)

Before ':'

(tick)

After ':'

(tick)

Other

After comma (e.g. in argument lists)

(tick)

After semicolon (e.g. in 'for' loops)

(tick)

After type cast

(error)

Imports

Use single class import

(tick)

Import a particular class from a package is imported rather than '.*'

Use fully qualified class names in Javadoc

(tick)

Use fully qualified class name rather than importing

Class count to use import with '*'

99

Specify number of classes to import from a package until switching to '.*'

Names count to use static import with '*'

99

Specify number of classes to import from a package until switching to '.*'

Layout

Imported classes will be grouped as below and sorted alphabetically within a grouping

JavaDoc

Alignment

Use these options to define how Javadoc comments are aligned.

Align parameter description

(tick)

If checked, parameter descriptions are aligned against the longest parameter name. Otherwise, the description is separated from the parameter name by a single space.

Align thrown exception description

(tick)

If checked, thrown exception descriptions are aligned against the longest exception name. Otherwise, the description is separated from the exception name by a single space.

Blank lines

Use these options to define where blank lines are inserted in the Javadoc comments.

After description

(tick)

If checked, a blank line is automatically inserted after the description section of Javadoc comment.

After parameter descriptions

(error)

If checked, a blank line is inserted after the group of @param tags.

After return tag

(error)

If checked, a blank line is inserted after the @return tag.

Invalid tags

Keep invalid tags

(tick)

If checked, the @invalidTag is preserved.

Keep empty @param tags

(tick)

If checked, the @param tags without description are preserved.

Keep empty @return tags

(tick)

If checked, the @return tags without description are preserved.

Keep empty @throws tags

(tick)

If checked, the @throws tags without description are preserved.

Other

Enable leading asterisks

(tick)

If checked, each line of a Javadoc comment starts with an asterisk.

Use @throws rather than @exception

(tick)

If checked, @throws tag is used.

Wrap at right margin

(error)

If checked, the text that exceeds the right margin, is wrapped to the next line.

Generate </p> on empty lines

(error)

If checked, </p> tag is automatically inserted to an empty line

Keep empty lines

(tick)

If checked, the empty lines, inserted by the user, are preserved

Do not wrap one-line comment

(error)

If checked, short comments will be kept in one line with the opening and closing tags