Skip to content

Commit

Permalink
@doc(default): set a default value for a parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
agarciadom committed Aug 4, 2015
1 parent fd20fd2 commit a76bfeb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion uk.ac.york.mondo.ecore2thrift/epsilon/ecore2thrift.egl
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ service [%=c.name%] {
iParameter = p.getNum();
}
%]
/* [%=p.getDoc()%] */ [%=iParameter%]: [%=p.getOptional(false)%] [%=p.getType()%] [%=p.name %],
/* [%=p.getDoc()%] */ [%=iParameter%]: [%=p.getOptional(false)%] [%=p.getType()%] [%=p.name %][%=p.getDefault()%],
[%
iParameter = iParameter + 1;
}
Expand Down
11 changes: 10 additions & 1 deletion uk.ac.york.mondo.ecore2thrift/epsilon/utilities.egl
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,15 @@ operation EClassifier getEntityThriftKeyword() {
}
}

operation ETypedElement getDefault() {
var d = self.getAnnotationValue("doc", "default");
if (d.isDefined()) {
return " = " + d;
} else {
return "";
}
}

operation EClassifier usedIn() {
return EOperation.all.select(op|op.eType = self or op.eParameters.exists(p|p.eType == self) or op.eExceptions.contains(self)).
collect(op|op.eContainer.name + "." + op.name).
Expand Down Expand Up @@ -136,7 +145,7 @@ operation describeEntityFields(c: EClass, iParameter: Integer): Integer {
iParameter = describeEntityFields(sf.eType, iParameter);
} else {
%]
/* [%=sf.getDoc()%] */ [%=iParameter%]: [%=sf.getOptional(c.isUnion()) %] [%=sf.getType()%] [%=sf.name%],
/* [%=sf.getDoc()%] */ [%=iParameter%]: [%=sf.getOptional(c.isUnion()) %] [%=sf.getType()%] [%=sf.name%][%=sf.getDefault()%],
[% iParameter = iParameter + 1;
}
}
Expand Down

0 comments on commit a76bfeb

Please sign in to comment.