Skip to content

Commit

Permalink
Inline firstStringSegment (#133)
Browse files Browse the repository at this point in the history
  • Loading branch information
dfed authored Jan 1, 2025
1 parent 238c5a5 commit 2babda3
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 38 deletions.
9 changes: 5 additions & 4 deletions Sources/SafeDICore/Extensions/AttributeSyntaxExtensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,13 @@ extension AttributeSyntax {

public var fulfillingPropertyName: String? {
guard let fulfilledByDependencyNamed,
let stringLiteral = StringLiteralExprSyntax(fulfilledByDependencyNamed)
let stringLiteral = StringLiteralExprSyntax(fulfilledByDependencyNamed),
case let .stringSegment(firstSegment) = stringLiteral.segments.first
else {
return nil
}

return stringLiteral.segments.firstStringSegment
return firstSegment.content.text
}

public var fulfilledByType: ExprSyntax? {
Expand Down Expand Up @@ -125,9 +126,9 @@ extension AttributeSyntax {
public var fulfillingTypeDescription: TypeDescription? {
if let expression = fulfilledByType,
let stringLiteral = StringLiteralExprSyntax(expression),
let firstStringSegement = stringLiteral.segments.firstStringSegment
case let .stringSegment(firstSegment) = stringLiteral.segments.first
{
TypeSyntax(stringLiteral: firstStringSegement).typeDescription
TypeSyntax(stringLiteral: firstSegment.content.text).typeDescription
} else {
ofType?.typeDescription
}
Expand Down
32 changes: 0 additions & 32 deletions Sources/SafeDICore/Extensions/StringLiteralSegmentListSyntax.swift

This file was deleted.

4 changes: 2 additions & 2 deletions Sources/SafeDIMacros/Macros/InjectableMacro.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ public struct InjectableMacro: PeerMacro {

if let stringLiteralExpression = StringLiteralExprSyntax(fulfilledByType),
stringLiteralExpression.segments.count == 1,
let stringLiteral = stringLiteralExpression.segments.firstStringSegment
case let .stringSegment(stringLiteral) = stringLiteralExpression.segments.first
{
switch TypeSyntax(stringLiteral: stringLiteral).typeDescription {
switch TypeSyntax(stringLiteral: stringLiteral.content.text).typeDescription {
case .simple, .nested:
break
case .composition, .optional, .implicitlyUnwrappedOptional, .some, .any, .metatype, .attributed, .array, .dictionary, .tuple, .closure, .unknown, .void:
Expand Down

0 comments on commit 2babda3

Please sign in to comment.