-
Notifications
You must be signed in to change notification settings - Fork 113
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: enhance the schema expr type check and impl the schema factory …
…using the dynamic type Signed-off-by: peefy <xpf6677@163.com>
- Loading branch information
Showing
24 changed files
with
189 additions
and
30 deletions.
There are no files selected for viewing
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
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
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
2 changes: 1 addition & 1 deletion
2
kclvm/tools/src/LSP/src/test_data/completion_test/import/external/kcl.mod
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
[package] | ||
|
||
[dependencies] | ||
k8s = "1.28" | ||
k8s = { oci = "oci://ghcr.io/kcl-lang/k8s", tag = "1.28" } |
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,19 @@ | ||
schema DataA: | ||
id?: int = 1 | ||
value?: str = "value" | ||
|
||
schema DataB: | ||
name?: str = "DataB" | ||
|
||
_dataFactory: {str:} = { | ||
A = DataA | ||
B = DataB | ||
} | ||
TypeA = _dataFactory["A"] | ||
TypeB = _dataFactory["B"] | ||
data0 = TypeA() | ||
data1 = TypeB() | ||
data2 = TypeA() {} | ||
data3 = TypeB {} | ||
data4 = TypeA {} | ||
data5 = TypeB {} |
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,15 @@ | ||
data0: | ||
id: 1 | ||
value: value | ||
data1: | ||
name: DataB | ||
data2: | ||
id: 1 | ||
value: value | ||
data3: | ||
name: DataB | ||
data4: | ||
id: 1 | ||
value: value | ||
data5: | ||
name: DataB |
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,19 @@ | ||
schema Foo: | ||
foo: str = "foo" | ||
|
||
schema Bar: | ||
bar: str = "bar" | ||
|
||
factory = lambda type: any, attrs: {:} = {} -> Foo | Bar { | ||
assert typeof(type) == "type" | ||
func = $type | ||
instance = func() {**attrs} | ||
} | ||
|
||
_foo = factory(Foo) | ||
_bar = factory(Bar) | ||
if typeof(_foo) == "Foo": | ||
foo = _foo as Foo | ||
|
||
if typeof(_bar) == "Bar": | ||
bar = _bar as Bar |
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 @@ | ||
foo: | ||
foo: foo | ||
bar: | ||
bar: bar |
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,19 @@ | ||
schema Foo: | ||
foo: str | ||
|
||
schema Bar: | ||
bar: str | ||
|
||
factory = lambda type: any, attrs: {:} = {} -> Foo | Bar { | ||
assert typeof(type) == "type" | ||
func = $type | ||
instance = func() {**attrs} | ||
} | ||
|
||
_foo = factory(Foo, {foo = "foo"}) # Note we set attributes here. | ||
_bar = factory(Bar, {bar = "bar"}) # Note we set attributes here. | ||
if typeof(_foo) == "Foo": | ||
foo = _foo as Foo | ||
|
||
if typeof(_bar) == "Bar": | ||
bar = _bar as Bar |
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 @@ | ||
foo: | ||
foo: foo | ||
bar: | ||
bar: bar |
Empty file.
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,3 @@ | ||
import pkg | ||
foo: pkg.Foo | pkg.Bar = pkg.Foo{} | ||
bar = foo as pkg.Foo |
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 @@ | ||
schema Foo: | ||
foo: int = 1 | ||
|
||
schema Bar: | ||
bar: int = 1 | ||
|
||
foo: Foo | Bar = Foo{} | ||
bar = foo as Foo |
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 @@ | ||
foo: | ||
foo: 1 | ||
bar: | ||
foo: 1 |
Oops, something went wrong.