Query syntax

A query is predicates on the parts of a declaration. Braces step into a part, and every predicate inside one pair of braces is tested against thesame part — so param{ label:completion is:sendable } is one parameter that is both, not two parameters that are one each.

Grammar

field:value
A predicate. Values run to the next space or bracket — selector:initWithFrame: and qname:Swift.Array need no quotes.
word
Free text: names by relevance, by camel-case part (table cell finds UITableViewCell) and by prefix.
scope{ … }
Step into a part. An empty thrown means the part exists.
is:flag
A flag of the current part (is:static, is:sendable) or its kind (is:func, is:protocol).
a b · a AND b · a & b
Both.
a | b · a OR b
Either.
-a · !a · NOT a
Not. Inside a scope, param{ -is:escaping } is a parameter that is not escaping; outside, -param{ is:escaping } is no escaping parameter at all.
( … )
Grouping, at any level.

Values

name:View
Exact, case-insensitive.
name:*Delegate
Wildcards: * and ?.
name:"table view"
A phrase of camel-case parts.
name:~cell
Contains the part “cell”.
name:/UI.*Cell/
A regular expression over the whole value.
pos:>1 · pos:1..3
Numbers compare and take ranges.

Type patterns

Shorthand fields — returns:, takes:, where:, mentions:, and like: on any type — take a Swift type with holes, and expand to the structural query you would otherwise write by hand.

_
Any type.
$T
A variable: the same type everywhere $T appears in the query.
Name · Module.Name · *Delegate
A type by name. * is a wildcard.
Name<A, _>
Generic arguments, in order.
T? · [T] · [K: V]
Optional, Array and Dictionary, written either way.
(A, b: B) · () · Void
A tuple, with labels; the empty tuple.
@Sendable (A) async throws -> R
A function type. Attributes, effects, labels and the number of parameters all count; (...) leaves the parameters open.
some P & Q · any P · T.Type
Opaque, existential and metatype.

Variables

req{ subject{ $T } constraint{ name:Hashable } } param{ type{ $T } } is one type that is both constrained to Hashable and taken as a parameter. A variable binds to a node’s qualified type; under - it must already be bound.

Examples

At the top: a declaration

A declaration: a type, protocol, extension or category, or one of their members

