Who Implements This Interface
Ask drag-lint for an interface and it lists every class that implements it, how it does so, and which method answers each interface method, resolution clauses and implements delegation included. A call through the interface is reported once, against the interface member, not spread over every class that might answer it.
The implementors report is new in drag-lint 1.40.0-alpha. Every output below is real output of the 1.40.0-alpha build, run on the small fixture shown in section 01.
Interfaces are how a large Delphi code base keeps its parts apart. Micronite, the quality and production-control software we build for manufacturers, uses them in a lot of places, and “which class actually runs when this is called?” kept coming up in code review. The IDE's search finds the text IJob. It does not tell you that a class implements IJob through an ancestor, or that a method has a different name because of a resolution clause.
Five ways to answer one interface
One interface, a derived interface and five classes. Each class reaches IJob by a different route:
IJob = interface
procedure Execute;
function Name: string;
end;
IRetryJob = interface(IJob)
procedure Retry;
end;
TPlainJob = class(TInterfacedObject, IJob) // lists it
TNightlyJob = class(TPlainJob) // inherits it; overrides Execute
TRetryJob = class(TInterfacedObject, IRetryJob) // via the derived interface
TRenamedJob = class(TInterfacedObject, IJob)
procedure IJob.Execute = RunJob; // resolution clause
TJobHost = class(TInterfacedObject, IJob)
property Inner: IJob read FInner implements IJob; // delegation
A second unit calls the interface: for Job in pJobs do begin Writeln(Job.Name); Job.Execute; end;
Who implements it, and how
drag-lint implementors --target IJob --db jobs.sqlite
uJobs.IJob (interface, uJobs.pas:6)
implementors (5):
TJobHost (delegated Inner) uJobs.pas:42
TNightlyJob (inherited TPlainJob) uJobs.pas:23
TPlainJob (lists) uJobs.pas:17
TRenamedJob (lists) uJobs.pas:35
TRetryJob (via IRetryJob) uJobs.pas:28
TNightlyJob never mentions IJob, and TRetryJob names only IRetryJob. Both are found, and the report says why each one counts.
Which method answers IJob.Execute
drag-lint implementors --target IJob.Execute --db jobs.sqlite
uJobs.IJob.Execute (interface-method, uJobs.pas:8)
implementors (5):
TJobHost (delegated Inner; answered by the object the property returns) uJobs.pas:46
TNightlyJob TNightlyJob.Execute (inherited TPlainJob) uJobs.pas:25 body :60
TPlainJob TPlainJob.Execute (lists) uJobs.pas:19 body :51
TRenamedJob TRenamedJob.RunJob (lists; resolution clause (Execute = RunJob)) uJobs.pas:38 body :79
TRetryJob TRetryJob.Execute (via IRetryJob) uJobs.pas:30 body :65
sites (1, attributed to the interface member per RB-5):
uRunner.pas:19 call in uRunner.RunAll
Three details matter here. For TNightlyJob the answer is its own override, not the ancestor's method. For TRenamedJob the answer is RunJob, because of the resolution clause. For TJobHost there is no method at all: the object the Inner property returns answers the call. Each row gives the declaration line and the line of the body.
The same question for IJob.Name shows the inherited case the other way round. TNightlyJob does not override Name, so its row names TPlainJob.Name:
TNightlyJob TPlainJob.Name (inherited TPlainJob) uJobs.pas:20 body :55
One call, one answer
Job.Execute in uRunner is a call to IJob.Execute, and the report files it there, once. It is not copied onto each of the five methods that could run, which would make five methods look called when the index cannot know which object is in Job at run time. To see the calls from the other side, ask for an implementing method with --uses:
drag-lint implementors --target TRenamedJob.RunJob --uses --db jobs.sqlite
uJobs.TRenamedJob.RunJob (method, uJobs.pas:38)
interface members it answers (1):
IJob.Execute TRenamedJob.RunJob (lists) uJobs.pas:38 body :79
sites (1, reaching it through the interface):
uRunner.pas:19 call in uRunner.RunAll via IJob.Execute
drag-lint query find-callers --name RunJob finds one name-only hit, the resolution clause on line 37 itself. The real call in uRunner never names RunJob. It reaches it only through IJob.Execute.
A class works as a target too. It lists the interfaces the class implements, inherited ones included, and what answers each member:
drag-lint implementors --target TRenamedJob --db jobs.sqlite
uJobs.TRenamedJob (class, uJobs.pas:35)
interface members answered (2):
IJob.Execute TRenamedJob.RunJob (lists; resolution clause (Execute = RunJob)) uJobs.pas:38 body :79
IJob.Name TRenamedJob.Name (lists) uJobs.pas:39 body :83
One engine, several doors
- RAD Studio: drag-lint > Reports > Who implements this interface (implementors)... draws the same report as a chart you can click. The editor shows
[N implementors]beside[N callers]. - VS Code or any LSP client: Go to Implementation on an interface lists its classes. On an interface method it jumps to the answering method of each class. A code lens reads “N implementors”.
- Agents: the MCP tool
get_implementorsreturns the--jsonform (implementors/1). - Diagrams:
--format dotor--format mermaid. The mermaid output forIJobstarts like this:
flowchart LR
n_uJobs_IJob["uJobs.IJob (interface)"]
n_uJobs_TJobHost["TJobHost"]
n_uJobs_IJob -->|delegated| n_uJobs_TJobHost
n_uJobs_TNightlyJob["TNightlyJob"]
n_uJobs_IJob -->|inherited| n_uJobs_TNightlyJob
Honest edges
- It reads the index. A class added since the last reindex is not listed yet. The IDE and the language server reindex on save.
- Re-index once. An index built before 1.40 has no delegation rows and points a resolution clause at the wrong row. One reindex fixes both.
- Library classes are counted, not listed, unless you ask. With
--library-dbthe report adds how many RTL or component classes implement the interface;--include-librarylists them. - Static, not run time. The report says which methods can answer a call. Which one does depends on the object, and the index cannot know that.