Skip to content

Commit 14a1ab9

Browse files
committed
Issue #48 - Corrected handling of template params as classifiers.
1 parent dd91554 commit 14a1ab9

File tree

5 files changed

+27
-10
lines changed

5 files changed

+27
-10
lines changed

org.modeldriven.alf/src/org/modeldriven/alf/execution/AlfBase.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
public abstract class AlfBase {
2626

27-
public static final String ALF_VERSION = "1.1.0a/maint-3";
27+
public static final String ALF_VERSION = "1.1.0a/maint-4";
2828

2929
protected boolean isVerbose = false;
3030

org.modeldriven.alf/src/org/modeldriven/alf/fuml/mapping/expressions/ExpressionMapping.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ public Classifier getType() throws MappingError {
5050
if (this.type == null) {
5151
ElementReference reference = this.getExpression().getType();
5252
if (reference != null) {
53+
if (reference.getImpl().isClassifierTemplateParameter()) {
54+
reference = reference.getImpl().getParameteredElement();
55+
}
5356
this.type = (Classifier)reference.getImpl().getUml();
5457
if (this.type == null) {
5558
FumlMapping mapping = this.fumlMap(reference);

org.modeldriven.alf/src/org/modeldriven/alf/syntax/common/impl/ElementReferenceImpl.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -512,10 +512,11 @@ public static ElementReference makeElementReference(Element element) {
512512
reference = templateBindings.get(element);
513513

514514
if (reference == null) {
515-
ExternalElementReference externalReference =
516-
new ExternalElementReference();
515+
ExternalElementReference externalReference = new ExternalElementReference();
517516
externalReference.setElement(element);
518517
reference = externalReference;
518+
} else if (reference.getImpl().isClassifierTemplateParameter()) {
519+
return reference.getImpl().getParameteredElement();
519520
}
520521
}
521522

@@ -557,6 +558,8 @@ public static ElementReference makeTypeReference(Element element) {
557558
public static ElementReference effectiveElementFor(ElementReference reference) {
558559
if (reference == null) {
559560
return null;
561+
} else if (reference.getImpl().isClassifierTemplateParameter()) {
562+
return reference.getImpl().getParameteredElement();
560563
} else {
561564
ElementReference boundElement = reference.getImpl().getEffectiveBoundElement();
562565
return boundElement == null? reference: boundElement;

org.modeldriven.alf/src/org/modeldriven/alf/syntax/common/impl/ExternalElementReferenceImpl.java

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -129,11 +129,19 @@ public boolean isClassifier() {
129129
// be a Classifier.
130130
element instanceof ClassifierTemplateParameter;
131131
}
132+
133+
protected Classifier asClassifier() {
134+
Element element = this.getSelf().getElement();
135+
if (element instanceof ClassifierTemplateParameter) {
136+
element = ((ClassifierTemplateParameter)element).getParameteredElement();
137+
}
138+
return (Classifier)element;
139+
}
132140

133141
@Override
134142
public boolean isAbstractClassifier() {
135143
return this.isClassifier() &&
136-
((Classifier)this.getSelf().getElement()).getIsAbstract();
144+
this.asClassifier().getIsAbstract();
137145
}
138146

139147
@Override
@@ -288,7 +296,7 @@ public boolean isClassifierTemplateParameter() {
288296
@Override
289297
public boolean isParameteredElement() {
290298
return this.isClassifier() &&
291-
((Classifier)this.getSelf().getElement()).getTemplateParameter() != null;
299+
this.asClassifier().getTemplateParameter() != null;
292300
}
293301

294302
@Override
@@ -360,7 +368,7 @@ public boolean hasReceptionFor(ElementReference signal) {
360368
@Override
361369
public Collection<ElementReference> parents() {
362370
if (this.isClassifier()) {
363-
return setOf(((Classifier)this.getSelf().getElement()).parents());
371+
return setOf(this.asClassifier().parents());
364372
} else {
365373
return new HashSet<ElementReference>();
366374
}
@@ -369,7 +377,7 @@ public Collection<ElementReference> parents() {
369377
@Override
370378
public Collection<ElementReference> allParents() {
371379
if (this.isClassifier()) {
372-
return setOf(((Classifier)this.getSelf().getElement()).allParents());
380+
return setOf(this.asClassifier().allParents());
373381
} else {
374382
return new HashSet<ElementReference>();
375383
}
@@ -451,7 +459,7 @@ public List<ElementReference> getAttributes() {
451459
List<ElementReference> attributes = new ArrayList<ElementReference>();
452460
if (this.isClassifier()) {
453461
for (Property attribute:
454-
ActivityGraph.getAllAttributes((Classifier)this.getSelf().getElement())) {
462+
ActivityGraph.getAllAttributes(this.asClassifier())) {
455463
attributes.add(ElementReferenceImpl.makeElementReference(attribute));
456464
}
457465
}
@@ -473,7 +481,7 @@ public List<ElementReference> getAssociationEnds() {
473481
public List<Member> getInheritableMembers() {
474482
List<Member> inheritableMembers = new ArrayList<Member>();
475483
if (this.isClassifier()) {
476-
Classifier classifier = (Classifier)this.getSelf().getElement();
484+
Classifier classifier = this.asClassifier();
477485
for (NamedElement element: classifier.inheritableMembers()) {
478486
List<String> names = classifier.getNamesOfMember(element);
479487
if (names.isEmpty()) {

org.modeldriven.alf/src/org/modeldriven/alf/syntax/units/impl/ExternalNamespaceImpl.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -551,8 +551,11 @@ private static ElementReference makeSubstitution(
551551
for (int i = 0; i < templateParameters.size(); i++) {
552552
if (reference.getImpl().equals(
553553
templateParameters.get(i).getImpl().getParameteredElement())) {
554-
return i >= templateArguments.size()? null:
554+
reference = i >= templateArguments.size()? null:
555555
templateArguments.get(i);
556+
if (reference != null && reference.getImpl().isClassifierTemplateParameter()) {
557+
reference = reference.getImpl().getParameteredElement();
558+
}
556559
}
557560
}
558561
return reference;

0 commit comments

Comments
 (0)