diff --git a/Cargo.lock b/Cargo.lock index 96b52f4..b13ff46 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -820,7 +820,7 @@ checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" [[package]] name = "lsp-positions" version = "0.3.3" -source = "git+https://github.com/nohehf/stack-graphs.git?rev=9551ad995c79277d950ac2e0d5d9a2d5e42631e2#9551ad995c79277d950ac2e0d5d9a2d5e42631e2" +source = "git+https://github.com/nohehf/stack-graphs.git?rev=41c9515b4f25b70e1e39526cd4c30c41988337c1#41c9515b4f25b70e1e39526cd4c30c41988337c1" dependencies = [ "bincode", "memchr", @@ -1210,7 +1210,7 @@ checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" [[package]] name = "stack-graphs" version = "0.13.0" -source = "git+https://github.com/nohehf/stack-graphs.git?rev=9551ad995c79277d950ac2e0d5d9a2d5e42631e2#9551ad995c79277d950ac2e0d5d9a2d5e42631e2" +source = "git+https://github.com/nohehf/stack-graphs.git?rev=41c9515b4f25b70e1e39526cd4c30c41988337c1#41c9515b4f25b70e1e39526cd4c30c41988337c1" dependencies = [ "bincode", "bitvec", @@ -1231,7 +1231,7 @@ dependencies = [ [[package]] name = "stack-graphs-python-bindings" -version = "0.0.11" +version = "0.0.12" dependencies = [ "pyo3", "stack-graphs", @@ -1472,7 +1472,7 @@ dependencies = [ [[package]] name = "tree-sitter-stack-graphs" version = "0.8.2" -source = "git+https://github.com/nohehf/stack-graphs.git?rev=9551ad995c79277d950ac2e0d5d9a2d5e42631e2#9551ad995c79277d950ac2e0d5d9a2d5e42631e2" +source = "git+https://github.com/nohehf/stack-graphs.git?rev=41c9515b4f25b70e1e39526cd4c30c41988337c1#41c9515b4f25b70e1e39526cd4c30c41988337c1" dependencies = [ "anyhow", "base64 0.21.7", @@ -1505,7 +1505,7 @@ dependencies = [ [[package]] name = "tree-sitter-stack-graphs-java" version = "0.3.0" -source = "git+https://github.com/nohehf/stack-graphs.git?rev=9551ad995c79277d950ac2e0d5d9a2d5e42631e2#9551ad995c79277d950ac2e0d5d9a2d5e42631e2" +source = "git+https://github.com/nohehf/stack-graphs.git?rev=41c9515b4f25b70e1e39526cd4c30c41988337c1#41c9515b4f25b70e1e39526cd4c30c41988337c1" dependencies = [ "tree-sitter-java", "tree-sitter-stack-graphs", @@ -1514,7 +1514,7 @@ dependencies = [ [[package]] name = "tree-sitter-stack-graphs-javascript" version = "0.1.0" -source = "git+https://github.com/nohehf/stack-graphs.git?rev=9551ad995c79277d950ac2e0d5d9a2d5e42631e2#9551ad995c79277d950ac2e0d5d9a2d5e42631e2" +source = "git+https://github.com/nohehf/stack-graphs.git?rev=41c9515b4f25b70e1e39526cd4c30c41988337c1#41c9515b4f25b70e1e39526cd4c30c41988337c1" dependencies = [ "serde", "serde_json", @@ -1527,7 +1527,7 @@ dependencies = [ [[package]] name = "tree-sitter-stack-graphs-python" version = "0.1.0" -source = "git+https://github.com/nohehf/stack-graphs.git?rev=9551ad995c79277d950ac2e0d5d9a2d5e42631e2#9551ad995c79277d950ac2e0d5d9a2d5e42631e2" +source = "git+https://github.com/nohehf/stack-graphs.git?rev=41c9515b4f25b70e1e39526cd4c30c41988337c1#41c9515b4f25b70e1e39526cd4c30c41988337c1" dependencies = [ "tree-sitter-python", "tree-sitter-stack-graphs", @@ -1536,7 +1536,7 @@ dependencies = [ [[package]] name = "tree-sitter-stack-graphs-typescript" version = "0.3.0" -source = "git+https://github.com/nohehf/stack-graphs.git?rev=9551ad995c79277d950ac2e0d5d9a2d5e42631e2#9551ad995c79277d950ac2e0d5d9a2d5e42631e2" +source = "git+https://github.com/nohehf/stack-graphs.git?rev=41c9515b4f25b70e1e39526cd4c30c41988337c1#41c9515b4f25b70e1e39526cd4c30c41988337c1" dependencies = [ "anyhow", "glob", diff --git a/Cargo.toml b/Cargo.toml index a561cde..178d434 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "stack-graphs-python-bindings" -version = "0.0.11" +version = "0.0.12" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html @@ -10,13 +10,13 @@ crate-type = ["cdylib"] [dependencies] pyo3 = "0.20.0" -stack-graphs = { git = "https://github.com/nohehf/stack-graphs.git", rev = "9551ad995c79277d950ac2e0d5d9a2d5e42631e2", features = [ +stack-graphs = { git = "https://github.com/nohehf/stack-graphs.git", rev = "41c9515b4f25b70e1e39526cd4c30c41988337c1", features = [ "storage", ] } -tree-sitter-stack-graphs = { git = "https://github.com/nohehf/stack-graphs.git", rev = "9551ad995c79277d950ac2e0d5d9a2d5e42631e2", features = [ +tree-sitter-stack-graphs = { git = "https://github.com/nohehf/stack-graphs.git", rev = "41c9515b4f25b70e1e39526cd4c30c41988337c1", features = [ "cli", ] } -tree-sitter-stack-graphs-java = { git = "https://github.com/nohehf/stack-graphs.git", rev = "9551ad995c79277d950ac2e0d5d9a2d5e42631e2" } -tree-sitter-stack-graphs-javascript = { git = "https://github.com/nohehf/stack-graphs.git", rev = "9551ad995c79277d950ac2e0d5d9a2d5e42631e2" } -tree-sitter-stack-graphs-python = { git = "https://github.com/nohehf/stack-graphs.git", rev = "9551ad995c79277d950ac2e0d5d9a2d5e42631e2" } -tree-sitter-stack-graphs-typescript = { git = "https://github.com/nohehf/stack-graphs.git", rev = "9551ad995c79277d950ac2e0d5d9a2d5e42631e2" } +tree-sitter-stack-graphs-java = { git = "https://github.com/nohehf/stack-graphs.git", rev = "41c9515b4f25b70e1e39526cd4c30c41988337c1" } +tree-sitter-stack-graphs-javascript = { git = "https://github.com/nohehf/stack-graphs.git", rev = "41c9515b4f25b70e1e39526cd4c30c41988337c1" } +tree-sitter-stack-graphs-python = { git = "https://github.com/nohehf/stack-graphs.git", rev = "41c9515b4f25b70e1e39526cd4c30c41988337c1" } +tree-sitter-stack-graphs-typescript = { git = "https://github.com/nohehf/stack-graphs.git", rev = "41c9515b4f25b70e1e39526cd4c30c41988337c1" } diff --git a/README.md b/README.md index 652d864..354babc 100644 --- a/README.md +++ b/README.md @@ -88,7 +88,7 @@ export const foo = "bar" ## Known stack-graphs / tree-sitter issues - Python: module resolution / imports seems to be broken: -- Typescript: module resolution doesn't work with file extensions (eg. `import { foo } from "./module"` is ok, but `import { foo } from "./module.ts"` is not). **An issue should be opened on the stack-graphs repo**. See: `tests/ts_ok_test.py` +- Typescript: module resolution doesn't work with file extensions (eg. `import { foo } from "./module"` is ok, but `import { foo } from "./module.ts"` is not). **PR opened, fixed on the fork**. See: `tests/ts_ok_test.py` - Typescript: tree-sitter-typescript fails when passing a generic type to a decorator: ## Development diff --git a/pyproject.toml b/pyproject.toml index 6f18dbb..022d6eb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -10,6 +10,6 @@ classifiers = [ "Programming Language :: Python :: Implementation :: CPython", "Programming Language :: Python :: Implementation :: PyPy", ] -version = "0.0.11" +version = "0.0.12" [tool.maturin] features = ["pyo3/extension-module"] diff --git a/tests/ts_ok_test.py b/tests/ts_ok_test.py index 9fcdda9..6be43e6 100644 --- a/tests/ts_ok_test.py +++ b/tests/ts_ok_test.py @@ -16,7 +16,6 @@ """ -# Stack graphs will fail on this: TODO(@nohehf): Open issue code2 = """ ;---index.ts--- import { foo } from "./module.js"; @@ -31,7 +30,6 @@ """ -# Stack graphs will fail on this: TODO(@nohehf): Open issue code3 = """ ;---index.ts--- import { foo } from "./module.ts"; @@ -40,7 +38,7 @@ ^{query} console.log(baz); -;---module.js--- +;---module.ts--- export const foo: string = "42"; ^{ref2} @@ -48,22 +46,7 @@ def test_ts_ok() -> None: - with string_to_virtual_files(code1) as (dir, positions): - db_path = os.path.join(dir, "db.sqlite") - dir = os.path.abspath(dir) - indexer = Indexer(db_path, [Language.TypeScript]) - indexer.index_all([dir]) - querier = Querier(db_path) - source_reference = positions["query"] - results = querier.definitions(source_reference) - assert len(results) == 2 - expected = [positions["ref1"], positions["ref2"]] - for i, result in enumerate(results): - assert result == expected[i] - - -def test_ts_fails_should_be_ok() -> None: - for code in [code2, code3]: + for code in [code1, code2, code3]: with string_to_virtual_files(code) as (dir, positions): db_path = os.path.join(dir, "db.sqlite") dir = os.path.abspath(dir) @@ -72,7 +55,7 @@ def test_ts_fails_should_be_ok() -> None: querier = Querier(db_path) source_reference = positions["query"] results = querier.definitions(source_reference) - assert ( - len(results) == 1 - ) # It should be 2, and find the ref2, but the module resolution doesn't work with file extensions - assert results[0] == positions["ref1"] + assert len(results) == 2 + expected = [positions["ref1"], positions["ref2"]] + for i, result in enumerate(results): + assert result == expected[i]