local-codebase-indexer 0.8.0__tar.gz → 0.9.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (120) hide show
  1. {local_codebase_indexer-0.8.0 → local_codebase_indexer-0.9.0}/AGENTS.md +10 -0
  2. {local_codebase_indexer-0.8.0 → local_codebase_indexer-0.9.0}/CHANGELOG.md +17 -0
  3. local_codebase_indexer-0.9.0/CLAUDE.md +5 -0
  4. {local_codebase_indexer-0.8.0 → local_codebase_indexer-0.9.0}/CONTRIBUTING.md +2 -0
  5. {local_codebase_indexer-0.8.0 → local_codebase_indexer-0.9.0}/MANIFEST.in +1 -1
  6. {local_codebase_indexer-0.8.0 → local_codebase_indexer-0.9.0}/PKG-INFO +5 -1
  7. {local_codebase_indexer-0.8.0 → local_codebase_indexer-0.9.0}/README.md +2 -0
  8. {local_codebase_indexer-0.8.0 → local_codebase_indexer-0.9.0}/README.zh-CN.md +2 -0
  9. {local_codebase_indexer-0.8.0 → local_codebase_indexer-0.9.0}/README.zh-TW.md +2 -0
  10. {local_codebase_indexer-0.8.0 → local_codebase_indexer-0.9.0}/TODO.md +3 -1
  11. {local_codebase_indexer-0.8.0 → local_codebase_indexer-0.9.0}/assets/demo-output.txt +3 -1
  12. local_codebase_indexer-0.9.0/assets/demo-preview.png +0 -0
  13. {local_codebase_indexer-0.8.0 → local_codebase_indexer-0.9.0}/assets/demo-report.json +21 -3
  14. local_codebase_indexer-0.9.0/assets/demo.gif +0 -0
  15. {local_codebase_indexer-0.8.0 → local_codebase_indexer-0.9.0}/benchmarks/queries_project.json +1 -1
  16. {local_codebase_indexer-0.8.0 → local_codebase_indexer-0.9.0}/docs/case-study.md +2 -1
  17. {local_codebase_indexer-0.8.0 → local_codebase_indexer-0.9.0}/docs/reference.md +4 -0
  18. {local_codebase_indexer-0.8.0 → local_codebase_indexer-0.9.0}/docs/reference.zh-CN.md +4 -0
  19. {local_codebase_indexer-0.8.0 → local_codebase_indexer-0.9.0}/docs/reference.zh-TW.md +4 -0
  20. local_codebase_indexer-0.9.0/docs/sql-legacy-support.md +65 -0
  21. {local_codebase_indexer-0.8.0 → local_codebase_indexer-0.9.0}/local_codebase_indexer/__init__.py +1 -1
  22. {local_codebase_indexer-0.8.0 → local_codebase_indexer-0.9.0}/local_codebase_indexer/cli.py +10 -3
  23. local_codebase_indexer-0.9.0/local_codebase_indexer/context.py +96 -0
  24. {local_codebase_indexer-0.8.0 → local_codebase_indexer-0.9.0}/local_codebase_indexer/core.py +5 -13
  25. {local_codebase_indexer-0.8.0 → local_codebase_indexer-0.9.0}/local_codebase_indexer/csdata.py +29 -6
  26. {local_codebase_indexer-0.8.0 → local_codebase_indexer-0.9.0}/local_codebase_indexer/dataflow.py +15 -8
  27. {local_codebase_indexer-0.8.0 → local_codebase_indexer-0.9.0}/local_codebase_indexer/db.py +5 -5
  28. {local_codebase_indexer-0.8.0 → local_codebase_indexer-0.9.0}/local_codebase_indexer/evaluation.py +4 -4
  29. {local_codebase_indexer-0.8.0 → local_codebase_indexer-0.9.0}/local_codebase_indexer/impact.py +20 -8
  30. {local_codebase_indexer-0.8.0 → local_codebase_indexer-0.9.0}/local_codebase_indexer/langparse.py +43 -26
  31. {local_codebase_indexer-0.8.0 → local_codebase_indexer-0.9.0}/local_codebase_indexer/locking.py +4 -5
  32. {local_codebase_indexer-0.8.0 → local_codebase_indexer-0.9.0}/local_codebase_indexer/mcp_server.py +13 -5
  33. {local_codebase_indexer-0.8.0 → local_codebase_indexer-0.9.0}/local_codebase_indexer/query.py +37 -542
  34. local_codebase_indexer-0.9.0/local_codebase_indexer/query_common.py +17 -0
  35. local_codebase_indexer-0.9.0/local_codebase_indexer/relations.py +182 -0
  36. local_codebase_indexer-0.9.0/local_codebase_indexer/rendering.py +273 -0
  37. {local_codebase_indexer-0.8.0 → local_codebase_indexer-0.9.0}/local_codebase_indexer/scanner.py +33 -13
  38. {local_codebase_indexer-0.8.0 → local_codebase_indexer-0.9.0}/local_codebase_indexer/sqlaccess.py +175 -53
  39. {local_codebase_indexer-0.8.0 → local_codebase_indexer-0.9.0}/local_codebase_indexer/synonyms.py +3 -1
  40. local_codebase_indexer-0.9.0/local_codebase_indexer/textdecode.py +42 -0
  41. local_codebase_indexer-0.9.0/local_codebase_indexer/vbdata.py +156 -0
  42. {local_codebase_indexer-0.8.0 → local_codebase_indexer-0.9.0}/local_codebase_indexer.egg-info/PKG-INFO +5 -1
  43. {local_codebase_indexer-0.8.0 → local_codebase_indexer-0.9.0}/local_codebase_indexer.egg-info/SOURCES.txt +9 -2
  44. {local_codebase_indexer-0.8.0 → local_codebase_indexer-0.9.0}/local_codebase_indexer.egg-info/requires.txt +2 -0
  45. {local_codebase_indexer-0.8.0 → local_codebase_indexer-0.9.0}/pyproject.toml +12 -1
  46. {local_codebase_indexer-0.8.0 → local_codebase_indexer-0.9.0}/scripts/render_demo.py +9 -4
  47. {local_codebase_indexer-0.8.0 → local_codebase_indexer-0.9.0}/server.json +2 -2
  48. {local_codebase_indexer-0.8.0 → local_codebase_indexer-0.9.0}/tests/test_navigation_stability.py +41 -0
  49. local_codebase_indexer-0.9.0/tests/test_sql_regressions.py +295 -0
  50. local_codebase_indexer-0.8.0/CLAUDE.md +0 -58
  51. local_codebase_indexer-0.8.0/assets/demo-preview.png +0 -0
  52. local_codebase_indexer-0.8.0/assets/demo.gif +0 -0
  53. local_codebase_indexer-0.8.0/requirements.txt +0 -10
  54. {local_codebase_indexer-0.8.0 → local_codebase_indexer-0.9.0}/.claude-plugin/marketplace.json +0 -0
  55. {local_codebase_indexer-0.8.0 → local_codebase_indexer-0.9.0}/LICENSE +0 -0
  56. {local_codebase_indexer-0.8.0 → local_codebase_indexer-0.9.0}/benchmarks/README.md +0 -0
  57. {local_codebase_indexer-0.8.0 → local_codebase_indexer-0.9.0}/benchmarks/baseline.json +0 -0
  58. {local_codebase_indexer-0.8.0 → local_codebase_indexer-0.9.0}/benchmarks/corpus/Auth/LoginService.cs +0 -0
  59. {local_codebase_indexer-0.8.0 → local_codebase_indexer-0.9.0}/benchmarks/corpus/Controllers/LotController.cs +0 -0
  60. {local_codebase_indexer-0.8.0 → local_codebase_indexer-0.9.0}/benchmarks/corpus/Controllers/ScrapController.cs +0 -0
  61. {local_codebase_indexer-0.8.0 → local_codebase_indexer-0.9.0}/benchmarks/corpus/Data/MesDbContext.cs +0 -0
  62. {local_codebase_indexer-0.8.0 → local_codebase_indexer-0.9.0}/benchmarks/corpus/Legacy/frmChangeLine.frm +0 -0
  63. {local_codebase_indexer-0.8.0 → local_codebase_indexer-0.9.0}/benchmarks/corpus/Models/DrillBreakEvent.cs +0 -0
  64. {local_codebase_indexer-0.8.0 → local_codebase_indexer-0.9.0}/benchmarks/corpus/Models/Lot.cs +0 -0
  65. {local_codebase_indexer-0.8.0 → local_codebase_indexer-0.9.0}/benchmarks/corpus/Models/ScrapRecord.cs +0 -0
  66. {local_codebase_indexer-0.8.0 → local_codebase_indexer-0.9.0}/benchmarks/corpus/Printing/LabelPrinter.cs +0 -0
  67. {local_codebase_indexer-0.8.0 → local_codebase_indexer-0.9.0}/benchmarks/corpus/Repositories/LotRepository.cs +0 -0
  68. {local_codebase_indexer-0.8.0 → local_codebase_indexer-0.9.0}/benchmarks/corpus/Repositories/ScrapRepository.cs +0 -0
  69. {local_codebase_indexer-0.8.0 → local_codebase_indexer-0.9.0}/benchmarks/corpus/Services/IScrapService.cs +0 -0
  70. {local_codebase_indexer-0.8.0 → local_codebase_indexer-0.9.0}/benchmarks/corpus/Services/InspectionService.cs +0 -0
  71. {local_codebase_indexer-0.8.0 → local_codebase_indexer-0.9.0}/benchmarks/corpus/Services/LotService.cs +0 -0
  72. {local_codebase_indexer-0.8.0 → local_codebase_indexer-0.9.0}/benchmarks/corpus/Services/ScrapService.cs +0 -0
  73. {local_codebase_indexer-0.8.0 → local_codebase_indexer-0.9.0}/benchmarks/corpus/Sql/MES_Lot.sql +0 -0
  74. {local_codebase_indexer-0.8.0 → local_codebase_indexer-0.9.0}/benchmarks/corpus/Sql/usp_Inspection_Report.sql +0 -0
  75. {local_codebase_indexer-0.8.0 → local_codebase_indexer-0.9.0}/benchmarks/corpus/Sql/usp_Lot_UpdateStatus.sql +0 -0
  76. {local_codebase_indexer-0.8.0 → local_codebase_indexer-0.9.0}/benchmarks/corpus/Sql/usp_Scrap_Insert.sql +0 -0
  77. {local_codebase_indexer-0.8.0 → local_codebase_indexer-0.9.0}/benchmarks/corpus/Utils/DateRangeHelper.cs +0 -0
  78. {local_codebase_indexer-0.8.0 → local_codebase_indexer-0.9.0}/benchmarks/corpus/Utils/PartNumberDecoder.cs +0 -0
  79. {local_codebase_indexer-0.8.0 → local_codebase_indexer-0.9.0}/benchmarks/corpus/Web/scrapForm.ts +0 -0
  80. {local_codebase_indexer-0.8.0 → local_codebase_indexer-0.9.0}/benchmarks/corpus/Web.config +0 -0
  81. {local_codebase_indexer-0.8.0 → local_codebase_indexer-0.9.0}/benchmarks/corpus/tools/export_report.py +0 -0
  82. {local_codebase_indexer-0.8.0 → local_codebase_indexer-0.9.0}/benchmarks/queries_stdlib.json +0 -0
  83. {local_codebase_indexer-0.8.0 → local_codebase_indexer-0.9.0}/benchmarks/queries_synthetic.json +0 -0
  84. {local_codebase_indexer-0.8.0 → local_codebase_indexer-0.9.0}/benchmarks/run_benchmark.py +0 -0
  85. {local_codebase_indexer-0.8.0 → local_codebase_indexer-0.9.0}/bin/indexer +0 -0
  86. {local_codebase_indexer-0.8.0 → local_codebase_indexer-0.9.0}/docs/discovery.md +0 -0
  87. {local_codebase_indexer-0.8.0 → local_codebase_indexer-0.9.0}/docs/launch/community.en.md +0 -0
  88. {local_codebase_indexer-0.8.0 → local_codebase_indexer-0.9.0}/docs/launch/community.zh-TW.md +0 -0
  89. {local_codebase_indexer-0.8.0 → local_codebase_indexer-0.9.0}/docs/launch/directory-entry.md +0 -0
  90. {local_codebase_indexer-0.8.0 → local_codebase_indexer-0.9.0}/index.md +0 -0
  91. {local_codebase_indexer-0.8.0 → local_codebase_indexer-0.9.0}/llms.txt +0 -0
  92. {local_codebase_indexer-0.8.0 → local_codebase_indexer-0.9.0}/local_codebase_indexer/__main__.py +0 -0
  93. {local_codebase_indexer-0.8.0 → local_codebase_indexer-0.9.0}/local_codebase_indexer/callgraph.py +0 -0
  94. {local_codebase_indexer-0.8.0 → local_codebase_indexer-0.9.0}/local_codebase_indexer/cscalls.py +0 -0
  95. {local_codebase_indexer-0.8.0 → local_codebase_indexer-0.9.0}/local_codebase_indexer/demo.py +2 -2
  96. {local_codebase_indexer-0.8.0 → local_codebase_indexer-0.9.0}/local_codebase_indexer/demo_project/Controllers/OrdersController.cs +0 -0
  97. {local_codebase_indexer-0.8.0 → local_codebase_indexer-0.9.0}/local_codebase_indexer/demo_project/Data/OrderRepository.cs +0 -0
  98. {local_codebase_indexer-0.8.0 → local_codebase_indexer-0.9.0}/local_codebase_indexer/demo_project/Models/Order.cs +0 -0
  99. {local_codebase_indexer-0.8.0 → local_codebase_indexer-0.9.0}/local_codebase_indexer/demo_project/README.md +0 -0
  100. {local_codebase_indexer-0.8.0 → local_codebase_indexer-0.9.0}/local_codebase_indexer/demo_project/Services/IOrderService.cs +0 -0
  101. {local_codebase_indexer-0.8.0 → local_codebase_indexer-0.9.0}/local_codebase_indexer/demo_project/Services/OrderService.cs +0 -0
  102. {local_codebase_indexer-0.8.0 → local_codebase_indexer-0.9.0}/local_codebase_indexer/demo_project/Sql/Sales_OrderHeader.sql +0 -0
  103. {local_codebase_indexer-0.8.0 → local_codebase_indexer-0.9.0}/local_codebase_indexer/demo_project/Sql/usp_ApproveOrder.sql +0 -0
  104. {local_codebase_indexer-0.8.0 → local_codebase_indexer-0.9.0}/local_codebase_indexer/demo_project/Views/Orders/Details.cshtml +0 -0
  105. {local_codebase_indexer-0.8.0 → local_codebase_indexer-0.9.0}/local_codebase_indexer/embedder.py +1 -1
  106. {local_codebase_indexer-0.8.0 → local_codebase_indexer-0.9.0}/local_codebase_indexer/pagination.py +0 -0
  107. {local_codebase_indexer-0.8.0 → local_codebase_indexer-0.9.0}/local_codebase_indexer.egg-info/dependency_links.txt +0 -0
  108. {local_codebase_indexer-0.8.0 → local_codebase_indexer-0.9.0}/local_codebase_indexer.egg-info/entry_points.txt +0 -0
  109. {local_codebase_indexer-0.8.0 → local_codebase_indexer-0.9.0}/local_codebase_indexer.egg-info/top_level.txt +0 -0
  110. {local_codebase_indexer-0.8.0 → local_codebase_indexer-0.9.0}/plugins/local-codebase-indexer/.claude-plugin/plugin.json +0 -0
  111. {local_codebase_indexer-0.8.0 → local_codebase_indexer-0.9.0}/plugins/local-codebase-indexer/.mcp.json +0 -0
  112. {local_codebase_indexer-0.8.0 → local_codebase_indexer-0.9.0}/scripts/release_assets.py +3 -3
  113. {local_codebase_indexer-0.8.0 → local_codebase_indexer-0.9.0}/setup.cfg +0 -0
  114. {local_codebase_indexer-0.8.0 → local_codebase_indexer-0.9.0}/tests/test_dataaccess.py +0 -0
  115. {local_codebase_indexer-0.8.0 → local_codebase_indexer-0.9.0}/tests/test_demo.py +0 -0
  116. {local_codebase_indexer-0.8.0 → local_codebase_indexer-0.9.0}/tests/test_evaluation.py +0 -0
  117. {local_codebase_indexer-0.8.0 → local_codebase_indexer-0.9.0}/tests/test_indexer.py +0 -0
  118. {local_codebase_indexer-0.8.0 → local_codebase_indexer-0.9.0}/tests/test_onnx_plumbing.py +0 -0
  119. {local_codebase_indexer-0.8.0 → local_codebase_indexer-0.9.0}/tests/test_release_assets.py +0 -0
  120. {local_codebase_indexer-0.8.0 → local_codebase_indexer-0.9.0}/tests/test_reliability.py +0 -0
