[英]IntelliJ Idea: Replace usages of constants by actual values in all classes in a package
In my Java project I was told to avoid the usage of integer and String constants in certain classes.在我的 Java 项目中,有人告诉我要避免在某些类中使用 integer 和字符串常量。 Is there any shortcut in IntelliJ Idea to replace all usages of String and integer constants by their actual values?
IntelliJ Idea 中是否有任何快捷方式可以用实际值替换 String 和 integer 常量的所有用法? Something like "Extracting constants backwards".
诸如“向后提取常量”之类的东西。 Because there are a lot of places to change and I wondered if there was some way to do it automatically.
因为有很多地方需要改变,我想知道是否有某种方法可以自动完成。
Initial: Do you mean something like this: https://www.jetbrains.com/help/idea/extract-constant.html初始:你的意思是这样的吗: https://www.jetbrains.com/help/idea/extract-constant.html
Update: I will try with an example, I guess this is your case (sorry if i misunderstood again)更新:我会尝试一个例子,我想这是你的情况(对不起,如果我再次误解了)
Lets say I have:可以说我有:
private static final String PAGE = "page";
private static final String LIMIT = "size";
private static final String SORT = "sort";
Then do a right click on the PAGE String: Refactor > Inline Field然后右键单击 PAGE 字符串:重构 > 内联字段
and do the Refactor并进行重构
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.