Search code examples
jsonmatlabmethodscustomizationcode-completion

Custom code completion for class methods?


In MATLAB, it is possible to define code suggestions and completions as explained in the documentation page titled "Customize Code Suggestions and Completions".

The snippets given therein, e.g.

{
  "_schemaVersion": "1.0.0",
  "anotherFunc":
  {
     "inputs":
     [
        {"name":"input1",  "kind":"required", "type":["numeric"]},
        {"name":"input2",  "kind":"required", "type":["numeric"]}
     ]
  }
}

show how we can control the predictions of functions found (presumably) in separate files in the same folder as functionSignatures.json.

Suppose I have a method called myMethod which resides in a class called myClass. Creating a JSON as above with "myMethod" instead of "anotherFunc" didn't seem to have an effect.

My question is - how can we define completions for class methods using this technique?


Solution

  • After some trial and error, it appears that the prediction/completion logic expects to see syntax like:

    "myClass.myMethod"
    

    In other words, this should work:

    {
      "_schemaVersion": "1.0.0",
      "myClass.myMethod":
      {
         "inputs":
         [
            ...
         ]
      }
    }