Skip to content

Commit d8638ef

Browse files
[WIP] Supports alternatives composed of all TerminalElement
1 parent 080e891 commit d8638ef

File tree

43 files changed

+122
-91
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+122
-91
lines changed

SysML2.NET.CodeGenerator/HandleBarHelpers/RulesHelper.cs

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,38 @@ private static void ProcessAlternatives(EncodedTextWriter writer, IClass umlClas
158158
}
159159
else
160160
{
161-
writer.WriteSafeString("throw new System.NotSupportedException(\"Multiple alternatives not implemented yet\");");
161+
if (alternatives.All(x => x.Elements.Count == 1))
162+
{
163+
var types = alternatives.SelectMany(x => x.Elements).Select(x => x.GetType()).Distinct().ToList();
164+
165+
if(types.Count == 1)
166+
{
167+
ProcessUnitypedAlternativesWithOneElement(writer, umlClass, alternatives, ruleGenerationContext);
168+
}
169+
else
170+
{
171+
writer.WriteSafeString($"throw new System.NotSupportedException(\"Multiple alternatives with only one of the different type not implemented yet - {string.Join(',', types.Select(x => x.Name))}\");");
172+
}
173+
}
174+
else
175+
{
176+
writer.WriteSafeString("throw new System.NotSupportedException(\"Multiple alternatives not implemented yet\");");
177+
}
178+
}
179+
}
180+
181+
private static void ProcessUnitypedAlternativesWithOneElement(EncodedTextWriter writer, IClass umlClass, IReadOnlyCollection<Alternatives> alternatives, RuleGenerationContext ruleGenerationContext)
182+
{
183+
var firstRuleElement = alternatives.ElementAt(0).Elements[0];
184+
185+
switch (firstRuleElement)
186+
{
187+
case TerminalElement terminalElement:
188+
writer.WriteSafeString($"stringBuilder.Append(\" {terminalElement.Value} \");");
189+
break;
190+
default:
191+
writer.WriteSafeString($"throw new System.NotSupportedException(\"Multiple alternatives with only {firstRuleElement.GetType().Name} not implemented yet\");");
192+
break;
162193
}
163194
}
164195

SysML2.NET/TextualNotation/AutoGenTextualNotationBuilder/ActionUsageTextualNotationBuilder.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public static void BuildActionUsageDeclaration(SysML2.NET.Core.POCO.Systems.Acti
5555
/// <param name="stringBuilder">The <see cref="StringBuilder" /> that contains the entire textual notation</param>
5656
public static void BuildActionNode(SysML2.NET.Core.POCO.Systems.Actions.IActionUsage poco, StringBuilder stringBuilder)
5757
{
58-
throw new System.NotSupportedException("Multiple alternatives not implemented yet");
58+
throw new System.NotSupportedException("Multiple alternatives with only NonTerminalElement not implemented yet");
5959
}
6060

6161
/// <summary>
@@ -176,7 +176,7 @@ public static void BuildEmptyActionUsage(SysML2.NET.Core.POCO.Systems.Actions.IA
176176
/// <param name="stringBuilder">The <see cref="StringBuilder" /> that contains the entire textual notation</param>
177177
public static void BuildEffectBehaviorUsage(SysML2.NET.Core.POCO.Systems.Actions.IActionUsage poco, StringBuilder stringBuilder)
178178
{
179-
throw new System.NotSupportedException("Multiple alternatives not implemented yet");
179+
throw new System.NotSupportedException("Multiple alternatives with only NonTerminalElement not implemented yet");
180180
}
181181

182182
/// <summary>

SysML2.NET/TextualNotation/AutoGenTextualNotationBuilder/AnnotatingElementTextualNotationBuilder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public static partial class AnnotatingElementTextualNotationBuilder
4242
/// <param name="stringBuilder">The <see cref="StringBuilder" /> that contains the entire textual notation</param>
4343
public static void BuildAnnotatingElement(SysML2.NET.Core.POCO.Root.Annotations.IAnnotatingElement poco, StringBuilder stringBuilder)
4444
{
45-
throw new System.NotSupportedException("Multiple alternatives not implemented yet");
45+
throw new System.NotSupportedException("Multiple alternatives with only NonTerminalElement not implemented yet");
4646
}
4747
}
4848
}

