-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds support for imports in code generation (#169)
* Modifies `generate_code_for_authorities` to traverse through all subdirectories of a schema authority to generate code * Modifies `generate` to generate code for header and inline imports * Adds a change for scalar template * Adds tests for inline and header imports * Remove `--schema` option
- Loading branch information
Showing
16 changed files
with
149 additions
and
85 deletions.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
code-gen-projects/input/bad/sequence_with_import/mismatched_sequence_element_type.ion
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[ mango ] // expected apple, banana or strawberry, found mango |
1 change: 1 addition & 0 deletions
1
code-gen-projects/input/bad/sequence_with_import/mismatched_sequence_type.ion
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
(apple banana) // expected list, found sexp |
5 changes: 5 additions & 0 deletions
5
code-gen-projects/input/bad/struct_with_inline_import/mismatched_import_type.ion
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
// simple struct with type mismatched import field | ||
{ | ||
A: "hello", | ||
B: false, // expected field type symbol | ||
} |
1 change: 1 addition & 0 deletions
1
code-gen-projects/input/good/sequence_with_import/empty_sequence.ion
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[] |
1 change: 1 addition & 0 deletions
1
code-gen-projects/input/good/sequence_with_import/valid_elements.ion
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[ apple, strawberry ] |
5 changes: 5 additions & 0 deletions
5
code-gen-projects/input/good/struct_with_inline_import/valid_fields.ion
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
// simple struct with all valid fields | ||
{ | ||
A: "hello", | ||
B: apple, | ||
} |
5 changes: 5 additions & 0 deletions
5
code-gen-projects/input/good/struct_with_inline_import/valid_optional_fields.ion
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
// simple struct with all valid fields | ||
{ | ||
A: "hello", | ||
// B: apple, // since `B` is an optional field, this is a valid struct | ||
} |
5 changes: 5 additions & 0 deletions
5
code-gen-projects/input/good/struct_with_inline_import/valid_unordered_fields.ion
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
// struct with unordered fields | ||
{ | ||
B: banana, | ||
A: "hello", | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
schema_header::{ | ||
imports: [ | ||
{ id: "utils/fruits.isl", type: fruits } | ||
] | ||
} | ||
|
||
type::{ | ||
name: sequence_with_import, | ||
type: list, | ||
element: fruits | ||
} | ||
|
||
schema_footer::{} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
type::{ | ||
name: struct_with_inline_import, | ||
type: struct, | ||
fields: { | ||
A: string, | ||
B: { id: "utils/fruits.isl", type: fruits } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
type::{ | ||
name: fruits, | ||
valid_values: [apple, banana, strawberry] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters