Skip to content

Commit

Permalink
Merge pull request #79 from asarazan/fix/star-imports
Browse files Browse the repository at this point in the history
fix missing json imports for star import strategy
  • Loading branch information
asarazan authored Apr 24, 2024
2 parents b1e8994 + cd0a856 commit 7ddf776
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
7 changes: 6 additions & 1 deletion src/kotlin/StandardKotlinImports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,10 @@ export const StandardKotlinImportList = [
`import kotlinx.serialization.json.jsonObject`,
];

export const StarKotlinImport = "import kotlinx.serialization.*";
export const StarKotlinImportList = [
"import kotlinx.serialization.*",
"import kotlinx.serialization.json.*",
];

export const StarKotlinImports = StarKotlinImportList.join("\n");
export const StandardKotlinImports = StandardKotlinImportList.join("\n");
4 changes: 2 additions & 2 deletions src/martok/Martok.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import _ from "lodash";
import { TsHelper } from "../typescript/TsHelper";
import {
StandardKotlinImportList,
StarKotlinImport,
StarKotlinImportList,
} from "../kotlin/StandardKotlinImports";
import { ImportGenerator } from "./ImportGenerator";
import { DeclarationGenerator } from "./declarations/DeclarationGenerator";
Expand Down Expand Up @@ -167,7 +167,7 @@ export class Martok {
package: `package ${pkg}`,
imports: [
...(this.config.options?.importStar
? [StarKotlinImport]
? StarKotlinImportList
: StandardKotlinImportList),
],
declarations: [],
Expand Down
5 changes: 3 additions & 2 deletions src/martok/MartokFormatter.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { MartokOutFile } from "./MartokOutFile";
import {
StandardKotlinImports,
StarKotlinImport,
StarKotlinImportList,
StarKotlinImports,
} from "../kotlin/StandardKotlinImports";
import { MartokConfig } from "./MartokConfig";
import { KlassPrinter } from "../kotlin/KlassPrinter";
Expand All @@ -27,7 +28,7 @@ ${file.text.declarations
return `${StandardFileHeader}
package ${this.config.package}
${this.config.options?.importStar ? StarKotlinImport : StandardKotlinImports}
${this.config.options?.importStar ? StarKotlinImports : StandardKotlinImports}
${files
.flatMap((value) =>
Expand Down

0 comments on commit 7ddf776

Please sign in to comment.