ek9_delete_file
Answers first: status (applied | ready | conflicts | would-fail), written and, on a refusal, referenceCount + referencingFiles[] before the per-site conflicts[]; edits[{file, type:delete, disposition}].
When to use it
You want whole files gone - path for one, paths:[...] for several deleted together (references between files of the set do not count). A .ek9 file is refused while files outside the set still reference its constructs, or while the workspace has compile errors (the check cannot be trusted) - force:true deletes anyway, with warnings for what breaks. The refusal lists the referencing files as referencingFiles.
When not to use it
- Deleting ONE construct inside a file that has others you keep - use
ek9_safe_delete(symbol:'Name', per-construct reference check). - Relocating rather than removing the file — use
ek9_move_file. - Only wanting to KNOW the reference impact without deleting — use
ek9_query_references. - Deleting a whole directory — use
ek9_delete_directory(this tool rejects directories).
Details
Give exactly one of path (one file) or paths (several, judged as one set: a reference from a file of the set is not external; without force nothing is deleted unless every file can go, and files[] says where each stands - ready, conflicts, unchecked, error). Paths must resolve inside the workspace root; directories are rejected — files only. With compile errors and force false a .ek9 delete is refused (status:error) - force:true deletes, warning 'force-delete-references-unchecked'. For .ek9 files a per-construct reference sweep (same-file refs excluded) yields status:'conflicts' (kind 'file-has-external-references', with referenceCount and referencingFiles first) when external refs exist and force is false, or status:'would-fail' on a forced dry-run with wouldBeDiagnostics kind 'broken-reference-after-force-delete' (one per site); non-.ek9 files delete directly with no check. useTrash=true routes via the OS trash when supported, else falls back to permanent deletion with a 'trash-unsupported-fell-back-to-permanent' warning — otherwise deletion is irreversible unless version-controlled.
Arguments
| Argument | Type | Required | What it is |
|---|---|---|---|
force | boolean | When false (default), the .ek9 reference check refuses deletion if workspace references point at constructs in the file. When true, the deletion proceeds REGARDLESS of references — the response includes warnings listing every reference that will fail to resolve. Also deletes while the workspace has compile errors (the reference check cannot be trusted), with a warning saying so. | |
path | string | File path: workspace-relative (preferred) or absolute inside the workspace. Must exist and be a file (directories: ek9_delete_directory). Give path or paths, not both. | |
paths | array of string | Several files to delete TOGETHER, instead of path - each a file path, workspace-relative (preferred) or absolute inside the workspace. References between files of the set do not count; the answer has files[], one entry per file. | |
useTrash | boolean | When true AND the runtime supports trash semantics, the file is moved to the OS trash rather than permanently deleted. Falls back to permanent deletion with a warning otherwise. |
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. 3 of the 5 recorded are shown.
Delete non ek9 file apply
Request
{
"path" : "NOTES.txt"
}
Response
{
"conflicts" : [ ],
"edits" : [ {
"disposition" : "permanent",
"file" : "NOTES.txt",
"type" : "delete"
} ],
"meta" : {
"serverMs" : "<timing>"
},
"risk" : {
"crossesModuleBoundary" : false,
"estimatedSeverity" : "trivial",
"fileCount" : 1,
"lineCount" : 0,
"touchesPublicApi" : false,
"touchesTests" : false
},
"status" : "applied",
"summary" : "Deleted NOTES.txt",
"workspaceHash" : "<workspace-hash>",
"wouldBeDiagnostics" : [ ],
"written" : true
}
Delete set mutual references ready
Request
{
"dryRun" : true,
"paths" : [ "greeting.ek9", "printer.ek9" ]
}
Response
{
"conflicts" : [ ],
"edits" : [ {
"disposition" : "permanent",
"externalReferenceCount" : 0,
"file" : "greeting.ek9",
"type" : "delete"
}, {
"disposition" : "permanent",
"externalReferenceCount" : 0,
"file" : "printer.ek9",
"type" : "delete"
} ],
"files" : [ {
"file" : "greeting.ek9",
"status" : "ready",
"summary" : "Would delete greeting.ek9"
}, {
"file" : "printer.ek9",
"status" : "ready",
"summary" : "Would delete printer.ek9"
} ],
"meta" : {
"serverMs" : "<timing>"
...
Cut short here: 15 more lines. The whole recorded call.
Delete set force with compile errors applied
Request
{
"force" : true,
"paths" : [ "broken.ek9", "NOTES.txt" ]
}
Response
{
"conflicts" : [ ],
"edits" : [ {
"disposition" : "permanent",
"externalReferenceCount" : 0,
"file" : "broken.ek9",
"type" : "delete"
}, {
"disposition" : "permanent",
"file" : "NOTES.txt",
"type" : "delete"
} ],
"files" : [ {
"file" : "broken.ek9",
"status" : "applied",
"summary" : "Deleted broken.ek9"
}, {
"file" : "NOTES.txt",
"status" : "applied",
"summary" : "Deleted NOTES.txt"
} ],
"meta" : {
"serverMs" : "<timing>"
},
...
Cut short here: 18 more lines. The whole recorded call.
See also
- Show me in the IDE: New EK9 File, New Directory, Delete File, Delete Directory