今天我們一樣還是透過 CursorInfo 查詢
並取得 key.annotated_decl
key.annotated_decl
但是,查詢對象改為 DispatchQueue.main.async
的 async
DispatchQueue.main.async { ... }
<Declaration>
func async(
group: <Type usr=\"c:objc(cs)OS_dispatch_group\">DispatchGroup</Type>? = nil,
qos: <Type usr=\"s:8Dispatch0A3QoSV\">DispatchQoS</Type> = .unspecified,
flags: <Type usr=\"s:8Dispatch0A13WorkItemFlagsV\">DispatchWorkItemFlags</Type> = [],
execute work: @escaping @convention(block) () -> <Type usr=\"s:s4Voida\">Void</Type>
)
</Declaration>
func async(
group: DispatchGroup? = nil,
qos: DispatchQos = .unspecified,
flags: DispatchWorkItemFlags = [],
execute work: @escaping @convention(block) () -> Void
)
透過解析 Function Call Expr
取得 last(index)
/first name
比較麻煩的是 closure 在 function call 會有三種表示方式。
async {}
async {
} label: {
}
async({})
trailing closure
args.last
labeled closure
args["label"]
normal closure
args["label"]
遇到無參數名稱,以及有預設值情況下難以判斷
於是我們再將定義拿去 visitor parse 一遍
func async(
group: DispatchGroup? = nil,
qos: DispatchQos = .unspecified,
flags: DispatchWorkItemFlags = [],
execute work: @escaping @convention(block) () -> Void
)
取得
trailing closure
execute
@escaping @convention(block) () -> Void
@escaping @convention(block) () -> Void
判斷目標:
@escaping
(() -> Void)
@convention(block)
)