FieldMeans
kind:struct, class, enum, actor, protocol, extension, category, func, init, var, subscript, case, field, associatedtype, typealias, deinit, method, property, ivar
lang:language:swift or objc
module:The image’s module: UIKitCore, SwiftUI
image:The image’s install path (wildcards welcome)
build:The OS build: 24A446
name:Bare name: body, initWithFrame:
qname:qualifiedName:Qualified name: SwiftUI.View.body
in:The enclosing container’s name
mod:modifier:modifiers:Keywords: static, final, override, mutating, nonatomic, copy, readonly, …
attr:attribute:attributes:@objc, @propertyWrapper, @resultBuilder, @globalActor, @retroactive, @Observable, …
accessor:get, set, modify, read, init
selector:sel:ObjC selector: initWithFrame:
encoding:ObjC type encoding
category:The class an ObjC category extends
conforms:conformsTo:The protocol a conformance extension conforms to
mangled:The Swift mangled name
vtable:A class method’s vtable offset
offset:A stored property’s or ivar’s byte offset: offset:>=0x40
size:A type’s instance size in bytes (Swift: computed statically; ObjC: instanceSize)
stride:A Swift type’s stride in bytes
align:A Swift type’s alignment in bytes
address:The implementation’s unslid address in the shared cache: address:0x1a93bf9c8
decl:signature:display:The declaration as written
returns:shorthandThe result matches a type pattern: returns:"some View", returns:Bool?
takes:shorthandSome parameter’s type matches a pattern: takes:"(Result<_, Error>) -> Void"
where:shorthandA generic requirement’s constraint matches: where:Hashable
mentions:shorthandThe type appears anywhere in the signature, at any depth: mentions:"[String: Any]"
actor:shorthandA closure in the signature is isolated to this global actor: actor:MainActor
conformsTo:shorthandA type or extension conforms to, inherits from or adopts: conformsTo:Sendable
FlagMeans
is:staticstatic / class member
is:exportedIts symbol is exported
is:overrideOverrides a superclass member
is:finalfinal
is:optionalAn @optional ObjC requirement
is:asyncasync
is:throwsthrows
is:containerA type, protocol, extension or category
is:memberA member of a container
is:swiftSwift
is:objcObjective-C
is:genericHas generic parameters
is:publicIn a public framework
is:safeCategoryPlaceholderAn accessibility bundle’s empty __FooAccessibility_super class: the placeholder FooAccessibility inherits from, re-pointed at Foo at load
is:accessibilityIn an accessibility bundle
is:privateIn a private framework
is:mainactorA closure in the signature is @MainActor (a method’s own isolation is not in the binary)
is:sendableClosureTakes a @Sendable closure
is:callbackTakes an escaping closure that returns Void — a completion handler
is:propertyA property: Swift var or field, or ObjC property
is:methodA method: Swift func or ObjC method
is:typeA type: struct, class, enum or actor (either language)
is:<kind>struct, class, enum, actor, protocol, extension, category, func, init, var, subscript, case, field, associatedtype, typealias, deinit, method, property, ivar
PartSteps into
param{}parameter{}params{}A parameter
req{}requirement{}where{}A generic requirement
generic{}A generic parameter
inherits{}super{}inherit{}conformances{}A superclass, adopted protocol or conformance
result{}returns{}value{}type{}The result: a function’s return type, a property’s or field’s type, an enum case’s payload
thrown{}The typed-throws error type
extends{}extended{}The type an extension or category extends
parent{}The enclosing container
any{}anywhere{}mentions{}Any type node anywhere in the signature

paramreached by param{}

A parameter of a function, initializer, subscript or method. Unknown fields apply to its type.

FieldMeans
pos:position:Position (0-based)
label:Argument label; for ObjC, the selector piece without its colon
name:The parameter’s own name (ObjC)
piece:ObjC selector piece: initWithFrame:
PartSteps into
type{}The parameter’s type

Fields and flags this part does not have apply to its type{}.

typereached by type{}child{}arg{}param{}returns{}thrown{}actor{}member{}base{}element{}deep{}subject{}constraint{}inherits{}result{}extends{}

A type: a node of a signature’s type tree

FieldMeans
kind:What the node is: nominal, genericParameter, associatedType, function, tuple, existential, opaque, metatype, pack, packExpansion, builtin, selfType, unknown
role:What the node is to its parent: genericArgument, parameter, result, thrownError, element, base, member, globalActor
pos:position:Position among siblings of the same role (0-based)
label:A closure parameter’s or tuple element’s label
name:Bare name: Array, A, Element, NSString
module:The module a nominal type is declared in
qname:qualifiedName:Qualified name: Swift.Array, Foundation.Data
nominal:nominalKind:A nominal’s kind: struct, class, enum, protocol, typealias, union
sugar:optional, array or dictionary when written with sugar
convention:A function type’s convention: block, c, thin
ownership:borrowing or consuming
attr:attribute:attributes:Attributes on the node: @Sendable, @escaping, @MainActor, nullable, …
pointers:Levels of * on an ObjC / C type
type:The type as written
like:shorthandThis node matches a type pattern: param{ like:"@escaping (Bool) -> Void" }
takes:shorthandA function type with a parameter matching a pattern
returns:shorthandA function type whose result matches a pattern
FlagMeans
is:sendable@Sendable function type
is:escaping@escaping function type
is:autoclosure@autoclosure
is:asyncasync function type
is:throwsthrowing function type
is:inoutinout parameter
is:variadicvariadic parameter
is:isolatedisolated parameter
is:sendingsending parameter
is:isolatedAny@isolated(any) function type
is:optionalOptional, written either way
is:genericA generic parameter
is:closureA function type of any convention
is:blockAn Objective-C block
is:<kind>nominal, genericParameter, associatedType, function, tuple, existential, opaque, metatype, pack, packExpansion, builtin, selfType, unknown, struct, class, enum, protocol, typealias, union
PartSteps into
child{}children{}Any direct child node
arg{}args{}argument{}A generic argument
param{}parameter{}params{}A function type’s parameter
returns{}A function type’s result
thrown{}A function type’s thrown error
actor{}A function type’s global actor
member{}members{}A protocol of an existential or opaque type
base{}What an associated type or metatype is reached from
element{}A tuple or pack element
deep{}descendant{}Any node below this one, at any depth

