Opened 9 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 Martin Sjölund, 9 years ago

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

comment:2 by Adrian Pop, 9 years ago

Cc: Adeel Asghar 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 Francesco Casella, 9 years ago

Milestone: Future1.9.4
Owner: changed from somebody to Adrian Pop
Priority: highblocker
Status: newassigned

comment:4 by Adrian Pop, 9 years ago

Status: assignedaccepted

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

Resolution: fixed
Status: acceptedclosed

comment:6 by Martin Sjölund, 9 years ago

Milestone: 1.9.41.9.4-1.9.x

Milestone renamed

comment:7 by Martin Sjölund, 9 years ago

Milestone: 1.9.4-1.9.x1.9.4

Milestone renamed

comment:8 by Adrian Pop, 6 years ago

Milestone: 1.9.41.14.0
Resolution: fixed
Status: closedreopened

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

Status: reopenedaccepted

comment:10 by Adrian Pop, 6 years ago

Resolution: invalid
Status: acceptedclosed

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.

Note: See TracTickets for help on using tickets.