Skip to content

Commit 7ea383a

Browse files
committed
* Visitor (getSpecialReference): Added, which relaces
hasRefSubsettingWithoutDeclaredName() (addNameWithId): If it's a special reference, use the reference name. (getNameWithNamespace): Allow enclosingNs to be null. * VStructure (hasRefSubsettingWithoutDeclaredName): Removed. (extractTitleName): Use getSpecialReference() instead of hasRefSubsettingWithoutDeclaredName(). (caseSatisfyRequirementUsage): Ditto. * SysML2PlantUMLStyle.StyleStereotypeDefaultSwitch: Ditto.
1 parent e09a1dd commit 7ea383a

3 files changed

Lines changed: 34 additions & 14 deletions

File tree

org.omg.sysml.plantuml/src/org/omg/sysml/plantuml/SysML2PlantUMLStyle.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -538,7 +538,7 @@ public String caseClass(Class object) {
538538

539539
@Override
540540
public String caseExhibitStateUsage(ExhibitStateUsage esu) {
541-
if (VStructure.hasRefSubsettingWithoutDeclaredName(esu)) {
541+
if (Visitor.getSpecialReference(esu) != null) {
542542
return " exhibit>> ";
543543
} else {
544544
return " exhibit state>> ";
@@ -547,12 +547,12 @@ public String caseExhibitStateUsage(ExhibitStateUsage esu) {
547547

548548
@Override
549549
public String caseSatisfyRequirementUsage(SatisfyRequirementUsage sru) {
550-
return "<<requirement>> ";
550+
return " requirement>> ";
551551
}
552552

553553
@Override
554554
public String caseIncludeUseCaseUsage(IncludeUseCaseUsage iucu) {
555-
if (VStructure.hasRefSubsettingWithoutDeclaredName(iucu)) {
555+
if (Visitor.getSpecialReference(iucu) != null) {
556556
return " include>> ";
557557
} else {
558558
return " include use case>> ";
@@ -561,7 +561,7 @@ public String caseIncludeUseCaseUsage(IncludeUseCaseUsage iucu) {
561561

562562
@Override
563563
public String casePerformActionUsage(PerformActionUsage pau) {
564-
if (VStructure.hasRefSubsettingWithoutDeclaredName(pau)) {
564+
if (Visitor.getSpecialReference(pau) != null) {
565565
return " perform>> ";
566566
} else {
567567
return " perform action>> ";
@@ -600,7 +600,7 @@ public String caseVerificationCaseDefinition(VerificationCaseDefinition acd) {
600600

601601
@Override
602602
public String caseEventOccurrenceUsage(EventOccurrenceUsage eou) {
603-
if (VStructure.hasRefSubsettingWithoutDeclaredName(eou)) {
603+
if (Visitor.getSpecialReference(eou) != null) {
604604
return " event>> ";
605605
} else {
606606
return " event occurrence>> ";

org.omg.sysml.plantuml/src/org/omg/sysml/plantuml/VStructure.java

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -229,13 +229,6 @@ private void insertActorLikeStyle(StringBuilder sb, Type typ) {
229229
}
230230
}
231231

232-
public static boolean hasRefSubsettingWithoutDeclaredName(Feature f) {
233-
if (f.getOwnedReferenceSubsetting() == null) return false;
234-
if (f.getDeclaredName() != null) return false;
235-
if (f.getDeclaredShortName() != null) return false;
236-
return true;
237-
}
238-
239232
protected String extractTitleName(Element e) {
240233
String name = getNameAnyway(e);
241234
StringBuilder sb = new StringBuilder();
@@ -254,7 +247,7 @@ protected String extractTitleName(Element e) {
254247
}
255248
sb.append(' ');
256249
added = appendSubsettings(sb, f) || added;
257-
if (!hasRefSubsettingWithoutDeclaredName(f)) {
250+
if (Visitor.getSpecialReference(f) == null) {
258251
sb.append(' ');
259252
added = appendReferenceSubsetting(sb, f) || added;
260253
}
@@ -323,7 +316,7 @@ public String caseSatisfyRequirementUsage(SatisfyRequirementUsage sru) {
323316
if ((ru != null) && (target != null)) {
324317
addPRelation(target, ru, sru, "<<satisfy>>");
325318
}
326-
if (hasRefSubsettingWithoutDeclaredName(sru)) return "";
319+
if (getSpecialReference(sru) != null) return "";
327320
return null;
328321
}
329322

org.omg.sysml.plantuml/src/org/omg/sysml/plantuml/Visitor.java

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,22 @@
3434

3535
import org.eclipse.emf.ecore.EObject;
3636
import org.omg.sysml.lang.sysml.Element;
37+
import org.omg.sysml.lang.sysml.EventOccurrenceUsage;
38+
import org.omg.sysml.lang.sysml.ExhibitStateUsage;
3739
import org.omg.sysml.lang.sysml.Feature;
3840
import org.omg.sysml.lang.sysml.FeatureChaining;
3941
import org.omg.sysml.lang.sysml.FeatureMembership;
4042
import org.omg.sysml.lang.sysml.FeatureTyping;
43+
import org.omg.sysml.lang.sysml.IncludeUseCaseUsage;
4144
import org.omg.sysml.lang.sysml.Membership;
4245
import org.omg.sysml.lang.sysml.Multiplicity;
4346
import org.omg.sysml.lang.sysml.MultiplicityRange;
4447
import org.omg.sysml.lang.sysml.Namespace;
48+
import org.omg.sysml.lang.sysml.PerformActionUsage;
4549
import org.omg.sysml.lang.sysml.Redefinition;
4650
import org.omg.sysml.lang.sysml.ReferenceSubsetting;
4751
import org.omg.sysml.lang.sysml.Relationship;
52+
import org.omg.sysml.lang.sysml.SatisfyRequirementUsage;
4853
import org.omg.sysml.lang.sysml.Subsetting;
4954
import org.omg.sysml.lang.sysml.Type;
5055
import org.omg.sysml.lang.sysml.util.SysMLSwitch;
@@ -336,7 +341,28 @@ protected void cQuote(String s) {
336341
}
337342
}
338343

344+
/* Check if the feature comes from a special notation of
345+
* <<perform>>, <<exhibit>>, <<event>>, <<include>>, and <<satisfy>> */
346+
public static Feature getSpecialReference(Element e) {
347+
if (!(e instanceof PerformActionUsage
348+
|| e instanceof ExhibitStateUsage
349+
|| e instanceof EventOccurrenceUsage
350+
|| e instanceof IncludeUseCaseUsage
351+
|| e instanceof SatisfyRequirementUsage)) return null;
352+
Feature f = (Feature) e;
353+
if (f.getDeclaredName() != null) return null;
354+
if (f.getDeclaredShortName() != null) return null;
355+
ReferenceSubsetting rs = f.getOwnedReferenceSubsetting();
356+
if (rs == null) return null;
357+
return rs.getReferencedFeature();
358+
}
359+
339360
protected int addNameWithId(Element e, String name, boolean force) {
361+
Feature ref = getSpecialReference(e);
362+
if (ref != null) {
363+
String refName = getRefName(ref, null);
364+
if (refName != null) name = refName;
365+
}
340366
quote(name);
341367
append(" as ");
342368
int id = addIdStr(e, force);
@@ -539,6 +565,7 @@ protected static String getFeatureChainName(Feature f) {
539565
private static String getNameWithNamespace(Feature f, org.omg.sysml.lang.sysml.Namespace enclosingNs) {
540566
String name = getFeatureName(f);
541567
if (name == null) return null;
568+
if (enclosingNs == null) return name;
542569

543570
org.omg.sysml.lang.sysml.Namespace pkg = f.getOwningNamespace();
544571
if ((pkg == null) || pkg.equals(enclosingNs)) return name;

0 commit comments

Comments
 (0)