lingua-franca 0.10.1
Lingua Franca code generator
Loading...
Searching...
No Matches
org.lflang.ast.FormattingUtil Class Reference

Utility functions that determine the specific behavior of the LF formatter. More...

Static Public Member Functions

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 Public Attributes

static final int DEFAULT_LINE_LENGTH = 100

Static Package Functions

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.

Static Package Attributes

static final long BADNESS_PER_CHARACTER_VIOLATING_LINE_LENGTH = 20
static final long BADNESS_PER_LEVEL_OF_COMMENT_DISPLACEMENT = 1000
static final long BADNESS_PER_NEWLINE = 1
static final int MAX_WHITESPACE_USED_FOR_ALIGNMENT = 20

Detailed Description

Utility functions that determine the specific behavior of the LF formatter.

Author
Peter Donovan
Billy Bao

Member Function Documentation

◆ 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
commentA comment associated with an element of components.
componentsA list of strings that will be rendered in sequence.
iThe position of the component associated with comment.
widthThe ideal number of columns available for comments that appear on their own line.
keepCommentsOnSameLineWhether to make a best-effort attempt to keep the comment on the same line as the associated string.
singleLineCommentPrefixThe prefix that marks the start of a single-line comment.
startColumnThe 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.

Member Data Documentation

◆ 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