CodeArts代码重构
【摘要】 重构是通过改变现有程序结构而不改变其功能和用途来提高代码的可重用性和可维护性。
CodeArts支持重构操作,提供了多种重要的重构类型,如下:
- 重命名
- 提取重构(方法、常数、接口、字段、变量、参数、超类)
- 引入重构 (字段、常量、变量、参数、参数对象、函数变量、功能参数)
- 复制重构
- 移动和更改重构
- 查找和替换重构
- 内联重构 (方法、字段、变量、匿名类、超类、参数)
- 设计模式与重构补全功能运用
CodeArts支持的重构操作
| 重构类型 | 支持操作 | 快捷键 |
| 重命名 | Rename Symbol | Shift+F6 |
| 提取重构 | Extract Superclass | |
| Extract Method Object | ||
| Extract Method | Ctrl+Alt+Shift+M |
|
| Extract Interface | ||
| Extract Delegate... | ||
| Encapsulate Fields | ||
| 引入重构 | Introduce Variable | Ctrl+Alt+V |
| Introduce Parameter | Ctrl+Alt+Shift+P |
|
| Introduce Parameter Object | ||
| Introduce Functional Variable | ||
| Introduce Functional Parameter | ||
| Introduce Field | Ctrl+Alt+Shift+F |
|
| Introduce Constant | Ctrl+Alt+C |
|
| 复制重构 | Copy Class | Shift+F5 |
| 移动和更改重构 | Push members down | |
| Pull members up | ||
| Move inner class to Upper level | ||
| Make Static | ||
| Change Method Signature | Ctrl+F6 |
|
| Change Class Signature | Ctrl+F6 |
|
| Type Migration | ||
| 查找和替换重构 | Replace Inheritance with Delegation | |
| Replace Constructor with Factory Method | ||
| Replace Constructor with Builder | ||
| 内联重构 | Inline Variable | |
| Inline to Anonymous Class | ||
| Inline Super Class | ||
| Inline Parameter | Ctrl+Alt+Shift+P |
|
| Inline Method | Ctrl+Alt+Shift+L |
|
| Inline Field | ||
| 其它重构 |
Invert Boolean | |
| Use Interface Where Possible | ||
| Convert Raw Types to Generics | ||
| Convert To Instance Method | ||
|
Remove Middleman
|
||
|
Safe Delete
|
Alt+Del
|
|
|
Move Static Members
|
【声明】本内容来自华为云开发者社区博主,不代表华为云及华为云开发者社区的观点和立场。转载时必须标注文章的来源(华为云社区)、文章链接、文章作者等基本信息,否则作者和本社区有权追究责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱:
cloudbbs@huaweicloud.com
- 点赞
- 收藏
- 关注作者
评论(0)