Skip to content

Commit 5f83ba1

Browse files
committed
Remove unnecessary src folder prepend in useShapeWriter
The SymbolProvider(SymbolVisitor) also includes the src folder, so this is unnecessary.
1 parent 078a230 commit 5f83ba1

File tree

3 files changed

+17
-22
lines changed

3 files changed

+17
-22
lines changed

smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/TypeScriptDelegator.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,6 @@ void useShapeWriter(Shape shape, Consumer<TypeScriptWriter> writerConsumer) {
9191
// Checkout/create the appropriate writer for the shape.
9292
Symbol symbol = symbolProvider.toSymbol(shape);
9393
String fileName = symbol.getDefinitionFile();
94-
if (!fileName.startsWith(Paths.get(".", CodegenUtils.SOURCE_FOLDER).toString())) {
95-
fileName = Paths.get(".", CodegenUtils.SOURCE_FOLDER, fileName).toString();
96-
}
9794
TypeScriptWriter writer = checkoutWriter(fileName);
9895

9996
// Add any needed DECLARE symbols.

smithy-typescript-codegen/src/test/java/software/amazon/smithy/typescript/codegen/CodegenVisitorTest.java

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,12 @@
33
import static org.hamcrest.MatcherAssert.assertThat;
44
import static org.hamcrest.Matchers.containsString;
55
import static org.hamcrest.Matchers.equalTo;
6+
import static org.junit.jupiter.api.Assertions.assertTrue;
67

78
import java.util.Optional;
8-
import org.junit.jupiter.api.Assertions;
99
import org.junit.jupiter.api.Test;
1010
import software.amazon.smithy.build.MockManifest;
1111
import software.amazon.smithy.build.PluginContext;
12-
import software.amazon.smithy.codegen.core.CodegenException;
1312
import software.amazon.smithy.model.Model;
1413
import software.amazon.smithy.model.node.Node;
1514
import software.amazon.smithy.model.node.ObjectNode;
@@ -36,10 +35,10 @@ public void generatesRuntimeConfigFiles() {
3635

3736
// Did we generate the runtime config files?
3837
// note that asserting the contents of runtime config files is handled in its own unit tests.
39-
Assertions.assertTrue(manifest.hasFile("package.json"));
40-
Assertions.assertTrue(manifest.hasFile(CodegenUtils.SOURCE_FOLDER + "/runtimeConfig.browser.ts"));
41-
Assertions.assertTrue(manifest.hasFile(CodegenUtils.SOURCE_FOLDER + "/runtimeConfig.ts"));
42-
Assertions.assertTrue(manifest.hasFile(CodegenUtils.SOURCE_FOLDER + "/index.ts"));
38+
assertTrue(manifest.hasFile("package.json"));
39+
assertTrue(manifest.hasFile(CodegenUtils.SOURCE_FOLDER + "/runtimeConfig.browser.ts"));
40+
assertTrue(manifest.hasFile(CodegenUtils.SOURCE_FOLDER + "/runtimeConfig.ts"));
41+
assertTrue(manifest.hasFile(CodegenUtils.SOURCE_FOLDER + "/index.ts"));
4342

4443
// Does the package.json file point to the runtime config?
4544
String packageJsonContents = manifest.getFileString("package.json").get();
@@ -69,8 +68,8 @@ public void decoratesSymbolProvider() {
6968

7069
new TypeScriptCodegenPlugin().execute(context);
7170

72-
Assertions.assertTrue(manifest.hasFile(CodegenUtils.SOURCE_FOLDER + "/Foo.ts"));
73-
assertThat(manifest.getFileString(CodegenUtils.SOURCE_FOLDER + "/Foo.ts").get(), containsString("export class Foo"));
71+
assertTrue(manifest.hasFile("Foo.ts"));
72+
assertThat(manifest.getFileString("Foo.ts").get(), containsString("export class Foo"));
7473
}
7574

7675
@Test
@@ -91,11 +90,11 @@ public void generatesServiceClients() {
9190
.build();
9291
new TypeScriptCodegenPlugin().execute(context);
9392

94-
Assertions.assertTrue(manifest.hasFile(CodegenUtils.SOURCE_FOLDER + "/Example.ts"));
93+
assertTrue(manifest.hasFile(CodegenUtils.SOURCE_FOLDER + "/Example.ts"));
9594
assertThat(manifest.getFileString(CodegenUtils.SOURCE_FOLDER + "/Example.ts").get(),
9695
containsString("export class Example extends ExampleClient"));
9796

98-
Assertions.assertTrue(manifest.hasFile(CodegenUtils.SOURCE_FOLDER + "/ExampleClient.ts"));
97+
assertTrue(manifest.hasFile(CodegenUtils.SOURCE_FOLDER + "/ExampleClient.ts"));
9998
assertThat(manifest.getFileString(CodegenUtils.SOURCE_FOLDER + "/ExampleClient.ts").get(), containsString("export class ExampleClient"));
10099
}
101100

smithy-typescript-codegen/src/test/java/software/amazon/smithy/typescript/codegen/TypeScriptDelegatorTest.java

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
package software.amazon.smithy.typescript.codegen;
22

3+
import static org.hamcrest.MatcherAssert.assertThat;
4+
import static org.hamcrest.Matchers.containsInAnyOrder;
5+
import static org.hamcrest.Matchers.equalTo;
6+
7+
import java.util.ArrayList;
8+
import java.util.List;
39
import org.junit.jupiter.api.Test;
410
import software.amazon.smithy.build.MockManifest;
511
import software.amazon.smithy.codegen.core.Symbol;
@@ -11,13 +17,6 @@
1117
import software.amazon.smithy.utils.ListUtils;
1218
import software.amazon.smithy.utils.Pair;
1319

14-
import java.util.ArrayList;
15-
import java.util.List;
16-
17-
import static org.hamcrest.MatcherAssert.assertThat;
18-
import static org.hamcrest.Matchers.containsInAnyOrder;
19-
import static org.hamcrest.Matchers.equalTo;
20-
2120
public class TypeScriptDelegatorTest {
2221
@Test
2322
public void vendsWritersForShapes() {
@@ -32,7 +31,7 @@ public void vendsWritersForShapes() {
3231
delegator.useShapeWriter(fooShape, writer -> writer.write("Hello!"));
3332
delegator.flushWriters();
3433

35-
assertThat(manifest.getFileString(CodegenUtils.SOURCE_FOLDER + "/Foo.txt").get(), equalTo("Hello!\n"));
34+
assertThat(manifest.getFileString("Foo.txt").get(), equalTo("Hello!\n"));
3635
}
3736

3837
@Test
@@ -61,7 +60,7 @@ public void appendsToOpenedWriterWithNewline() {
6160
delegator.useShapeWriter(fooShape, writer -> writer.write("Goodbye!"));
6261
delegator.flushWriters();
6362

64-
assertThat(manifest.getFileString(CodegenUtils.SOURCE_FOLDER + "/Foo.txt").get(), equalTo("Hello!\n\nGoodbye!\n"));
63+
assertThat(manifest.getFileString("Foo.txt").get(), equalTo("Hello!\n\nGoodbye!\n"));
6564
}
6665

6766
@Test

0 commit comments

Comments
 (0)