-
Notifications
You must be signed in to change notification settings - Fork 132
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 completion item for string union types #1392
Conversation
Signed-off-by: shruti2522 <shruti.apc01@gmail.com>
Hello @shruti2522 Please note that the position of cc @He1pa Could you help review it? |
Okay got it @Peefy , I will push the code for dot completion. Should I undo the attribute completion logic here? |
Pull Request Test Coverage Report for Build 9476907236Warning: This coverage report may be inaccurate.This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.
Details
💛 - Coveralls |
Sure. Undo it |
Signed-off-by: shruti2522 <shruti.apc01@gmail.com>
Done @Peefy |
Signed-off-by: shruti2522 <shruti.apc01@gmail.com>
Hello. You can just add symbol complete items here for the string lit type 😄: https://github.com/kcl-lang/kcl/blob/main/kclvm/sema/src/core/symbol.rs#L385 |
Hello @Peefy, I tried using |
Signed-off-by: shruti2522 <shruti.apc01@gmail.com>
cc @He1pa Could you help give more comments? |
Hello, I attempted to integrate the
current behaviour: Screencast.from.2024-06-11.13-25-37.webm |
cc @He1pa Could you help review it? |
Signed-off-by: shruti2522 <shruti.apc01@gmail.com> make fmt Signed-off-by: shruti2522 <shruti.apc01@gmail.com> add symbol complete items for string lit type Signed-off-by: shruti2522 <shruti.apc01@gmail.com>
done @Peefy Screencast.from.2024-06-12.02-20-01.webm |
@@ -318,6 +318,91 @@ fn completion_dot( | |||
} | |||
None => {} | |||
} | |||
|
|||
if let Some(scope) = gs.look_up_scope(pos) { |
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.
Why do we need to get all the symbols in the scope here? I think it is enough to just modify the get_all_attributes part, and the complete function should not be modified.
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.
done @He1pa
Signed-off-by: shruti2522 <shruti.apc01@gmail.com> make fmt Signed-off-by: shruti2522 <shruti.apc01@gmail.com> conditional attrs for union types Signed-off-by: shruti2522 <shruti.apc01@gmail.com>
94faaf1
to
19efb90
Compare
Hello @shruti2522 I think just modifying the symbol.rs file is enough, there is no need to modify the
TypeKind::Union(types) => {
if types.iter().all(|ut| {
matches!(
&ut.kind,
TypeKind::StrLit(_) | TypeKind::Str
)
}) {
self.get_symbol_by_fully_qualified_name(BUILTIN_STR_PACKAGE)
} else {
None
}
}
TypeKind::StrLit(_) | TypeKind::Str => {
let mut result = vec![];
if let Some(symbol_ref) = self.get_type_symbol(ty, module_info) {
if let Some(symbol) = self.get_symbol(symbol_ref) {
result = symbol.get_all_attributes(self, module_info);
}
}
result
} Besides, you need to add more unit tests for this feature. |
Signed-off-by: shruti2522 <shruti.apc01@gmail.com>
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.
LGTM
1. Does this PR affect any open issues?(Y/N) and add issue references (e.g. "fix #123", "re #123".):
fix [Enhancement] Add completion item for the string union types. #1391
2. What is the scope of this PR (e.g. component or file name):
kclvm/tools/src/LSP/src/completion.rs
3. Provide a description of the PR(e.g. more details, effects, motivations or doc link):
Screencast.from.2024-06-06.21-56-13.webm
4. Are there any breaking changes?(Y/N) and describe the breaking changes(e.g. more details, motivations or doc link):
5. Are there test cases for these changes?(Y/N) select and add more details, references or doc links: