Skip to content

Commit 8005a23

Browse files
committed
format code
1 parent dfce952 commit 8005a23

File tree

12 files changed

+141
-75
lines changed

12 files changed

+141
-75
lines changed

Firestore/Swift/Source/ExpressionImplementation.swift

Lines changed: 76 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,10 @@ extension Expression {
129129
/// - Parameter otherBits: The integer literal operand.
130130
/// - Returns: A new "FunctionExpression" representing the bitwise XOR operation.
131131
func bitXor(_ otherBits: Int) -> FunctionExpression {
132-
return FunctionExpression(functionName: "bit_xor", args: [self, Helper.sendableToExpr(otherBits)])
132+
return FunctionExpression(
133+
functionName: "bit_xor",
134+
args: [self, Helper.sendableToExpr(otherBits)]
135+
)
133136
}
134137

135138
/// Creates an expression applying bitwise XOR between this expression and a UInt8 literal.
@@ -226,7 +229,10 @@ extension Expression {
226229
/// - Parameter y: The number of bits (Int literal) to shift by.
227230
/// - Returns: A new "FunctionExpression" representing the bitwise right shift operation.
228231
func bitRightShift(_ y: Int) -> FunctionExpression {
229-
return FunctionExpression(functionName: "bit_right_shift", args: [self, Helper.sendableToExpr(y)])
232+
return FunctionExpression(
233+
functionName: "bit_right_shift",
234+
args: [self, Helper.sendableToExpr(y)]
235+
)
230236
}
231237

232238
/// Creates an expression applying bitwise right shift to this expression by a number of bits
@@ -272,7 +278,10 @@ extension Expression {
272278
/// - Parameter vector: The other vector as a `VectorValue` to compare against.
273279
/// - Returns: A new `FunctionExpression` representing the Manhattan distance.
274280
func manhattanDistance(_ vector: VectorValue) -> FunctionExpression {
275-
return FunctionExpression(functionName: "manhattan_distance", args: [self, Helper.sendableToExpr(vector)])
281+
return FunctionExpression(
282+
functionName: "manhattan_distance",
283+
args: [self, Helper.sendableToExpr(vector)]
284+
)
276285
}
277286

278287
/// Calculates the Manhattan (L1) distance between this vector expression and another vector
@@ -287,7 +296,10 @@ extension Expression {
287296
/// - Parameter vector: The other vector as `[Double]` to compare against.
288297
/// - Returns: A new `FunctionExpression` representing the Manhattan distance.
289298
func manhattanDistance(_ vector: [Double]) -> FunctionExpression {
290-
return FunctionExpression(functionName: "manhattan_distance", args: [self, Helper.sendableToExpr(vector)])
299+
return FunctionExpression(
300+
functionName: "manhattan_distance",
301+
args: [self, Helper.sendableToExpr(vector)]
302+
)
291303
}
292304

293305
/// Creates an expression that replaces the first occurrence of a literal substring within this
@@ -477,7 +489,10 @@ public extension Expression {
477489
}
478490

479491
func arrayContains(_ element: Sendable) -> BooleanExpression {
480-
return BooleanExpression(functionName: "array_contains", args: [self, Helper.sendableToExpr(element)])
492+
return BooleanExpression(
493+
functionName: "array_contains",
494+
args: [self, Helper.sendableToExpr(element)]
495+
)
481496
}
482497

483498
func arrayContainsAll(_ values: [Expression]) -> BooleanExpression {
@@ -509,7 +524,10 @@ public extension Expression {
509524
}
510525

511526
func arrayGet(_ offset: Int) -> FunctionExpression {
512-
return FunctionExpression(functionName: "array_get", args: [self, Helper.sendableToExpr(offset)])
527+
return FunctionExpression(
528+
functionName: "array_get",
529+
args: [self, Helper.sendableToExpr(offset)]
530+
)
513531
}
514532

515533
func arrayGet(_ offsetExpression: Expression) -> FunctionExpression {
@@ -648,31 +666,43 @@ public extension Expression {
648666
}
649667

650668
func regexContains(_ pattern: String) -> BooleanExpression {
651-
return BooleanExpression(functionName: "regex_contains", args: [self, Helper.sendableToExpr(pattern)])
669+
return BooleanExpression(
670+
functionName: "regex_contains",
671+
args: [self, Helper.sendableToExpr(pattern)]
672+
)
652673
}
653674

654675
func regexContains(_ pattern: Expression) -> BooleanExpression {
655676
return BooleanExpression(functionName: "regex_contains", args: [self, pattern])
656677
}
657678

658679
func regexMatch(_ pattern: String) -> BooleanExpression {
659-
return BooleanExpression(functionName: "regex_match", args: [self, Helper.sendableToExpr(pattern)])
680+
return BooleanExpression(
681+
functionName: "regex_match",
682+
args: [self, Helper.sendableToExpr(pattern)]
683+
)
660684
}
661685

662686
func regexMatch(_ pattern: Expression) -> BooleanExpression {
663687
return BooleanExpression(functionName: "regex_match", args: [self, pattern])
664688
}
665689

666690
func stringContains(_ substring: String) -> BooleanExpression {
667-
return BooleanExpression(functionName: "string_contains", args: [self, Helper.sendableToExpr(substring)])
691+
return BooleanExpression(
692+
functionName: "string_contains",
693+
args: [self, Helper.sendableToExpr(substring)]
694+
)
668695
}
669696

670697
func stringContains(_ expression: Expression) -> BooleanExpression {
671698
return BooleanExpression(functionName: "string_contains", args: [self, expression])
672699
}
673700

674701
func startsWith(_ prefix: String) -> BooleanExpression {
675-
return BooleanExpression(functionName: "starts_with", args: [self, Helper.sendableToExpr(prefix)])
702+
return BooleanExpression(
703+
functionName: "starts_with",
704+
args: [self, Helper.sendableToExpr(prefix)]
705+
)
676706
}
677707

678708
func startsWith(_ prefix: Expression) -> BooleanExpression {
@@ -723,7 +753,10 @@ public extension Expression {
723753
func substring(position: Int, length: Int? = nil) -> FunctionExpression {
724754
let positionExpr = Helper.sendableToExpr(position)
725755
if let length = length {
726-
return FunctionExpression(functionName: "substring", args: [self, positionExpr, Helper.sendableToExpr(length)])
756+
return FunctionExpression(
757+
functionName: "substring",
758+
args: [self, positionExpr, Helper.sendableToExpr(length)]
759+
)
727760
} else {
728761
return FunctionExpression(functionName: "substring", args: [self, positionExpr])
729762
}
@@ -817,35 +850,53 @@ public extension Expression {
817850
}
818851

819852
func cosineDistance(_ vector: VectorValue) -> FunctionExpression {
820-
return FunctionExpression(functionName: "cosine_distance", args: [self, Helper.sendableToExpr(vector)])
853+
return FunctionExpression(
854+
functionName: "cosine_distance",
855+
args: [self, Helper.sendableToExpr(vector)]
856+
)
821857
}
822858

823859
func cosineDistance(_ vector: [Double]) -> FunctionExpression {
824-
return FunctionExpression(functionName: "cosine_distance", args: [self, Helper.sendableToExpr(vector)])
860+
return FunctionExpression(
861+
functionName: "cosine_distance",
862+
args: [self, Helper.sendableToExpr(vector)]
863+
)
825864
}
826865

827866
func dotProduct(_ expression: Expression) -> FunctionExpression {
828867
return FunctionExpression(functionName: "dot_product", args: [self, expression])
829868
}
830869

831870
func dotProduct(_ vector: VectorValue) -> FunctionExpression {
832-
return FunctionExpression(functionName: "dot_product", args: [self, Helper.sendableToExpr(vector)])
871+
return FunctionExpression(
872+
functionName: "dot_product",
873+
args: [self, Helper.sendableToExpr(vector)]
874+
)
833875
}
834876

835877
func dotProduct(_ vector: [Double]) -> FunctionExpression {
836-
return FunctionExpression(functionName: "dot_product", args: [self, Helper.sendableToExpr(vector)])
878+
return FunctionExpression(
879+
functionName: "dot_product",
880+
args: [self, Helper.sendableToExpr(vector)]
881+
)
837882
}
838883

839884
func euclideanDistance(_ expression: Expression) -> FunctionExpression {
840885
return FunctionExpression(functionName: "euclidean_distance", args: [self, expression])
841886
}
842887

843888
func euclideanDistance(_ vector: VectorValue) -> FunctionExpression {
844-
return FunctionExpression(functionName: "euclidean_distance", args: [self, Helper.sendableToExpr(vector)])
889+
return FunctionExpression(
890+
functionName: "euclidean_distance",
891+
args: [self, Helper.sendableToExpr(vector)]
892+
)
845893
}
846894

847895
func euclideanDistance(_ vector: [Double]) -> FunctionExpression {
848-
return FunctionExpression(functionName: "euclidean_distance", args: [self, Helper.sendableToExpr(vector)])
896+
return FunctionExpression(
897+
functionName: "euclidean_distance",
898+
args: [self, Helper.sendableToExpr(vector)]
899+
)
849900
}
850901

851902
// MARK: Timestamp operations
@@ -909,11 +960,17 @@ public extension Expression {
909960
}
910961

911962
func ifError(_ catchValue: Sendable) -> FunctionExpression {
912-
return FunctionExpression(functionName: "if_error", args: [self, Helper.sendableToExpr(catchValue)])
963+
return FunctionExpression(
964+
functionName: "if_error",
965+
args: [self, Helper.sendableToExpr(catchValue)]
966+
)
913967
}
914968

915969
func ifAbsent(_ defaultValue: Sendable) -> FunctionExpression {
916-
return FunctionExpression(functionName: "if_absent", args: [self, Helper.sendableToExpr(defaultValue)])
970+
return FunctionExpression(
971+
functionName: "if_absent",
972+
args: [self, Helper.sendableToExpr(defaultValue)]
973+
)
917974
}
918975

919976
// MARK: Sorting

Firestore/Swift/Source/SwiftAPI/Firestore+Pipeline.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,11 @@
2222
import Foundation
2323

2424
@objc public extension Firestore {
25-
/// Creates a `PipelineSource` that can be used to build and execute a pipeline of operations on the Firestore database.
25+
/// Creates a `PipelineSource` that can be used to build and execute a pipeline of operations on
26+
/// the Firestore database.
2627
///
27-
/// A pipeline is a sequence of stages that are executed in order. Each stage can perform an operation on the data, such as filtering, sorting, or transforming it.
28+
/// A pipeline is a sequence of stages that are executed in order. Each stage can perform an
29+
/// operation on the data, such as filtering, sorting, or transforming it.
2830
///
2931
/// Example usage:
3032
/// ```swift

Firestore/Swift/Source/SwiftAPI/Pipeline/Aggregates/AliasedAggregate.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@
1515
/// An `AggregateFunction` that has been given an alias.
1616
public struct AliasedAggregate {
1717
let aggregate: AggregateFunction
18-
18+
1919
let alias: String
2020
}

Firestore/Swift/Source/SwiftAPI/Pipeline/Expressions/Expression.swift

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,8 @@ public protocol Expression: Sendable {
455455
/// Field("tags").arrayGet(Field("favoriteTagIndex"))
456456
/// ```
457457
///
458-
/// - Parameter offsetExpression: An `Expression` (evaluating to an Int) representing the offset of the
458+
/// - Parameter offsetExpression: An `Expression` (evaluating to an Int) representing the offset
459+
/// of the
459460
/// element to return.
460461
/// - Returns: A new `FunctionExpression` representing the "arrayGet" operation.
461462
func arrayGet(_ offsetExpression: Expression) -> FunctionExpression
@@ -1014,8 +1015,8 @@ public protocol Expression: Sendable {
10141015
///
10151016
/// - Parameter position: An `Expression` (evaluating to an Int) for the index of the first
10161017
/// character.
1017-
/// - Parameter length: Optional `Expression` (evaluating to an Int) for the length of the substring. If
1018-
/// `nil`, goes to the end.
1018+
/// - Parameter length: Optional `Expression` (evaluating to an Int) for the length of the
1019+
/// substring. If `nil`, goes to the end.
10191020
/// - Returns: A new `FunctionExpression` representing the substring.
10201021
func substring(position: Expression, length: Expression?) -> FunctionExpression
10211022

@@ -1055,8 +1056,8 @@ public protocol Expression: Sendable {
10551056
/// Field("settings").mapRemove(Field("keyToRemove"))
10561057
/// ```
10571058
///
1058-
/// - Parameter keyExpression: An `Expression` (evaluating to a string) representing the key to remove from
1059-
/// the map.
1059+
/// - Parameter keyExpression: An `Expression` (evaluating to a string) representing the key to
1060+
/// remove from the map.
10601061
/// - Returns: A new `FunctionExpression` representing the "map_remove" operation.
10611062
func mapRemove(_ keyExpression: Expression) -> FunctionExpression
10621063

@@ -1477,15 +1478,16 @@ public protocol Expression: Sendable {
14771478
/// root itself.
14781479
func collectionId() -> FunctionExpression
14791480

1480-
/// Creates an expression that returns the result of `catchExpression` if this expression produces an
1481-
/// error during evaluation, otherwise returns the result of this expression.
1481+
/// Creates an expression that returns the result of `catchExpression` if this expression produces
1482+
/// an error during evaluation, otherwise returns the result of this expression.
14821483
///
14831484
/// ```swift
14841485
/// // Try dividing "a" by "b", return field "fallbackValue" on error (e.g., division by zero)
14851486
/// Field("a").divide(Field("b")).ifError(Field("fallbackValue"))
14861487
/// ```
14871488
///
1488-
/// - Parameter catchExpression: The `Expression` to evaluate and return if this expression errors.
1489+
/// - Parameter catchExpression: The `Expression` to evaluate and return if this expression
1490+
/// errors.
14891491
/// - Returns: A new "FunctionExpression" representing the "ifError" operation.
14901492
func ifError(_ catchExpression: Expression) -> FunctionExpression
14911493

Firestore/Swift/Source/SwiftAPI/Pipeline/Expressions/FunctionExpressions/BooleanExpression.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public class BooleanExpression: FunctionExpression, @unchecked Sendable {
5252
/// ```
5353
///
5454
/// - Returns: An `AggregateFunction` that performs the conditional count.
55-
func countIf() -> AggregateFunction {
55+
public func countIf() -> AggregateFunction {
5656
return AggregateFunction(functionName: "count_if", args: [self])
5757
}
5858

@@ -106,7 +106,7 @@ public class BooleanExpression: FunctionExpression, @unchecked Sendable {
106106
public static func && (lhs: BooleanExpression,
107107
rhs: @autoclosure () throws -> BooleanExpression) rethrows
108108
-> BooleanExpression {
109-
try BooleanExpression(functionName: "and", args: [lhs, rhs()])
109+
try BooleanExpression(functionName: "and", args: [lhs, rhs()])
110110
}
111111

112112
/// Combines two boolean expressions with a logical OR (`||`).
@@ -130,7 +130,7 @@ public class BooleanExpression: FunctionExpression, @unchecked Sendable {
130130
public static func || (lhs: BooleanExpression,
131131
rhs: @autoclosure () throws -> BooleanExpression) rethrows
132132
-> BooleanExpression {
133-
try BooleanExpression(functionName: "or", args: [lhs, rhs()])
133+
try BooleanExpression(functionName: "or", args: [lhs, rhs()])
134134
}
135135

136136
/// Combines two boolean expressions with a logical XOR (`^`).
@@ -154,7 +154,7 @@ public class BooleanExpression: FunctionExpression, @unchecked Sendable {
154154
public static func ^ (lhs: BooleanExpression,
155155
rhs: @autoclosure () throws -> BooleanExpression) rethrows
156156
-> BooleanExpression {
157-
try BooleanExpression(functionName: "xor", args: [lhs, rhs()])
157+
try BooleanExpression(functionName: "xor", args: [lhs, rhs()])
158158
}
159159

160160
/// Negates a boolean expression with a logical NOT (`!`).

Firestore/Swift/Source/SwiftAPI/Pipeline/Expressions/FunctionExpressions/FunctionExpression.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,11 @@
1414

1515
/// Represents a function call in a pipeline.
1616
///
17-
/// A `FunctionExpression` is an expression that represents a function call with a given name and arguments.
17+
/// A `FunctionExpression` is an expression that represents a function call with a given name and
18+
/// arguments.
1819
///
19-
/// `FunctionExpression`s are typically used to perform operations on data in a pipeline, such as mathematical calculations, string manipulations, or array operations.
20+
/// `FunctionExpression`s are typically used to perform operations on data in a pipeline, such as
21+
/// mathematical calculations, string manipulations, or array operations.
2022
public class FunctionExpression: Expression, BridgeWrapper, @unchecked Sendable {
2123
let bridge: ExprBridge
2224

Firestore/Swift/Source/SwiftAPI/Pipeline/Expressions/FunctionExpressions/RandomExpression.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
/// .collection("users")
2727
/// .where(RandomExpression().lessThan(0.1))
2828
/// ```
29-
internal class RandomExpression: FunctionExpression, @unchecked Sendable {
29+
class RandomExpression: FunctionExpression, @unchecked Sendable {
3030
/// Creates a new `RandomExpression` that generates a random number.
3131
init() {
3232
super.init(functionName: "rand", args: [])

Firestore/Swift/Source/SwiftAPI/Pipeline/Ordering.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public struct Ordering: @unchecked Sendable {
2020
public let expression: Expression
2121
/// The direction to order in.
2222
public let direction: Direction
23-
23+
2424
let bridge: OrderingBridge
2525

2626
init(expression: Expression, direction: Direction) {

Firestore/Swift/Source/SwiftAPI/Pipeline/Pipeline.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ import Foundation
2424
///
2525
/// A pipeline takes data sources, such as Firestore collections or collection groups, and applies
2626
/// a series of stages that are chained together. Each stage takes the output from the previous
27-
/// stage (or the data source) and produces an output for the next stage (or as the final output of the
28-
/// pipeline).
27+
/// stage (or the data source) and produces an output for the next stage (or as the final output of
28+
/// the pipeline).
2929
///
3030
/// Expressions can be used within each stage to filter and transform data through the stage.
3131
///

Firestore/Swift/Source/SwiftAPI/Pipeline/PipelineSource.swift

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
/// A `PipelineSource` is the entry point for building a Firestore pipeline. It allows you to specify the source of the data for the pipeline, which can be a collection, a collection group, a list of documents, or the entire database.
15+
/// A `PipelineSource` is the entry point for building a Firestore pipeline. It allows you to
16+
/// specify the source of the data for the pipeline, which can be a collection, a collection group,
17+
/// a list of documents, or the entire database.
1618
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
1719
public struct PipelineSource: @unchecked Sendable {
1820
let db: Firestore
@@ -76,7 +78,8 @@ public struct PipelineSource: @unchecked Sendable {
7678

7779
/// Creates a `Pipeline` from an existing `Query`.
7880
///
79-
/// This allows you to convert a standard Firestore query into a pipeline, which can then be further modified with additional pipeline stages.
81+
/// This allows you to convert a standard Firestore query into a pipeline, which can then be
82+
/// further modified with additional pipeline stages.
8083
///
8184
/// - Parameter query: The `Query` to convert into a pipeline.
8285
/// - Returns: A `Pipeline` that is equivalent to the given query.

0 commit comments

Comments
 (0)