find-unit
Finds which indexed unit declares a symbol, and adds that unit to a file's uses clause.
Read this when a symbol is undeclared and you need the unit to add to uses. find-unit --name X --in file looks the declaring unit up in the index and can add it to the file (--apply, with a backup unless --no-backup).
How to run it
Full flag list: find-unit in the CLI reference.
Flags
| Flag | Argument | Meaning | Default |
|---|---|---|---|
--name | <Symbol> | ||
--in | <file> | ||
--json | |||
--apply | |||
--no-backup | |||
--db | <db> |
Where to click
- RAD Studio main menu: drag-lint > Uses & Dependencies > Find Unit for Symbol (add to uses)...
Needs: index
Pitfalls
- for an RTL/VCL/third-party X, point --db at the PLATFORM LIBRARY database (resolve-dbs --platform win64) -- a project DB holds only that project's units.
Details
Finds which indexed unit declares a symbol, and adds that unit to a file's
uses clause. Reach for it when a symbol is undeclared and you want the fix
looked up straight from the index.
Running it from the CLI
drag-lint find-unit --name <Symbol> --in <file> [--json|--apply|--no-backup] --db <db>
--name is the undeclared symbol; --in is the file to add the uses
entry to. --db is required (not bracketed in the usage line). The usage
line lists --apply as a flag; whether omitting it produces a dry run is
not documented in the help text for this verb.
Reaching it in the IDE
No IDE surface -- this is a CLI-only feature. It is NOT the same as the
IDE's Quick-Fix: Add Unit for Undeclared at Cursor (Ctrl+Alt+U).
The quick-fix parses a COMPILER DIAGNOSTIC, so it needs a prior build and a
message that already names the unit. find-unit --name <Symbol> answers
straight from the index instead, with no prior compile and no existing
diagnostic message required -- it is strictly more capable here.
What it needs
An index IS required. The project's DB lives at
<project folder>\_D-RAG\<project file>.sqlite; run
drag-lint resolve-dbs --project <X.dproj> if unsure.
Example
Illustrative:
drag-lint find-unit --name TStringList --in C:\Projects\MyApp\Unit1.pas --apply --db C:\Projects\MyApp\_D-RAG\MyApp.sqlite
This would look up which indexed unit declares TStringList and add it to
Unit1.pas's uses clause.