ek9_pull_up

Moves the named methods/operators from a subclass into its superclass, dropping 'override' on the moved declarations; answers status and edits[] (one DELETE per member + one INSERT on the superclass).

Category: Editor · Compare: Pull Members Up (IntelliJ)

When to use it

'Move describe() from Circle up to its superclass' is one call with symbol:'Circle', members:['describe'] - no file or line needed; the superclass comes from the 'extends' clause. Use it when a subclass member belongs on the parent (siblings duplicate it, or the abstraction was authored one level too low).

When not to use it

Details

V1: to the superclass only, with subclass and superclass declared in the SAME file — a trait target, cross-file targets and fields are follow-ups and return status:error today. The superclass must already be 'as open' / 'as abstract'; this tool does not add it — chain ek9_make_open first. An unopened superclass (E05030), a member referencing subclass-only state, a name collision on the superclass, or a sibling now shadowing without override (E05120) are caught by the scratch-compile would-fail gate.

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 stringyesNames of methods/operators on the subclass to pull up. Operators use their symbol form (e.g. '==', '<=>').
superclassstringOptional — the superclass name. When omitted it is resolved from the subclass's 'extends' clause; when supplied it is validated against that superclass.
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 6 recorded are shown.

No superclass error

Request

{
  "file" : "solo.ek9",
  "line" : 6,
  "members" : [ "label" ]
}

Response

{
  "conflicts" : [ ],
  "edits" : [ ],
  "error" : {
    "message" : "'Solo' has no superclass to pull up to — it does not 'extends' a parent class"
  },
  "meta" : {
    "serverMs" : "<timing>"
  },
  "status" : "error",
  "summary" : "'Solo' has no superclass to pull up to — it does not 'extends' a parent class",
  "wouldBeDiagnostics" : [ ],
  "written" : false
}

Member not found error

Request

{
  "file" : "hierarchy.ek9",
  "line" : 10,
  "members" : [ "nope" ]
}

Response

{
  "conflicts" : [ ],
  "edits" : [ ],
  "error" : {
    "message" : "Member 'nope' is not a method/operator of Child (fields are not yet supported by this tool)"
  },
  "meta" : {
    "serverMs" : "<timing>"
  },
  "status" : "error",
  "summary" : "Member 'nope' is not a method/operator of Child (fields are not yet supported by this tool)",
  "wouldBeDiagnostics" : [ ],
  "written" : false
}

Dirty overlay divergent

Request

{
  "dirtyOverlay" : [ {
    "content" : "#!ek9\ndefines module demo.pullup\n\n  defines class\n\n    Parent as open\n      id as Integer: 0\n      label()\n        <- rtn as String: \"hi\"\n      default operator ?\n\n    Child extends Parent\n\n//EOF\n",
    "file" : "hierarchy.ek9"
  } ],
  "dryRun" : true,
  "file" : "hierarchy.ek9",
  "line" : 12,
  "members" : [ "label" ]
}

Response

{
  "conflicts" : [ ],
  "edits" : [ ],
  "error" : {
    "message" : "Member 'label' is not a method/operator of Child (fields are not yet supported by this tool)"
  },
  "meta" : {
    "serverMs" : "<timing>"
  },
  "status" : "error",
  "summary" : "Member 'label' is not a method/operator of Child (fields are not yet supported by this tool)",
  "wouldBeDiagnostics" : [ ],
  "written" : false
}

See also