@@ -77,3 +77,13 @@ The package is `local_codebase_indexer/`. See `docs/reference.md` for design not
77
77
  ## First-run demo (0.8.0)
78
78
 
79
79
  Run `local-codebase-indexer demo` without a database or model. It uses a temporary bundled synthetic project, checks four relationships, and leaves the current project alone. `--output <new-or-empty-directory>` keeps a copy; `--json` returns evidence and timings. This is a supported-path demonstration, not a production accuracy or time-savings measurement.
80
+
81
+ ## SQL and legacy-source correctness (0.9.0)
82
+
83
+ - Run `python -m ruff check local_codebase_indexer scripts`, `python -m mypy`, and the full pytest suite before publishing. CI covers Linux and Windows on Python 3.10, 3.12, and 3.13.
84
+ - Dependency declarations live in `pyproject.toml`; `requirements.txt` was removed to avoid drift.
85
+ - Source decoding and context extraction handle BOM-tagged UTF-16/UTF-32. True binary files are excluded consistently by scanning and status.
86
+ - `data-access` has additive `schema_changes` entries (`access=schema`) for table/index DDL. They are not row writers. File-level SQL changes appear in impact with before/current/after labels and source evidence.
87
+ - VB6 `.frm`/`.bas`/`.cls` SQL strings get procedure owners. Complete SQL at known ADO/DAO receivers may be confirmed; unknown receivers or incomplete concatenation remain probable/uncertain. No VB6 call graph or runtime execution proof is implied.
88
+ - Explicit negations in `.ai_context/ignore` can include default source directories such as `!bin/` and `!bin/**`, overriding `.gitignore`. Include excluded parents first. `.git`, `.svn`, `.hg`, and `.ai_context` remain excluded.
89
+ - Keep `query.py` as the facade/search implementation; navigation, source context, and rendering live in `relations.py`, `context.py`, and `rendering.py`. Legacy public imports from `query` remain supported.
@@ -1,5 +1,22 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.9.0
4
+
5
+ - Fix a first-run Windows lock-file initialization race found by concurrent-process CI; serialize index ignore-file creation.
6
+
7
+ - Fix SQL aliases `a` / `an` / `the`, parameterized TOP, UPDATE table hints, old NOLOCK hints, and comma sources after JOIN predicates.
8
+ - Preserve bracketed/quoted identifiers and linked-server names, including spaces, backslashes, escaped delimiters, and quoted dots. Ignore keywords inside identifiers and nested block comments.
9
+ - Exclude cursor FETCH and scalar TRIM FROM operands from table reads; analyze literal OPENQUERY SQL as uncertain.
10
+ - Decode BOM-tagged UTF-16/UTF-32 before binary detection; make source context and freshness diagnostics consistent. True binary files no longer remain pending forever.
11
+ - Attribute constant C# SQL to each executing method without sharing same-named constants across unrelated classes.
12
+ - Add conservative VB6 SQL analysis for .frm/.bas/.cls, with enclosing method owners and explicit confidence levels.
13
+ - Track table/index schema operations separately from row writes; include file-level SQL and before/after source evidence in Git impact.
14
+ - Allow explicit project-ignore negations to include default build/dependency-named source directories, preserving hard exclusions for VCS and index state.
15
+ - Split relation, context, and rendering code out of the query facade while preserving public imports and commands.
16
+ - Clear the existing mypy errors; add Ruff/mypy CI and release gates; test Windows and Linux on Python 3.10, 3.12, and 3.13.
17
+ - Canonical assistant instructions live in AGENTS.md; CLAUDE.md points there. Remove duplicate requirements.txt dependency declarations.
18
+ - Index format 9 triggers one full rebuild after upgrade. See docs/sql-legacy-support.md for supported patterns and limitations.
19
+
3
20
  ## 0.8.0
