ek9_organize_references

Deletes the unused entries of one file's 'references' block (usage judged by a scratch compile, so functions, types and name-collisions are all right) and answers the editor envelope: status (applied | ready | error), written, edits[] - one delete per unused line - and summary; an already-clean file is applied with empty edits[].

Category: Editor · Compare: Optimize Imports (IntelliJ) / Remove Unused Imports

When to use it

'Remove the references this file no longer uses' is one call: {file:'x.ek9'} - the remove-only half of ek9_sync_references (its addMissing:false).

When not to use it

Details

Detection is compiler-driven and cascade-safe: a scratch compile with the whole block deleted pre-filters the definitely-used names, then each remaining candidate is confirmed by deleting only its line and checking the error count doesn't rise (a cascade-masked-but-used reference is kept). Immune to case conventions and name collisions; degrades to a lexer name-heuristic (over-retains, never wrongly deletes) when no scratch compile can run. Never returns status:'conflicts'; interleaved comments and kept entries are preserved exactly (targeted per-line delete).

Arguments

ArgumentTypeRequiredWhat it is
filestringyesThe .ek9 source file whose references block to trim - workspace-relative (absolute inside the workspace accepted).

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.

No references block noop

Request

{
  "file" : "Hello.ek9"
}

Response

{
  "conflicts" : [ ],
  "edits" : [ ],
  "meta" : {
    "serverMs" : "<timing>"
  },
  "risk" : {
    "crossesModuleBoundary" : false,
    "estimatedSeverity" : "trivial",
    "fileCount" : 0,
    "lineCount" : 0,
    "touchesPublicApi" : false,
    "touchesTests" : false
  },
  "status" : "applied",
  "summary" : "No references block in Hello.ek9 — nothing to remove",
  "workspaceHash" : "<workspace-hash>",
  "wouldBeDiagnostics" : [ ],
  "written" : true
}

Unused reference removed

Request

{
  "file" : "main.ek9"
}

Response

{
  "conflicts" : [ ],
  "edits" : [ {
    "before" : "    org.lib::bar",
    "endLine" : 5,
    "file" : "main.ek9",
    "startLine" : 5,
    "type" : "delete"
  } ],
  "meta" : {
    "serverMs" : "<timing>"
  },
  "risk" : {
    "crossesModuleBoundary" : false,
    "estimatedSeverity" : "trivial",
    "fileCount" : 1,
    "lineCount" : 1,
    "touchesPublicApi" : false,
    "touchesTests" : false
  },
  "status" : "applied",
  "summary" : "Removed 1 unused reference(s) from main.ek9",
  "workspaceHash" : "<workspace-hash>",
  "wouldBeDiagnostics" : [ ],
...

Cut short here: 2 more lines. The whole recorded call.

See also