Skip to content

Commit

Permalink
Feature(LSP): Completion and enhancement for GotoDefinition (#475)
Browse files Browse the repository at this point in the history
Feat(LSP): Completion and enhancement for GotoDefinition
1. complete: import pkg, schema attr, builtin functions(str functions), pkg's definition and system module functions
2. goto def: schema attr and schema attr type
  • Loading branch information
He1pa committed Apr 6, 2023
1 parent 9c16d1d commit 0651e98
Show file tree
Hide file tree
Showing 80 changed files with 1,374 additions and 346 deletions.
3 changes: 2 additions & 1 deletion kclvm/parser/src/parser/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use super::Parser;

use either::{self, Either};
use kclvm_ast::node_ref;
use kclvm_ast::token::Token;

use crate::parser::precedence::Precedence;
use kclvm_ast::ast::*;
Expand Down Expand Up @@ -2233,7 +2234,7 @@ impl<'a> Parser<'a> {
Box::new(Node::node(
Expr::Missing(MissingExpr),
// The text range of missing expression is zero.
self.sess.struct_token_loc(self.prev_token, self.token),
self.sess.struct_token_loc(self.token, self.token),
))
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
source: parser/src/tests/error_recovery.rs
assertion_line: 156
expression: "crate::tests::parsing_module_string(r#\"assert\"#)"
---
Module {
Expand All @@ -18,7 +17,7 @@ Module {
),
filename: "",
line: 1,
column: 0,
column: 6,
end_line: 1,
end_column: 6,
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
source: parser/src/tests/error_recovery.rs
assertion_line: 158
expression: "crate::tests::parsing_module_string(r#\"assert True,,, 'msg'\"#)"
---
Module {
Expand Down Expand Up @@ -32,7 +31,7 @@ Module {
),
filename: "",
line: 1,
column: 11,
column: 12,
end_line: 1,
end_column: 13,
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
source: parser/src/tests/error_recovery.rs
assertion_line: 145
expression: "crate::tests::parsing_module_string(r#\"a = \"#)"
---
Module {
Expand Down Expand Up @@ -34,7 +33,7 @@ Module {
),
filename: "",
line: 1,
column: 2,
column: 4,
end_line: 1,
end_column: 4,
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
source: parser/src/tests/error_recovery.rs
assertion_line: 147
expression: "crate::tests::parsing_module_string(r#\"a: int =\"#)"
---
Module {
Expand Down Expand Up @@ -34,7 +33,7 @@ Module {
),
filename: "",
line: 1,
column: 7,
column: 8,
end_line: 1,
end_column: 8,
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
source: parser/src/tests/error_recovery.rs
assertion_line: 150
expression: "crate::tests::parsing_module_string(r#\"a = b = \"#)"
---
Module {
Expand Down Expand Up @@ -48,7 +47,7 @@ Module {
),
filename: "",
line: 1,
column: 6,
column: 8,
end_line: 1,
end_column: 8,
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
source: parser/src/tests/error_recovery.rs
assertion_line: 69
expression: "crate::tests::parsing_expr_string(r#\"a -not- b\"#)"
---
Node {
Expand Down Expand Up @@ -38,7 +37,7 @@ Node {
),
filename: "",
line: 1,
column: 3,
column: 6,
end_line: 1,
end_column: 7,
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
source: parser/src/tests/error_recovery.rs
assertion_line: 112
expression: "crate::tests::parsing_expr_string(r#\"a(\"#)"
---
Node {
Expand Down Expand Up @@ -29,7 +28,7 @@ Node {
),
filename: "",
line: 1,
column: 1,
column: 2,
end_line: 1,
end_column: 2,
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
source: parser/src/tests/error_recovery.rs
assertion_line: 114
expression: "crate::tests::parsing_expr_string(r#\"a(a,,)\"#)"
---
Node {
Expand Down Expand Up @@ -45,7 +44,7 @@ Node {
),
filename: "",
line: 1,
column: 3,
column: 4,
end_line: 1,
end_column: 5,
},
Expand All @@ -55,7 +54,7 @@ Node {
),
filename: "",
line: 1,
column: 4,
column: 5,
end_line: 1,
end_column: 6,
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
source: parser/src/tests/error_recovery.rs
assertion_line: 72
expression: "crate::tests::parsing_expr_string(r#\"a <> b\"#)"
---
Node {
Expand Down Expand Up @@ -33,7 +32,7 @@ Node {
),
filename: "",
line: 1,
column: 2,
column: 3,
end_line: 1,
end_column: 4,
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
source: parser/src/tests/error_recovery.rs
assertion_line: 75
expression: "crate::tests::parsing_expr_string(r#\"a <<< b\"#)"
---
Node {
Expand Down Expand Up @@ -34,7 +33,7 @@ Node {
),
filename: "",
line: 1,
column: 2,
column: 4,
end_line: 1,
end_column: 5,
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
source: parser/src/tests/error_recovery.rs
assertion_line: 76
expression: "crate::tests::parsing_expr_string(r#\"a <+< b\"#)"
---
Node {
Expand Down Expand Up @@ -37,7 +36,7 @@ Node {
),
filename: "",
line: 1,
column: 3,
column: 4,
end_line: 1,
end_column: 5,
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
source: parser/src/tests/error_recovery.rs
assertion_line: 64
expression: "crate::tests::parsing_expr_string(\"{**a, *b}\")"
---
Node {
Expand Down Expand Up @@ -47,7 +46,7 @@ Node {
),
filename: "",
line: 1,
column: 4,
column: 6,
end_line: 1,
end_column: 7,
},
Expand Down Expand Up @@ -85,7 +84,7 @@ Node {
),
filename: "",
line: 1,
column: 8,
column: 9,
end_line: 1,
end_column: 9,
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
source: parser/src/tests/error_recovery.rs
assertion_line: 69
expression: "crate::tests::parsing_expr_string(\"{if True: a = , b = 2}\")"
---
Node {
Expand Down Expand Up @@ -52,7 +51,7 @@ Node {
),
filename: "",
line: 1,
column: 12,
column: 14,
end_line: 1,
end_column: 15,
},
Expand All @@ -61,7 +60,7 @@ Node {
},
filename: "",
line: 1,
column: 12,
column: 14,
end_line: 1,
end_column: 15,
},
Expand Down Expand Up @@ -118,7 +117,7 @@ Node {
),
filename: "",
line: 1,
column: 20,
column: 21,
end_line: 1,
end_column: 22,
},
Expand All @@ -129,7 +128,7 @@ Node {
),
filename: "",
line: 1,
column: 20,
column: 21,
end_line: 1,
end_column: 22,
},
Expand All @@ -138,7 +137,7 @@ Node {
},
filename: "",
line: 1,
column: 20,
column: 21,
end_line: 1,
end_column: 22,
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
source: parser/src/tests/error_recovery.rs
assertion_line: 70
expression: "crate::tests::parsing_expr_string(\"{if True: *a, b = 2}\")"
---
Node {
Expand Down Expand Up @@ -38,7 +37,7 @@ Node {
),
filename: "",
line: 1,
column: 8,
column: 10,
end_line: 1,
end_column: 11,
},
Expand Down Expand Up @@ -76,7 +75,7 @@ Node {
),
filename: "",
line: 1,
column: 11,
column: 12,
end_line: 1,
end_column: 13,
},
Expand All @@ -85,7 +84,7 @@ Node {
},
filename: "",
line: 1,
column: 11,
column: 12,
end_line: 1,
end_column: 13,
},
Expand Down Expand Up @@ -142,7 +141,7 @@ Node {
),
filename: "",
line: 1,
column: 18,
column: 19,
end_line: 1,
end_column: 20,
},
Expand All @@ -153,7 +152,7 @@ Node {
),
filename: "",
line: 1,
column: 18,
column: 19,
end_line: 1,
end_column: 20,
},
Expand All @@ -162,7 +161,7 @@ Node {
},
filename: "",
line: 1,
column: 18,
column: 19,
end_line: 1,
end_column: 20,
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
source: parser/src/tests/error_recovery.rs
assertion_line: 65
expression: "crate::tests::parsing_expr_string(\"{a = 1,, b = 2}\")"
---
Node {
Expand Down Expand Up @@ -60,7 +59,7 @@ Node {
),
filename: "",
line: 1,
column: 6,
column: 7,
end_line: 1,
end_column: 8,
},
Expand Down Expand Up @@ -99,7 +98,7 @@ Node {
),
filename: "",
line: 1,
column: 9,
column: 11,
end_line: 1,
end_column: 12,
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
source: parser/src/tests/error_recovery.rs
assertion_line: 63
expression: "crate::tests::parsing_expr_string(\"{*a, **b}\")"
---
Node {
Expand All @@ -19,7 +18,7 @@ Node {
),
filename: "",
line: 1,
column: 0,
column: 1,
end_line: 1,
end_column: 2,
},
Expand Down Expand Up @@ -60,7 +59,7 @@ Node {
),
filename: "",
line: 1,
column: 3,
column: 5,
end_line: 1,
end_column: 7,
},
Expand Down
Loading

0 comments on commit 0651e98

Please sign in to comment.