-
Notifications
You must be signed in to change notification settings - Fork 122
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add advanced resolver api to get definition within scope (#1442)
* feat: add advanced resolver api to get definition within scope. fix nested scehma config completion Signed-off-by: he1pa <18012015693@163.com> * fmt code Signed-off-by: he1pa <18012015693@163.com> --------- Signed-off-by: he1pa <18012015693@163.com>
- Loading branch information
Showing
9 changed files
with
150 additions
and
52 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
4 changes: 2 additions & 2 deletions
4
kclvm/tools/src/LSP/src/snapshots/kcl_language_server__completion__tests__lambda_1.snap
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,5 +1,5 @@ | ||
--- | ||
source: tools/src/LSP/src/completion.rs | ||
expression: "format!(\"{:?}\", labels)" | ||
expression: "format!(\"{:?}\",\n {\n let(file, program, _, gs) =\n compile_test_file(\"src/test_data/completion_test/lambda/lambda_1/lambda_1.k\")\n ; let pos = KCLPos\n { filename : file.clone(), line : 8, column : Some(5), } ; let tool =\n toolchain :: default() ; let mut got =\n completion(None, & program, & pos, & gs, & tool).unwrap() ; match &\n mut got\n {\n CompletionResponse :: Array(arr) =>\n {\n let mut labels : Vec < String > =\n arr.iter().map(| item | item.label.clone()).collect() ;\n labels.sort() ; let builtin_func_lables : Vec < String > =\n BUILTIN_FUNCTIONS.iter().map(| (name, func) |\n {\n func_ty_complete_label(name, & func.into_func_type())\n }).collect() ; println! (\"{:?}\", builtin_func_lables) ; let\n labels : Vec < String > =\n labels.iter().filter(| label |!\n builtin_func_lables.contains(label)).map(| label |\n label.clone()).collect() ; println! (\"{:?}\", labels) ; labels\n } CompletionResponse :: List(_) => panic! (\"test failed\"),\n }\n })" | ||
--- | ||
["abs(…)", "all_true(…)", "any_true(…)", "bin(…)", "bool(…)", "case", "cases", "dict(…)", "float(…)", "func1", "hex(…)", "int(…)", "isunique(…)", "len(…)", "list(…)", "max(…)", "min(…)", "multiplyof(…)", "oct(…)", "option(…)", "ord(…)", "pow(…)", "print(…)", "range(…)", "round(…)", "sorted(…)", "str(…)", "sum(…)", "typeof(…)", "zip(…)"] | ||
["case", "cases", "func1"] |
5 changes: 5 additions & 0 deletions
5
...c/snapshots/kcl_language_server__completion__tests__schema_attr_newline_completion_0.snap
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 @@ | ||
--- | ||
source: tools/src/LSP/src/completion.rs | ||
expression: "format!(\"{:?}\",\n {\n let(file, program, _, gs) =\n compile_test_file(\"src/test_data/completion_test/newline/schema/schema_0/schema_0.k\")\n ; let pos = KCLPos\n { filename : file.clone(), line : 8, column : Some(4), } ; let tool =\n toolchain :: default() ; let mut got =\n completion(Some('\\n'), & program, & pos, & gs, & tool).unwrap() ;\n match & mut got\n {\n CompletionResponse :: Array(arr) =>\n {\n let mut labels : Vec < String > =\n arr.iter().map(| item | item.label.clone()).collect() ;\n labels.sort() ; let builtin_func_lables : Vec < String > =\n BUILTIN_FUNCTIONS.iter().map(| (name, func) |\n {\n func_ty_complete_label(name, & func.into_func_type())\n }).collect() ; let labels : Vec < String > =\n labels.iter().filter(| label |!\n builtin_func_lables.contains(label)).map(| label |\n label.clone()).collect() ; labels\n } CompletionResponse :: List(_) => panic! (\"test failed\"),\n }\n })" | ||
--- | ||
["a", "c"] |
5 changes: 5 additions & 0 deletions
5
...snapshots/kcl_language_server__completion__tests__schema_attr_newline_completion_0_1.snap
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 @@ | ||
--- | ||
source: tools/src/LSP/src/completion.rs | ||
expression: "format!(\"{:?}\",\n {\n let(file, program, _, gs) =\n compile_test_file(\"src/test_data/completion_test/newline/schema/schema_0/schema_0.k\")\n ; let pos = KCLPos\n { filename : file.clone(), line : 5, column : Some(4), } ; let tool =\n toolchain :: default() ; let mut got =\n completion(Some('\\n'), & program, & pos, & gs, & tool).unwrap() ;\n match & mut got\n {\n CompletionResponse :: Array(arr) =>\n {\n let mut labels : Vec < String > =\n arr.iter().map(| item | item.label.clone()).collect() ;\n labels.sort() ; let builtin_func_lables : Vec < String > =\n BUILTIN_FUNCTIONS.iter().map(| (name, func) |\n {\n func_ty_complete_label(name, & func.into_func_type())\n }).collect() ; let labels : Vec < String > =\n labels.iter().filter(| label |!\n builtin_func_lables.contains(label)).map(| label |\n label.clone()).collect() ; labels\n } CompletionResponse :: List(_) => panic! (\"test failed\"),\n }\n })" | ||
--- | ||
[] |
5 changes: 5 additions & 0 deletions
5
...c/snapshots/kcl_language_server__completion__tests__schema_attr_newline_completion_1.snap
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 @@ | ||
--- | ||
source: tools/src/LSP/src/completion.rs | ||
expression: "format!(\"{:?}\",\n {\n let(file, program, _, gs) =\n compile_test_file(\"src/test_data/completion_test/newline/schema/schema_1/schema_1.k\")\n ; let pos = KCLPos\n { filename : file.clone(), line : 10, column : Some(4), } ; let tool =\n toolchain :: default() ; let mut got =\n completion(None, & program, & pos, & gs, & tool).unwrap() ; match &\n mut got\n {\n CompletionResponse :: Array(arr) =>\n {\n let mut labels : Vec < String > =\n arr.iter().map(| item | item.label.clone()).collect() ;\n labels.sort() ; let builtin_func_lables : Vec < String > =\n BUILTIN_FUNCTIONS.iter().map(| (name, func) |\n {\n func_ty_complete_label(name, & func.into_func_type())\n }).collect() ; println! (\"{:?}\", builtin_func_lables) ; let\n labels : Vec < String > =\n labels.iter().filter(| label |!\n builtin_func_lables.contains(label)).map(| label |\n label.clone()).collect() ; println! (\"{:?}\", labels) ; labels\n } CompletionResponse :: List(_) => panic! (\"test failed\"),\n }\n })" | ||
--- | ||
["name"] |
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 |
---|---|---|
|
@@ -5,5 +5,5 @@ schema Person[b: int](Base): | |
c: int | ||
|
||
p1= Person(b){ | ||
|
||
} |
13 changes: 13 additions & 0 deletions
13
kclvm/tools/src/LSP/src/test_data/completion_test/newline/schema/schema_1/schema_1.k
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 Name: | ||
name: str | ||
|
||
schema Person: | ||
name: Name | ||
age: int | ||
|
||
p = Person{ | ||
name: Name{ | ||
|
||
} | ||
} | ||
|