Skip to content

Commit

Permalink
Structure definitiona formatting fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
maccasoft committed Jun 12, 2024
1 parent be04811 commit 381f5f3
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -582,4 +582,18 @@ void testExpressions() {
+ "", text);
}

@Test
void testStructureDefinition() {
Formatter subject = new Spin2Formatter();
String text = subject.format(""
+ "CON point(x,y)\n"
+ " line(point a,point b,color)\n"
+ "");
Assertions.assertEquals(""
+ "CON\n"
+ " point(x, y)\n"
+ " line(point a, point b, color)\n"
+ "", text);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,10 @@ void formatConstant(FormatterStringBuilder sb) {
}
break;
case 4:
if ("(".equals(token.getText()) || ")".equals(token.getText())) {
sb.append(token);
break;
}
if ("=".equals(token.getText())) {
sb.append(" ");
sb.append(token);
Expand All @@ -260,7 +264,7 @@ void formatConstant(FormatterStringBuilder sb) {
state = 6;
break;
}
if (sb.lastChar() != ' ') {
if (sb.lastChar() != ' ' && sb.lastChar() != '(') {
sb.append(" ");
}
sb.append(token);
Expand Down

0 comments on commit 381f5f3

Please sign in to comment.