We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
IdentifierTypeSyntax
detectExpressionType
1 parent ceca416 commit c183a5eCopy full SHA for c183a5e
Sources/ManagedModelMacros/Utilities/ExpressionType.swift
@@ -8,6 +8,10 @@ import SwiftSyntax
8
extension ExprSyntax {
9
10
func detectExpressionType() -> TypeSyntax? {
11
+ guard let idType = detectExpressionTypeName() else { return nil }
12
+ return TypeSyntax(IdentifierTypeSyntax(name: .identifier(idType)))
13
+ }
14
+ func detectExpressionTypeName() -> String? {
15
// TODO: detect base types and such
16
// - check function expressions, like:
17
// - `Data()`?
@@ -18,7 +22,8 @@ extension ExprSyntax {
18
22
case .integerLiteralExpr : return "Swift.Int"
19
23
case .floatLiteralExpr : return "Swift.Double"
20
24
case .booleanLiteralExpr : return "Swift.Bool"
21
- default: break
25
+ default:
26
+ break
27
}
28
29
return nil
0 commit comments