Skip to content

Commit

Permalink
jump-to-lib
Browse files Browse the repository at this point in the history
  • Loading branch information
vuvoth committed Mar 21, 2024
1 parent 162ed2c commit a533850
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 11 deletions.
2 changes: 1 addition & 1 deletion crates/lsp/src/global_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use lsp_types::{

use parser::token_kind::TokenKind;
use rowan::ast::AstNode;
use syntax::abstract_syntax_tree::{AstCircomProgram, AstComponentDecl};
use syntax::abstract_syntax_tree::AstCircomProgram;
use syntax::syntax::SyntaxTreeBuilder;
use syntax::syntax_node::SyntaxToken;

Expand Down
30 changes: 20 additions & 10 deletions crates/lsp/src/handler/goto_definition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,7 @@ pub fn lookup_component(template: &AstTemplateDef, text: SyntaxText) -> Option<A
None
}

pub fn lookup_definition(
file: &FileDB,
ast: &AstCircomProgram,
semantic_data: &SemanticData,
token: &SyntaxToken,
) -> Vec<Location> {
let template_list = ast.template_list();

let mut res = Vec::new();
let mut signal_outside = false;
pub fn jump_to_lib(file: &FileDB, token: &SyntaxToken) -> Vec<Location> {
if let Some(include_lib) = lookup_node_wrap_token(TokenKind::IncludeKw, token) {
if let Some(ast_include) = AstInclude::cast(include_lib) {
if let Some(abs_lib_ans) = ast_include.lib() {
Expand All @@ -85,6 +76,25 @@ pub fn lookup_definition(
}
}

Vec::new()
}

pub fn lookup_definition(
file: &FileDB,
ast: &AstCircomProgram,
semantic_data: &SemanticData,
token: &SyntaxToken,
) -> Vec<Location> {
let template_list = ast.template_list();

let mut res = Vec::new();

if token.kind() == TokenKind::CircomString {
return jump_to_lib(file, token);
}

let mut signal_outside = false;

if let Some(component_call) = lookup_node_wrap_token(TokenKind::ComponentCall, token) {
// find template called.
if let Some(ast_component_call) = AstComponentCall::cast(component_call) {
Expand Down

0 comments on commit a533850

Please sign in to comment.