4
21
 
5
22
  - MIT license and SPDX package metadata.
@@ -0,0 +1,5 @@
1
+ # Instructions for Claude
2
+
3
+ Read and follow [AGENTS.md](AGENTS.md) before working on this repository. It is the canonical source for development checks, all seven MCP tools (including `codebase_index_doctor`), CLI usage, confidence labels, and release validation.
4
+
5
+ Installation dependencies are declared in `pyproject.toml`. Use `python -m pip install -e ".[dev,onnx]" onnx` for development.
@@ -8,6 +8,8 @@ Use Python 3.10+ in a virtual environment:
8
8
 
9
9
  ```bash
10
10
  python -m pip install -e ".[dev,onnx]" onnx build twine
11
+ python -m ruff check local_codebase_indexer scripts
12
+ python -m mypy
11
13
  python -m pytest -q
12
14
  python -m build
13
15
  python -m twine check dist/*
@@ -1,4 +1,4 @@
1
- include server.json CHANGELOG.md README*.md TODO.md AGENTS.md CLAUDE.md llms.txt index.md requirements.txt
1
+ include server.json CHANGELOG.md README*.md TODO.md AGENTS.md CLAUDE.md llms.txt index.md
2
2
  graft scripts
3
3
  graft tests
4
4
  graft plugins
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: local-codebase-indexer
3
- Version: 0.8.0
3
+ Version: 0.9.0
4
4
  Summary: Trace SQL Server tables to C# callers and Razor pages locally. MCP server and CLI for code search and change impact.
5
5
  Author: sfy257000
6
6
  License-Expression: MIT
@@ -36,6 +36,8 @@ Requires-Dist: onnxruntime; extra == "onnx"
36
36
  Requires-Dist: tokenizers; extra == "onnx"
37
37
  Provides-Extra: dev
38
38
  Requires-Dist: pytest; extra == "dev"
39
+ Requires-Dist: ruff>=0.9; extra == "dev"
40
+ Requires-Dist: mypy>=1.14; extra == "dev"
39
41
  Provides-Extra: media
40
42
  Requires-Dist: Pillow>=10; extra == "media"
41
43
  Dynamic: license-file
@@ -127,4 +129,6 @@ Relations show callers; impact compares Git snapshots; search combines identifie
127
129
 
128
130
  Found a wrong edge or missing result? Open a [reproducible issue](https://github.com/sfy257000/local-codebase-indexer/issues/new/choose). [Contributions](https://github.com/sfy257000/local-codebase-indexer/blob/main/CONTRIBUTING.md) are welcome. Licensed under [MIT](https://github.com/sfy257000/local-codebase-indexer/blob/main/LICENSE).
129
131
 
132
+ [SQL / Unicode / VB6 support and upgrade notes](https://github.com/sfy257000/local-codebase-indexer/blob/main/docs/sql-legacy-support.md)
133
+
130
134
  <!-- mcp-name: io.github.sfy257000/local-codebase-indexer -->
@@ -85,4 +85,6 @@ Relations show callers; impact compares Git snapshots; search combines identifie
85
85
 
86
86
  Found a wrong edge or missing result? Open a [reproducible issue](https://github.com/sfy257000/local-codebase-indexer/issues/new/choose). [Contributions](https://github.com/sfy257000/local-codebase-indexer/blob/main/CONTRIBUTING.md) are welcome. Licensed under [MIT](https://github.com/sfy257000/local-codebase-indexer/blob/main/LICENSE).
87
87
 
88
+ [SQL / Unicode / VB6 support and upgrade notes](https://github.com/sfy257000/local-codebase-indexer/blob/main/docs/sql-legacy-support.md)
89
+
88
90
  <!-- mcp-name: io.github.sfy257000/local-codebase-indexer -->
@@ -84,3 +84,5 @@ local-codebase-indexer --root "/path/to/project" doctor
84
84
  - 先选一张已知用途的数据表核对结果。遗漏文件时运行 `doctor --path path/to/file.cs`,检查 `.gitignore` 和 `.ai_context/ignore`。更多[限制](docs/reference.zh-CN.md)与[待办](TODO.md)可查手册。
85
85
 
86
86
  发现错误关系或漏查,请附最小示例[提交 issue](https://github.com/sfy257000/local-codebase-indexer/issues/new/choose)。欢迎[贡献](CONTRIBUTING.md)。采用 [MIT 许可](LICENSE)。
87
+
88
+ [SQL/Unicode/VB6 支援與升級說明](docs/sql-legacy-support.md)
@@ -84,3 +84,5 @@ local-codebase-indexer --root "/path/to/project" doctor
84
84
  - 先選一張已知用途的資料表核對結果。漏掉檔案時執行 `doctor --path path/to/file.cs`,檢查 `.gitignore` 與 `.ai_context/ignore`。更多[限制](docs/reference.zh-TW.md)與[待辦](TODO.md)可查手冊。
85
85
 
86
86
  發現錯誤關係或漏查,請附最小範例[回報 issue](https://github.com/sfy257000/local-codebase-indexer/issues/new/choose)。歡迎[貢獻](CONTRIBUTING.md)。採用 [MIT 授權](LICENSE)。
87
+
88
+ [SQL/Unicode/VB6 支援與升級說明](docs/sql-legacy-support.md)
@@ -5,7 +5,7 @@ Priorities come from the benchmark (`benchmarks/run_benchmark.py`, baseline in `
5
5
  ## Next