SysML2.NET/TextualNotation/AutoGenTextualNotationBuilder/ClassifierTextualNotationBuilder.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public static partial class ClassifierTextualNotationBuilder
4343
public static void BuildSubclassificationPart(SysML2.NET.Core.POCO.Core.Classifiers.IClassifier poco, StringBuilder stringBuilder)
4444
{
4545
using var ownedRelationshipOfSubclassificationIterator = poco.OwnedRelationship.OfType<SysML2.NET.Core.POCO.Core.Classifiers.Subclassification>().GetEnumerator();
46-
throw new System.NotSupportedException("Multiple alternatives not implemented yet");
46+
stringBuilder.Append(" :> ");
4747
ownedRelationshipOfSubclassificationIterator.MoveNext();
4848

4949
if (ownedRelationshipOfSubclassificationIterator.Current != null)
@@ -92,7 +92,7 @@ public static void BuildClassifierDeclaration(SysML2.NET.Core.POCO.Core.Classifi
9292
stringBuilder.Append(' ');
9393
}
9494

95-
throw new System.NotSupportedException("Multiple alternatives not implemented yet");
95+
throw new System.NotSupportedException("Multiple alternatives with only NonTerminalElement not implemented yet");
9696
TypeTextualNotationBuilder.BuildTypeRelationshipPart(poco, stringBuilder);
9797

9898
}
@@ -106,7 +106,7 @@ public static void BuildClassifierDeclaration(SysML2.NET.Core.POCO.Core.Classifi
106106
public static void BuildSuperclassingPart(SysML2.NET.Core.POCO.Core.Classifiers.IClassifier poco, StringBuilder stringBuilder)
107107
{
108108
using var ownedRelationshipOfSubclassificationIterator = poco.OwnedRelationship.OfType<SysML2.NET.Core.POCO.Core.Classifiers.Subclassification>().GetEnumerator();
109-
throw new System.NotSupportedException("Multiple alternatives not implemented yet");
109+
stringBuilder.Append(" :> ");
110110
ownedRelationshipOfSubclassificationIterator.MoveNext();
111111

112112
if (ownedRelationshipOfSubclassificationIterator.Current != null)

SysML2.NET/TextualNotation/AutoGenTextualNotationBuilder/ConjugationTextualNotationBuilder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public static void BuildConjugation(SysML2.NET.Core.POCO.Core.Types.IConjugation
6464
stringBuilder.Append("conjugate ");
6565
throw new System.NotSupportedException("Multiple alternatives not implemented yet");
6666
stringBuilder.Append(' ');
67-
throw new System.NotSupportedException("Multiple alternatives not implemented yet");
67+
stringBuilder.Append(" ~ ");
6868
throw new System.NotSupportedException("Multiple alternatives not implemented yet");
6969
stringBuilder.Append(' ');
7070
RelationshipTextualNotationBuilder.BuildRelationshipBody(poco, stringBuilder);

SysML2.NET/TextualNotation/AutoGenTextualNotationBuilder/ConnectionUsageTextualNotationBuilder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public static partial class ConnectionUsageTextualNotationBuilder
4242
/// <param name="stringBuilder">The <see cref="StringBuilder" /> that contains the entire textual notation</param>
4343
public static void BuildConnectorPart(SysML2.NET.Core.POCO.Systems.Connections.IConnectionUsage poco, StringBuilder stringBuilder)
4444
{
45-
throw new System.NotSupportedException("Multiple alternatives not implemented yet");
45+
throw new System.NotSupportedException("Multiple alternatives with only NonTerminalElement not implemented yet");
4646
}
4747

4848
/// <summary>

SysML2.NET/TextualNotation/AutoGenTextualNotationBuilder/ConnectorTextualNotationBuilder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public static partial class ConnectorTextualNotationBuilder
4242
/// <param name="stringBuilder">The <see cref="StringBuilder" /> that contains the entire textual notation</param>
4343
public static void BuildConnectorDeclaration(SysML2.NET.Core.POCO.Kernel.Connectors.IConnector poco, StringBuilder stringBuilder)
4444
{
45-
throw new System.NotSupportedException("Multiple alternatives not implemented yet");
45+
throw new System.NotSupportedException("Multiple alternatives with only NonTerminalElement not implemented yet");
4646
}
4747

4848
/// <summary>

SysML2.NET/TextualNotation/AutoGenTextualNotationBuilder/ControlNodeTextualNotationBuilder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public static partial class ControlNodeTextualNotationBuilder
4242
/// <param name="stringBuilder">The <see cref="StringBuilder" /> that contains the entire textual notation</param>
4343
public static void BuildControlNode(SysML2.NET.Core.POCO.Systems.Actions.IControlNode poco, StringBuilder stringBuilder)
4444
{
45-
throw new System.NotSupportedException("Multiple alternatives not implemented yet");
45+
throw new System.NotSupportedException("Multiple alternatives with only NonTerminalElement not implemented yet");
4646
}
4747
}
4848
}

SysML2.NET/TextualNotation/AutoGenTextualNotationBuilder/DefinitionTextualNotationBuilder.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public static void BuildDefinitionExtensionKeyword(SysML2.NET.Core.POCO.Systems.
6060
/// <param name="stringBuilder">The <see cref="StringBuilder" /> that contains the entire textual notation</param>
6161
public static void BuildDefinitionPrefix(SysML2.NET.Core.POCO.Systems.DefinitionAndUsage.IDefinition poco, StringBuilder stringBuilder)
6262
{
63-
throw new System.NotSupportedException("Multiple alternatives not implemented yet");
63+
throw new System.NotSupportedException("Multiple alternatives with only AssignmentElement not implemented yet");
6464
BuildDefinitionExtensionKeyword(poco, stringBuilder);
6565

6666
}
@@ -86,7 +86,7 @@ public static void BuildDefinitionDeclaration(SysML2.NET.Core.POCO.Systems.Defin
8686
/// <param name="stringBuilder">The <see cref="StringBuilder" /> that contains the entire textual notation</param>
8787
public static void BuildExtendedDefinition(SysML2.NET.Core.POCO.Systems.DefinitionAndUsage.IDefinition poco, StringBuilder stringBuilder)
8888
{
89-
throw new System.NotSupportedException("Multiple alternatives not implemented yet");
89+
throw new System.NotSupportedException("Multiple alternatives with only AssignmentElement not implemented yet");
9090
BuildDefinitionExtensionKeyword(poco, stringBuilder);
9191
stringBuilder.Append("def ");
9292
BuildDefinition(poco, stringBuilder);

SysML2.NET/TextualNotation/AutoGenTextualNotationBuilder/DifferencingTextualNotationBuilder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public static partial class DifferencingTextualNotationBuilder
4242
/// <param name="stringBuilder">The <see cref="StringBuilder" /> that contains the entire textual notation</param>
4343
public static void BuildDifferencing(SysML2.NET.Core.POCO.Core.Types.IDifferencing poco, StringBuilder stringBuilder)
4444
{
45-
throw new System.NotSupportedException("Multiple alternatives not implemented yet");
45+
throw new System.NotSupportedException("Multiple alternatives with only AssignmentElement not implemented yet");
4646
}
4747
}
4848
}

0 commit comments

Comments
 (0)