Skip to content

Commit bdada01

Browse files
[WIP] Supports last assignement case
1 parent 6ee629e commit bdada01

File tree

2 files changed

+21
-19
lines changed

2 files changed

+21
-19
lines changed

SysML2.NET.CodeGenerator/HandleBarHelpers/RulesHelper.cs

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -313,29 +313,31 @@ private static void ProcessRuleElement(EncodedTextWriter writer, IClass umlClass
313313
}
314314
else if(targetProperty.QueryIsReferenceProperty())
315315
{
316-
if (assignmentElement.Value is NonTerminalElement nonTerminalElement)
316+
switch (assignmentElement.Value)
317317
{
318-
var previousCaller = ruleGenerationContext.CallerRule;
319-
ruleGenerationContext.CallerRule = nonTerminalElement;
320-
ProcessNonTerminalElement(writer, targetProperty.Type as IClass, nonTerminalElement, $"poco.{targetPropertyName}", ruleGenerationContext);
321-
ruleGenerationContext.CallerRule = previousCaller;
322-
}
323-
else if (assignmentElement.Value is ValueLiteralElement valueLiteralElement && valueLiteralElement.QueryIsQualifiedName())
324-
{
325-
writer.WriteSafeString($"{Environment.NewLine}if (poco.{targetPropertyName} != null){Environment.NewLine}");
326-
writer.WriteSafeString($"{{{Environment.NewLine}");
327-
writer.WriteSafeString($"stringBuilder.Append(poco.{targetPropertyName}.qualifiedName);{Environment.NewLine}");
328-
writer.WriteSafeString("stringBuilder.Append(' ');");
329-
writer.WriteSafeString($"{Environment.NewLine}}}");
330-
}
331-
else
332-
{
333-
writer.WriteSafeString("throw new System.NotSupportedException(\"Assigment of reference element not supported yet for this case\");");
318+
case NonTerminalElement nonTerminalElement:
319+
{
320+
var previousCaller = ruleGenerationContext.CallerRule;
321+
ruleGenerationContext.CallerRule = nonTerminalElement;
322+
ProcessNonTerminalElement(writer, targetProperty.Type as IClass, nonTerminalElement, $"poco.{targetPropertyName}", ruleGenerationContext);
323+
ruleGenerationContext.CallerRule = previousCaller;
324+
break;
325+
}
326+
case ValueLiteralElement valueLiteralElement when valueLiteralElement.QueryIsQualifiedName():
327+
writer.WriteSafeString($"{Environment.NewLine}if (poco.{targetPropertyName} != null){Environment.NewLine}");
328+
writer.WriteSafeString($"{{{Environment.NewLine}");
329+
writer.WriteSafeString($"stringBuilder.Append(poco.{targetPropertyName}.qualifiedName);{Environment.NewLine}");
330+
writer.WriteSafeString("stringBuilder.Append(' ');");
331+
writer.WriteSafeString($"{Environment.NewLine}}}");
332+
break;
333+
default:
334+
writer.WriteSafeString("throw new System.NotSupportedException(\"Assigment of reference element not supported yet for this case\");");
335+
break;
334336
}
335337
}
336338
else
337339
{
338-
writer.WriteSafeString("throw new System.NotSupportedException(\"Assigment of non-string value not yet supported\");");
340+
writer.WriteSafeString($"stringBuilder.Append(poco.{targetPropertyName}.ToString());");
339341
}
340342
}
341343
}

SysML2.NET/TextualNotation/AutoGenTextualNotationBuilder/LiteralIntegerTextualNotationBuilder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public static partial class LiteralIntegerTextualNotationBuilder
4242
/// <param name="stringBuilder">The <see cref="StringBuilder" /> that contains the entire textual notation</param>
4343
public static void BuildLiteralInteger(SysML2.NET.Core.POCO.Kernel.Expressions.ILiteralInteger poco, StringBuilder stringBuilder)
4444
{
45-
throw new System.NotSupportedException("Assigment of non-string value not yet supported");
45+
stringBuilder.Append(poco.Value.ToString());
4646

4747
}
4848
}

0 commit comments

Comments
 (0)