Opened 10 years ago
Closed 6 years ago
#3417 closed defect (invalid)
Create API updateClass for merging parsed AST with existing AST
| Reported by: | Adrian Pop | Owned by: | Adrian Pop |
|---|---|---|---|
| Priority: | blocker | Milestone: | 1.14.0 |
| Component: | Interactive Environment | Version: | trunk |
| Keywords: | Cc: | Adeel Asghar |
Description
When supporting #2905 we need to reload packages (package.mo) which would make the contents of the package vanish if we do not merge parsed AST with the existing AST.
Change History (10)
comment:1 by , 10 years ago
comment:2 by , 10 years ago
| Cc: | added |
|---|
I guess it would be something like parseFileAndMerge(file) which will take the AST of the file and merge it with the existing AST (already loaded ones). If the class parsed already exists in the loaded AST then the contents will be merged, not replaced.
So if you have A.B.C loaded and you reload B then C will still be in the AST.
comment:3 by , 10 years ago
| Milestone: | Future → 1.9.4 |
|---|---|
| Owner: | changed from to |
| Priority: | high → blocker |
| Status: | new → assigned |
comment:4 by , 10 years ago
| Status: | assigned → accepted |
|---|
Added support for this in 45515a6/OMCompiler.
Added test in 3539b9b/OpenModelica-testsuite.
Adapted OMEdit OMCProxy.cpp in b1c9a9e/OMEdit.
@adeas31, can you give it a try and see if it works fine?
Basically we have a new input for loadString(merge=false) which will merge the AST if merge=true, not replace it. Default merge=false.
comment:5 by , 10 years ago
| Resolution: | → fixed |
|---|---|
| Status: | accepted → closed |
comment:8 by , 6 years ago
| Milestone: | 1.9.4 → 1.14.0 |
|---|---|
| Resolution: | fixed |
| Status: | closed → reopened |
New issue shows up:
loadString("package P
model M end M;
end P;");
getErrorString();
getClassNames(P);
getErrorString();
loadString("package P
annotation();
end P;", merge=true);
getErrorString();
getClassNames(P);
getErrorString();
running this script looses model M :)
comment:9 by , 6 years ago
| Status: | reopened → accepted |
|---|
comment:10 by , 6 years ago
| Resolution: | → invalid |
|---|---|
| Status: | accepted → closed |
What it does is actually correct, it replaces the contents of the file containing P with the contents of the new file containing P. If M would have been loaded from another file than P then it would have been kept.

How is this something needed by #2905? Please provide an example of what the API needs to look like.