I'd like a VS Code feature like Find Usages in Pycharm, which can find all reads and writes of a variable. Take a simple file for example:
class Foo:
def __init__(self, bar):
self.bar = bar
def do_something(self):
bar1 = "hhhhh"
if bar1 == self.bar:
print("do something")
In Pycharm using "Find Usages" of self.bar
:
I've tried "Find all references" but it doesn't work:
as it doesn't find if bar1 == self.bar:
.
Update: searching for just occurrences is not what I am asking, as it just matches keywords which includes other variables with same name and also occurrences in comments.
Update: turns out to be a known issue in Microsoft python language server: github.com/microsoft/python-language-server/issues/1174
You can use the Find All References command to find where particular code elements are referenced throughout your codebase. The Find All References command is available on the context (right-click) menu of the element you want to find references to. Or, if you are a keyboard user, press Shift + F12.
The problem occurs with my user setting of python extension jediEnabled
option as false:
"python.jediEnabled": false,
so switch back to the default:
// Enables Jedi as IntelliSense engine instead of Microsoft Python Analysis Engine.
"python.jediEnabled": true,
and "Find all references" works in the example!
Maybe it's a bug in Microsoft Python Analysis Engine.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With