Skip to content

Commit

Permalink
PR feedback
Browse files Browse the repository at this point in the history
- Add comments about method splitting
- Add overloads with default values
- Clarify condition about using a temporary writer
  • Loading branch information
jduo committed Sep 24, 2024
1 parent cd33092 commit dc1c66d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,16 @@ private Expressions() {}
* Converts a list of expressions to Java source code, optionally emitting
* extra type information in generics.
*/
public static String toString(List<? extends Node> expressions, String sep,
boolean generics) {
return toString(expressions, sep, generics, false);
}

/**
* Converts a list of expressions to Java source code, optionally emitting
* extra type information in generics. Optionally splits the generated method if
* the method is too large.
*/
public static String toString(List<? extends Node> expressions, String sep,
boolean generics, boolean methodSplit) {
final ExpressionWriter writer = new ExpressionWriter(generics, methodSplit);
Expand All @@ -70,6 +80,14 @@ public static String toString(List<? extends Node> expressions, String sep,
/**
* Converts an expression to Java source code.
*/
public static String toString(Node expression) {
return toString(expression, false);
}

/**
* Converts an expression to Java source code.
* Optionally splits the generated method if the method is too large.
*/
public static String toString(Node expression, boolean methodSplit) {
return toString(Collections.singletonList(expression), "", true, methodSplit);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ public MethodDeclaration(int modifier, String name, Type resultType,
}

@Override public void accept(ExpressionWriter writer) {
// Conditionally serialize the method declaration directly to the supplied writer if method
// splitting is enabled or to a temporary writer that will generate code for the method that
// can be split before being serialized to the supplied writer.
final ExpressionWriter writerForUnsplitMethod = writer.usesMethodSplitting()
? writer.duplicateState() : writer;

Expand Down

0 comments on commit dc1c66d

Please sign in to comment.