Skip to content

Commit

Permalink
Revert "Merge array bindings in AbsynUtil.mergeAnnotations (#12249)" (#…
Browse files Browse the repository at this point in the history
…12253)

This reverts commit dcdcb56.
  • Loading branch information
perost committed Apr 16, 2024
1 parent e1464fb commit 497739f
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 83 deletions.
46 changes: 0 additions & 46 deletions OMCompiler/Compiler/FrontEnd/AbsynUtil.mo
Expand Up @@ -4003,7 +4003,6 @@ algorithm
try
mod2 := List.find(res, function isModificationOfPath(path=p));
mod1 := subModsInSameOrder(mod2, mod);
mod1 := mergeAnnotationEqMod(mod2, mod1);
(res, true) := List.replaceOnTrue(mod1, res, function isModificationOfPath(path=p));
else
res := mod::res;
Expand All @@ -4012,51 +4011,6 @@ algorithm
res := listReverse(res);
end mergeAnnotations2;

function mergeAnnotationEqMod
input Absyn.ElementArg oldMod;
input output Absyn.ElementArg newMod;
protected
Absyn.Modification mod1, mod2;
algorithm
() := match (oldMod, newMod)
case (Absyn.ElementArg.MODIFICATION(modification = SOME(mod1)),
Absyn.ElementArg.MODIFICATION())
algorithm
if isSome(newMod.modification) then
SOME(mod2) := newMod.modification;
mod2.eqMod := mergeAnnotationEqMod2(mod1.eqMod, mod2.eqMod);
newMod.modification := SOME(mod2);
else
newMod.modification := SOME(mod1);
end if;
then
();

else ();
end match;
end mergeAnnotationEqMod;

function mergeAnnotationEqMod2
input Absyn.EqMod oldEqMod;
input output Absyn.EqMod newEqMod;
protected
Absyn.Exp e1, e2;
algorithm
newEqMod := match (oldEqMod, newEqMod)
// Special merging rule for annotations, concatenate array bindings
// (such as Diagram(graphics = {...})).
case (Absyn.EqMod.EQMOD(exp = e1 as Absyn.Exp.ARRAY()),
Absyn.EqMod.EQMOD(exp = e2 as Absyn.Exp.ARRAY()))
algorithm
newEqMod.exp := Absyn.Exp.ARRAY(listAppend(e1.arrayExp, e2.arrayExp));
then
newEqMod;

case (_, Absyn.EqMod.EQMOD()) then newEqMod;
else oldEqMod;
end match;
end mergeAnnotationEqMod2;

