如何使用重构从类中删除泛型类型 [英] how can I remove generic type from class using refactoring
问题描述
我有这个课程:
public class TimeIntCo<T> extends TimeValueCo<Integer>
{
}
我决定T类型是不需要,并且它不会在类中使用(我知道它总是Integer)。
但是,我有很多类似于 TimeIntCo&整数>
。
有没有办法使用Eclipse重构来删除 T
类型,而不引起引用中的任何错误? br>
我的意思是一步一步,而不是找到&替换。
I decided that the T type is not needed anymore, and it is not used in the class (I know it is always Integer).
However, I have a lot of references for the class that looks like TimeIntCo<Integer>
.
Is there a way using Eclipse refactoring to remove the T
type without causing any error in references?
I mean to do it in one step and not find&replace.
编辑:更清楚 - 如果我从类中删除 T
我有大约10,000个错误,我不想手动执行,我更希望不要使用find&替换,因为我认为重构更安全。
to be more clear - if I just remove T
from class I have about 10,000 errors, I don't want to do it manually, and I prefer not to use find&replace because I consider refactor safer.
推荐答案
我怀疑有一个重构。只需删除< T>
,保存文件,并修复可能导致的任何编译错误。 (如果没有使用 T
类型参数,则不应该有任何编译错误来纠正...)
I doubt that there is a refactor for this. Just delete the <T>
, save the file, and go through and fix any compilation errors that might result. (If the T
type parameter is not used, there shouldn't be any compilation errors to correct ...)
@ohadshai评论:
@ohadshai comments:
然后我在eclipse中有大约10,000个错误...
then I have about 10,000 errors in eclipse...
我敢打赌,大多数可以通过更改少量的子类声明来修复。
I bet that most of them can be fixed by changing a small number of subclass declarations.
你知道任何其他IDE吗? IDEA?
Do you know any other IDE that does that? IDEA?
不,我没有。重构通常用于保留原始源代码含义的简单转换。这种转型不太可能这样做。
No I don't. Refactors are generally used for simple transformations that preserve the meaning of the original source code. This transformation is unlikely to do that.
这篇关于如何使用重构从类中删除泛型类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!