Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions 10 common/src/main/java/dev/cel/common/ast/CelExprFormatter.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package dev.cel.common.ast;

import com.google.common.collect.ImmutableSet;
import java.util.Locale;

/** Provides string formatting support for {@link CelExpr}. */
final class CelExprFormatter {
Expand All @@ -33,7 +34,7 @@ static String format(CelExpr celExpr) {

private void formatExpr(CelExpr celExpr) {
CelExpr.ExprKind.Kind exprKind = celExpr.exprKind().getKind();
append(String.format("%s [%d] {", exprKind, celExpr.id()));
append(String.format(Locale.getDefault(), "%s [%d] {", exprKind, celExpr.id()));
if (!EXCLUDED_NEWLINE_KINDS.contains(exprKind)) {
appendNewline();
}
Expand Down Expand Up @@ -103,7 +104,8 @@ private void appendConst(CelConstant celConstant) {
appendWithoutIndent("\"" + celConstant.stringValue() + "\"");
break;
case BYTES_VALUE:
appendWithoutIndent(String.format("b\"%s\"", celConstant.bytesValue().toStringUtf8()));
appendWithoutIndent(
String.format(Locale.getDefault(), "b\"%s\"", celConstant.bytesValue().toStringUtf8()));
break;
default:
append("Unknown kind: " + celConstant.getKind());
Expand Down Expand Up @@ -184,7 +186,7 @@ private void appendStruct(CelExpr.CelStruct celStruct) {
indent();
for (CelExpr.CelStruct.Entry entry : celStruct.entries()) {
appendNewline();
appendWithNewline(String.format("ENTRY [%d] {", entry.id()));
appendWithNewline(String.format(Locale.getDefault(), "ENTRY [%d] {", entry.id()));
indent();
appendWithNewline("field_key: " + entry.fieldKey());
if (entry.optionalEntry()) {
Expand Down Expand Up @@ -214,7 +216,7 @@ private void appendMap(CelExpr.CelMap celMap) {
} else {
firstLine = false;
}
appendWithNewline(String.format("MAP_ENTRY [%d] {", entry.id()));
appendWithNewline(String.format(Locale.getDefault(), "MAP_ENTRY [%d] {", entry.id()));
indent();
appendWithNewline("key: {");
indent();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Optional;

Expand Down Expand Up @@ -2042,7 +2043,7 @@ private static ZoneId timeZone(String tz) {
// Example: "-9:30" -> "-09:30" and "9:30" -> "+09:30"
String formattedOffset =
((hourOffset < 0) ? "-" : "+")
+ String.format("%02d:%02d", Math.abs(hourOffset), minOffset);
+ String.format(Locale.getDefault(), "%02d:%02d", Math.abs(hourOffset), minOffset);

return ZoneId.of(formattedOffset);

Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.