Skip to content

Commit

Permalink
feat: add completion item for string union types (#1392)
Browse files Browse the repository at this point in the history
* feat: add completion item for string union types

Signed-off-by: shruti2522 <[email protected]>

* feat: add completion items for string_union_types

Signed-off-by: shruti2522 <[email protected]>

* remove unwanted code

Signed-off-by: shruti2522 <[email protected]>

* conditional completion for str and str lit

Signed-off-by: shruti2522 <[email protected]>

* add symbol complete items for string lit type

Signed-off-by: shruti2522 <[email protected]>

make fmt

Signed-off-by: shruti2522 <[email protected]>

add symbol complete items for string lit type

Signed-off-by: shruti2522 <[email protected]>

* make fmt

Signed-off-by: shruti2522 <[email protected]>

* conditional attrs for union types

Signed-off-by: shruti2522 <[email protected]>

make fmt

Signed-off-by: shruti2522 <[email protected]>

conditional attrs for union types

Signed-off-by: shruti2522 <[email protected]>

* add return value for union type to get_type_symbol

Signed-off-by: shruti2522 <[email protected]>

---------

Signed-off-by: shruti2522 <[email protected]>
  • Loading branch information
shruti2522 authored Jun 12, 2024
1 parent 0b210eb commit 5d94abe
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions kclvm/sema/src/core/symbol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -329,8 +329,16 @@ impl SymbolData {
TypeKind::Dict(_) => None,
TypeKind::NumberMultiplier(_) => None,
TypeKind::Function(_) => None,
TypeKind::Union(_) => None,

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::Schema(schema_ty) => {
let fully_qualified_ty_name = schema_ty.pkgpath.clone() + "." + &schema_ty.name;

Expand Down Expand Up @@ -373,7 +381,7 @@ impl SymbolData {
TypeKind::IntLit(_) => vec![],
TypeKind::Float => vec![],
TypeKind::FloatLit(_) => vec![],
TypeKind::Str => {
TypeKind::Str | TypeKind::StrLit(_) => {
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) {
Expand All @@ -382,7 +390,6 @@ impl SymbolData {
}
result
}
TypeKind::StrLit(_) => vec![],
TypeKind::List(_) => vec![],
TypeKind::Dict(_) => vec![],
TypeKind::NumberMultiplier(_) => vec![],
Expand Down

0 comments on commit 5d94abe

Please sign in to comment.