作者热门文章
- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我想要像 Find Usages 这样的 VS Code 功能在 Pycharm 中,它可以找到一个变量的所有读写。以一个简单的文件为例:
class Foo:
def __init__(self, bar):
self.bar = bar
def do_something(self):
bar1 = "hhhhh"
if bar1 == self.bar:
print("do something")
在 Pycharm 中使用 self.bar
的“Find Usages”:
我试过“查找所有引用文献”,但它不起作用:
因为它没有找到 if bar1 == self.bar:
。
更新:我要的不是只搜索出现次数,因为它只匹配关键字,其中包括具有相同名称的其他变量以及评论中出现的次数。
更新:原来是 Microsoft python 语言服务器中的一个已知问题:github.com/microsoft/python-language-server/issues/1174
最佳答案
问题发生在我将 python 扩展 jediEnabled
选项的用户设置为 false 时:
"python.jediEnabled": false,
所以切换回默认值:
// Enables Jedi as IntelliSense engine instead of Microsoft Python Analysis Engine.
"python.jediEnabled": true,
并且“查找所有引用”在示例中有效!
可能是 Microsoft Python 分析引擎中的错误。
关于python - VS 代码 : How to find all references of a variable in python?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57105741/
我是一名优秀的程序员,十分优秀!