Skip to content

Commit d931f0e

Browse files
committed
formatting fixes
1 parent 0ac2c72 commit d931f0e

File tree

2 files changed

+43
-43
lines changed

2 files changed

+43
-43
lines changed

smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/documentation/StructureExampleGenerator.java

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,11 @@ public static String generateStructuralHintDocumentation(Shape shape, Model mode
5252
buffer.toString()
5353
.split("\n"))
5454
.map(line -> line.replaceAll(
55-
"([\\w\\\",:] )\\s+",
55+
"([\\w\\\",:\\[\\{] )\\s+",
5656
"$1"))
5757
.collect(Collectors.joining("\n"));
5858

59-
return s;
59+
return s.replaceAll(",$", ";");
6060
}
6161

6262
private static void structure(StructureShape structureShape,
@@ -73,7 +73,7 @@ private static void structure(StructureShape structureShape,
7373
append(indentation + 2, buffer, member.getMemberName() + ": ");
7474
shape(member, buffer, model, indentation + 2, shapeTracker);
7575
});
76-
append(indentation, buffer, "}\n");
76+
append(indentation, buffer, "},\n");
7777
}
7878
}
7979

@@ -88,7 +88,7 @@ private static void union(UnionShape unionShape,
8888
append(indentation + 2, buffer, member.getMemberName() + ": ");
8989
shape(member, buffer, model, indentation + 2, shapeTracker);
9090
});
91-
append(indentation, buffer, "}\n");
91+
append(indentation, buffer, "},\n");
9292
}
9393

9494
private static void shape(Shape shape,
@@ -104,8 +104,8 @@ private static void shape(Shape shape,
104104
}
105105

106106
shapeTracker.mark(shape, indentation);
107-
if (shapeTracker.getOccurrenceDepths(shape) > 5) {
108-
append(indentation, buffer, "\"<" + shape.getId().getName() + ">\"");
107+
if (shapeTracker.getOccurrenceDepths(shape) > 2) {
108+
append(indentation, buffer, "\"<" + shape.getId().getName() + ">\"\n");
109109
} else {
110110
switch (target.getType()) {
111111
case BIG_DECIMAL:
@@ -186,7 +186,7 @@ private static void shape(Shape shape,
186186
.stream()
187187
.map(s -> "\"" + s + "\"")
188188
.collect(Collectors.joining(" || "));
189-
append(indentation, buffer, enumeration);
189+
append(indentation, buffer, enumeration + ",");
190190
break;
191191
case INT_ENUM:
192192
IntEnumShape intEnumShape = (IntEnumShape) target;
@@ -195,7 +195,7 @@ private static void shape(Shape shape,
195195
.stream()
196196
.map(i -> Integer.toString(i))
197197
.collect(Collectors.joining(" || "));
198-
append(indentation, buffer, intEnumeration);
198+
append(indentation, buffer, intEnumeration + ",");
199199
break;
200200
case OPERATION:
201201
case RESOURCE:
@@ -205,37 +205,37 @@ private static void shape(Shape shape,
205205
append(indentation, buffer, "\"...\",");
206206
break;
207207
}
208-
}
209208

210-
switch (target.getType()) {
211-
case STRUCTURE:
212-
case UNION:
213-
case LIST:
214-
case SET:
215-
case MAP:
216-
break;
217-
case BIG_DECIMAL:
218-
case BIG_INTEGER:
219-
case BLOB:
220-
case BOOLEAN:
221-
case BYTE:
222-
case DOCUMENT:
223-
case DOUBLE:
224-
case ENUM:
225-
case FLOAT:
226-
case INTEGER:
227-
case INT_ENUM:
228-
case LONG:
229-
case MEMBER:
230-
case OPERATION:
231-
case RESOURCE:
232-
case SERVICE:
233-
case SHORT:
234-
case STRING:
235-
case TIMESTAMP:
236-
default:
237-
checkRequired(indentation, buffer, shape);
238-
break;
209+
switch (target.getType()) {
210+
case STRUCTURE:
211+
case UNION:
212+
case LIST:
213+
case SET:
214+
case MAP:
215+
break;
216+
case BIG_DECIMAL:
217+
case BIG_INTEGER:
218+
case BLOB:
219+
case BOOLEAN:
220+
case BYTE:
221+
case DOCUMENT:
222+
case DOUBLE:
223+
case ENUM:
224+
case FLOAT:
225+
case INTEGER:
226+
case INT_ENUM:
227+
case LONG:
228+
case MEMBER:
229+
case OPERATION:
230+
case RESOURCE:
231+
case SERVICE:
232+
case SHORT:
233+
case STRING:
234+
case TIMESTAMP:
235+
default:
236+
checkRequired(indentation, buffer, shape);
237+
break;
238+
}
239239
}
240240
}
241241

smithy-typescript-codegen/src/test/java/software/amazon/smithy/typescript/codegen/documentation/StructureExampleGeneratorTest.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public class StructureExampleGeneratorTest {
6666
public void generatesStructuralHintDocumentation_map() {
6767
assertThat(
6868
StructureExampleGenerator.generateStructuralHintDocumentation(map, model),
69-
equalTo("{\n \"<keys>\": \"STRING_VALUE\", \n},"));
69+
equalTo("{\n \"<keys>\": \"STRING_VALUE\", \n};"));
7070
}
7171

7272
@Test
@@ -75,19 +75,19 @@ public void generatesStructuralHintDocumentation_structure() {
7575
StructureExampleGenerator.generateStructuralHintDocumentation(structure, model),
7676
equalTo("{\n"
7777
+ " string: \"STRING_VALUE\", \n"
78-
+ " list: [ \n"
78+
+ " list: [ \n"
7979
+ " \"STRING_VALUE\", \n"
8080
+ " ],\n"
81-
+ " map: { \n"
81+
+ " map: { \n"
8282
+ " \"<keys>\": \"STRING_VALUE\", \n"
8383
+ " },\n"
84-
+ "}"));
84+
+ "};"));
8585
}
8686

8787
@Test
8888
public void generatesStructuralHintDocumentation_list() {
8989
assertThat(
9090
StructureExampleGenerator.generateStructuralHintDocumentation(list, model),
91-
equalTo("[\n \"STRING_VALUE\", \n],"));
91+
equalTo("[\n \"STRING_VALUE\", \n];"));
9292
}
9393
}

0 commit comments

Comments
 (0)