Skip to content

Commit

Permalink
Allowing member acccess to mark a property as used
Browse files Browse the repository at this point in the history
  • Loading branch information
nerdsupremacist committed Jan 25, 2021
1 parent b6dcb1d commit 7655694
Showing 1 changed file with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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."
)
]
}
}

Expand All @@ -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
}
}
}

0 comments on commit 7655694

Please sign in to comment.