diff --git a/Sources/Graphaello/Processing/Pipeline/Diagnostics/UnusedWarningDiagnoser.swift b/Sources/Graphaello/Processing/Pipeline/Diagnostics/UnusedWarningDiagnoser.swift index b5e7738..14456a7 100644 --- a/Sources/Graphaello/Processing/Pipeline/Diagnostics/UnusedWarningDiagnoser.swift +++ b/Sources/Graphaello/Processing/Pipeline/Diagnostics/UnusedWarningDiagnoser.swift @@ -24,8 +24,12 @@ struct UnusedWarningDiagnoser: WarningDiagnoser { verifier.walk(syntax) guard !verifier.isUsed else { return [] } - return [Warning(location: property.code.location, - descriptionText: "Unused Property `\(property.name)` belongs to a View and is fetching data from GraphQL. This can be wasteful. Consider using it or removing the property.")] + return [ + Warning( + location: property.code.location, + descriptionText: "Unused Property `\(property.name)` belongs to a View and is fetching data from GraphQL. This can be wasteful. Consider using it or removing the property." + ) + ] } } @@ -45,4 +49,13 @@ class UsageVerifier: SyntaxVisitor { isUsed = true } } + + override func visitPost(_ node: MemberAccessExprSyntax) { + if node.name.text == property.name, + let parent = node.base?.as(IdentifierExprSyntax.self), + parent.identifier.tokenKind == .selfKeyword { + + isUsed = true + } + } }