Skip to content

Commit

Permalink
Wrap List/Set Creator Expressions More Aggressively
Browse files Browse the repository at this point in the history
  • Loading branch information
cwarden committed Dec 13, 2023
1 parent fab8b80 commit 11d239f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 7 additions & 0 deletions formatter/format_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,13 @@ func TestStatement(t *testing.T) {
`List<SBQQ__QuoteLineGroup__c> originalGroups = Database.query('SELECT ' +
String.join(new List<String>(qlgfields.keySet()), ',') +
' FROM SBQQ__QuoteLineGroup__c WHERE Id IN :originalGroupIds');`},

{
`public static final List<Schema.SObjectField> MY_IMPORTANT_FIELDS = new List<Schema.SObjectField>{ My_Object__c.The_Field__c, My_Object__c.The_Better_Field__c };`,
`public static final List<Schema.SObjectField> MY_IMPORTANT_FIELDS = new List<Schema.SObjectField>{
My_Object__c.The_Field__c,
My_Object__c.The_Better_Field__c
};`},
}
for _, tt := range tests {
input := antlr.NewInputStream(tt.input)
Expand Down
2 changes: 1 addition & 1 deletion formatter/visitors.go
Original file line number Diff line number Diff line change
Expand Up @@ -1199,7 +1199,7 @@ func (v *FormatVisitor) VisitSetCreatorRest(ctx *parser.SetCreatorRestContext) i
for _, i := range ctx.AllExpression() {
expressions = append(expressions, v.visitRule(i).(string))
}
if len(ctx.GetText()) > 80 {
if len(ctx.GetText()) > 50 {
return fmt.Sprintf("{\n%s\n}", v.indent(strings.Join(expressions, ",\n")))
}
return fmt.Sprintf("{ %s }", strings.Join(expressions, ", "))
Expand Down

0 comments on commit 11d239f

Please sign in to comment.