Place member attributes on methods and variables instead of class#330
Place member attributes on methods and variables instead of class#330luizgustavo09 wants to merge 2 commits intouber:masterfrom
Conversation
c0d2381 to
756faef
Compare
sidepelican
left a comment
There was a problem hiding this comment.
It's better than before.
| let shouldFilterMemberAttributes = item is MethodModel || item is VariableModel | ||
|
|
||
| if shouldFilterMemberAttributes { | ||
| let memberAttributes = ["@available", "@objc", "@discardableResult"] |
There was a problem hiding this comment.
Why were only these three chosen?
If using filters, you'll need to cover all combinations of Model types and attributes.
There was a problem hiding this comment.
It's the same discussed here
We're thinking about we don't need to filter because there's no use case where the attribute should be on class scope
There was a problem hiding this comment.
I'm not filtering anymore, assuming the every attribute must be nested with the method/var
| let availableAttr = (attributes ?? []) | ||
| .filter { $0.contains("@available") } | ||
| .joined(separator: "\n") | ||
| let availableStr = availableAttr.isEmpty ? "" : "\(1.tab)\(availableAttr)\n" | ||
|
|
||
| let objcAttr = (attributes ?? []) | ||
| .filter { $0.contains("@objc") } | ||
| .joined(separator: " ") | ||
| let objcStr = objcAttr.isEmpty ? "" : "\(objcAttr) " |
There was a problem hiding this comment.
It would be endless to add processing for each attribute individually.
There was a problem hiding this comment.
I agree, but the problem is that the @available attribute is usually above the method/variable, etc.
@objc, @discardableResult remains in line with the declaration.
What is your suggestion for these cases? Could we handle only the @available attribute?
There was a problem hiding this comment.
changed to handle only @available, I don't remember if swift has another use case where the attribute stay above
|
Question: was expecting this |
955d020 to
e2df490
Compare
|
Actually, The following code won't compile, right? struct S {
@available(macOS 99, *) // stored properties cannot be marked potentially unavailable with '@available'
var a: Int
} |
This is something I'm fine with either way. |
Description
Fixes #211
Member attributes like
@available,@objc, and@discardableResultare now placed on methods and variables instead of the mock class.Changes
attributesfield toMethodModelandVariableModel@availableabove and any other inlineTesting
MemberAttributeTestscovering attributes on methods and variables