6
6
 
7
7
  0. **MCP Registry discovery**: the 0.8.0 release workflow publishes `server.json` after PyPI succeeds, using GitHub OIDC. Verify the live entry after each release; a local manifest alone does not establish publication. See [discovery instructions](docs/discovery.md).
8
- 1. **Resolve `FROM a JOIN b ON ..., c`** (a comma list after a JOIN loses `c`), non-sink SQL proc-name literals (`Run("usp_X")`), EF `this.ToTable(..)` inside `EntityTypeConfiguration<T>` (entity not taken from the base class yet), and EF updates through tracked entities when the entity was loaded in another method than the one calling `SaveChanges` (only same-method read + `SaveChanges` is listed, as uncertain).
8
+ 1. **Remaining data-flow gaps**: non-sink SQL proc-name literals (`Run("usp_X")`), EF `this.ToTable(..)` inside `EntityTypeConfiguration<T>` (entity not taken from the base class yet), and EF updates through tracked entities when the entity was loaded in another method than the one calling `SaveChanges` (only same-method read + `SaveChanges` is listed, as uncertain).
9
9
  2. **C# call graph gaps**: overload resolution by argument type, delegates / lambdas / extension methods, call chains longer than one level. Without Roslyn these stay approximate; edges carry `confirmed` / `probable` / `candidate`.
