-
Couldn't load subscription status.
- Fork 174
ModelicaReference: add AutoCompletion subpackage #2837
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
ModelicaReference/package.mo
Outdated
| package AutoCompletion "Auto completion information for Modelica IDEs" | ||
| package Annotations "Auto completion information on annotations" | ||
| record experiment "Define default experiment parameters" | ||
| Real StartTime(unit = "s") "Default start time of simulation"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of hardcoding the unit here it should be using the proper type Modelica.SIunits.Time instead of Real. Same for the rest.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a little bit weird actually. Because ModelicaReference does not depend on the standard library. So I think it's correct to define it as Real with a unit set manually...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. Didn't think about that.
ModelicaReference/package.mo
Outdated
| Real Tolerance(min = 0) "Default relative integration tolerance"; | ||
| end experiment; | ||
| annotation( | ||
| Documentation(info = "<html><head></head><body>In this package annotations are gathered in their record-like form together with meta information such as descriptions, units, min, max, etc.</body></html>")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove superfluous <head> and <body> tags.
f74f5c3 to
c7020c1
Compare
|
Fixed tags, restored |
|
I'm not sure if this fits into ModelicaReference at the moment (there is some old MCP(s) about standardizing annotations as Modelica code - which has been inactive for quite some time). The leads to the second part: if it weren't in ModelicaReference - but somewhere else - the unit-dependency would also be a non-issue. |
|
I think the ModelicaReference is a good place for all existing, standardised, annotations. But I would not want them duplicated. So if the existing documentation could be combined with the type then I think it would be a nice enhancement. I can not see a problem in changing the existing class experiment "experiment"
extends ModelicaReference.Icons.Information;
annotation ();
end experiment;to record experiment "experiment"
extends ModelicaReference.Icons.Information;
Real StartTime(unit = "s") "Default start time of simulation";
Real StopTime(unit = "s") "Default stop time of simulation";
Real Interval(unit = "s", min = 0) "Resolution for the result grid";
Real Tolerance(unit = "1", min = 0) "Default relative integration tolerance";
annotation ();
end experiment; |
|
Agree, duplicating is bad, I thought it is inherently user-readable docs, but I have not noticed it can be naturally combined. |
|
Hmm, I realized why description == name -- it is viewed better in doc browser then. Is it necessary to have some short summaries at all (in some "strict" machine readable form, that is, not "the first paragraph if it is HTML, otherwise the first string, or maybe something else...") or always show the full HTML description (it would probably be useful for the user). |
|
Could you rephrase that? I'm not sure I understand what you mean. |
I agree that duplication within ModelicaReference would be bad. It is possible that ModelicaReference is a good place for the annotations in this form, but I'm not certain. My issue is that we will try to do two things with one class and that it may create conflicting requirements; not only for this class - but also e.g., for marking which classes are relevant in this way. Maybe that is not a problem in practice - I don't know. |
|
@dietmarw I tried first to ask whether I need |
|
@HansOlsson my original thoughts were:
Some random thoughts:
|
|
Another thought: maybe user-accessible Modelica package would encourage more people to contribute to this machine-readable documentation (as well as will be easily browsable source of "textbook-form" annotation descriptions) but another separate root package may clutter package tree in editor. |
|
In order to move forward. Any problem to add the annotations as I suggested? |
To start with, add an experiment annotation as an example.
c7020c1 to
432058a
Compare
|
Refactored as suggested. I just waited a bit to collect different opinions. For now, refactored only single annotation, so I can support this and see how it would behave. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Technically the PR contains correct information.
But I'm unsure if we want it. On one hand it is a good idea to have annotations defined using code - making them clearer.
On the other hand it is not clear if it will solve the original issue (auto-completion in OMEdit), since vendor-annotations are missing and I assume they are useful for this (e.g. to set solver method); and we also have the conflicting idea of having a special "documentation class" replacing "class" and now suddenly experiment is a "record".
Looking through the rest of ModelicaReference.Annotations I notice that only this one, Dialog, and Documentation could have contents defined in this way. (And some that are missing.)
However, I also noticed that absoluteValue, choicesAllMatching, dateModified, defaultComponentName, defaultComponentPrefixes, defaultConnectionStructurallyInconsistent, DocumentationClass, Evaluate, HideResult, InlineAfterIndexReduction, LateInline, ... are all attributes that could be defined using primitive types, similarly as the contents of this annotation. (There are some more complicated ones like choices, derivative, DynamicSelect, and Inverse.)
I don't know how to define e.g. "Boolean absoluteValue;" as an annotation for components in a good way - or even if we should, but I believe we should consider that before adding this. Obviously obsolete and preferredView require special care - since the class defining the obsolete-annotation isn't obsolete itself.
|
There is one technology that I would like to promote whenever I hear auto-completion or syntax-highlight and it is the Language Server Protocol (LSP)! LSP was inventend and open-sourced by Microsoft for Visual Studio Code for offering advanced IDE features (as the mentioned ones, but also go to definition, type checking, linting, code folding, find usage, prettyprint etc). LSP is a protocol for communication between an editor/IDE and a language server. On the editor side it is supported by Visual Studio Code, emacs, Sublime, Atom, Eclipse and many others. On the language side, there are servers for most of the popular languages (C++, Python, Go, Rust...). But, there is no language server yet for Modelica! Most of the features required like parsing a library are implemented in each tool, Dymola, OpenModelica, JModelica..., so in my naive view, implementing a Modelica language server would be a somewhat low hanging fruit!? Read more about LSP here: See some nice animated gifs of LSP in action here: |
I even tried to implement it in Scala with OMC as a backend (at the first glance, it seemed the simplest solution to me), but stumbled upon LSP support in different editors (or probably my implementation was broken, but diagnostic in tools was quite poor -- most probably I was doing something wrong...). If this does matter, it was about half-a-year ago. |
|
Based on the feedback until now it really turns into a tool specific problem. And unless a complete solution based on Modelica syntax is presented and can be evaluated as replacing (parts) of ModelicaReference I can only agree with @HansOlsson that ModelicaReference is not the right place (yet). @atrosinenko I suggest you continue with |
Sounds good to me. |


To start with, add an experiment annotation as an example, so one can debug this feature and extend it separately.
This PR is related to OpenModelica/OMEdit#219 and is based on already existing text in this repo, as well as a Modelica Standard. Unfortunately, this will probably be partial copy-paste of
ModelicaReference.Annotationsinstead of plain its usage, since descriptions there are more standard-related and human-readable than machine-readable formal record-like form.Another idea, is to gather there documentation on the keywords, too, to not hardcode it in the IDE code.