将代码重构为VS Code中的子函数

huangapple go评论67阅读模式
英文:

Refactor code into a subfunction in VS Code

问题

如果它们是VS Code中的内置功能或扩展,以将任何选定的代码重构为子函数?或者至少分析代码并显示所有需要提供为函数参数的依赖项/变量。我知道Pycharm有这样的功能。

我的最低目标是提前看到创建子函数需要多少工作量,或者是否有意义(而不需要提供大量参数)。

我在谈论Python。

英文:

If they're a built-in function or extension in VS Code to refactor any selected code into a subfunction? Or at least to analyse the code and show all dependencies/variables that would need to be provided as function parameters. I know such a functionality from Pycharm.

My least goal would be to see in advance how much effort it would be to create a subfunction - or if it is meaningful at all (without providing dozens of parameters).

I am talking about Python.

答案1

得分: 1

你可以阅读有关Python 重构的文档。

Python 扩展添加了以下重构功能:提取变量、提取方法和重命名模块。它还支持实现附加重构功能的扩展,如排序导入

将代码重构为VS Code中的子函数

在选择代码后,您可以单击左侧的黄色灯泡来进行自动重构。

英文:

You can read document about Python Refactoring.

The Python extension adds the following refactoring functionalities: Extract Variable, Extract Method and Rename Module. It also supports extensions that implement additional refactoring features such as Sort Imports.

将代码重构为VS Code中的子函数

After selecting the code, you can click on the yellow light bulb on the left to automatic refactoring.

huangapple
  • 本文由 发表于 2023年6月5日 14:57:20
  • 转载请务必保留本文链接:https://go.coder-hub.com/76404111.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定