diff --git a/lsproxy/Cargo.toml b/lsproxy/Cargo.toml index e5f1b7bd..1ca1d66a 100644 --- a/lsproxy/Cargo.toml +++ b/lsproxy/Cargo.toml @@ -23,8 +23,8 @@ serde_json = "1.0" strum = "0.25" strum_macros = "0.25" tokio = { version = "1.0", features = ["full", "process"] } -utoipa = { git = "https://github.com/juhaku/utoipa.git", rev = "cecda0531bf7d90800af66b186055932ee730526", features = ["actix_extras"] } -utoipa-swagger-ui = { git = "https://github.com/juhaku/utoipa.git", rev = "cecda0531bf7d90800af66b186055932ee730526", features = ["actix-web"] } +utoipa = { version = "5.4", features = ["actix_extras"] } +utoipa-swagger-ui = { version = "9.0.2", features = ["actix-web"] } rand = "0.8" async-trait = "0.1" futures = "0.3" diff --git a/lsproxy/src/ast_grep/symbol/rules/javascript/function.yml b/lsproxy/src/ast_grep/symbol/rules/javascript/function.yml index 079f0b59..9cbc656b 100644 --- a/lsproxy/src/ast_grep/symbol/rules/javascript/function.yml +++ b/lsproxy/src/ast_grep/symbol/rules/javascript/function.yml @@ -8,6 +8,11 @@ rule: any: - kind: function_declaration - kind: function_expression + not: + inside: + any: + - kind: assignment_expression + - kind: pair - kind: generator_function - kind: generator_function_declaration - kind: variable_declarator @@ -22,9 +27,18 @@ rule: pattern: $CONTEXT - kind: property_identifier inside: - kind: pair - has: - any: - - kind: function_expression - - kind: arrow_function - pattern: $CONTEXT + any: + - kind: pair + has: + any: + - kind: function_expression + - kind: arrow_function + pattern: $CONTEXT + - kind: member_expression + inside: + kind: assignment_expression + has: + any: + - kind: arrow_function + - kind: function_expression + pattern: $CONTEXT diff --git a/lsproxy/src/lsp/manager/language_tests/js_tests.rs b/lsproxy/src/lsp/manager/language_tests/js_tests.rs index 3e8ee301..1a6af855 100644 --- a/lsproxy/src/lsp/manager/language_tests/js_tests.rs +++ b/lsproxy/src/lsp/manager/language_tests/js_tests.rs @@ -503,6 +503,54 @@ async fn test_file_symbols_functions_js() -> Result<(), Box Result<(), Box> { .as_ref() .ok_or("Manager is not initialized")?; + tokio::time::sleep(tokio::time::Duration::from_secs(3)).await; + let definition_response = manager .find_definition( "main.php", diff --git a/sample_project/js/functions.js b/sample_project/js/functions.js index c3493f4a..3ac69015 100644 --- a/sample_project/js/functions.js +++ b/sample_project/js/functions.js @@ -22,3 +22,13 @@ const topLevelFuncExprConst = function namedInnerFuncExpr() {}; // Assignment expression with an arrow function let assignedArrowLet; assignedArrowLet = () => {}; + +// Assignment to module.exports with a named function expression +module.exports.exampleFunc = function exampleFuncInner() { + console.log("hello"); +}; + +// Assignment to module.exports with an arrow function +module.exports.exampleFunc = () => { + console.log("hello"); +} diff --git a/scripts/test.sh b/scripts/test.sh index 5e6bbbde..87b79ccb 100755 --- a/scripts/test.sh +++ b/scripts/test.sh @@ -5,7 +5,7 @@ set -e # Exit immediately if a command exits with a non-zero status # Build the application using the build Dockerfile docker build -t lsproxy-dev lsproxy -if ! docker run --rm -v "$(pwd)/lsproxy":/usr/src/app -v "$(pwd)":/mnt/lsproxy_root lsproxy-dev cargo test $@; then +if ! docker run --rm -v "$(pwd)/lsproxy":/usr/src/app -v "$(pwd)":/mnt/lsproxy_root lsproxy-dev cargo test --target-dir /tmp/target $@; then echo "Tests failed. Exiting." exit 1 fi