Is it possible to annotate types so the tab completion works properly?

23 visualizzazioni (ultimi 30 giorni)
I'm working on a project in Matlab which is pretty large and has many objects and functions. Matlab isn't exactly the best language for object oriented programming but its what I have to work with so it is what it is.
When writing functions that work on objects obviously the IDE has absolutely no idea what is the class of the variables being passed in since Matlab is dynamically typed. This means that the tab completion has no way to poll properties and is fairly useless.
In Python which can have similar issues this is remidied by optional type "hints" you can write in code.
# Regular Python code
def square(x):
y = x**2
return y
# Hinted Python code
def hinted_square(x: int) -> int:
y = x**2
y: int
return y
This is used both by static analyzers, and many IDEs because it can now do tab completion as it knows what the types are.
I don't really care too much about static analysis, but it would be really nice if I could get tab completion to work so I'm wondering if there is anything equivalent for MATLAB.

Risposta accettata

Guillaume
Guillaume il 9 Lug 2019
Matlab a way to customise tab completion with the functionsignatures.json file.It's not particularly well documented and when I last tried it, it behaved inconsistently with class methods. I don't think I found a way to make it work with properties but I've never had enough time to investigate properly.
  2 Commenti
Jehanzeb Mirza
Jehanzeb Mirza il 9 Lug 2019
Modificato: Jehanzeb Mirza il 9 Lug 2019
Seems about what I was looking for, its a bit more convoluted than I'd like though.
Thanks!
Rik
Rik il 9 Lug 2019
I have also had some issues with it. I would agree with it being a bit more complicated than ideal, although I don't have a real solution either.

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Graphics Object Programming in Help Center e File Exchange

Prodotti


Release

R2019a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by