Opened 6 years ago
Closed 5 years ago
#5333 closed enhancement (fixed)
Autocompletion of annotations
Reported by: | Francesco Casella | Owned by: | Anatoly Trosinenko |
---|---|---|---|
Priority: | high | Milestone: | 1.14.0 |
Component: | OMEdit | Version: | |
Keywords: | Cc: | Adeel Asghar |
Description
When writing annotations, it would be really nice to have an autocompletion facility that shows all the available options. In particular, the capitalization of annotations doesn't really follow a consisten logic, some start with a capital letter, some with a small letter, so the autocompletion would help a lot avoiding mistakes, which are not caught by the compiler. For example, if I write
annotation(Experiment(stopTime = 3));
this is simply ignored by omc, but I don't get the intended behaviour.
Change History (21)
comment:1 by , 6 years ago
comment:3 by , 6 years ago
Implemented some working stub in https://github.com/OpenModelica/OMEdit/pull/219. To actually make it usable, it should be filled with actual annotations to complete.
comment:4 by , 6 years ago
Is OpenModelica/OMEdit repo archival "by design" or "by accident"? Now, I cannot even comment on already open PR.
comment:6 by , 6 years ago
Use this https://github.com/OpenModelica/OpenModelica/pull/115 from now on.
follow-up: 8 comment:7 by , 6 years ago
Spotted a bug in implementation: suppose you type annotation(Ex
. It will suggest you experiment
but when selected, it produces annotation(Experiment(
(with capital letter E
).
comment:8 by , 6 years ago
Replying to atrosinenko:
Spotted a bug in implementation: suppose you type
annotation(Ex
. It will suggest youexperiment
but when selected, it producesannotation(Experiment(
(with capital letterE
).
Fixed in 3d25372/OpenModelica.
comment:10 by , 5 years ago
@casella and @atrosinenko is there something left for this ticket? I believe we can close this now.
follow-up: 12 comment:11 by , 5 years ago
I double checked what is available now:
- I started writing a new model
- I wrote
annotation(
and hit Ctrl-space: a list of the available annotation popped up; unfortunately, it also contains items that don't belong there, such asComplex
,Modelica
etc. - if I select, e.g.,
experiment
and then hit Ctrl-space again, I get lots of irrelevant items, but not the relevant ones, such asStartTime
,StopTime
etc.
I think some further refinements are needed before we can consider this feature complete.
comment:12 by , 5 years ago
Replying to casella:
I double checked what is available now:
- I started writing a new model
- I wrote
annotation(
and hit Ctrl-space: a list of the available annotation popped up; unfortunately, it also contains items that don't belong there, such asComplex
,Modelica
etc.
@atrosinenko can we filter out the loaded classes when we are inside an annotation?
- if I select, e.g.,
experiment
and then hit Ctrl-space again, I get lots of irrelevant items, but not the relevant ones, such asStartTime
,StopTime
etc.
This should work with c4d95ff/OpenModelica. The AutoCompletion
package was not part of the new frontend.
I think some further refinements are needed before we can consider this feature complete.
comment:13 by , 5 years ago
@atrosinenko can we filter out the loaded classes when we are inside an annotation?
Probably yes. I would like to examine this tomorrow.
comment:14 by , 5 years ago
Could be tested in https://github.com/OpenModelica/OpenModelica/pull/386. There, an annotation is considered closed primarily when parentheses nesting goes to zero or ';' is encountered. When in an unclosed annotation, only annotations are suggested.
comment:17 by , 5 years ago
Looks quite good. As far as I understand, there are still three things missing:
- the
derivative
annotation (see section 12.7.1 of the Specification) - the __OpenModelica_commandLineOptions annotation
- the __OpenModelica_simulationFlags annotation
follow-up: 19 comment:18 by , 5 years ago
Yes we can add them to the ModelicaBuiltin.mo,
record derivative Integer order = 1; String noDerivative; String zeroDerivative; end derivative; record __OpenModelica_commandLineOptions end __OpenModelica_commandLineOptions; record __OpenModelica_simulationFlags end __OpenModelica_simulationFlags;
The list of options for __OpenModelica_commandLineOptions
and __OpenModelica_simulationFlags
are huge and is not recommended to add such annotations manually.
comment:19 by , 5 years ago
Replying to adeas31:
Yes we can add them to the ModelicaBuiltin.mo,
record derivative Integer order = 1; String noDerivative; String zeroDerivative; end derivative; record __OpenModelica_commandLineOptions end __OpenModelica_commandLineOptions; record __OpenModelica_simulationFlags end __OpenModelica_simulationFlags;
OK.
The list of options for
__OpenModelica_commandLineOptions
and__OpenModelica_simulationFlags
are huge and is not recommended to add such annotations manually.
Agreed.
comment:21 by , 5 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Works like a charm. Thanks @atrosinenko and @adeas31 for implementing this nice feature!
We should check the annotations for errors, should be rather easy to do with the NF.