mirror of
https://github.com/apple/pkl.git
synced 2026-04-11 03:06:55 +02:00
Format interpolated expressions as single line (#1247)
This forces iterpolated expressions to be single-line, so that newline literals within the bounds of two string delimiters can be seen as verbatime newlines in the resulting string. Edge case: in the case of a line comment, it's not possible to keep this as a single line expression. These are kept as multi-line expressions. Also: * Remove `ForceWrap`, this node is not used. * Rename `StringConstant` -> `StringChars`
This commit is contained in:
@@ -965,7 +965,7 @@ public class GenericParser {
|
||||
case STRING_PART -> {
|
||||
var tk = next();
|
||||
if (!tk.text(lexer).isEmpty()) {
|
||||
children.add(make(NodeType.STRING_CONSTANT, tk.span));
|
||||
children.add(make(NodeType.STRING_CHARS, tk.span));
|
||||
}
|
||||
}
|
||||
case STRING_ESCAPE_NEWLINE,
|
||||
@@ -1004,7 +1004,7 @@ public class GenericParser {
|
||||
case STRING_PART -> {
|
||||
var tk = next();
|
||||
if (!tk.text(lexer).isEmpty()) {
|
||||
children.add(make(NodeType.STRING_CONSTANT, tk.span));
|
||||
children.add(make(NodeType.STRING_CHARS, tk.span));
|
||||
}
|
||||
}
|
||||
case STRING_NEWLINE -> children.add(make(NodeType.STRING_NEWLINE, next().span));
|
||||
@@ -1383,7 +1383,7 @@ public class GenericParser {
|
||||
}
|
||||
}
|
||||
children.add(makeTerminal(next())); // string end
|
||||
return new Node(NodeType.STRING_CONSTANT, children);
|
||||
return new Node(NodeType.STRING_CHARS, children);
|
||||
}
|
||||
|
||||
private FullToken expect(Token type, String errorKey, Object... messageArgs) {
|
||||
|
||||
@@ -67,7 +67,7 @@ public enum NodeType {
|
||||
TYPE_ARGUMENT_LIST_ELEMENTS,
|
||||
OBJECT_PARAMETER_LIST,
|
||||
TYPE_PARAMETER,
|
||||
STRING_CONSTANT,
|
||||
STRING_CHARS,
|
||||
OPERATOR,
|
||||
STRING_NEWLINE,
|
||||
STRING_ESCAPE,
|
||||
|
||||
Reference in New Issue
Block a user