From 4b4c358c006b8046a589316da070ac6fd95589f5 Mon Sep 17 00:00:00 2001 From: Peter Aronsson Date: Mon, 24 Apr 2006 06:52:36 +0000 Subject: [PATCH] Implemented getDocumentationAnnotation. git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@2340 f25d12d1-65f4-0310-ae8a-bbce733d8d8e --- Compiler/Interactive.mo | 176 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 176 insertions(+) diff --git a/Compiler/Interactive.mo b/Compiler/Interactive.mo index 37576bef13d..9cc6e2eeb5c 100644 --- a/Compiler/Interactive.mo +++ b/Compiler/Interactive.mo @@ -1378,6 +1378,14 @@ algorithm then (resstr,st); + case (ISTMTS(interactiveStmtLst = {IEXP(exp = Absyn.CALL(function_ = Absyn.CREF_IDENT(name = "getDocumentationAnnotation"),functionArgs = Absyn.FUNCTIONARGS(args = {Absyn.CREF(componentReg = cr)})))}),(st as SYMBOLTABLE(ast = p,explodedAst = s,instClsLst = ic,lstVarVal = iv,compiledFunctions = cf))) + local Absyn.Path path; + equation + path = Absyn.crefToPath(cr); + resstr = getDocumentationAnnotation(path, p); + then + (resstr,st); + case (ISTMTS(interactiveStmtLst = {IEXP(exp = Absyn.CALL(function_ = Absyn.CREF_IDENT(name = "getPackages"),functionArgs = Absyn.FUNCTIONARGS(args = {Absyn.CREF(componentReg = cr)})))}),(st as SYMBOLTABLE(ast = p,explodedAst = s,instClsLst = ic,lstVarVal = iv,compiledFunctions = cf))) local Absyn.Path path; equation @@ -10062,6 +10070,33 @@ algorithm end matchcontinue; end getDiagramAnnotation; +protected function getDocumentationAnnotation "function: getDocumentationAnnotation + + Thisfunction takes a Path and a Program and returns a comma separated + string of values for the Documentation annotation for the class named by the + first argument. +" + input Absyn.Path inPath; + input Absyn.Program inProgram; + output String outString; +algorithm + outString:= + matchcontinue (inPath,inProgram) + local + Absyn.Class cdef; + String str; + Absyn.Path modelpath; + Absyn.Program p; + case (modelpath,p) + equation + cdef = getPathedClassInProgram(modelpath, p); + str = getDocumentationAnnotationInClass(cdef); + then + str; + case (_,_) then "{}"; + end matchcontinue; +end getDocumentationAnnotation; + protected function getIconAnnotation "function: getIconAnnotation Thisfunction takes a Path and a Program and returns a comma separated string of values for the icon annotation for the class named by the @@ -10935,6 +10970,39 @@ algorithm end matchcontinue; end getDiagramAnnotationInClass; +protected function getDocumentationAnnotationInClass "function: getDocumentationAnnotationInClass + + Retrieve the documentation annotation as a string from the class passed as + argument. +" + input Absyn.Class inClass; + output String outString; +algorithm + outString:= + matchcontinue (inClass) + local + list publst,protlst,lst; + String str,res; + list parts; + list annlst; + case (Absyn.CLASS(body = Absyn.PARTS(classParts = parts))) + equation + publst = getPublicList(parts) "class def." ; + protlst = getProtectedList(parts); + lst = listAppend(publst, protlst); + str = getDocumentationAnnotationInElementitemlist(lst); + then + str; + case (Absyn.CLASS(body = Absyn.DERIVED(comment = SOME(Absyn.COMMENT(SOME(Absyn.ANNOTATION(annlst)),_))))) + equation + str = getDocumentationAnnotationStr(annlst); + res = Util.stringAppendList({"{",str,"}"}); + then + res; + case (_) then ""; + end matchcontinue; +end getDocumentationAnnotationInClass; + protected function getDiagramAnnotationInElementitemlist "function: getDiagramAnnotationInElementitemlist Retrieve the diagram annotation from an element item list passed as @@ -10965,6 +11033,37 @@ algorithm end matchcontinue; end getDiagramAnnotationInElementitemlist; +protected function getDocumentationAnnotationInElementitemlist "function: getDocumentationAnnotationInElementitemlist + + Retrieve the into annotation from an element item list passed as + argument. +" + input list inAbsynElementItemLst; + output String outString; +algorithm + outString:= + matchcontinue (inAbsynElementItemLst) + local + String s1,s2,str; + list annlst; + list xs; + case {} then ""; + case ((Absyn.ANNOTATIONITEM(annotation_ = Absyn.ANNOTATION(elementArgs = annlst)) :: _)) + equation + s1 = getDocumentationAnnotationStr(annlst); + s2 = stringAppend("{", s1); + str = stringAppend(s2, "}"); + then + str; + case ((_ :: xs)) + equation + str = getDocumentationAnnotationInElementitemlist(xs); + then + str; + end matchcontinue; +end getDocumentationAnnotationInElementitemlist; + + protected function getDiagramAnnotationStr "function: getDiagramAnnotationStr Helperfunction to get_diagram_anonotation_in_elementitemlist. @@ -10992,6 +11091,83 @@ algorithm end matchcontinue; end getDiagramAnnotationStr; +protected function getDocumentationAnnotationStr "function: getDocumentationAnnotationStr + + Helperfunction to getDocumentationAnnotationInElementitemlist. +" + input list inAbsynElementArgLst; + output String outString; +algorithm + outString:= + matchcontinue (inAbsynElementArgLst) + local + String str; + Absyn.ElementArg ann; + Option mod; + list xs; + case (((ann as Absyn.MODIFICATION(componentReg = Absyn.CREF_IDENT(name = "Documentation"),modification = mod)) :: _)) + equation + str = getDocumentationAnnotationString(mod); + then + str; + case ((_ :: xs)) + equation + str = getDocumentationAnnotationStr(xs); + then + str; + end matchcontinue; +end getDocumentationAnnotationStr; + +protected function getDocumentationAnnotationString + input Option mod; + output String docStr; +algorithm + docStr := matchcontinue (mod) + local list arglst; + case (SOME(Absyn.CLASSMOD(elementArgLst = arglst))) + local + list strs; + String s; + equation + strs = getDocumentationAnnotationString2(arglst); + s = Util.stringDelimitList(strs,","); + then s; + case (_) + then ""; + end matchcontinue; +end getDocumentationAnnotationString; + +protected function getDocumentationAnnotationString2 "Helper function to getDocumentationAnnotationString" + input list eltArgs; + output list strs; +algorithm + strs := matchcontinue (eltArgs) + local Absyn.Exp exp; + list xs; + case ({}) then {}; + case (Absyn.MODIFICATION(componentReg = Absyn.CREF_IDENT(name = "info"), + modification=SOME(Absyn.CLASSMOD(expOption=SOME(exp))))::xs) + local String s; list ss; + equation + s = Dump.printExpStr(exp); + ss = getDocumentationAnnotationString2(xs); + then s::ss; + + case (Absyn.MODIFICATION(componentReg = Absyn.CREF_IDENT(name = "revisions"), + modification=SOME(Absyn.CLASSMOD(expOption=SOME(exp))))::xs) + local String s; list ss; + equation + s = Dump.printExpStr(exp); + ss = getDocumentationAnnotationString2(xs); + then s::ss; + case (_::xs) + local list ss; + equation + ss = getDocumentationAnnotationString2(xs); + then ss; + end matchcontinue; +end getDocumentationAnnotationString2; + protected function getNthPublicConnectorStr "function: getNthPublicConnectorStr Helperfunction to get_nth_connector.