public function mergeCommentAnnotation
"Merges an annotation into a Absyn.Comment option."
input Absyn.Annotation inAnnotation;
Expand Down
5 changes: 3 additions & 2 deletions testsuite/openmodelica/diff/AddClassAnnotation1.mos
Expand Up @@ -24,8 +24,9 @@ answer := "model M1
Line(points={{-60,50},{60,50}}, color={0,0,255}),
Line(points={{0,90},{0,50}}, color={0,0,255})}),
Diagram(coordinateSystem(
preserveAspectRatio=false, extent = {{-100, -100}, {100, 100}, {-100, -100}, {100, 100}}, initialScale = 0.1, grid = {2, 2}), graphics={
Line(points={{-60,50},{60,50}}, color={0,0,255}), Line(points = {{-60, 50}, {60, 50}}, color = {0, 0, 255}), Rectangle(origin = {-30, -43}, extent = {{-74, 49}, {74, -49}})}));
preserveAspectRatio=false,
extent={{-100,-100},{100,100}}, initialScale = 0.1, grid = {2, 2}), graphics={
Line(points={{-60,50},{60,50}}, color={0,0,255}), Rectangle(origin = {-30, -43}, extent = {{-74, 49}, {74, -49}})}));
end M1;";
s2 := listFile(M1);
s3 := diffModelicaFileListings(s1, s2, OpenModelica.Scripting.DiffFormat.plain);
Expand Down
12 changes: 6 additions & 6 deletions testsuite/openmodelica/interactive-API/AddClassAnnotation.mos
Expand Up @@ -48,10 +48,10 @@ getIconAnnotation(EB);
// true
// true
// true
// {-,-,-,-,-,-,-,,{Polygon(true, {0.0, 0.0}, 0.0, {0, 0, 127}, {0, 0, 127}, LinePattern.Solid, FillPattern.Solid, 0.25, {{-100.0, 100.0}, {100.0, 0.0}, {-100.0, -100.0}}, Smooth.None), Polygon(true, {0.0, 0.0}, 0.0, {0, 0, 127}, {0, 0, 127}, LinePattern.Solid, FillPattern.Solid, 0.25, {{0.0, 50.0}, {100.0, 0.0}, {0.0, -50.0}, {0.0, 50.0}}, Smooth.None), Rectangle(true, {0.0, 0.0}, 0.0, {0, 0, 255}, {0, 0, 255}, LinePattern.Solid, FillPattern.None, 0.25, BorderPattern.None, {{-100.0, 100.0}, {100.0, -100.0}}, 0.0)}}
// {-,-,-,-,-,-,-,,{Polygon(true, {0.0, 0.0}, 0.0, {0, 0, 127}, {0, 0, 127}, LinePattern.Solid, FillPattern.Solid, 0.25, {{0.0, 50.0}, {100.0, 0.0}, {0.0, -50.0}, {0.0, 50.0}}, Smooth.None), Rectangle(true, {0.0, 0.0}, 0.0, {0, 0, 255}, {0, 0, 255}, LinePattern.Solid, FillPattern.None, 0.25, BorderPattern.None, {{-100.0, 100.0}, {100.0, -100.0}}, 0.0)}}
// {-,-,-,-,-,-,-,,{Polygon(true, {0.0, 0.0}, 0.0, {0, 0, 127}, {0, 0, 127}, LinePattern.Solid, FillPattern.Solid, 0.25, {{-100.0, 100.0}, {100.0, 0.0}, {-100.0, -100.0}}, Smooth.None), Polygon(true, {0.0, 0.0}, 0.0, {0, 0, 127}, {0, 0, 127}, LinePattern.Solid, FillPattern.Solid, 0.25, {{0.0, 50.0}, {100.0, 0.0}, {0.0, -50.0}, {0.0, 50.0}}, Smooth.None), Rectangle(true, {0.0, 0.0}, 0.0, {0, 0, 255}, {0, 0, 255}, LinePattern.Solid, FillPattern.None, 0.25, BorderPattern.None, {{-100.0, 100.0}, {100.0, -100.0}}, 0.0)}}
// {-,-,-,-,-,-,-,,{Polygon(true, {0.0, 0.0}, 0.0, {0, 0, 127}, {0, 0, 127}, LinePattern.Solid, FillPattern.Solid, 0.25, {{0.0, 50.0}, {100.0, 0.0}, {0.0, -50.0}, {0.0, 50.0}}, Smooth.None), Rectangle(true, {0.0, 0.0}, 0.0, {0, 0, 255}, {0, 0, 255}, LinePattern.Solid, FillPattern.None, 0.25, BorderPattern.None, {{-100.0, 100.0}, {100.0, -100.0}}, 0.0)}}
// {-,-,-,-,-,-,-,,{Polygon(true, {0.0, 0.0}, 0.0, {0, 0, 127}, {0, 0, 127}, LinePattern.Solid, FillPattern.Solid, 0.25, {{-100.0, 100.0}, {100.0, 0.0}, {-100.0, -100.0}}, Smooth.None), Polygon(true, {0.0, 0.0}, 0.0, {0, 0, 127}, {0, 0, 127}, LinePattern.Solid, FillPattern.Solid, 0.25, {{0.0, 50.0}, {100.0, 0.0}, {0.0, -50.0}, {0.0, 50.0}}, Smooth.None), Rectangle(true, {0.0, 0.0}, 0.0, {0, 0, 255}, {0, 0, 255}, LinePattern.Solid, FillPattern.None, 0.25, BorderPattern.None, {{-100.0, 100.0}, {100.0, -100.0}}, 0.0)}}
// {-,-,-,-,-,-,-,,{Polygon(true, {0.0, 0.0}, 0.0, {0, 0, 127}, {0, 0, 127}, LinePattern.Solid, FillPattern.Solid, 0.25, {{0.0, 50.0}, {100.0, 0.0}, {0.0, -50.0}, {0.0, 50.0}}, Smooth.None), Rectangle(true, {0.0, 0.0}, 0.0, {0, 0, 255}, {0, 0, 255}, LinePattern.Solid, FillPattern.None, 0.25, BorderPattern.None, {{-100.0, 100.0}, {100.0, -100.0}}, 0.0)}}
// {-,-,-,-,-,-,-,,{Polygon(true, {0.0, 0.0}, 0, {0, 0, 127}, {0, 0, 127}, LinePattern.Solid, FillPattern.Solid, 0.25, {{0, 50}, {100, 0}, {0, -50}, {0, 50}}, Smooth.None), Rectangle(true, {0.0, 0.0}, 0, {0, 0, 255}, {0, 0, 255}, LinePattern.Solid, FillPattern.None, 0.25, BorderPattern.None, {{-100, 100}, {100, -100}}, 0)}}
// {-,-,-,-,-,-,-,,{Polygon(true, {0.0, 0.0}, 0, {0, 0, 127}, {0, 0, 127}, LinePattern.Solid, FillPattern.Solid, 0.25, {{0, 50}, {100, 0}, {0, -50}, {0, 50}}, Smooth.None), Rectangle(true, {0.0, 0.0}, 0, {0, 0, 255}, {0, 0, 255}, LinePattern.Solid, FillPattern.None, 0.25, BorderPattern.None, {{-100, 100}, {100, -100}}, 0)}}
// {-,-,-,-,-,-,-,,{Polygon(true, {0.0, 0.0}, 0, {0, 0, 127}, {0, 0, 127}, LinePattern.Solid, FillPattern.Solid, 0.25, {{0, 50}, {100, 0}, {0, -50}, {0, 50}}, Smooth.None), Rectangle(true, {0.0, 0.0}, 0, {0, 0, 255}, {0, 0, 255}, LinePattern.Solid, FillPattern.None, 0.25, BorderPattern.None, {{-100, 100}, {100, -100}}, 0)}}
// {-,-,-,-,-,-,-,,{Polygon(true, {0.0, 0.0}, 0, {0, 0, 127}, {0, 0, 127}, LinePattern.Solid, FillPattern.Solid, 0.25, {{0, 50}, {100, 0}, {0, -50}, {0, 50}}, Smooth.None), Rectangle(true, {0.0, 0.0}, 0, {0, 0, 255}, {0, 0, 255}, LinePattern.Solid, FillPattern.None, 0.25, BorderPattern.None, {{-100, 100}, {100, -100}}, 0)}}
// {-,-,-,-,-,-,-,,{Polygon(true, {0.0, 0.0}, 0, {0, 0, 127}, {0, 0, 127}, LinePattern.Solid, FillPattern.Solid, 0.25, {{0, 50}, {100, 0}, {0, -50}, {0, 50}}, Smooth.None), Rectangle(true, {0.0, 0.0}, 0, {0, 0, 255}, {0, 0, 255}, LinePattern.Solid, FillPattern.None, 0.25, BorderPattern.None, {{-100, 100}, {100, -100}}, 0)}}
// {-,-,-,-,-,-,-,,{Polygon(true, {0.0, 0.0}, 0, {0, 0, 127}, {0, 0, 127}, LinePattern.Solid, FillPattern.Solid, 0.25, {{0, 50}, {100, 0}, {0, -50}, {0, 50}}, Smooth.None), Rectangle(true, {0.0, 0.0}, 0, {0, 0, 255}, {0, 0, 255}, LinePattern.Solid, FillPattern.None, 0.25, BorderPattern.None, {{-100, 100}, {100, -100}}, 0)}}
// endResult
1 change: 0 additions & 1 deletion testsuite/openmodelica/interactive-API/Makefile
Expand Up @@ -79,7 +79,6 @@ ListExpressions.mos \
ListImport.mos \
ListMultilineComment.mos \
loadClassContentString1.mos \
loadClassContentString2.mos \
loadFileInteractiveQualified.mos \
matrices.mos \
Modelica.Media.Examples.getComponents.mos \
Expand Down
Expand Up @@ -139,19 +139,19 @@ getClassNames(B, includeConstants=true);
// Integer x = 33;
// Real z;
// annotation(
// Icon(graphics = {Line(points = {{0, 0}, {100, 100}}), Line(color = {127, 127, 127}, arrow = {Arrow.None, Arrow.Open}, points = {{-50, -50}, {50, 50}, {100, 0}, {0, 100}})}),
// Icon(graphics = {Line(color = {127, 127, 127}, arrow = {Arrow.None, Arrow.Open}, points = {{-50, -50}, {50, 50}, {100, 0}, {0, 100}})}),
// Diagram(graphics = {Line(color = {127, 127, 127}, arrow = {Arrow.None, Arrow.Open}, points = {{-50, -50}, {50, 50}, {100, 0}, {0, 100}})}),
// Documentation(info = \"<HTML>foo</HTML>\", revisions = \"1.0\"));
// end test;
// end A;"
// Evaluating: getErrorString()
// ""
// Evaluating: getIconAnnotation(A.test)
// {-,-,-,-,-,-,-,,{Line(true, {0.0, 0.0}, 0.0, {{0.0, 0.0}, {100.0, 100.0}}, {0, 0, 0}, LinePattern.Solid, 0.25, {Arrow.None, Arrow.None}, 3.0, Smooth.None), Line(true, {0.0, 0.0}, 0.0, {{-50.0, -50.0}, {50.0, 50.0}, {100.0, 0.0}, {0.0, 100.0}}, {127, 127, 127}, LinePattern.Solid, 0.25, {Arrow.None, Arrow.Open}, 3.0, Smooth.None)}}
// {-,-,-,-,-,-,-,,{Line(true, {0.0, 0.0}, 0, {{-50, -50}, {50, 50}, {100, 0}, {0, 100}}, {127, 127, 127}, LinePattern.Solid, 0.25, {Arrow.None, Arrow.Open}, 3, Smooth.None)}}
// Evaluating: getErrorString()
// ""
// Evaluating: getDiagramAnnotation(A.test)
// {-,-,-,-,-,-,-,,{Line(true, {0.0, 0.0}, 0.0, {{-50.0, -50.0}, {50.0, 50.0}, {100.0, 0.0}, {0.0, 100.0}}, {127, 127, 127}, LinePattern.Solid, 0.25, {Arrow.None, Arrow.Open}, 3.0, Smooth.None)}}
// {-,-,-,-,-,-,-,,{Line(true, {0.0, 0.0}, 0, {{-50, -50}, {50, 50}, {100, 0}, {0, 100}}, {127, 127, 127}, LinePattern.Solid, 0.25, {Arrow.None, Arrow.Open}, 3, Smooth.None)}}
// Evaluating: getErrorString()
// ""
// Evaluating: getDocumentationAnnotation(A.test)
Expand Down Expand Up @@ -218,19 +218,19 @@ getClassNames(B, includeConstants=true);
// Integer x = 33;
// Real z;
// annotation(
// Icon(graphics = {Line(points = {{0, 0}, {100, 100}}), Line(color = {127, 127, 127}, arrow = {Arrow.None, Arrow.Open}, points = {{-50, -50}, {50, 50}, {100, 0}, {0, 100}})}),
// Icon(graphics = {Line(color = {127, 127, 127}, arrow = {Arrow.None, Arrow.Open}, points = {{-50, -50}, {50, 50}, {100, 0}, {0, 100}})}),
// Diagram(graphics = {Line(color = {127, 127, 127}, arrow = {Arrow.None, Arrow.Open}, points = {{-50, -50}, {50, 50}, {100, 0}, {0, 100}})}),
// Documentation(info = \"<HTML>foo</HTML>\", revisions = \"1.0\"));
// end test;
// end A;"
// Evaluating: getErrorString()
// ""
// Evaluating: getIconAnnotation(A.test)
// {-10.0,-10.0,10.0,10.0,{Line(true, {{0.0, 0.0}, {100.0, 100.0}}, {0, 0, 0}, LinePattern.Solid, 0.25, {Arrow.None, Arrow.None}, 3.0, false), Line(true, {{-50.0, -50.0}, {50.0, 50.0}, {100.0, 0.0}, {0.0, 100.0}}, {127, 127, 127}, LinePattern.Solid, 0.25, {Arrow.None, Arrow.Open}, 3.0, false)}}
// {-10.0,-10.0,10.0,10.0,{Line(true, {{-50, -50}, {50, 50}, {100, 0}, {0, 100}}, {127, 127, 127}, LinePattern.Solid, 0.25, {Arrow.None, Arrow.Open}, 3.0, false)}}
// Evaluating: getErrorString()
// ""
// Evaluating: getDiagramAnnotation(A.test)
// {-100.0,-100.0,100.0,100.0,{Line(true, {{-50.0, -50.0}, {50.0, 50.0}, {100.0, 0.0}, {0.0, 100.0}}, {127, 127, 127}, LinePattern.Solid, 0.25, {Arrow.None, Arrow.Open}, 3.0, false)}}
// {-100.0,-100.0,100.0,100.0,{Line(true, {{-50, -50}, {50, 50}, {100, 0}, {0, 100}}, {127, 127, 127}, LinePattern.Solid, 0.25, {Arrow.None, Arrow.Open}, 3.0, false)}}
// Evaluating: getErrorString()
// ""
// Evaluating: getDocumentationAnnotation(A.test)
Expand Down
22 changes: 0 additions & 22 deletions testsuite/openmodelica/interactive-API/loadClassContentString2.mos

This file was deleted.

0 comments on commit 497739f

Please sign in to comment.