# 更改签名

> For the complete documentation index, see [llms.txt](https://www.jetbrains.com/zh-cn/help/clion/llms.txt).

> **TL;DR**
> `重构 | 更改签名`
>
>
>
> `Ctrl+F6` (Windows), `⌘ F6` (macOS), `⌘ F6` (IntelliJ IDEA Classic (macOS)), `⌘ ⌥ S` (macOS System Shortcuts), `Ctrl+F6` (XWin), `Ctrl+F6` (GNOME), `Ctrl+6` (KDE), `Ctrl+F6` (Emacs), `Ctrl+F6` (Sublime Text), `Ctrl+F6` (Sublime Text (macOS)), `⌘ F6` (Xcode), `Ctrl+R, S` (Visual Studio), `⌘ R, S` (Visual Studio (macOS)), `Ctrl+F6` (ReSharper), `⌘ F6` (ReSharper (macOS)), `Ctrl+F6` (QtCreator), `⌘ F6` (QtCreator (macOS)), `Ctrl+F6` (NetBeans), `Alt+Shift+C` (Eclipse), `⌘ ⌥ C` (Eclipse (macOS))
>
>
>
> 快捷方式： `Ctrl+F6` (Windows), `⌘ F6` (macOS), `⌘ F6` (IntelliJ IDEA Classic (macOS)), `⌘ ⌥ S` (macOS System Shortcuts), `Ctrl+F6` (XWin), `Ctrl+F6` (GNOME), `Ctrl+6` (KDE), `Ctrl+F6` (Emacs), `Ctrl+F6` (Sublime Text), `Ctrl+F6` (Sublime Text (macOS)), `⌘ F6` (Xcode), `Ctrl+R, S` (Visual Studio), `⌘ R, S` (Visual Studio (macOS)), `Ctrl+F6` (ReSharper), `⌘ F6` (ReSharper (macOS)), `Ctrl+F6` (QtCreator), `⌘ F6` (QtCreator (macOS)), `Ctrl+F6` (NetBeans), `Alt+Shift+C` (Eclipse), `⌘ ⌥ C` (Eclipse (macOS))
>
>
>
> 重构设置：  `设置 | 编辑器 | 常规`
>
>
>
> 重构可用

更改签名 重构结合了几种可以应用于函数签名的不同修改。 您可以使用此重构来：

* 更改函数名称和返回类型

* 添加、移除和重新排序参数

在更改函数签名时，CLion 会搜索该函数的所有用法，并更新所有可以安全修改的调用、实现和覆盖替换，以反映更改。

Procedure: 添加参数

1. 点击  `return` 值，该值已用红色高亮显示。

2. 按 `Alt+Enter` (Windows), `⌥ ⏎` (macOS), `⌥ ⏎` (IntelliJ IDEA Classic (macOS)), `⌥ ⏎` (macOS System Shortcuts), `Alt+Enter` (XWin), `Alt+Enter` (GNOME), `Alt+Enter` (KDE), `Alt+Enter` (Emacs), `Alt+Enter` (Sublime Text), `⌥ ⏎` (Sublime Text (macOS)), `⌥ ⏎` (Xcode), `Alt+Enter` (Visual Studio), `⌥ ⏎` (Visual Studio (macOS)), `Alt+Enter` (ReSharper), `⌥ ⏎` (ReSharper (macOS)), `Alt+Enter` (QtCreator), `⌥ ⏎` (QtCreator (macOS)), `Alt+Enter` (NetBeans), `Ctrl+1` (Eclipse), `⌘ 1` (Eclipse (macOS))并选择   创建参数‘>parameter_name<’。  。

3. 在   更改签名  对话框中，调整参数设置或接受建议的设置。

4. 点击   重构  。

Procedure: 更改函数签名

1. 将插入符号放置在您想要重构的函数上。

2. 按 `Ctrl+F6` (Windows), `⌘ F6` (macOS), `⌘ F6` (IntelliJ IDEA Classic (macOS)), `⌘ ⌥ S` (macOS System Shortcuts), `Ctrl+F6` (XWin), `Ctrl+F6` (GNOME), `Ctrl+6` (KDE), `Ctrl+F6` (Emacs), `Ctrl+F6` (Sublime Text), `Ctrl+F6` (Sublime Text (macOS)), `⌘ F6` (Xcode), `Ctrl+R, S` (Visual Studio), `⌘ R, S` (Visual Studio (macOS)), `Ctrl+F6` (ReSharper), `⌘ F6` (ReSharper (macOS)), `Ctrl+F6` (QtCreator), `⌘ F6` (QtCreator (macOS)), `Ctrl+F6` (NetBeans), `Alt+Shift+C` (Eclipse), `⌘ ⌥ C` (Eclipse (macOS))或从主菜单或上下文菜单中选择  `重构 | 更改签名` 。

3. 在   更改签名   对话框中，对函数签名进行必要的更改。

* 在 名称 字段中更改函数名称。

* 在 返回值类型 字段中更改函数返回类型。

* 使用表格和 ![Add](https://resources.jetbrains.com/help/img/idea/2026.3/app.expui.general.add.svg)/ ![移除](https://resources.jetbrains.com/help/img/idea/2026.3/app.expui.general.remove.svg)/ ![向上移动](https://resources.jetbrains.com/help/img/idea/2026.3/app.general.arrowUp.svg)/ ![向下移动](https://resources.jetbrains.com/help/img/idea/2026.3/app.general.arrowDown.svg) 按钮管理函数参数。 添加参数时，在相应的行中指定新参数的属性： Type 、 名称 和 默认值 。 默认值 字段设置用作用法参数的类型值。 如果您将此字段留空，CLion 将使用默认类型值（例如，数字使用 `0` ，指针使用 `nullptr` ）。 ![更改签名对话框](https://resources.jetbrains.com/help/img/idea/2026.3/cl_change_signature_default.png) > **Note:** > [自动补全](auto-completing-code.html) 可用于 Type 和 默认值 字段。

* 您还可以使用相应的复选框使函数成为 `const` 、 `constexpr` 或 `noexcept` 。

## 示例

C/C++:

|  调整前  |  调整后  |
| --- | --- |
|     ```CPLUSPLUS //Initial function signature int exFunction2(int a, int b) {     int x = a+b;     return x; };  int main() {     int a = 0, b = 1;     int x = exFunction2(a, b);     return 0; }  ```    |     ```CPLUSPLUS //Name changed, the third parameter introduced int exFunction3(int a, int b, int c) {     int x = a+b;     return x; };  int main() {     int a = 0, b = 1;     int x = exFunction3(a, b, 0); //default value '0' added     return 0; }  ```    |

Python:

|  调整前  |  调整后  |
| --- | --- |
|     ```PYTHON # This function will be renamed def fibonacci( n ): a, b = 0, 1 while b < n: print( b ) a, b = b, a+b  n = int(input("n = ")) fibonacci( n )  ```    |     ```PYTHON # Function with the new name def fibonacci_numbers( n ): a, b = 0, 1 while b < n: print( b ) a, b = b, a+b  n = int(input("n = ")) fibonacci_numbers( n )  ```    |

JavaScript:

|  调整前  |  调整后  |
| --- | --- |
|     ```JAVASCRIPT //This function will be renamed //and a default parameter will be added function result() { }  function show_result() {     alert('Result: ' + result()); }   ```    |     ```JAVASCRIPT //Function with a new name and default parameter function generate_result(input = 100) { }  function show_result() {     alert('Result: ' + generate_result()); }  ```    |

## See also

### 外部链接

[JetBrains CLion Blog](http://blog.jetbrains.com/clion/2014/12/refactorings-in-clion-be-safe-and-quick/)

