diff --git a/editors/code/README.md b/editors/code/README.md index 670b01f..fd3ecec 100644 --- a/editors/code/README.md +++ b/editors/code/README.md @@ -48,12 +48,9 @@ The `aptos-move-analyzer` Visual Studio Code extension works via two components: #### A. Download the precompiled binaries for the aptos-move-analyzer language server(Recommended) -```Windows``` -> Download [aptos-move-analyzer-win-installer-v0.3.0.msi](https://github.com/movebit/move/releases/tag/aptos-move-analyzer-v0.4.0), and proceed with the installation. This installation program will automatically add the path of `aptos-move-analyzer` to the **PATH** environment variable. - ```MacOS & Ubuntu``` - > 1.Download binary files for the corresponding platform from [aptos-move-analyzer-releases-pages](https://github.com/movebit/move/releases/tag/aptos-move-analyzer-v0.5.0). + > 1.Download binary files for the corresponding platform from [aptos-move-analyzer-releases-pages](https://github.com/movebit/aptos-move-analyzer/releases/tag/aptos-move-analyzer-v1.0.0). > > 2.Rename it to `aptos-move-analyzer`. > @@ -67,7 +64,7 @@ The `aptos-move-analyzer` language server is a Rust program, so we suggest insta **Execute the below command to install `aptos_move_analyzer`** ``` -cargo install --git https://github.com/movebit/move --branch release/aptos-move-analyzer aptos-move-analyzer +cargo install --git https://github.com/movebit/aptos-move-analyzer --branch release/aptos-move-analyzer aptos-move-analyzer ``` The installation may take some time, often several minutes. After installation, the `aptos-move-analyzer` program is in your `cargo` binary directory. On macOS and Linux, this directory is usually `~/.cargo/bin`. You should make sure this location is in your `PATH` environment variable via `export PATH="$PATH:~/.cargo/bin"` . @@ -153,6 +150,6 @@ When you first open a project, there will be some dependencies (configured in Mo ## Support -1.If you find any issues, please report a GitHub issue to the [movebit/move-analyzer-issue](https://github.com/movebit/move-analyzer-issue) repository to get help. +1.If you find any issues, please report a GitHub issue to the [aptos-move-analyzer-issues](https://github.com/movebit/aptos-move-analyzer/issues) repository to get help. 2.Welcome to the developer discussion group as well: [MoveAnalyzer](https://t.me/moveanalyzer). diff --git a/src/completion.rs b/src/completion.rs index 365156d..8ec5172 100644 --- a/src/completion.rs +++ b/src/completion.rs @@ -309,7 +309,6 @@ pub fn on_completion_request(context: &Context, request: &Request) -> lsp_server if candidate_modules.is_empty() { log::error!("cannot get target module\n"); } - log::info!("-------------------- 0624 --------------------"); let file_buffer_str = current_project.current_modifing_file_content.as_str(); let buffer = Some(file_buffer_str); @@ -363,7 +362,6 @@ pub fn on_completion_request(context: &Context, request: &Request) -> lsp_server ¤t_project.global_env, ); items.extend_from_slice(&module_items); - log::info!("Tok::Period"); } _ => { // If the user's cursor is positioned anywhere other than following a `.`, `:`, or `::`, @@ -393,12 +391,6 @@ pub fn on_completion_request(context: &Context, request: &Request) -> lsp_server } } - // if let Some(cursor_line_buffer) = &cursor_line { - // let identifiers = identifiers(cursor_line_buffer.as_str(), ¤t_project.global_env, &fpath); - // // log::info!("identifiers = {:?}", identifiers); - // items.extend_from_slice(&identifiers); - // } - let result = serde_json::to_value(items).expect("could not serialize completion response"); let response = lsp_server::Response::new_ok(request.id.clone(), result); let ret_response = response.clone(); diff --git a/src/inlay_hints.rs b/src/inlay_hints.rs index d0f4315..0a9e2bf 100644 --- a/src/inlay_hints.rs +++ b/src/inlay_hints.rs @@ -22,15 +22,6 @@ pub fn on_inlay_hints( let fpath = parameters.text_document.uri.to_file_path().unwrap(); let fpath = path_concat(std::env::current_dir().unwrap().as_path(), fpath.as_path()); - // if !inlay_hints_config.enable { - // log::info!("inlay-hints is not enabled."); - // return Response { - // id: "".to_string().into(), - // result: Some(serde_json::json!({"msg": "Inlay-hints is not enabled."})), - // error: None, - // }; - // } - let mut handler = Handler::new(fpath.clone(), parameters.range); match context.projects.get_project(&fpath) { Some(x) => x, diff --git a/src/references.rs b/src/references.rs index e64dc59..3eedad8 100644 --- a/src/references.rs +++ b/src/references.rs @@ -25,7 +25,8 @@ use move_model::{ symbol::Symbol, }; use std::{ - collections::{BTreeSet, HashMap}, path::{Path, PathBuf} + collections::{BTreeSet, HashMap}, + path::{Path, PathBuf}, }; /// Handles on_references_request of the language server. @@ -290,9 +291,14 @@ impl Handler { }; } - fn process_fn_name(&mut self, env: &GlobalEnv, target_fun: &FunctionEnv) { + fn process_fn_name( + &mut self, + env: &GlobalEnv, + capture_loc: &move_model::model::Loc, + target_fun: &FunctionEnv, + ) { let mut result_candidates: Vec = Vec::new(); - let mut capture_loc = target_fun.get_loc(); + let mut capture_loc = capture_loc.clone(); let target_fn_str = target_fun.get_name_str(); capture_loc = move_model::model::Loc::new( capture_loc.file_id(), @@ -332,6 +338,7 @@ impl Handler { self.capture_items_span.push(capture_loc.span()); } } + fn process_parameter(&mut self, env: &GlobalEnv, target_fun: &FunctionEnv) { let fun_paras = target_fun.get_parameters(); log::info!("process_parameter >> fun_paras: {:?}", fun_paras); @@ -340,7 +347,7 @@ impl Handler { for (para_idx, para) in fun_paras.iter().enumerate() { if para.2.span().start() > self.mouse_span.end() { if para_idx == 0 { - return self.process_fn_name(env, target_fun); + return self.process_fn_name(env, &target_fun.get_loc(), target_fun); } break; } @@ -352,7 +359,7 @@ impl Handler { } } if fun_paras.is_empty() { - return self.process_fn_name(env, target_fun); + return self.process_fn_name(env, &target_fun.get_loc(), target_fun); } let para = &fun_paras[correct_para_idx]; @@ -592,8 +599,7 @@ impl Handler { let field_source = env.get_source(&field_loc); if let Ok(atomic_field_str) = field_source { if let Some(index) = atomic_field_str.find("\n".to_string().as_str()) { - let atomic_field_end = - field_start + codespan::ByteOffset(index as i64); + let atomic_field_end = field_start + codespan::ByteOffset(index as i64); let atomic_field_loc = move_model::model::Loc::new( target_struct_loc.file_id(), codespan::Span::new(field_start, atomic_field_end), @@ -726,51 +732,7 @@ impl Handler { { let called_module = env.get_module(*mid); let called_fun = called_module.get_function(*fid); - log::info!( - " -- process_call -- get_called_functions = {:?}", - called_fun.get_full_name_str() - ); - - if let Some(calling_fns) = called_fun.get_calling_functions() { - let mut result_candidates: Vec = Vec::new(); - for caller in calling_fns { - let f = env.get_function(caller); - let mut caller_fun_loc = f.get_loc(); - // need locate called_fun.get_full_name_str() in f's body source - let f_source = env.get_source(&caller_fun_loc); - if let Ok(f_source_str) = f_source { - if let Some(index) = - f_source_str.find(called_fun.get_name_str().as_str()) - { - let target_len: usize = called_fun.get_name_str().len(); - let start = caller_fun_loc.span().start() - + codespan::ByteOffset(index as i64); - let end = - start + codespan::ByteOffset(target_len as i64); - caller_fun_loc = move_model::model::Loc::new( - caller_fun_loc.file_id(), - codespan::Span::new(start, end), - ); - } - } - let (caller_fun_file, caller_fun_line) = - env.get_file_and_location(&caller_fun_loc).unwrap(); - - let result = FileRange { - path: PathBuf::from(caller_fun_file), - line_start: caller_fun_line.line.0, - col_start: caller_fun_line.column.0, - line_end: caller_fun_line.line.0, - col_end: caller_fun_line.column.0 - + called_fun.get_name_str().len() as u32, - }; - result_candidates.push(result); - } - if !result_candidates.is_empty() { - self.result_ref_candidates.push(result_candidates); - self.capture_items_span.push(this_call_loc.span()); - } - } + self.process_fn_name(env, &this_call_loc, &called_fun); } } @@ -789,17 +751,7 @@ impl Handler { for callee in spec_fun.callees.clone() { let module = env.get_module(callee.module_id); let decl = module.get_spec_fun(callee.id); - - let (caller_fun_file, caller_fun_line) = - env.get_file_and_location(&decl.loc).unwrap(); - let result = FileRange { - path: PathBuf::from(caller_fun_file), - line_start: caller_fun_line.line.0, - col_start: caller_fun_line.column.0, - line_end: caller_fun_line.line.0, - col_end: caller_fun_line.column.0, - }; - result_candidates.push(result); + result_candidates.push(self.convert_loc_to_file_range(env, &decl.loc)); } if !result_candidates.is_empty() { self.result_ref_candidates.push(result_candidates); @@ -822,7 +774,6 @@ impl Handler { let mut result_candidates: Vec = Vec::new(); let called_module = env.get_module(*mid); let called_struct = called_module.get_struct(*sid); - log::trace!(">> called_struct = {:?}", called_struct.get_full_name_str()); let called_field = called_struct.get_field(*fid); let field_name = called_field.get_name(); @@ -831,26 +782,6 @@ impl Handler { // for each_mod in env.get_modules() { // result_candidates.append(&mut self.find_field_used_of_module(&each_mod, field_name)); // } - - let field_name_str = field_name.display(env.symbol_pool()); - - let called_struct_loc = called_struct.get_loc(); - let call_struct_source = env.get_source(&called_struct_loc); - if let Ok(call_struct_str) = call_struct_source { - if let Some(index) = call_struct_str.find(field_name_str.to_string().as_str()) { - let field_start = called_struct_loc.span().start() - + codespan::ByteOffset(index as i64); - let field_len = field_name_str.to_string().len(); - let field_end = - field_start + codespan::ByteOffset(field_len as i64); - let field_loc = move_model::model::Loc::new( - called_struct_loc.file_id(), - codespan::Span::new(field_start, field_end), - ); - log::info!("field_loc = {:?}", env.get_source(&field_loc)); - result_candidates.push(self.convert_loc_to_file_range(env, &field_loc)); - } - } if !result_candidates.is_empty() { self.result_ref_candidates.push(result_candidates); self.capture_items_span.push(this_call_loc.span()); @@ -1085,18 +1016,17 @@ impl Handler { if let Some(index) = stc_ref_fn_source.find(mouse_capture_ty_symbol_str.as_str()) { - let capture_ref_ty_start = stc_ref_fn_loc.span().start() - + codespan::ByteOffset(index as i64); + let capture_ref_ty_start = + stc_ref_fn_loc.span().start() + codespan::ByteOffset(index as i64); let capture_ref_ty_end = capture_ref_ty_start - + codespan::ByteOffset( - mouse_capture_ty_symbol_str.len() as i64, - ); + + codespan::ByteOffset(mouse_capture_ty_symbol_str.len() as i64); let result_loc = move_model::model::Loc::new( stc_ref_fn_loc.file_id(), codespan::Span::new(capture_ref_ty_start, capture_ref_ty_end), ); - result_candidates.push(self.convert_loc_to_file_range(env, &result_loc)); + result_candidates + .push(self.convert_loc_to_file_range(env, &result_loc)); stc_ref_fn_loc = move_model::model::Loc::new( stc_ref_fn_loc.file_id(), codespan::Span::new( diff --git a/tests/test_document_symbols.rs b/tests/test_document_symbols.rs index 584aba4..2afce70 100644 --- a/tests/test_document_symbols.rs +++ b/tests/test_document_symbols.rs @@ -177,8 +177,6 @@ mod tests { ] ), ); - // // std::thread::sleep(Duration::new(1, 0)); - // log::info!("\n------------------------------\n"); eprintln!("actual_r = {:?}", actual_r.result); eprintln!("\n\n\n"); // log::trace!("expect_r = {:?}", expect_r);