Skip to content

Commit

Permalink
Fix for #3574.
Browse files Browse the repository at this point in the history
- Implement support for all kinds of classes in
  Interactive.addClassAnnotationToClass and
  Interactive.getAnnotationInClass.
  • Loading branch information
perost committed Nov 24, 2015
1 parent 2b1abe8 commit 13854c1
Show file tree
Hide file tree
Showing 3 changed files with 205 additions and 271 deletions.
57 changes: 48 additions & 9 deletions Compiler/FrontEnd/Absyn.mo
Expand Up @@ -4371,18 +4371,31 @@ public function setClassName "author: BZ
Sets the name of the class"
input Class inClass;
input String newName;
output Class outClass;
protected
Ident n;
Boolean p,f,e;
Restriction r;
ClassDef body;
Info info;
output Class outClass = inClass;
algorithm
CLASS(_, p, f, e, r, body, info) := inClass;
outClass := CLASS(newName, p, f, e, r, body, info);
outClass := match outClass
case CLASS()
algorithm
outClass.name := newName;
then
outClass;
end match;
end setClassName;

public function setClassBody
input Class inClass;
input ClassDef inBody;
output Class outClass = inClass;
algorithm
outClass := match outClass
case CLASS()
algorithm
outClass.body := inBody;
then
outClass;
end match;
end setClassBody;

public function crefEqual " Checks if the name of a ComponentRef is
equal to the name of another ComponentRef, including subscripts.
See also crefEqualNoSubs."
Expand Down Expand Up @@ -5651,6 +5664,32 @@ algorithm
res := listReverse(res);
end mergeAnnotations2;

public function mergeCommentAnnotation
"Merges an annotation into a Comment option."
input Annotation inAnnotation;
input Option<Comment> inComment;
output Option<Comment> outComment;
algorithm
outComment := match inComment
local
Annotation ann;
Option<String> cmt;

// No comment, create a new one.
case NONE()
then SOME(COMMENT(SOME(inAnnotation), NONE()));

// A comment without annotation, insert the annotation.
case SOME(COMMENT(annotation_ = NONE(), comment = cmt))
then SOME(COMMENT(SOME(inAnnotation), cmt));

// A comment with annotation, merge the annotations.
case SOME(COMMENT(annotation_ = SOME(ann), comment = cmt))
then SOME(COMMENT(SOME(mergeAnnotations(ann, inAnnotation)), cmt));

end match;
end mergeCommentAnnotation;

function isModificationOfPath
"returns true or false if the given path is in the list of modifications"
input ElementArg mod;
Expand Down

0 comments on commit 13854c1

Please sign in to comment.