mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
ChangeUIDAction: fix review issues: IDEA-CR-32493
This commit is contained in:
@@ -15,6 +15,7 @@ import com.siyeh.ig.psiutils.CommentTracker;
|
||||
import org.jetbrains.annotations.Nls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.security.SecureRandom;
|
||||
import java.util.Random;
|
||||
|
||||
|
||||
@@ -37,11 +38,11 @@ public class ChangeUIDAction extends PsiElementBaseIntentionAction {
|
||||
PsiField field = PsiTreeUtil.getParentOfType(element, PsiField.class);
|
||||
if (field == null) return;
|
||||
PsiExpression initializer = field.getInitializer();
|
||||
if (initializer == null) return;
|
||||
PsiElementFactory factory = JavaPsiFacade.getElementFactory(project);
|
||||
Application application = ApplicationManager.getApplication();
|
||||
Random random = application.isUnitTestMode() ? new Random(42) : new Random();
|
||||
Random random = application.isUnitTestMode() ? new Random(42) : new SecureRandom();
|
||||
PsiExpression newInitializer = factory.createExpressionFromText(Long.toString(random.nextLong()) + "L", null);
|
||||
if (initializer == null) return;
|
||||
new CommentTracker().replaceAndRestoreComments(initializer, newInitializer);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<html>
|
||||
<body>
|
||||
<p>Intention to change serialVersionUID initializer to randomly generated one</p>
|
||||
<p>Changes the initializer of a serialVersionUID field to a randomly generated one</p>
|
||||
</body>
|
||||
</html>
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// "Randomly change serial version UID" "true"
|
||||
// "Randomly change 'serialVersionUID' initializer" "true"
|
||||
|
||||
import java.util.function.BinaryOperator;
|
||||
import java.util.function.Function;
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// "Randomly change serial version UID" "true"
|
||||
// "Randomly change 'serialVersionUID' initializer" "true"
|
||||
|
||||
import java.util.function.BinaryOperator;
|
||||
import java.util.function.Function;
|
||||
|
||||
@@ -568,4 +568,4 @@ collapse.selection.overlapping.warning.text=Overlapping fold region(s) exist
|
||||
collapse.selection.overlapping.warning.ok=Remove
|
||||
collapse.selection.overlapping.warning.cancel=Cancel
|
||||
|
||||
change.uid.action.name=Randomly change serial version UID
|
||||
change.uid.action.name=Randomly change 'serialVersionUID' initializer
|
||||
Reference in New Issue
Block a user