-
Notifications
You must be signed in to change notification settings - Fork 863
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve support for string templates
The initial implementation passed through the entire string unmodified, this allows formatting the Java expressions inside the `\{...}`. See #1010 Co-authored-by: butterunderflow <[email protected]> PiperOrigin-RevId: 592889073
- Loading branch information
1 parent
8afdfca
commit 28be4be
Showing
6 changed files
with
103 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
core/src/test/resources/com/google/googlejavaformat/java/testdata/StringTemplate.input
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
public class StringTemplates { | ||
void test(){ | ||
var m = STR."template \{example}xxx"; | ||
var nested = STR."template \{example.foo()+ STR."templateInner\{example}"}xxx }"; | ||
var nestNested = STR."template \{example0. | ||
foo() + | ||
STR."templateInner\{example1.test(STR."\{example2 | ||
}")}"}xxx }"; | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
core/src/test/resources/com/google/googlejavaformat/java/testdata/StringTemplate.output
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
public class StringTemplates { | ||
void test() { | ||
var m = STR."template \{example}xxx"; | ||
var nested = STR."template \{example.foo() + STR."templateInner\{example}"}xxx }"; | ||
var nestNested = | ||
STR."template \{ | ||
example0.foo() + STR."templateInner\{example1.test(STR."\{example2}")}"}xxx }"; | ||
} | ||
} |