From df135a63665ab17667ee8f7ccd4d24c480d31b8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Per=20=C3=96stlund?= Date: Wed, 6 Sep 2023 15:04:28 +0200 Subject: [PATCH] Fix InteractiveUtil.getPathedElementInProgram for builtins (#11131) - Retry the lookup in the builtin environment if the element isn't found among the userdefined elements. --- OMCompiler/Compiler/Script/InteractiveUtil.mo | 6 +++++- testsuite/openmodelica/interactive-API/getClassComment.mos | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/OMCompiler/Compiler/Script/InteractiveUtil.mo b/OMCompiler/Compiler/Script/InteractiveUtil.mo index af9487d6bf1..056b455de7d 100644 --- a/OMCompiler/Compiler/Script/InteractiveUtil.mo +++ b/OMCompiler/Compiler/Script/InteractiveUtil.mo @@ -4633,7 +4633,11 @@ public function getPathedElementInProgram protected Absyn.Class cls; algorithm - cls := getClassInProgram(AbsynUtil.pathFirstIdent(path), program); + try + cls := getClassInProgram(AbsynUtil.pathFirstIdent(path), program); + else + cls := getClassInProgram(AbsynUtil.pathFirstIdent(path), FBuiltin.getInitialFunctions()); + end try; if AbsynUtil.pathIsIdent(path) then // Since the program only stores classes instead of elements we have to diff --git a/testsuite/openmodelica/interactive-API/getClassComment.mos b/testsuite/openmodelica/interactive-API/getClassComment.mos index 357a4436d70..97da34b8cd6 100644 --- a/testsuite/openmodelica/interactive-API/getClassComment.mos +++ b/testsuite/openmodelica/interactive-API/getClassComment.mos @@ -23,6 +23,7 @@ getClassComment(P.M2); getClassComment(P.M3); getClassComment(P.M); getClassComment(P.ME); +getClassComment(OpenModelica.Scripting.loadFile); // Result: // true @@ -32,4 +33,5 @@ getClassComment(P.ME); // "After constraint" // "M comment" // "ME comment" +// "load file (*.mo) and merge it with the loaded AST." // endResult