Closed weissi closed 2 years ago
It does not support trimming implicit self
either, so would be good to have both options.
Adding or removing explicit self
would likely require semantic information about the symbols, not just the syntax, to distinguish identifiers and know whether they're members of self
and that the code could be changed without changing its behavior.
It might be possible to approximate it by tracking symbols in their lexical scopes and use that to determine which symbol is being referred to, we wouldn't have access to the compiler Decl
s that would let us be 100% confident that self
is the same as the container for some property x
if it's also in the presence of other shadowing names.
FYI SwiftLint has a semantic version of this https://github.com/realm/SwiftLint/#configuration and SwiftFormat has a best effort version where it inserts and removes only ones it's confident about AFAIUI
Closing this as not planned, since we would need semantic information to do this correctly, and I prefer not to implement a syntax-only version that is incomplete.
Additional Detail from JIRA
| | | |------------------|-----------------| |Votes | 0 | |Component/s | swift-format | |Labels | New Feature | |Assignee | None | |Priority | Medium | md5: 0eee30a579bfbe4ae0442eb637819834Issue Description:
AFAIK,
swift-format
doesn't support adding explicitself.
everywhere. It would be great if it could do that.