reqreached by req{}

A generic requirement (`where` clause). Unknown fields apply to its constraint.

FieldMeans
kind:conformance, superclass, sameType, layout, inverse, sameShape
layout:A layout requirement’s layout: AnyObject, _Trivial, …
text:The requirement as written: A: Hashable
FlagMeans
is:conformanceA: P
is:superclassA: SomeClass
is:sameTypeA.Element == B
is:layoutA: AnyObject
is:inverseA: ~Copyable
PartSteps into
subject{}The constrained side: A, A.Element
constraint{}The constraining side: the protocol, class or type

Fields and flags this part does not have apply to its constraint{}.

genericreached by generic{}

A generic parameter (the binary keeps no source names: A, B, A1, …)

FieldMeans
name:A, B, A1
depth:Nesting depth: 0 for the outermost generic context
index:Index within its depth
FlagMeans
is:ownDeclared by this declaration, not an enclosing one

parentreached by parent{}

The declaration’s enclosing container

FieldMeans
kind:struct, class, protocol, extension, category, …
name:UIView
qname:qualifiedName:SwiftUI.View

anywherereached by any{}

Any type node anywhere in the declaration’s signature

FieldMeans
kind:What the node is: nominal, genericParameter, associatedType, function, tuple, existential, opaque, metatype, pack, packExpansion, builtin, selfType, unknown
role:What the node is to its parent: genericArgument, parameter, result, thrownError, element, base, member, globalActor
label:A closure parameter’s or tuple element’s label
name:Bare name: Array, A, Element, NSString
module:The module a nominal type is declared in
qname:qualifiedName:Qualified name: Swift.Array, Foundation.Data
nominal:nominalKind:A nominal’s kind: struct, class, enum, protocol, typealias, union
attr:attribute:attributes:Attributes on the node: @Sendable, @escaping, @MainActor, nullable, …
type:The type as written
path:Where the node sits: parameters[0]/genericArgument[1], result, requirements[2]/constraint
depth:How deep below its tree’s root
FlagMeans
is:sendable@Sendable function type
is:escaping@escaping function type
is:asyncasync function type
is:throwsthrowing function type
is:inoutinout parameter
is:variadicvariadic parameter
is:genericA generic parameter
is:closureA function type of any convention
is:<kind>nominal, genericParameter, associatedType, function, tuple, existential, opaque, metatype, pack, packExpansion, builtin, selfType, unknown, struct, class, enum, protocol, typealias, union

Limits

  • The index maps type trees 5 levels deep. A query that reaches deeper, or uses a variable, is answered in two steps — the index narrows, then each candidate is checked exactly — and says so beside the count. It is exact, but a broad one may stop at its scan budget.
  • Binaries keep no generic parameter names: they are A, B, A1 by depth and position.
  • Not in the binary at all, so not searchable: a method’s own @MainActor (a closure type’s global actor is — actor:MainActor), @available, Swift parameter names, default argument values, doc comments.
  • Field offsets are computed statically and left out where a generic parameter’s layout moves them. ObjC ivar offsets come from class_ro_t; a Swift class’s ivars there are filled in at runtime and have none.