CodeArts IDE
CodeArts IDE
- 最新动态
- 产品介绍
- 快速入门
-
用户指南
- 下载CodeArts IDE客户端
- 登录CodeArts IDE客户端
- 激活CodeArts IDE客户端
- 配置CodeArts IDE用户权限
- CodeArts IDE产品功能介绍
- CodeArts IDE基础操作介绍
- 使用CodeArts IDE for C/C++
- 使用CodeArts IDE for Java
- 使用CodeArts IDE for Python
- 使用CodeArts IDE for RemoteShell
- 最佳实践
- 常见问题
- API参考
- 视频帮助
- 文档下载
- 通用参考
链接复制成功!
内联方法
此重构允许您用方法的主体替换方法的用法。这与提取方法相反。
执行重构
- 在代码编辑器中,将光标放置在要内联的方法的声明或调用上。
- 在编辑器上下文菜单中,选择“重构 > 内联方法...”,或按“Ctrl+Shift+Alt+L”。
- 在打开的“内联方法”对话框中,选择是否在方法的所有引用都内联后保留该方法。
- 单击“重构”以应用重构。
示例
例如,内联方法add,用方法的主体替换其调用。
重构前
class InlineMethod {
private int a;
private int b;
public void InlineMethod() {
int c = add(a, b);
int d = add(a, c);
}
private int add(int a, int b) {
return a + b;
}
}
重构后
class InlineMethod {
private int a;
private int b;
public void InlineMethod() {
int c = a + b;
int d = a + c;
}
}
父主题: 内联重构