org.eclipse.jdt.internal.formatter.comment |
Package-level Javadoc
Provides facilities to format comments in Java source code.
Package Specification
This package provides interfaces and implementations for three kinds of comment types used in
Java source code:
- Javadoc comments
- Multi-line comments
- Single-line comments
Comment Formatting
Comment regions form the principle access point to the formatting of comments. To create a comment
region for a specified comment type, the factory method
CommentObjectFactory#createRegion(IDocument, TypedPosition, String, Map, StyledText)
should be used.
The formatting process is then launch by calling CommentRegion#format(String), where
the argument denotes the desired indentation. This method returns a textedit representing the changes that where made during
the formatting process. The document for which the comment region was created is therefore guaranteed
to remain unchanged.
Internally, the comment region is first cast into comment lines to form the basis of the following scan step:
Each comment line is scanned for valid prefixes and tokenized afterwards. This tokenize step yields a stream of
tokens called comment ranges that are then marked with attributes representing information about the kind of
token associated with that comment range.
Once the comment ranges have enough attributed information, the comment region wraps the comment ranges at
the line margin boundary. This is coordinated by a set of rules that can be contributed to a certain type of comment
region. At this point of time, the comment range stream already represents the formatted comment region. The last
step therefore is to record the edits and to construct the resulting text edit, which describes all the changes that were
made to the comment region.
Note that the changes are not directly applied to the document. Clients are responsible for applying the textedit
and updating and preserving the document structure.
All the objects used during comment formatting should not directly be instantiated, but
rather retrieved from the factory CommentObjectFactory. This factory ensures
that the right kind of regions and lines are returned for a specific comment type.
|
Java Source File Name | Type | Comment |
CommentFormatterUtil.java | Class | Comment formatting utils. |
CommentLine.java | Class | General comment line in a comment region. |
CommentRange.java | Class | Range in a comment region in comment region coordinates. |
CommentRegion.java | Class | Comment region in a source code document. |
HTMLEntity2JavaReader.java | Class | SubstitutionTextReader that will substitute plain text values
for html entities encountered in the original text. |
IBorderAttributes.java | Interface | Comment region border attributes. |
ICommentAttributes.java | Interface | General comment range attributes. |
IHtmlTagDelimiters.java | Interface | Html tag constants. |
IJavaDocTagConstants.java | Interface | Javadoc tag constants. |
Java2HTMLEntityReader.java | Class | SubstitutionTextReader that will substitute html entities for
html symbols encountered in the original text. |
JavaDocLine.java | Class | Javadoc comment line in a comment region. |
JavaDocRegion.java | Class | Javadoc region in a source code document. |
MultiCommentLine.java | Class | Multi-line comment line in a comment region. |
MultiCommentRegion.java | Class | Multi-comment region in a source code document. |
SingleCommentLine.java | Class | Single-line comment line in a comment region. |
SubstitutionTextReader.java | Class | Reads the text contents from a reader and computes for each character
a potential substitution. |