[Question] Is there a way to detect capture lists?
Nobody has claimed this yet.
- Dominant language
- Swift
- Stars
- 2.4k
- Forks
- 237
- PR merge metrics
- No merged PRs in 30d
Description
Hi! Thanks for the amazing tool!
Could you help me to deal with swift capture lists?
$ sourcekitten syntax --text "[weak module]" returns
[
{
"type" : "source.lang.swift.syntaxtype.identifier",
"offset" : 1,
"length" : 4
},
{
"type" : "source.lang.swift.syntaxtype.identifier",
"offset" : 6,
"length" : 6
}
]
Same for unowned
$ sourcekitten syntax --text "[unowned module]"
[
{
"type" : "source.lang.swift.syntaxtype.identifier",
"offset" : 1,
"length" : 7
},
{
"type" : "source.lang.swift.syntaxtype.identifier",
"offset" : 9,
"length" : 6
}
]
Note that both weak and unowned are described as identifiers. However they are expected to be attribute.builtins like in the following examples:
$ sourcekitten syntax --text "unowned var module = module"
[
{
"type" : "source.lang.swift.syntaxtype.attribute.builtin",
"offset" : 0,
"length" : 7
},
{
"type" : "source.lang.swift.syntaxtype.keyword",
"offset" : 8,
"length" : 3
},
{
"type" : "source.lang.swift.syntaxtype.identifier",
"offset" : 12,
"length" : 6
},
{
"type" : "source.lang.swift.syntaxtype.identifier",
"offset" : 21,
"length" : 6
}
]
$ sourcekitten syntax --text "weak var module = module"
[
{
"type" : "source.lang.swift.syntaxtype.attribute.builtin",
"offset" : 0,
"length" : 4
},
{
"type" : "source.lang.swift.syntaxtype.keyword",
"offset" : 5,
"length" : 3
},
{
"type" : "source.lang.swift.syntaxtype.identifier",
"offset" : 9,
"length" : 6
},
{
"type" : "source.lang.swift.syntaxtype.identifier",
"offset" : 18,
"length" : 6
}
]
I want to write a swiftlint rule for restricting unowned usages.
Any help is appreciated. Thanks in advance!
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the two sourcekitten syntax --text capture-list examples and compare them with the weak var and unowned var outputs in the issue. Determine whether the requested outcome is syntax classification support or usage guidance for SwiftLint; the issue does not identify files, tests, or a defined completion criterion.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- swift
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100