Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
7e5077f
feat: Add callable types lookup table with language-specific support
agentic-labs-demo Jan 22, 2025
3e7aa80
refactor: Replace function check with is_callable() method
agentic-labs-demo Jan 22, 2025
012bf01
feat: Add comprehensive callable types for multiple programming langu…
agentic-labs-demo Jan 22, 2025
6df51cd
refactor: Replace lazy_static with once_cell and consolidate imports
agentic-labs-demo Jan 22, 2025
53bdb92
feat: Add once_cell dependency to Cargo.toml
agentic-labs-demo Jan 22, 2025
c0c386f
fix: Clone typescript before inserting to resolve moved value error
agentic-labs-demo Jan 22, 2025
d5784ae
refactor: Extract shared logic for checking external or callable defi…
agentic-labs-demo Jan 22, 2025
41ed7ba
refactor: Simplify external definition check with consistent early re…
agentic-labs-demo Jan 22, 2025
d5613ad
refactor: Simplify symbol match and references retrieval in AstGrepCl…
agentic-labs-demo Jan 22, 2025
ca95887
Simplify
agentic-labs-demo Jan 22, 2025
75830df
refactor: Improve resolve_definition_chain with clearer base and recu…
agentic-labs-demo Jan 22, 2025
027a2e0
feat: Add recursive depth limit to definition resolution with error h…
agentic-labs-demo Jan 22, 2025
f4135d1
feat: Add error handling for RecursionLimitExceeded in handlers
agentic-labs-demo Jan 22, 2025
d3d2e27
More info
agentic-labs-demo Jan 22, 2025
bb42f81
feat: Add extensive debug logging to symbol reference finding process
agentic-labs-demo Jan 22, 2025
12d1f54
feat: Add debug logging for is_callable method to diagnose rule_id ma…
agentic-labs-demo Jan 22, 2025
f72f22d
feat: Add debug macro import to manager.rs
agentic-labs-demo Jan 22, 2025
2221de0
feat: Add log::debug import to types.rs
agentic-labs-demo Jan 22, 2025
bc5948a
fix: Correct Python language case and improve is_callable debug logging
agentic-labs-demo Jan 22, 2025
55ac308
style: Normalize Python language key to lowercase in CALLABLE_TYPES map
agentic-labs-demo Jan 22, 2025
f1294e7
refactor: Update language keys to match ast-grep's capitalization
agentic-labs-demo Jan 22, 2025
287ccec
refactor: Remove debug logging from recursive symbol reference finding
agentic-labs-demo Jan 22, 2025
b8443db
refactor: Remove debug logging from is_callable method
agentic-labs-demo Jan 22, 2025
b5368ab
refactor: Simplify find_referenced_symbols by removing recursive defi…
agentic-labs-demo Jan 22, 2025
a4cf7e7
refactor: Remove unused RecursionLimitExceeded error variant
agentic-labs-demo Jan 22, 2025
8f582ba
refactor: Remove Mutex from Manager and simplify locking mechanism
agentic-labs-demo Jan 23, 2025
4fda98c
refactor: Modify Manager initialization to use mutable access before …
agentic-labs-demo Jan 23, 2025
d0dfd87
Remove mutex
agentic-labs-demo Jan 23, 2025
f044ec6
refactor: Simplify test data for referenced symbols response
agentic-labs-demo Jan 23, 2025
6020aae
test: Sort definitions by path and line for consistent comparison
agentic-labs-demo Jan 23, 2025
ab1ec1d
refactor: Add sorting logic to test_python_class_referenced_symbols c…
agentic-labs-demo Jan 23, 2025
21decd8
Clean up
agentic-labs-demo Jan 23, 2025
7d4760a
Upversion
agentic-labs-demo Jan 23, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lsproxy/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "lsproxy"
version = "0.3.2"
version = "0.3.3"
edition = "2021"

[lib]
Expand Down
18 changes: 16 additions & 2 deletions lsproxy/src/ast_grep/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,21 @@ impl AstGrepClient {
self.scan_file(IDENTIFIER_CONFIG_PATH, file_name).await
}

pub async fn get_symbol_and_references(
&self,
file_name: &str,
position: &lsp_types::Position,
full_scan: bool,
) -> Result<(AstGrepMatch, Vec<AstGrepMatch>), Box<dyn std::error::Error>> {
let symbol_match = self
.get_symbol_match_from_position(file_name, position)
.await?;
let references = self
.get_references_contained_in_symbol_match(file_name, &symbol_match, full_scan)
.await?;
Ok((symbol_match, references))
}

