ek9_query_type_hierarchy
Answers first: subtypeNames (implementedBy on a trait), superNames, traitNames, allowedSubtypes for a sealed trait - complete workspace-wide - then the full graph.
When to use it
'Who extends or implements X, and what does X extend' is one call with symbol:'X' - no file needed; file + line only from an IDE cursor.
When not to use it
- the methods/operators callable on the type, not its ancestry (use
ek9_query_effective_api) - the structure (own fields/methods) of ONE construct, not the inheritance chain (use
ek9_query_construct) - details of a single symbol under the cursor, not the whole tree (use
ek9_inspect_symbol_at_cursor) - the API of a BUILT-IN language type (String, List, …) (use
ek9_help; this tool only walks workspace types)
Details
Hierarchy queries are meaningful only for CLASS, TRAIT, RECORD, COMPONENT; SERVICE/APPLICATION/PROGRAM/ENUMERATION return basic info with empty superChain/subtypes, and a location resolving to no aggregate type returns status:'not-found'. Two depth metrics: root-level `depth` is distance from the inheritance root DOWN to the queried type; each subtype's `depth` is distance FROM the queried type (1=direct child). `subtypes` holds ALL transitive descendants (counted by subtypeCount/summary.totalDescendants; summary.directSubtypes counts depth 1 only), plus isOpen (always) and, when applicable, transitive allTraits, sealed/allowedSubtypes/exhaustive, and generic markers.
Arguments
| Argument | Type | Required | What it is |
|---|---|---|---|
among | array of string | Names to answer FOR: 'which of these ...' - the name lists shrink to these and amongUnmatched names the ones that are not in the answer. Bare names, 'mod::Type' or 'Type.member'; a MODULE name stands for every construct in it ('which in scale.m07 do not ...' = amongUnmatched). | |
column | integer | 0-based char offset of the target identifier on 'line' (an IDE cursor). OMIT it and pass symbol:'<name>' instead, or omit both and the first identifier on the line is taken (right for a declaration line). Reuse a column from ek9_inspect_symbol_at_cursor verbatim. | |
file | string | The EK9 source file - OPTIONAL when symbol is a construct name; required to anchor on a member or a use site. | |
line | integer | 1-based line of the declaration or a reference - OMIT it and pass symbol:'<name>' to let the tool find the line (a model counting lines in a file miscounts); if you do count, use ek9_read_file(lineNumbers:true). | |
symbol | string | A construct NAME alone ('Shape', 'sample.deps.core::Validator') - no file needed, the tool finds it workspace-wide; or, with file (+ line), the identifier you mean there. |
It also takes the arguments every tool takes.
Recorded calls
Real calls, recorded against small projects and checked on every build - a changed answer fails it.
Type hierarchy shape
Request
{
"file" : "MyRecord.ek9",
"line" : 5
}
Response
{
"declaredAt" : {
"file" : "MyRecord.ek9",
"line" : 5
},
"depth" : 1,
"fullyQualifiedName" : "com.example::MyRecord",
"genus" : "RECORD",
"isOpen" : false,
"meta" : {
"serverMs" : "<timing>"
},
"name" : "MyRecord",
"status" : "ok",
"subtypeCount" : 0,
"subtypeNames" : [ ],
"subtypeNamesCover" : "every descendant workspace-wide, direct and indirect - nothing to verify",
"subtypes" : [ ],
"summary" : {
"directSubtypes" : 0,
"superDepth" : 1,
"totalDescendants" : 0,
"traitCount" : 0
},
...
Cut short here: 15 more lines. The whole recorded call.
See also
- Show me in the IDE: Chapter 20: a generic type, read
- Fixes E05030
- Fixes E05240
- Fixes E05250