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 Adrian Pop, 6 years ago

We should check the annotations for errors, should be rather easy to do with the NF.

comment:2 by Francesco Casella, 6 years ago

Good point, I just opened #5334 on this topic.

comment:3 by Anatoly Trosinenko, 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 Anatoly Trosinenko, 6 years ago

Is OpenModelica/OMEdit repo archival "by design" or "by accident"? Now, I cannot even comment on already open PR.

comment:5 by Adeel Asghar, 6 years ago

OMEdit is moved to OpenModelica git repository.

comment:7 by Anatoly Trosinenko, 5 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).

in reply to:  7 comment:8 by Adeel Asghar, 5 years ago

Replying to atrosinenko:

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).

Fixed in 3d25372/OpenModelica.

comment:9 by Anatoly Trosinenko, 5 years ago

Thanks!

comment:10 by Adeel Asghar, 5 years ago

@casella and @atrosinenko is there something left for this ticket? I believe we can close this now.

comment:11 by Francesco Casella, 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 as Complex, 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 as StartTime, StopTime etc.

I think some further refinements are needed before we can consider this feature complete.

in reply to:  11 comment:12 by Adeel Asghar, 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 as Complex, 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 as StartTime, 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 Anatoly Trosinenko, 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 Anatoly Trosinenko, 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:15 by Adeel Asghar, 5 years ago

@casella this is ready for testing again.

comment:16 by Francesco Casella, 5 years ago

I'll check that with tomorrow's nightly build

comment:17 by Francesco Casella, 5 years ago

Looks quite good. As far as I understand, there are still three things missing:

comment:18 by Adeel Asghar, 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.

in reply to:  18 comment:19 by Francesco Casella, 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:20 by Adeel Asghar, 5 years ago

comment:21 by Francesco Casella, 5 years ago

Resolution: fixed
Status: newclosed

Works like a charm. Thanks @atrosinenko and @adeas31 for implementing this nice feature!

Note: See TracTickets for help on using tickets.