pub async fn get_references_contained_in_symbol_match(
&self,
file_name: &str,
Expand All @@ -67,8 +82,7 @@ impl AstGrepClient {
let contained_references = matches
.into_iter()
.filter(|m| {
let contained = symbol_match
.contains(m);
let contained = symbol_match.contains(m);

contained && (full_scan || m.rule_id != "non-function")
})
Expand Down
23 changes: 4 additions & 19 deletions lsproxy/src/ast_grep/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,25 +46,10 @@ impl AstGrepMatch {
self.file == other.file
&& self.get_context_range().start.line <= other.get_context_range().start.line
&& self.get_context_range().end.line >= other.get_context_range().end.line
&& (self.get_context_range().start.line != other.get_context_range().start.line || self.get_context_range().start.column <= other.get_context_range().start.column)
&& (self.get_context_range().end.line != other.get_context_range().end.line || self.get_context_range().end.column >= other.get_context_range().end.column)
}

pub fn contains_location(&self, loc: &lsp_types::Location) -> bool {
self.file == loc.uri.path()
&& self.get_context_range().start.line <= loc.range.start.line
&& self.get_context_range().end.line >= loc.range.end.line
&& (self.get_context_range().start.line != loc.range.start.line || self.get_context_range().start.column <= loc.range.start.character)
&& (self.get_context_range().end.line != loc.range.end.line || self.get_context_range().end.column >= loc.range.end.character)

}

pub fn contains_locationlink(&self, link: &lsp_types::LocationLink) -> bool {
self.file == link.target_uri.path()
&& self.get_context_range().start.line <= link.target_range.start.line
&& self.get_context_range().end.line >= link.target_range.end.line
&& (self.get_context_range().start.line != link.target_range.start.line || self.get_context_range().start.column <= link.target_range.start.character)
&& (self.get_context_range().end.line != link.target_range.end.line || self.get_context_range().end.column >= link.target_range.end.character)
&& (self.get_context_range().start.line != other.get_context_range().start.line
|| self.get_context_range().start.column <= other.get_context_range().start.column)
&& (self.get_context_range().end.line != other.get_context_range().end.line
|| self.get_context_range().end.column >= other.get_context_range().end.column)
}
}

Expand Down
18 changes: 7 additions & 11 deletions lsproxy/src/handlers/definitions_in_file.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use actix_web::web::{Data, Query};
use actix_web::HttpResponse;
use log::{error, info};
use log::info;

use crate::api_types::{ErrorResponse, FileSymbolsRequest, Symbol};
use crate::AppState;
Expand Down Expand Up @@ -40,16 +40,12 @@ pub async fn definitions_in_file(
"Received definitions in file request for file: {}",
info.file_path
);
let manager = match data.manager.lock() {
Ok(guard) => guard,
Err(e) => {
error!("Failed to acquire lock on LSP manager: {}", e);
return HttpResponse::InternalServerError().json(ErrorResponse {
error: "Internal server error".to_string(),
});
}
};
match manager.definitions_in_file_ast_grep(&info.file_path).await {

match data
.manager
.definitions_in_file_ast_grep(&info.file_path)
.await
{
Ok(symbols) => {
let symbol_response: Vec<Symbol> = symbols
.into_iter()
Expand Down
16 changes: 9 additions & 7 deletions lsproxy/src/handlers/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,21 @@ impl IntoHttpResponse for LspManagerError {
log::error!("LSP error: {}", self);
match self {
Self::FileNotFound(path) => HttpResponse::BadRequest().json(ErrorResponse {
error: format!("File not found: {}", path)
}),
Self::LspClientNotFound(lang) => HttpResponse::InternalServerError().json(ErrorResponse {
error: format!("LSP client not found for {:?}", lang)
error: format!("File not found: {}", path),
}),
Self::LspClientNotFound(lang) => {
HttpResponse::InternalServerError().json(ErrorResponse {
error: format!("LSP client not found for {:?}", lang),
})
}
Self::InternalError(msg) => HttpResponse::InternalServerError().json(ErrorResponse {
error: format!("Internal error: {}", msg)
error: format!("Internal error: {}", msg),
}),
Self::UnsupportedFileType(path) => HttpResponse::BadRequest().json(ErrorResponse {
error: format!("Unsupported file type: {}", path)
error: format!("Unsupported file type: {}", path),
}),
Self::NotImplemented(msg) => HttpResponse::NotImplemented().json(ErrorResponse {
error: format!("Not implemented: {}", msg)
error: format!("Not implemented: {}", msg),
}),
}
}
Expand Down
16 changes: 4 additions & 12 deletions lsproxy/src/handlers/find_definition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,7 @@ pub async fn find_definition(
info.position.path, info.position.position.line, info.position.position.character
);

let manager = match data.manager.lock() {
Ok(manager) => manager,
Err(e) => {
error!("Failed to lock manager: {:?}", e);
return HttpResponse::InternalServerError().json(ErrorResponse {
error: format!("Failed to lock manager: {}", e),
});
}
};
let file_identifiers = match manager.get_file_identifiers(&info.position.path).await {
let file_identifiers = match data.manager.get_file_identifiers(&info.position.path).await {
Ok(identifiers) => identifiers,
Err(e) => {
error!("Failed to get file identifiers: {:?}", e);
Expand All @@ -78,7 +69,8 @@ pub async fn find_definition(
}
};

let definitions = match manager
let definitions = match data
.manager
.find_definition(
&info.position.path,
LspPosition {
Expand All @@ -95,7 +87,7 @@ pub async fn find_definition(
};

let source_code_context = if info.include_source_code {
match fetch_definition_source_code(&manager, &definitions).await {
match fetch_definition_source_code(&data.manager, &definitions).await {
Ok(context) => Some(context),
Err(e) => {
error!("Failed to fetch definition source code: {:?}", e);
Expand Down
11 changes: 1 addition & 10 deletions lsproxy/src/handlers/find_identifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,7 @@ pub async fn find_identifier(
"Received identifier request for file: {}, name: {}, position: {:?}",
info.path, info.name, info.position
);
let manager = match data.manager.lock() {
Ok(manager) => manager,
Err(e) => {
error!("Failed to lock manager: {:?}", e);
return HttpResponse::InternalServerError().json(ErrorResponse {
error: format!("Failed to lock manager: {}", e),
});
}
};
let file_identifiers = match manager.get_file_identifiers(&info.path).await {
let file_identifiers = match data.manager.get_file_identifiers(&info.path).await {
Ok(identifiers) => identifiers,
Err(e) => {
error!("Failed to get file identifiers: {:?}", e);
Expand Down
Loading