10
10
 
11
11
  ## Deferred (not worth doing yet)
@@ -22,6 +22,8 @@ Priorities come from the benchmark (`benchmarks/run_benchmark.py`, baseline in `
22
22
 
23
23
  ## Done
24
24
 
25
+ - 0.9.0: SQL alias/hint/TOP and quoted-name fixes; cursor/TRIM false-positive removal; nested comments and uncertain OPENQUERY analysis; comma sources after JOIN; BOM-aware Unicode source/context handling; constant SQL method attribution; VB6 SQL analysis; separate DDL/schema impact; explicit ignore overrides; modular navigation/context/rendering; lint/mypy CI and Windows Python 3.10/3.12/3.13.
26
+
25
27
  - 0.7.0: revision-bound search cursors; historical target snapshots; model content identities; process coordination and crash recovery; focus-preserving context; synonym hot reload; retrieval explanations; project evaluation runner; automatic validated Release assets. Representative user-authored evaluation questions and broader semantic retrieval remain ongoing work.
26
28
 
27
29
  - 0.6.0: complete before/after impact analysis with cached historical indexes; resilient MCP input validation; nested ignore negations; root validation; doctor diagnostics; bounded and filtered search; confidence-filtered data-access pagination with no hidden full-output caps; general paraphrases; mandatory ONNX dependencies in CI. See CHANGELOG.md for validation and limitations.
@@ -9,6 +9,8 @@ table Sales_OrderHeader
9
9
  [confirmed] method Shop.Data.OrderRepository.Approve Data/OrderRepository.cs:24 update (csharp_sp) via usp_ApproveOrder
10
10
  READ BY (1)
11
11
  [confirmed] method Shop.Data.OrderRepository.Get Data/OrderRepository.cs:19 select (csharp_sql)
12
+ SCHEMA CHANGED BY (1)
13
+ [confirmed] file Sql/Sales_OrderHeader.sql Sql/Sales_OrderHeader.sql:1 create_table (sql)
12
14
  USED BY PROGRAMS (1)
13
15
  [probable] Orders read/write Controllers/OrdersController.cs (Approve, Details)
14
16
  pages: Views/Orders/Details.cshtml
@@ -16,7 +18,7 @@ note: Static analysis: dynamic SQL is listed under 'possible' and cannot be reso
16
18
 
17
19
  Verified 4/4 expected relationships: PASS
18
20
  Exact table mentions: 3 files; controller/page reachability is computed separately.
19
- Local timing: index 16.2 ms; data-access 0.6 ms.
21
+ Local timing: index 17.2 ms; data-access 0.6 ms.
20
22
  This fixture does not establish accuracy or time savings on your project.
21
23
 
22
24
  Try your project:
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "schema_version": 1,
3
3
  "sample_kind": "synthetic",
4
- "package_version": "0.8.0",
4
+ "package_version": "0.9.0",
5
5
  "scenario": "Trace Sales_OrderHeader to C# code, a controller, and a Razor page",
6
6
  "environment": {
7
7
  "python": "3.12.14",
@@ -22,8 +22,8 @@
22
22
  "warnings": []
23
23
  },
24
24
  "timing_ms": {
25
- "index": 16.199,
26
- "data_access": 0.565
25
+ "index": 17.207,
26
+ "data_access": 0.579
27
27
  },
28
28
  "literal_reference_files": [
29
29
  "Data/OrderRepository.cs",
@@ -100,6 +100,24 @@
100
100
  ],
101
101
  "executed_by": [],
102
102
  "mapped_by": [],
103
+ "schema_changes": [
104
+ {
105
+ "source": "Sql/Sales_OrderHeader.sql",
106
+ "source_type": "file",
107
+ "source_id": null,
108
+ "file_path": "Sql/Sales_OrderHeader.sql",
109
+ "line": 1,
110
+ "target": "Sales_OrderHeader",
111
+ "op": "create_table",
112
+ "access": "schema",
113
+ "via": "sql",
114
+ "confidence": "confirmed",
115
+ "evidence": "CREATE TABLE dbo.Sales_OrderHeader (",
116
+ "detail": "",
117
+ "depth": 0,
118
+ "via_chain": []
119
+ }
120
+ ],
103
121
  "possible": [],
104
122
  "programs": [
105
123
  {
@@ -2,7 +2,7 @@
2
2
  "version": 1,
3
3
  "description": "Curated navigation smoke questions about this repository's actual implementation. These are not collected user queries or an independent quality benchmark. Replace them with real questions from your own workflow.",
4
4
  "queries": [
5
- {"id":"source-encoding","query":"Which function decodes source bytes using UTF-8, Big5 and cp1252?","language":"python","relevant":[{"file":"local_codebase_indexer/core.py","symbol":"decode_bytes"}]},
5
+ {"id":"source-encoding","query":"Which function decodes source bytes using UTF-8, Big5 and cp1252?","language":"python","relevant":[{"file":"local_codebase_indexer/textdecode.py","symbol":"decode_bytes"}]},
6
6
  {"id":"extension-language","query":"Map a file extension to its parser language","language":"python","relevant":[{"file":"local_codebase_indexer/scanner.py","symbol":"language_for"}]},
7
7
  {"id":"excluded-file","query":"Explain why a path is excluded by ignore rules or its parent directory","language":"python","relevant":[{"file":"local_codebase_indexer/scanner.py","symbol":"explain_path"}]},
8
8
  {"id":"mcp-validation","query":"Validate MCP arguments against their schema types and required properties","language":"python","relevant":[{"file":"local_codebase_indexer/mcp_server.py","symbol":"_validate"}]},
@@ -41,13 +41,14 @@ The stored-procedure and repository access entries are `confirmed`; the rolled-u
41
41
 
42
42
  ## Recorded result
43
43
 
44
- [`assets/demo-report.json`](../assets/demo-report.json) contains the complete report, environment, exact-reference baseline, confidence labels, and measured timings. [`demo-output.txt`](../assets/demo-output.txt) contains the full text output. These are one recorded run of version 0.8.0; rerunning produces different timings.
44
+ [`assets/demo-report.json`](../assets/demo-report.json) contains the complete report, environment, exact-reference baseline, confidence labels, and measured timings. [`demo-output.txt`](../assets/demo-output.txt) contains the full text output. These are one recorded run of version 0.9.0; rerunning produces different timings.
45
45
 
46
46
  | Observation | Recorded value |
47
47
  |---|---|
48
48
  | Files indexed | 9, with 0 failed (8 C#/SQL/Razor source files and a README) |
49
49
  | Symbols / chunks | 29 / 23 |
50
50
  | Exact table-name reference files | 3 |
51
+ | Schema operations | 1 `create_table`, separate from data writes |
51
52
  | SQL / C# access | 2 writers, including the indirect stored-procedure writer; 1 reader |
52
53
  | Program / page roll-up | `Orders` actions `Approve`, `Details`; `Views/Orders/Details.cshtml` |
53
54
  | Scenario checks | 4 / 4 pass |
@@ -184,3 +184,7 @@ python -m pytest -q
184
184
  ```
185
185
 
186
186
  <!-- mcp-name: io.github.sfy257000/local-codebase-indexer -->
187
+
188
+ ## SQL, Unicode, VB6, and schema updates
189
+
190
+ See [0.9.0 support and upgrade notes](sql-legacy-support.md) for SQL fixes, VB6 confidence limits, separate schema operations, Unicode decoding, and explicit default-directory overrides. The first index update rebuilds format 9.
@@ -120,3 +120,7 @@ local-codebase-indexer --root <项目> data-access MES_Lot --full
120
120
  ```bash
121
121
  python -m pytest -q
122
122
  ```
123
+
124
+ ## SQL, Unicode, VB6, and schema updates
125
+
126
+ See [0.9.0 support and upgrade notes](sql-legacy-support.md) for SQL fixes, VB6 confidence limits, separate schema operations, Unicode decoding, and explicit default-directory overrides. The first index update rebuilds format 9.
@@ -137,3 +137,7 @@ local-codebase-indexer --root <專案> data-access MES_Lot --full
137
137
  ```bash
138
138
  python -m pytest -q
139
139
  ```
140
+
141
+ ## SQL, Unicode, VB6, and schema updates
142
+
143
+ See [0.9.0 support and upgrade notes](sql-legacy-support.md) for SQL fixes, VB6 confidence limits, separate schema operations, Unicode decoding, and explicit default-directory overrides. The first index update rebuilds format 9.
@@ -0,0 +1,65 @@
1
+ # SQL correctness and legacy source support (0.9.0)
2
+
3
+ The seven MCP tools and existing CLI commands remain available. The index format changes to version 9: the first update after upgrading rebuilds the index to replace previously missing or incorrect edges. On a large project this first run can take longer; subsequent updates are incremental.
4
+
5
+ ## SQL Server references
6
+
7
+ The parser handles aliases such as `a`, `an`, and `the`; parameterized `TOP (@n)` and simple parenthesized expressions; `UPDATE ... WITH (ROWLOCK) SET`; and old table hints such as `FROM dbo.Lot (NOLOCK) t`. A comma source after `JOIN ... ON` is included, while commas in nested expressions are not treated as table lists.
8
+
9
+ Bracketed and double-quoted names preserve escaped delimiters, spaces, punctuation, and linked-server qualifiers. For example:
10
+
11
+ ```sql
12
+ UPDATE a SET Status = 'Approved'
13
+ FROM [ntemes\mes].MESDB.dbo.[Lot Master] a;
14
+ ```
15
+
16
+ ```bash
17
+ local-codebase-indexer --root /path/to/project data-access "Lot Master" --full
18
+ ```
19
+
20
+ Names are still queried by their final object-name segment. Inspect qualifiers/source evidence when different databases use the same table name; this is not a SQL Server catalog resolver.
21
+
22
+ Cursor `FETCH ... FROM` and scalar `TRIM(... FROM ...)` do not create table reads. Nested block comments are masked as a whole. Literal SQL inside `OPENQUERY` is surfaced as **uncertain**, like dynamic SQL, because the remote catalog and execution are not validated. Existing dynamic SQL uncertainty remains visible.
23
+
24
+ C# file-level SQL strings passed to database APIs are attributed to each executing method at its use site. Constants of the same name in different classes do not share their values. A SQL-looking field declaration can still appear as a probable, unproven lead; it is not proof the string executes.
25
+
26
+ ## Unicode source
27
+
28
+ UTF-8, Big5, and cp1252 behavior is retained. BOM-tagged UTF-16 LE/BE and UTF-32 LE/BE are recognized before binary detection and decoded consistently by indexing, context extraction, and diagnostics. BOM-less UTF-16 is not guessed. True binary files are excluded from both scanning and freshness checks, so they do not remain permanently pending as new files.
29
+
30
+ ## Schema changes
31
+
32
+ `CREATE TABLE`, `ALTER TABLE`, `DROP TABLE`, `CREATE INDEX`, and `DROP INDEX ... ON` use `access=schema`. `data-access` returns them in an additive `schema_changes` section, with the same confidence filters and pagination as other sections. Procedures' `touches` results can also include `schema_changes`.
33
+
34
+ Schema operations are separate from row readers/writers. `impact` includes file-level SQL even when it has no containing symbol, with source evidence and historical snapshot labels. This identifies source-level schema operations; it does not calculate column-level migration safety or validate a live database.
35
+
36
+ ## VB6 sources
37
+
38
+ `.frm`, `.bas`, and `.cls` retain text-search support and now expose SQL strings under their enclosing Sub/Function/Property. Analysis includes literals, doubled quotes, constants/variables, `&`/`+` concatenation, line continuations, and common `.Execute`, `.Open`, and `.CommandText` sites. Apostrophe and `Rem` comments are excluded.
39
+
40
+ Complete SQL at an explicitly declared ADO/DAO receiver can be `confirmed` as a static call site. An unknown receiver or incomplete expression remains `probable`; an unknown table or unresolved command is `uncertain`. This does not prove the receiver's runtime state. VB6 symbols use `vb6_method` so they cannot be mistaken for SQL functions or C# call targets. There is no VB6 compiler, full VB6 call graph, general `With`-block resolution, or interpretation of arbitrary functions constructing SQL.
41
+
42
+ ## Include a source directory that has a conventional build name
43
+
44
+ Defaults still exclude generated/dependency directories. If your application keeps real source in `bin`, `packages`, `build`, or `dist`, put explicit negations in `.ai_context/ignore`:
45
+
46
+ ```gitignore
47
+ !bin/
48
+ !bin/**
49
+ !packages/
50
+ !packages/**
51
+ !build/
52
+ !build/**
53
+ !dist/
54
+ !dist/**
55
+ ```
56
+
57
+ These project rules have final precedence over `.gitignore`. Include excluded parents as well when the directory is nested. `.git`, `.svn`, `.hg`, and `.ai_context` remain excluded to prevent indexing repository/index state. Symlinks and size limits retain their existing behavior. Check an individual result with `doctor --path bin/RealSource.cs`.
58
+
59
+ ## Verification and development
60
+
61
+ `tests/test_sql_regressions.py` contains the reported syntax cases, negative examples, all four Unicode BOM encodings, constant ownership, schema impact, VB6, and directory opt-in tests. The rest of the test suite covers search, call navigation, ONNX, MCP recovery, concurrency, pagination, and package/release validation.
62
+
63
+ CI runs the suite on Linux and Windows with Python 3.10/3.12/3.13, plus installed-package checks. Ruff checks correctness/imports and mypy checks the package with incremental typing (untyped third-party imports are allowed). They are also release validation gates. Dependencies are declared only in `pyproject.toml`.
64
+
65
+ `query.py` remains the facade and hybrid-search implementation. `relations.py`, `context.py`, and `rendering.py` separate navigation, source extraction, and presentation. Existing `from local_codebase_indexer.query import CodebaseTools, render_*` imports continue to work.
@@ -1,3 +1,3 @@
1
1
  """Universal Local Codebase Indexer & Context Provider (see index.md)."""
2
2
 
3
- __version__ = "0.8.0"
3
+ __version__ = "0.9.0"
@@ -127,8 +127,15 @@ def main(argv: list[str] | None = None) -> int:
127
127
  _fix_stdio(serving=args.cmd == "serve")
128
128
  root = os.path.abspath(args.root)
129
129
 
130
- from .query import (render_context, render_data_access, render_impact, render_relations, render_search,
131
- render_status, render_doctor)
130
+ from .query import (
131
+ render_context,
132
+ render_data_access,
133
+ render_doctor,
134
+ render_impact,
135
+ render_relations,
136
+ render_search,
137
+ render_status,
138
+ )
132
139
 
133
140
  t = None
134
141
  try:
@@ -136,7 +143,7 @@ def main(argv: list[str] | None = None) -> int:
136
143
  from .mcp_server import serve
137
144
  return serve(root)
138
145
  if args.cmd == "demo":
139
- from .demo import run_demo, render_demo
146
+ from .demo import render_demo, run_demo
140
147
  res = run_demo(args.output)
141
148
  _emit(res, render_demo(res), args.json)
142
149
  return 0 if res['passed'] else 3
@@ -0,0 +1,96 @@
1
+ """Bounded source context extraction that retains requested focus lines."""
2
+ from __future__ import annotations
3
+
4
+ import os
5
+ import sqlite3
6
+
7
+ from .query_common import _consistent_read
8
+ from .scanner import extra_roots
9
+
10
+ MAX_CONTEXT_CHARS = 24000
11
+
12
+ def _inside(path: str, base: str) -> bool:
13
+ try:
14
+ return os.path.commonpath([path, base]) == base
15
+ except ValueError:
16
+ return False
17
+
18
+ class ContextTools:
19
+ root: str
20
+ conn: sqlite3.Connection
21
+
22
+ # ------------------------------------------------------------------ Tool 3
23
+ @_consistent_read(refresh=True)
24
+ def optimized_context(self, file_path: str, focus_lines: list[int], padding_lines: int = 15) -> dict:
25
+ abs_path = os.path.abspath(os.path.join(self.root, file_path))
26
+ allowed = [self.root, *extra_roots(self.root)]
27
+ if not any(_inside(abs_path, r) for r in allowed):
28
+ raise ValueError("file_path must stay inside the project root or an extra root")
29
+ if not os.path.isfile(abs_path):
30
+ raise FileNotFoundError(file_path)
31
+ if not focus_lines:
32
+ raise ValueError("focus_lines must contain at least one line number")
33
+ pad = max(0, int(padding_lines if padding_lines is not None else 15))
34
+
35
+ from .textdecode import iter_decoded_lines
36
+
37
+ focuses = sorted({int(line) for line in focus_lines if int(line) >= 1})
38
+ if not focuses:
39
+ raise ValueError('focus_lines must contain positive line numbers')
40
+ pad_ranges = [(max(1, line - pad), line + pad) for line in focuses]
41
+ wanted: dict[int, str] = {}
42
+ total = 0
43
+ with open(abs_path, 'rb') as stream:
44
+ for total, decoded in enumerate(iter_decoded_lines(stream), start=1):
45
+ if any(a <= total <= b for a, b in pad_ranges):
46
+ wanted[total] = decoded
47
+ if not any(line <= total for line in focuses):
48
+ raise ValueError('All focus lines are outside the file')
49
+
50
+ width = len(str(total))
51
+ selected = {}
52
+ clipped = []
53
+ remaining = MAX_CONTEXT_CHARS
54
+ separator = '\n ...\n'
55
+ # Reserve enough space for separators even when selected lines are disjoint.
56
+ overhead = len(separator) + 1
57
+ valid_focuses = [line for line in focuses if line in wanted]
58
+ for i, line in enumerate(valid_focuses):
59
+ text = f"{line:>{width}} | {wanted[line]}"
60
+ allowance = max(0, remaining // (len(valid_focuses) - i) - overhead)
61
+ if len(text) > allowance:
62
+ clipped.append(line)
63
+ marker = ' ... [line truncated]'
64
+ text = text[:max(0, allowance - len(marker))] + marker[:allowance]
65
+ if text:
66
+ selected[line] = text
67
+ remaining -= len(text) + overhead
68
+ neighbors = sorted((n for n in wanted if n not in selected),
69
+ key=lambda n: (min(abs(n - line) for line in valid_focuses), n))
70
+ for line in neighbors:
71
+ text = f"{line:>{width}} | {wanted[line]}"
72
+ if len(text) + overhead <= remaining:
73
+ selected[line] = text
74
+ remaining -= len(text) + overhead
75
+ merged: list[list[int]] = []
76
+ for line in sorted(selected):
77
+ if merged and line == merged[-1][1] + 1:
78
+ merged[-1][1] = line
79
+ else:
80
+ merged.append([line, line])
81
+ parts = ['\n'.join(selected[n] for n in range(a, b + 1)) for a, b in merged]
82
+ truncated = bool(clipped) or len(selected) < len(wanted)
83
+ symbols = [
84
+ {"symbol": r["qualified_name"], "type": r["symbol_type"], "start_line": r["start_line"], "end_line": r["end_line"]}
85
+ for r in self.conn.execute(
86
+ "SELECT * FROM symbols WHERE file_path=? AND symbol_type != 'namespace' AND start_line<=? AND end_line>=? "
87
+ "ORDER BY (end_line-start_line) LIMIT 5",
88
+ (file_path.replace("\\", "/"), max(valid_focuses), min(valid_focuses)))
89
+ ]
90
+ return {
91
+ "file_path": file_path, "total_lines": total, "ranges": merged,
92
+ "enclosing_symbols": symbols, "truncated": truncated,
93
+ "omitted_lines": len(wanted) - len(selected), "truncated_lines": clipped,
94
+ "context": separator.join(parts),
95
+ }
96
+
@@ -10,16 +10,17 @@ import sqlite3
10
10
  import subprocess
11
11
  import time
12
12
  import uuid
13
- from contextlib import contextmanager
14
13
  from collections import defaultdict
14
+ from contextlib import contextmanager
15
15
  from dataclasses import dataclass, field
16
16
 
17
17
  from . import db as dbmod
18
18
  from .callgraph import resolve_calls
19
19
  from .embedder import get_embedder, split_identifier
20
20
  from .langparse import CLASS_LIKE, parse_file
21
- from .scanner import iter_files
22
21
  from .locking import IndexBusyError, index_lock, is_busy
22
+ from .scanner import iter_files
23
+ from .textdecode import decode_bytes, is_binary_data
23
24
 
24
25
  _TYPE_KINDS = tuple(CLASS_LIKE)
25
26
 
@@ -42,15 +43,6 @@ def _file_transaction(conn: sqlite3.Connection):
42
43
  conn.execute("RELEASE index_file")
43
44
 
44
45
 
45
- def decode_bytes(data: bytes) -> str:
46
- for enc in ("utf-8-sig", "big5", "cp1252"):
47
- try:
48
- return data.decode(enc)
49
- except UnicodeDecodeError:
50
- continue
51
- return data.decode("utf-8", errors="replace")
52
-
53
-
54
46
  _CJK_RUN = re.compile(r"[\u4e00-\u9fff]+")
55
47
 
56
48
 
@@ -189,7 +181,7 @@ class Indexer:
189
181
  changed = True
190
182
  stats.warnings.append(f"{sf.rel_path}: {exc}")
191
183
  continue
192
- if b"\x00" in data[:8192]:
184
+ if is_binary_data(data):
193
185
  seen.discard(sf.rel_path) # drop any earlier entry for it
194
186
  stats.skipped += 1
195
187
  continue
@@ -566,7 +558,7 @@ def resolve_dependencies(conn: sqlite3.Connection) -> None:
566
558
  deps.add((r[0], t, "inheritance"))
567
559
 
568
560
  for r in conn.execute("SELECT DISTINCT file_path, name FROM raw_refs WHERE kind='ident'"):
569
- targets = type_files.get(r[1])
561
+ targets = type_files.get(r[1], set())
570
562
  if targets and len(targets) <= 5:
571
563
  for t in targets:
572
564
  if t != r[0]:
@@ -78,8 +78,19 @@ class _Extractor:
78
78
  spans.sort(key=lambda t: (t[0], t[1].start))
79
79
  self.spans = [s for _, s in spans]
80
80
  self.file_env: dict[str, _Cand] = {}
81
+ self.class_env: dict[str, dict[str, _Cand]] = {}
81
82
  self.cands: list[_Cand] = []
82
83
 
84
+ def _class_key(self, node) -> str:
85
+ names = []
86
+ while node is not None:
87
+ if node.type in {'class_declaration', 'struct_declaration', 'record_declaration', 'namespace_declaration'}:
88
+ name = node.child_by_field_name('name')
89
+ if name is not None:
90
+ names.append(self.text(name))
91
+ node = node.parent
92
+ return '.'.join(reversed(names))
93
+
83
94
  # ---------------------------------------------------------------- helpers
84
95
  def text(self, n) -> str:
85
96
  return self.src[n.start_byte:n.end_byte].decode("utf-8", errors="replace")
@@ -120,7 +131,7 @@ class _Extractor:
120
131
  @staticmethod
121
132
  def arg_exprs(arglist) -> list:
122
133
  """[(expression node, is_named_argument)] for an argument_list node."""
123
- out = []
134
+ out: list[tuple] = []
124
135
  if arglist is None:
125
136
  return out
126
137
  for a in arglist.named_children:
@@ -174,7 +185,13 @@ class _Extractor:
174
185
  return (c.text, c.complete) if c else None
175
186
  if t == "member_access_expression":
176
187
  name = n.child_by_field_name("name")
177
- c = self.file_env.get(self.text(name)) if name is not None else None
188
+ raw = self.text(n)
189
+ receiver = n.child_by_field_name('expression')
190
+ if receiver is not None and self.text(receiver) == 'this' and name is not None:
191
+ c = env.get(self.text(name))
192
+ else:
193
+ matches = [value for key, value in self.file_env.items() if key == raw or key.endswith('.' + raw)]
194
+ c = matches[0] if len(matches) == 1 else None
178
195
  return (c.text, c.complete) if c else None
179
196
  if t == "invocation_expression":
180
197
  c = self._builder_of(n, env)
@@ -264,7 +281,7 @@ class _Extractor:
264
281
  # ---------------------------------------------------------------- traversal
265
282
  def run(self, root) -> list[Access]:
266
283
  self._collect_file_consts(root)
267
- env: dict[str, _Cand] = dict(self.file_env)
284
+ env: dict[str, _Cand] = {}
268
285
  stack: list = [("node", root)]
269
286
  while stack:
270
287
  kind, n = stack.pop()
@@ -275,7 +292,7 @@ class _Extractor:
275
292
  continue
276
293
  if n.type in _SCOPES:
277
294
  stack.append(("exit", (len(self.cands), n, env)))
278
- env = dict(self.file_env)
295
+ env = dict(self.class_env.get(self._class_key(n), {}))
279
296
  for c in reversed(n.children):
280
297
  stack.append(("node", c))
281
298
  continue
@@ -294,10 +311,13 @@ class _Extractor:
294
311
  for d in _walk(n, "variable_declarator"):
295
312
  ident, init = self._declarator(d)
296
313
  if ident and init is not None and self._is_stringy(init):
297
- r = self.evaluate(init, self.file_env)
314
+ owner = self._class_key(n)
315
+ local = self.class_env.setdefault(owner, {})
316
+ r = self.evaluate(init, local)
298
317
  if r:
299
318
  c = _Cand(r[0], r[1], self.line(init))
300
- self.file_env[ident] = c
319
+ local[ident] = c
320
+ self.file_env[owner + '.' + ident] = c
301
321
  self.cands.append(c)
302
322
  continue
303
323
  if n.type in _SCOPES:
@@ -395,6 +415,9 @@ class _Extractor:
395
415
  if expr.type in ("identifier", "invocation_expression"):
396
416
  c = env.get(self.text(expr)) if expr.type == "identifier" else self._builder_of(expr, env)
397
417
  if c is not None:
418
+ if any(c is value for value in self.file_env.values()):
419
+ self.cands.append(_Cand(c.text, c.complete, self.line(expr), sink=True, proc_ok=first))
420
+ return True
398
421
  c.sink = True
399
422
  c.proc_ok = c.proc_ok or first
400
423
  return True