-
Notifications
You must be signed in to change notification settings - Fork 121
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add hints for schema config expr #1589
Closed
Closed
Changes from 3 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
12ecc6f
modify walk config expr
shruti2522 422aa4c
set local scope
shruti2522 9859903
add hint
shruti2522 039f9dd
add schema hint
shruti2522 38757d5
updated snap
shruti2522 f080459
reduce complexity of with_hint
shruti2522 6da4b75
add test for nested schema hints
shruti2522 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
31 changes: 31 additions & 0 deletions
31
...ls/src/LSP/src/snapshots/kcl_language_server__inlay_hints__tests__schema_config_hint.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,31 @@ | ||
--- | ||
source: tools/src/LSP/src/inlay_hints.rs | ||
assertion_line: 127 | ||
expression: "format!(\"{:#?}\", res)" | ||
--- | ||
Some( | ||
[ | ||
InlayHint { | ||
position: Position { | ||
line: 3, | ||
character: 10, | ||
}, | ||
label: LabelParts( | ||
[ | ||
InlayHintLabelPart { | ||
value: "Name: ", | ||
tooltip: None, | ||
location: None, | ||
command: None, | ||
}, | ||
], | ||
), | ||
kind: None, | ||
text_edits: None, | ||
tooltip: None, | ||
padding_left: None, | ||
padding_right: None, | ||
data: None, | ||
}, | ||
], | ||
) |
6 changes: 6 additions & 0 deletions
6
kclvm/tools/src/LSP/src/test_data/inlay_hints/schema_config_hint/schema_config_hint.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,6 @@ | ||
schema Name: | ||
name: str | ||
|
||
n: Name = { | ||
name = "kcl" | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The complexity of this function is a bit high, and other methods can be used to determine it.
Besides, why add hint only for the assign_stmt
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess hints have to applied only for anonymous schema configs, like
that's why I used assign_stmt to determine if type annotations exist for the same, if yes then hints are applied, otherwise not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
config
in theName
schema also needs hints e.g.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hints are being applied for the
config
tooThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about this code, an assign stmt with the type annotation and the right value is a schema expr.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess we need to add check for schema_expr too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What I mean is that there are many such grammars, not just checking schema_exp or assign_stmt, but there needs to be a more effective way.