Intellij Idea重构-如何使多个类扩展基类? [英] Intellij Idea Refactoring - How do I make multiple classes extend a base class?

查看:248
本文介绍了Intellij Idea重构-如何使多个类扩展基类?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有10个Java类,它们具有相同的字段和相同的构造函数来初始化这些字段.我希望将重复的代码提取到一个超类中,然后所有10个类都应扩展该超类.我想使用Intellij Idea进行此重构.

I have 10 Java classes which have the same fields and same constructor to initialize those fields. I wanted the duplicated code to be extracted into a super class and then all the 10 classes should extend that super class. I want to do this refactoring with Intellij Idea.

通过使用Refactor> Extract> Superclass,我能够从10个类之一中将所需的代码提取到称为BaseClass的超类中.现在,我想使用Intellij自动使其余9个类扩展BaseClass.我该怎么办?

I was able to extract the desired code from one of the 10 classes into a super class called BaseClass by using Refactor > Extract > Superclass. Now, I want to use Intellij to automatically make the remaining 9 classes extend BaseClass. How do I do that ?

推荐答案

AFAIK没有这样的重构.

AFAIK there is no such refactoring.

查找重复项并替换重构也无济于事.

我认为,您必须手动执行此操作.

I think, you have to do this manually.

这篇关于Intellij Idea重构-如何使多个类扩展基类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