Utility functions that determine the specific behavior of the LF formatter.
More...
|
| static String | render (EObject object, int lineLength, Target target, boolean codeMapTags) |
| | Return a String representation of object, with lines wrapped at lineLength, with the assumption that the target language is target.
|
| static String | render (Model object) |
| | Return a String representation of object using a reasonable default line length.
|
| static String | render (Model object, int lineLength) |
| | Return a String representation of object, with lines wrapped at lineLength.
|
| static Function< EObject, String > | renderer (Target target) |
| | Return a function that renders AST nodes for the given target.
|
|
| static String | lineWrapComments (List< String > comments, int width, String singleLineCommentPrefix) |
| | Break lines at spaces so that each line is no more than width columns long, if possible.
|
| static boolean | placeComment (List< String > comment, List< String > components, int i, int width, boolean keepCommentsOnSameLine, String singleLineCommentPrefix, int startColumn) |
| | Merge comment into the given list of strings without changing the length of the list, preferably in a place that indicates that comment is associated with the ith string.
|
Utility functions that determine the specific behavior of the LF formatter.
- Author
- Peter Donovan
-
Billy Bao
◆ lineWrapComments()
| String org.lflang.ast.FormattingUtil.lineWrapComments |
( |
List< String > | comments, |
|
|
int | width, |
|
|
String | singleLineCommentPrefix ) |
|
staticpackage |
Break lines at spaces so that each line is no more than width columns long, if possible.
Normalize whitespace. Merge consecutive single-line comments.
◆ placeComment()
| boolean org.lflang.ast.FormattingUtil.placeComment |
( |
List< String > | comment, |
|
|
List< String > | components, |
|
|
int | i, |
|
|
int | width, |
|
|
boolean | keepCommentsOnSameLine, |
|
|
String | singleLineCommentPrefix, |
|
|
int | startColumn ) |
|
staticpackage |
Merge comment into the given list of strings without changing the length of the list, preferably in a place that indicates that comment is associated with the ith string.
- Parameters
-
| comment | A comment associated with an element of components. |
| components | A list of strings that will be rendered in sequence. |
| i | The position of the component associated with comment. |
| width | The ideal number of columns available for comments that appear on their own line. |
| keepCommentsOnSameLine | Whether to make a best-effort attempt to keep the comment on the same line as the associated string. |
| singleLineCommentPrefix | The prefix that marks the start of a single-line comment. |
| startColumn | The ideal starting column of a comment |
- Returns
- Whether the comment placement succeeded.
◆ render() [1/3]
| String org.lflang.ast.FormattingUtil.render |
( |
EObject | object, |
|
|
int | lineLength, |
|
|
Target | target, |
|
|
boolean | codeMapTags ) |
|
static |
Return a String representation of object, with lines wrapped at lineLength, with the assumption that the target language is target.
◆ render() [2/3]
| String org.lflang.ast.FormattingUtil.render |
( |
Model | object | ) |
|
|
static |
Return a String representation of object using a reasonable default line length.
◆ render() [3/3]
| String org.lflang.ast.FormattingUtil.render |
( |
Model | object, |
|
|
int | lineLength ) |
|
static |
Return a String representation of object, with lines wrapped at lineLength.
◆ renderer()
| Function< EObject, String > org.lflang.ast.FormattingUtil.renderer |
( |
Target | target | ) |
|
|
static |
Return a function that renders AST nodes for the given target.
◆ BADNESS_PER_CHARACTER_VIOLATING_LINE_LENGTH
| final long org.lflang.ast.FormattingUtil.BADNESS_PER_CHARACTER_VIOLATING_LINE_LENGTH = 20 |
|
staticpackage |
◆ BADNESS_PER_LEVEL_OF_COMMENT_DISPLACEMENT
| final long org.lflang.ast.FormattingUtil.BADNESS_PER_LEVEL_OF_COMMENT_DISPLACEMENT = 1000 |
|
staticpackage |
◆ BADNESS_PER_NEWLINE
| final long org.lflang.ast.FormattingUtil.BADNESS_PER_NEWLINE = 1 |
|
staticpackage |
◆ DEFAULT_LINE_LENGTH
| final int org.lflang.ast.FormattingUtil.DEFAULT_LINE_LENGTH = 100 |
|
static |
◆ MAX_WHITESPACE_USED_FOR_ALIGNMENT
| final int org.lflang.ast.FormattingUtil.MAX_WHITESPACE_USED_FOR_ALIGNMENT = 20 |
|
staticpackage |
The documentation for this class was generated from the following file:
- /Users/runner/work/lingua-franca/lingua-franca/core/src/main/java/org/lflang/ast/FormattingUtil.java