Skip to content

Commit

Permalink
add function symbol kind to lsp
Browse files Browse the repository at this point in the history
Signed-off-by: shruti2522 <[email protected]>
  • Loading branch information
shruti2522 committed May 31, 2024
1 parent fbc4bf8 commit 67cb3c8
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
11 changes: 11 additions & 0 deletions kclvm/sema/src/core/symbol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,17 @@ impl SymbolData {
symbol_ref,
);
}

for (id, _) in self.values.iter() {
let symbol_ref = SymbolRef {
id,
kind: SymbolKind::Function,
};
self.symbols_info.fully_qualified_name_map.insert(
self.get_fully_qualified_name(symbol_ref).unwrap(),
symbol_ref,
);
}
}

pub fn alloc_package_symbol(&mut self, pkg: PackageSymbol) -> SymbolRef {
Expand Down
1 change: 1 addition & 0 deletions kclvm/tools/src/LSP/src/document_symbol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ fn symbol_kind_to_document_symbol_kind(kind: KCLSymbolKind) -> Option<SymbolKind
KCLSymbolKind::Schema => Some(SymbolKind::STRUCT),
KCLSymbolKind::Attribute => Some(SymbolKind::PROPERTY),
KCLSymbolKind::Value => Some(SymbolKind::VARIABLE),
KCLSymbolKind::Function => Some(SymbolKind::FUNCTION),
KCLSymbolKind::Package => Some(SymbolKind::PACKAGE),
KCLSymbolKind::TypeAlias => Some(SymbolKind::TYPE_PARAMETER),
KCLSymbolKind::Unresolved => Some(SymbolKind::NULL),
Expand Down
2 changes: 2 additions & 0 deletions kclvm/tools/src/LSP/src/semantic_token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ pub const LEGEND_TYPE: &[SemanticTokenType] = &[
SemanticTokenType::MACRO,
SemanticTokenType::COMMENT,
SemanticTokenType::PARAMETER,
SemanticTokenType::FUNCTION,
];

pub(crate) struct KCLSemanticToken {
Expand Down Expand Up @@ -63,6 +64,7 @@ pub(crate) fn get_kind(ty: SymbolKind, symbol: &KCLSymbol, gs: &GlobalState) ->
SymbolKind::Package => Some(type_index(SemanticTokenType::NAMESPACE)),
SymbolKind::TypeAlias => Some(type_index(SemanticTokenType::TYPE)),
SymbolKind::Value => Some(type_index(SemanticTokenType::VARIABLE)),
SymbolKind::Function => Some(type_index(SemanticTokenType::FUNCTION)),
SymbolKind::Rule => Some(type_index(SemanticTokenType::MACRO)),
SymbolKind::Unresolved => match &symbol.get_definition() {
Some(def_ref) => match gs.get_symbols().get_symbol(*def_ref) {
Expand Down

0 comments on commit 67cb3c8

Please sign in to comment.