简体   繁体   English

转到 VS Code 中的声明(如在 Pycharm 中)

[英]Go to declaration in VS Code(as in Pycharm)

just trying to find correct tool for me to start with Python when tried PyCharm -to learn about possible attributes for some object- used an option : "Go to declaration":在尝试 PyCharm 时,只是试图为我找到正确的工具以从 Python 开始 - 以了解某些对象的可能属性 - 使用了一个选项:“转到声明”: 在此处输入图片说明

which brought me to declaration and i could see the available options :这让我进行了声明,我可以看到可用的选项: 在此处输入图片说明

when tried to do the same in VS Code:当试图在 VS Code 中做同样的事情时: 在此处输入图片说明

i'm getting this result :我得到这个结果: 在此处输入图片说明

I have two questions : 1) how to go to declaration to see the possible options in VS Code ?我有两个问题:1)如何去声明以查看 VS Code 中的可能选项? 2) Can You advise me some plugin - that can explore the definition and may be bring this Params in auto completion ? 2)你能告诉我一些插件 - 可以探索定义并且可以在自动完成中引入这个参数吗?

** just to mention i have Python extension installed...: ** 只是提一下我安装了 Python 扩展...: 在此处输入图片说明

To 1) Yes, obviously there is "Go to definition" functionality. 1) 是的,显然有“转到定义”功能。 Otherwise the menu entry wouldn't make any sense, would it?否则菜单项没有任何意义,是吗?

If no definition was found that means vscode does not have any information about this part, which can have several reasons (eg the source code or at least a typings file for that is not available).如果没有找到定义,则意味着 vscode 没有关于这部分的任何信息,这可能有多种原因(例如,源代码或至少一个类型文件不可用)。

It seems obvious but for completeness let me say: "Go to definition" functionality must be provided by an extension for that language.这似乎很明显,但为了完整起见,让我说:“转到定义”功能必须由该语言的扩展提供。 Hence you need one that generates that info for vscode.因此,您需要一个为 vscode 生成该信息的工具。

To 2) No, we cannot recommend any software here. 2) 不,我们不能在这里推荐任何软件。 This is off-topic for Stackoverflow.这是 Stackoverflow 的题外话。 Use the extension search in vscode and see what's available.在 vscode 中使用扩展搜索并查看可用的内容。 Often there is more than one extension for a given language and you can try out what works best for you.通常,一种给定的语言有多个扩展,您可以尝试最适合您的扩展。

Usually this means one of two things:通常这意味着以下两种情况之一:

  1. The source file where the definition is is not inside the PYTHONPATH定义所在的源文件不在PYTHONPATH 中
  2. The definition is in a Cython file.定义在Cython文件中。

1 is easy to fix: Either make sure you selected the correct python binary in VS Code or (in case of custom libraries or ones which are outside Python's default library locations) add it to PYTHONPATH manually. 1 很容易修复:确保您在 VS Code 中选择了正确的 python 二进制文件,或者(如果是自定义库或 Python 默认库位置之外的库)手动将其添加到 PYTHONPATH。

2 usually means there is nothing you can do as the VS Code Python extension currently does not analyze any C extensions. 2 通常意味着您无能为力,因为 VS Code Python 扩展目前不分析任何 C 扩展。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM