Skip to content

Commit

Permalink
Always dump extends as array in getModelInstance (#9741)
Browse files Browse the repository at this point in the history
  • Loading branch information
perost committed Nov 23, 2022
1 parent ba26732 commit acf5a61
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 72 deletions.
18 changes: 5 additions & 13 deletions OMCompiler/Compiler/Script/NFApi.mo
Expand Up @@ -981,11 +981,7 @@ algorithm
json := JSON.addPairNotNull("prefixes", dumpJSONClassPrefixes(def), json);

if not listEmpty(exts) then
if InstNode.isDerivedClass(node) then
json := JSON.addPair("extends", dumpJSONExtends(listHead(exts)), json);
else
json := JSON.addPair("extends", dumpJSONExtendsList(exts), json);
end if;
json := JSON.addPair("extends", dumpJSONExtendsList(exts), json);
end if;

json := dumpJSONCommentOpt(cmt, node, json);
Expand Down Expand Up @@ -1020,15 +1016,11 @@ algorithm
exts := ClassTree.getExtends(Class.classTree(InstNode.getClass(node)));

if not arrayEmpty(exts) then
if InstNode.isDerivedClass(node) then
j := dumpJSONInstanceIconExtends(exts[1]);
else
j := JSON.emptyArray();
j := JSON.emptyArray();

for ext in exts loop
j := JSON.addElement(dumpJSONInstanceIconExtends(ext), j);
end for;
end if;
for ext in exts loop
j := JSON.addElement(dumpJSONInstanceIconExtends(ext), j);
end for;

json := JSON.addPair("extends", j, json);
end if;
Expand Down
17 changes: 4 additions & 13 deletions doc/instanceAPI/getModelInstance.schema.json
Expand Up @@ -67,19 +67,10 @@
},
"extends": {
"description": "The extends clauses in the class instance",
"oneOf": [
{
"description": "The extends clauses in a long class definition",
"type": "array",
"items": {
"$ref": "#/definitions/extends"
}
},
{
"description": "The extended class in a short class definition",
"$ref": "#/definitions/extends"
}
]
"type": "array",
"items": {
"$ref": "#/definitions/extends"
}
},
"components": {
"description": "The components in the class instance",
Expand Down
Expand Up @@ -43,9 +43,11 @@ getModelInstance(M, prettyPrint = true);
// \"$value\": \"\\\"Angle\\\"\"
// }
// },
// \"extends\": {
// \"baseClass\": \"Real\"
// },
// \"extends\": [
// {
// \"baseClass\": \"Real\"
// }
// ],
// \"source\": {
// \"filename\": \"<interactive>\",
// \"lineStart\": 3,
Expand Down
46 changes: 26 additions & 20 deletions testsuite/openmodelica/instance-API/GetModelInstanceDerived1.mos
Expand Up @@ -32,9 +32,11 @@ getErrorString();
// \"prefixes\": {
// \"direction\": \"input\"
// },
// \"extends\": {
// \"baseClass\": \"Real\"
// },
// \"extends\": [
// {
// \"baseClass\": \"Real\"
// }
// ],
// \"source\": {
// \"filename\": \"<interactive>\",
// \"lineStart\": 2,
Expand All @@ -52,25 +54,29 @@ getErrorString();
// \"modifiers\": {
// \"start\": \"1.0\"
// },
// \"extends\": {
// \"baseClass\": {
// \"name\": \"RealInput\",
// \"restriction\": \"type\",
// \"prefixes\": {
// \"direction\": \"input\"
// },
// \"extends\": {
// \"baseClass\": \"Real\"
// },
// \"source\": {
// \"filename\": \"<interactive>\",
// \"lineStart\": 2,
// \"columnStart\": 3,
// \"lineEnd\": 2,
// \"columnEnd\": 30
// \"extends\": [
// {
// \"baseClass\": {
// \"name\": \"RealInput\",
// \"restriction\": \"type\",
// \"prefixes\": {
// \"direction\": \"input\"
// },
// \"extends\": [
// {
// \"baseClass\": \"Real\"
// }
// ],
// \"source\": {
// \"filename\": \"<interactive>\",
// \"lineStart\": 2,
// \"columnStart\": 3,
// \"lineEnd\": 2,
// \"columnEnd\": 30
// }
// }
// }
// },
// ],
// \"source\": {
// \"filename\": \"<interactive>\",
// \"lineStart\": 3,
Expand Down
46 changes: 26 additions & 20 deletions testsuite/openmodelica/instance-API/GetModelInstanceDerived2.mos
Expand Up @@ -21,9 +21,11 @@ getModelInstance(RealInput2, true); getErrorString();
// \"prefixes\": {
// \"direction\": \"input\"
// },
// \"extends\": {
// \"baseClass\": \"Real\"
// },
// \"extends\": [
// {
// \"baseClass\": \"Real\"
// }
// ],
// \"source\": {
// \"filename\": \"<interactive>\",
// \"lineStart\": 2,
Expand All @@ -39,25 +41,29 @@ getModelInstance(RealInput2, true); getErrorString();
// \"modifiers\": {
// \"start\": \"1.0\"
// },
// \"extends\": {
// \"baseClass\": {
// \"name\": \"RealInput\",
// \"restriction\": \"type\",
// \"prefixes\": {
// \"direction\": \"input\"
// },
// \"extends\": {
// \"baseClass\": \"Real\"
// },
// \"source\": {
// \"filename\": \"<interactive>\",
// \"lineStart\": 2,
// \"columnStart\": 3,
// \"lineEnd\": 2,
// \"columnEnd\": 30
// \"extends\": [
// {
// \"baseClass\": {
// \"name\": \"RealInput\",
// \"restriction\": \"type\",
// \"prefixes\": {
// \"direction\": \"input\"
// },
// \"extends\": [
// {
// \"baseClass\": \"Real\"
// }
// ],
// \"source\": {
// \"filename\": \"<interactive>\",
// \"lineStart\": 2,
// \"columnStart\": 3,
// \"lineEnd\": 2,
// \"columnEnd\": 30
// }
// }
// }
// },
// ],
// \"source\": {
// \"filename\": \"<interactive>\",
// \"lineStart\": 3,
Expand Down
Expand Up @@ -40,9 +40,11 @@ getModelInstance(P.RealInput, prettyPrint=true);
// \"prefixes\": {
// \"direction\": \"input\"
// },
// \"extends\": {
// \"baseClass\": \"Real\"
// },
// \"extends\": [
// {
// \"baseClass\": \"Real\"
// }
// ],
// \"source\": {
// \"filename\": \"<interactive>\",
// \"lineStart\": 7,
Expand Down

0 comments on commit acf5a61

Please sign in to comment.