ek9_implement_methods

Inserts an 'override' stub for every abstract trait method the class has not implemented; answers status and edits[] (one INSERT block), or an error carrying the resolutions[] a concrete-diamond collision needs.

Category: Editor · Compare: Implement Methods (IntelliJ)

When to use it

'Implement every missing trait method on Order' is one call with symbol:'Order' - no file, line or mode needed. Use it when a CLASS declares traits (`with trait of X, Y`) and its unimplemented abstract trait methods should be stubbed in one batch.

When not to use it

Details

Every generated stub carries `override` (trait methods are never bare, per E05120); an all-abstract multi-trait collision auto-resolves to a single override, while a concrete diamond (at least one trait supplies a BODY) makes stubs mode return status:error with a ready-to-edit resolutions[] payload — retry with resolutions[], each picking source 'trait:<Name>' (delegate to that body; rejected if that trait declares it abstract) or 'override' (your own stub, whose //AI: lead names the trait bodies to combine). An already-implemented method is a no-op with EMPTY edits[] — never a conflicts status. would-fail = a generated stub references an unresolvable type; errors on non-class targets (record/trait/component/enum).

Arguments

ArgumentTypeRequiredWhat it is
filestringThe EK9 source file - OPTIONAL when symbol is a construct name; required to anchor on a member or a use site.
lineinteger1-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).
membersarray of anyOptional - only implement these methods (each must be an unimplemented trait method). A name gets a placeholder body; {name, statements:[...]} is written WITH that body, so one call implements the trait. Omit to implement all outstanding with placeholders.
modestring: stubs | conflict-resolutionOptional: stubs (the default - placeholder bodies for every outstanding method) or conflict-resolution (inferred whenever resolutions[] is sent).
resolutionsarray of objectOne {methodName, source} per conflicting method; source is 'trait:<TraitName>' or 'override'. Sending it selects conflict-resolution mode.
symbolstringA 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. 3 of the 12 recorded are shown.

Non class target refused

Request

{
  "file" : "shapes.ek9",
  "line" : 6,
  "mode" : "stubs"
}

Response

{
  "conflicts" : [ ],
  "edits" : [ ],
  "error" : {
    "message" : "Cannot implement methods on a trait — applies to classes only"
  },
  "meta" : {
    "serverMs" : "<timing>"
  },
  "status" : "error",
  "summary" : "Cannot implement methods on a trait — applies to classes only",
  "wouldBeDiagnostics" : [ ],
  "written" : false
}

Invalid trait delegation

Request

{
  "file" : "widgets.ek9",
  "line" : 16,
  "mode" : "conflict-resolution",
  "resolutions" : [ {
    "methodName" : "label",
    "source" : "trait:Named"
  } ]
}

Response

{
  "conflicts" : [ ],
  "edits" : [ ],
  "error" : {
    "message" : "Resolution 'trait:Named' for 'label' is invalid — every trait declares label() abstract — use source 'override'"
  },
  "meta" : {
    "serverMs" : "<timing>"
  },
  "status" : "error",
  "summary" : "Resolution 'trait:Named' for 'label' is invalid — every trait declares label() abstract — use source 'override'",
  "wouldBeDiagnostics" : [ ],
  "written" : false
}

No outstanding methods

Request

{
  "file" : "shapes.ek9",
  "line" : 12,
  "mode" : "stubs"
}

Response

{
  "conflicts" : [ ],
  "edits" : [ ],
  "meta" : {
    "serverMs" : "<timing>"
  },
  "resolvedPath" : "<workspace-root>/shapes.ek9",
  "risk" : {
    "crossesModuleBoundary" : false,
    "estimatedSeverity" : "trivial",
    "fileCount" : 0,
    "lineCount" : 0,
    "touchesPublicApi" : false,
    "touchesTests" : false
  },
  "status" : "applied",
  "summary" : "All trait methods on Square are already implemented; no insertions made",
  "workspaceHash" : "<workspace-hash>",
  "wouldBeDiagnostics" : [ ],
  "written" : true
}

See also