CodeArts IDE
CodeArts IDE
- 最新动态
- 产品介绍
- 快速入门
- 用户指南
- 最佳实践
- API参考
- 常见问题
- 文档下载
- 通用参考
链接复制成功!
内联超类
这个重构操作允许您将超类的成员移动到子类中,并删除超类。这与提取超类相反。
执行重构
- 在代码编辑器中,将光标放在您想要内联的超类的声明或引用位置。
- 在主菜单或编辑器上下文菜单中,选择Refactor>Inline Superclass。
- 在打开的 Inline Superclass 对话框中,选择是否在所有内联位置完成后保留超类。
- 单击Refactor以应用重构操作。
示例
举个例子,让我们将类InlineSuperClass内联并删除,将其成员移动到SubClass中。
重构前
class InlineSuperClass { public int returnValue() { ... } public int returnNewValue() { ... } } class SubClass extends InlineSuperClass { private int myValue; int someMethod() { if (myValue > returnValue()) { return returnNewValue(); } return 0; } }
重构后
class SubClass { private int myValue; int someMethod() { if (myValue > returnValue()) { return returnNewValue(); } return 0; } public int returnValue() { ... } public int returnNewValue() { ... } }
父主题: 内联重构