Skip to content

Commit 2d700ff

Browse files
adeas31OpenModelica-Hudson
authored andcommitted
Updated getClassInformation to get more information for OMEdit.
1 parent 3bfc949 commit 2d700ff

File tree

3 files changed

+56
-5
lines changed

3 files changed

+56
-5
lines changed

Compiler/FrontEnd/ModelicaBuiltin.mo

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3620,6 +3620,8 @@ function getClassInformation
36203620
output Boolean fileReadOnly;
36213621
output Integer lineNumberStart, columnNumberStart, lineNumberEnd, columnNumberEnd;
36223622
output String dimensions[:];
3623+
output Boolean isProtectedClass;
3624+
output Boolean isDocumentationClass;
36233625
external "builtin";
36243626
annotation(
36253627
Documentation(info="<html>

Compiler/Script/CevalScriptBackend.mo

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -823,7 +823,8 @@ algorithm
823823

824824
case (cache,_,"getClassInformation",_,st,_)
825825
then (cache,Values.TUPLE({Values.STRING(""),Values.STRING(""),Values.BOOL(false),Values.BOOL(false),Values.BOOL(false),Values.STRING(""),
826-
Values.BOOL(false),Values.INTEGER(0),Values.INTEGER(0),Values.INTEGER(0),Values.INTEGER(0),Values.ARRAY({},{0})}),st);
826+
Values.BOOL(false),Values.INTEGER(0),Values.INTEGER(0),Values.INTEGER(0),Values.INTEGER(0),Values.ARRAY({},{0}),
827+
Values.BOOL(false),Values.BOOL(false)}),st);
827828

828829
case (cache,_,"diffModelicaFileListings",{Values.STRING(s1),Values.STRING(s2),Values.ENUM_LITERAL(name=path)},(st as GlobalScript.SYMBOLTABLE(ast = p)),_)
829830
algorithm
@@ -5147,17 +5148,25 @@ protected function getClassInformation
51475148
output Values.Value res_1;
51485149
protected
51495150
String name,file,strPartial,strFinal,strEncapsulated,res,cmt,str_readonly,str_sline,str_scol,str_eline,str_ecol;
5150-
String dim_str;
5151-
Boolean partialPrefix,finalPrefix,encapsulatedPrefix,isReadOnly;
5151+
String dim_str,lastIdent;
5152+
Boolean partialPrefix,finalPrefix,encapsulatedPrefix,isReadOnly,isProtectedClass,isDocClass;
51525153
Absyn.Restriction restr;
51535154
Absyn.ClassDef cdef;
5154-
Absyn.Class c;
51555155
Integer sl,sc,el,ec;
5156+
Absyn.Path classPath;
51565157
algorithm
51575158
Absyn.CLASS(name,partialPrefix,finalPrefix,encapsulatedPrefix,restr,cdef,SOURCEINFO(file,isReadOnly,sl,sc,el,ec,_)) := Interactive.getPathedClassInProgram(path, p);
51585159
res := Dump.unparseRestrictionStr(restr);
51595160
cmt := getClassComment(cdef);
51605161
file := Util.testsuiteFriendly(file);
5162+
if Absyn.pathIsIdent(Absyn.makeNotFullyQualified(path)) then
5163+
isProtectedClass := false;
5164+
else
5165+
lastIdent := Absyn.pathLastIdent(Absyn.makeNotFullyQualified(path));
5166+
classPath := Absyn.stripLast(path);
5167+
isProtectedClass := Interactive.isProtectedClass(classPath, lastIdent, p);
5168+
end if;
5169+
isDocClass := Interactive.getDocumentationClassAnnotation(path, p);
51615170
res_1 := Values.TUPLE({
51625171
Values.STRING(res),
51635172
Values.STRING(cmt),
@@ -5170,7 +5179,9 @@ algorithm
51705179
Values.INTEGER(sc),
51715180
Values.INTEGER(el),
51725181
Values.INTEGER(ec),
5173-
getClassDimensions(cdef)
5182+
getClassDimensions(cdef),
5183+
Values.BOOL(isProtectedClass),
5184+
Values.BOOL(isDocClass)
51745185
});
51755186
end getClassInformation;
51765187

Compiler/Script/Interactive.mo

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11919,6 +11919,44 @@ algorithm
1191911919
end matchcontinue;
1192011920
end getAnnotationStr;
1192111921

11922+
public function getDocumentationClassAnnotation
11923+
"Returns the documentation class annotation of a class.
11924+
This is annotated with the annotation:
11925+
annotation (DocumentationClass=true); in the class definition"
11926+
input Absyn.Path className;
11927+
input Absyn.Program p;
11928+
output Boolean isDocClass;
11929+
algorithm
11930+
isDocClass := match(className,p)
11931+
local
11932+
String docStr;
11933+
case(_,_)
11934+
equation
11935+
docStr = getNamedAnnotation(className,p,Absyn.IDENT("DocumentationClass"),SOME("false"),getDocumentationClassAnnotationModStr);
11936+
then
11937+
stringEq(docStr, "true");
11938+
end match;
11939+
end getDocumentationClassAnnotation;
11940+
11941+
protected function getDocumentationClassAnnotationModStr
11942+
"Extractor function for DocumentationClass"
11943+
input Option<Absyn.Modification> mod;
11944+
output String docStr;
11945+
algorithm
11946+
docStr := matchcontinue(mod)
11947+
local Absyn.Exp e;
11948+
11949+
case(SOME(Absyn.CLASSMOD(eqMod = Absyn.EQMOD(exp=e))))
11950+
equation
11951+
docStr = Dump.printExpStr(e);
11952+
then
11953+
docStr;
11954+
11955+
else "false";
11956+
11957+
end matchcontinue;
11958+
end getDocumentationClassAnnotationModStr;
11959+
1192211960
protected function getDefaultComponentName
1192311961
"Returns the default component name of a class.
1192411962
This is annotated with the annotation:

0 commit comments

Comments
 (0)