diff --git a/Sources/SafeDICore/Extensions/AttributeSyntaxExtensions.swift b/Sources/SafeDICore/Extensions/AttributeSyntaxExtensions.swift index 148e6e47..0bc71a7a 100644 --- a/Sources/SafeDICore/Extensions/AttributeSyntaxExtensions.swift +++ b/Sources/SafeDICore/Extensions/AttributeSyntaxExtensions.swift @@ -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? { @@ -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 } diff --git a/Sources/SafeDICore/Extensions/StringLiteralSegmentListSyntax.swift b/Sources/SafeDICore/Extensions/StringLiteralSegmentListSyntax.swift deleted file mode 100644 index a2be0c75..00000000 --- a/Sources/SafeDICore/Extensions/StringLiteralSegmentListSyntax.swift +++ /dev/null @@ -1,32 +0,0 @@ -// Distributed under the MIT License -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -import SwiftSyntax - -extension StringLiteralSegmentListSyntax { - public var firstStringSegment: String? { - switch first { - case let .stringSegment(stringSegmentSyntax): - stringSegmentSyntax.content.text - case .expressionSegment, .none: - nil - } - } -} diff --git a/Sources/SafeDIMacros/Macros/InjectableMacro.swift b/Sources/SafeDIMacros/Macros/InjectableMacro.swift index 53276999..a837da26 100644 --- a/Sources/SafeDIMacros/Macros/InjectableMacro.swift +++ b/Sources/SafeDIMacros/Macros/InjectableMacro.swift @@ -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: