Light‑weight CodeLens provider that shows how many times a Python function / method / class is referenced in your workspace (PyCharm style). Click the indicator to open the built‑in references panel and navigate.
✨ Features
Function / method / class reference counting (per symbol line)
Fast: initial pass only does regex scan; expensive reference resolution deferred until CodeLens is revealed
Smarter method filtering: excludes definitions and class headers; only counts real attribute calls like obj.method(...)
Independent enable/disable toggles for classes and functions
Optional inclusion of the definition itself in the count
Optionally hide CodeLens when count is zero
⚙️ Settings
All settings are under pythonReferenceCounter namespace:
If the language server only returns in-file results, perform a naive full-workspace text search as a fallback (may over-count)
📦 Requirements
VS Code >= 1.102.0
Python files in a workspace folder (no external index needed)
🚀 Usage
Install the extension
Open a Python file
Hover near a function / class line or scroll it into view – a CodeLens like 3 references appears
Click the lens to open the references panel
Adjust behavior via Settings > Extensions > Python Reference Counter
🧠 How It Works (Brief)
Provide phase: cheap regex finds candidate class / def lines and creates placeholder CodeLens objects
Resolve phase: when a lens becomes visible, executes built‑in vscode.executeReferenceProvider and post‑filters method references so only true call sites (preceded by .) remain
Definition filtering & zero‑count hiding applied per user settings
📌 Limitations / Notes
Static analysis only—dynamic usages via getattr, reflection, metaprogramming not detected
Method detection relies on indentation + dot call heuristic; very unusual formatting may reduce accuracy
Multi‑line signatures with decorators are supported (basic pattern)