Apply 'Copy of existing static method body' fixes

GitOrigin-RevId: 139c1d45abf749d40ec4e1c9004b16dea0b3a954
This commit is contained in:
Tagir Valeev
2024-07-05 19:36:03 +00:00
committed by intellij-monorepo-bot
parent e1b597714c
commit 31b989d0cd
16 changed files with 111 additions and 220 deletions
@@ -14,6 +14,7 @@ import com.intellij.psi.search.searches.ReferencesSearch;
import com.intellij.psi.util.PsiUtil;
import com.intellij.refactoring.BaseRefactoringProcessor;
import com.intellij.refactoring.changeSignature.ChangeSignatureUtil;
import com.intellij.refactoring.extractSuperclass.ExtractSuperClassUtil;
import com.intellij.refactoring.listeners.RefactoringEventData;
import com.intellij.refactoring.util.RefactoringUIUtil;
import com.intellij.usageView.UsageInfo;
@@ -125,17 +126,13 @@ public class ChangeClassSignatureProcessor extends BaseRefactoringProcessor {
@Nullable
@Override
protected RefactoringEventData getBeforeData() {
RefactoringEventData data = new RefactoringEventData();
data.addElement(myClass);
return data;
return ExtractSuperClassUtil.createAfterData(myClass);
}
@Nullable
@Override
protected RefactoringEventData getAfterData(UsageInfo @NotNull [] usages) {
RefactoringEventData data = new RefactoringEventData();
data.addElement(myClass);
return data;
return ExtractSuperClassUtil.createAfterData(myClass);
}
private void doRefactoring(UsageInfo[] usages) throws IncorrectOperationException {
@@ -10,17 +10,18 @@ import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.*;
import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.psi.search.searches.ReferencesSearch;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.psi.util.PsiUtilCore;
import com.intellij.refactoring.BaseRefactoringProcessor;
import com.intellij.refactoring.HelpID;
import com.intellij.refactoring.RefactoringBundle;
import com.intellij.refactoring.extractSuperclass.ExtractSuperClassUtil;
import com.intellij.refactoring.listeners.RefactoringEventData;
import com.intellij.refactoring.move.MoveCallback;
import com.intellij.refactoring.move.MoveMemberViewDescriptor;
import com.intellij.refactoring.util.CommonRefactoringUtil;
import com.intellij.refactoring.util.MoveRenameUsageInfo;
import com.intellij.refactoring.util.RefactoringConflictsUtil;
import com.intellij.refactoring.util.RefactoringUtil;
import com.intellij.usageView.UsageInfo;
import com.intellij.usageView.UsageViewDescriptor;
import com.intellij.usageView.UsageViewUtil;
@@ -91,9 +92,7 @@ public class MoveMembersProcessor extends BaseRefactoringProcessor {
@Override
protected @Nullable RefactoringEventData getAfterData(UsageInfo @NotNull [] usages) {
RefactoringEventData eventData = new RefactoringEventData();
eventData.addElement(myTargetClass);
return eventData;
return ExtractSuperClassUtil.createAfterData(myTargetClass);
}
private void setOptions(MoveMembersOptions dialog) {
@@ -136,7 +135,7 @@ public class MoveMembersProcessor extends BaseRefactoringProcessor {
usagesList.add(usage);
}
else {
if (!isInMovedElement(ref)) {
if (!RefactoringUtil.isInMovedElement(ref, myMembersToMove)) {
usagesList.add(new MoveMembersUsageInfo(member, ref, null, ref, psiReference));
}
}
@@ -156,13 +155,6 @@ public class MoveMembersProcessor extends BaseRefactoringProcessor {
}
}
private boolean isInMovedElement(PsiElement element) {
for (PsiMember member : myMembersToMove) {
if (PsiTreeUtil.isAncestor(member, element, false)) return true;
}
return false;
}
@Override
protected void performRefactoring(final UsageInfo @NotNull [] usages) {
PsiClass targetClass = JavaPsiFacade.getInstance(myProject).findClass(myOptions.getTargetClassName(),
@@ -188,27 +188,7 @@ public class LegacyJsonSchemaObjectMerger implements JsonSchemaObjectMerger {
public static @Nullable JsonSchemaType getSubtypeOfBoth(@NotNull JsonSchemaType selfType,
@NotNull JsonSchemaType otherType) {
if (otherType == JsonSchemaType._any) return selfType;
if (selfType == JsonSchemaType._any) return otherType;
return switch (selfType) {
case _string -> otherType == JsonSchemaType._string || otherType == JsonSchemaType._string_number ? JsonSchemaType._string : null;
case _number -> {
if (otherType == JsonSchemaType._integer) yield JsonSchemaType._integer;
yield otherType == JsonSchemaType._number || otherType == JsonSchemaType._string_number ? JsonSchemaType._number : null;
}
case _integer -> otherType == JsonSchemaType._number
|| otherType == JsonSchemaType._string_number
|| otherType == JsonSchemaType._integer ? JsonSchemaType._integer : null;
case _object -> otherType == JsonSchemaType._object ? JsonSchemaType._object : null;
case _array -> otherType == JsonSchemaType._array ? JsonSchemaType._array : null;
case _boolean -> otherType == JsonSchemaType._boolean ? JsonSchemaType._boolean : null;
case _null -> otherType == JsonSchemaType._null ? JsonSchemaType._null : null;
case _string_number -> otherType == JsonSchemaType._integer
|| otherType == JsonSchemaType._number
|| otherType == JsonSchemaType._string
|| otherType == JsonSchemaType._string_number ? otherType : null;
default -> otherType;
};
return JsonSchemaObjectImpl.getSubtypeOfBoth(selfType, otherType);
}
public static HashMap<String, JsonSchemaObjectImpl> mergeProperties(@NotNull Map<String, JsonSchemaObjectImpl> baseProperties,
@@ -205,11 +205,7 @@ public class GeneratedParserUtilBase {
@Contract(mutates = "param1")
public static boolean consumeToken(PsiBuilder builder, IElementType token) {
addVariantSmart(builder, token, true);
if (nextTokenIsFast(builder, token)) {
builder.advanceLexer();
return true;
}
return false;
return consumeTokenFast(builder, token);
}
public static boolean consumeTokenFast(PsiBuilder builder, IElementType token) {
@@ -972,7 +968,7 @@ public class GeneratedParserUtilBase {
Arrays.sort(strings);
count = 0;
for (String s : strings) {
if (s.length() == 0) continue;
if (s.isEmpty()) continue;
if (count++ > 0) {
if (count > MAX_VARIANTS_TO_DISPLAY) {
sb.append(" ").append(AnalysisBundle.message("parsing.error.and.ellipsis"));
@@ -4,10 +4,9 @@ package com.intellij.openapi.options.newEditor;
import com.intellij.CommonBundle;
import com.intellij.ide.HelpTooltip;
import com.intellij.ide.SaveAndSyncHandler;
import com.intellij.ide.plugins.newui.EventHandler;
import com.intellij.idea.ActionsBundle;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.actionSystem.ActionManager;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.DataProvider;
import com.intellij.openapi.actionSystem.ShortcutSet;
import com.intellij.openapi.application.ApplicationManager;
@@ -227,8 +226,7 @@ public class SettingsDialog extends DialogWrapper implements DataProvider {
}
static @Nullable ShortcutSet getFindActionShortcutSet() {
AnAction action = ActionManager.getInstance().getAction(ACTION_FIND);
return action == null ? null : action.getShortcutSet();
return EventHandler.getShortcuts(ACTION_FIND);
}
private class ApplyActionWrapper extends AbstractAction {
@@ -77,8 +77,7 @@ public abstract class AbstractRearrangerTest extends BasePlatformTestCase {
ArrangementAtomMatchCondition[] conditions = new ArrangementAtomMatchCondition[tokens.length + 1];
conditions[0] = atom(nameFilter);
for (int i = 0; i < tokens.length; i++) conditions[i + 1] = atom(tokens[i]);
ArrangementMatchCondition compositeCondition = ArrangementUtil.combine(conditions);
return new StdArrangementMatchRule(new StdArrangementEntryMatcher(compositeCondition));
return rule(conditions);
}
}
@@ -53,10 +53,7 @@ public final class IntMapForwardIndex implements IntForwardIndex, MeasurableInde
@Override
public int keysCountApproximately() {
if (myPersistentMap instanceof MeasurableIndexStore) {
return ((MeasurableIndexStore)myPersistentMap).keysCountApproximately();
}
return KEYS_COUNT_UNKNOWN;
return MeasurableIndexStore.keysCountApproximatelyIfPossible(myPersistentMap);
}
@Override
@@ -7,117 +7,107 @@ package com.intellij.util.io;
@SuppressWarnings({"PointlessBitwiseExpression", "PointlessArithmeticExpression"})
public final class Bits {
/*
* Methods for unpacking primitive values from byte arrays starting at
* given offsets.
*/
/*
* Methods for unpacking primitive values from byte arrays starting at
* given offsets.
*/
public static boolean getBoolean(byte[] b, int off) {
return b[off] != 0;
}
public static boolean getBoolean(byte[] b, int off) {
return b[off] != 0;
}
public static char getChar(byte[] b, int off) {
return (char) (((b[off + 1] & 0xFF) << 0) +
((b[off + 0] & 0xFF) << 8));
}
public static char getChar(byte[] b, int off) {
return (char)(((b[off + 1] & 0xFF) << 0) +
((b[off + 0] & 0xFF) << 8));
}
public static short getShort(byte[] b, int off) {
return (short) (((b[off + 1] & 0xFF) << 0) +
((b[off + 0] & 0xFF) << 8));
}
public static short getShort(byte[] b, int off) {
return (short)(((b[off + 1] & 0xFF) << 0) +
((b[off + 0] & 0xFF) << 8));
}
public static int getInt(byte[] b, int off) {
return ((b[off + 3] & 0xFF) << 0) +
((b[off + 2] & 0xFF) << 8) +
((b[off + 1] & 0xFF) << 16) +
((b[off + 0] & 0xFF) << 24);
}
public static int getInt(byte[] b, int off) {
return ((b[off + 3] & 0xFF) << 0) +
((b[off + 2] & 0xFF) << 8) +
((b[off + 1] & 0xFF) << 16) +
((b[off + 0] & 0xFF) << 24);
}
public static float getFloat(byte[] b, int off) {
int i = ((b[off + 3] & 0xFF) << 0) +
((b[off + 2] & 0xFF) << 8) +
((b[off + 1] & 0xFF) << 16) +
((b[off + 0] & 0xFF) << 24);
return Float.intBitsToFloat(i);
}
public static float getFloat(byte[] b, int off) {
int i = ((b[off + 3] & 0xFF) << 0) +
((b[off + 2] & 0xFF) << 8) +
((b[off + 1] & 0xFF) << 16) +
((b[off + 0] & 0xFF) << 24);
return Float.intBitsToFloat(i);
}
public static long getLong(byte[] b, int off) {
return ((b[off + 7] & 0xFFL) << 0) +
((b[off + 6] & 0xFFL) << 8) +
((b[off + 5] & 0xFFL) << 16) +
((b[off + 4] & 0xFFL) << 24) +
((b[off + 3] & 0xFFL) << 32) +
((b[off + 2] & 0xFFL) << 40) +
((b[off + 1] & 0xFFL) << 48) +
((b[off + 0] & 0xFFL) << 56);
}
public static long getLong(byte[] b, int off) {
return ((b[off + 7] & 0xFFL) << 0) +
((b[off + 6] & 0xFFL) << 8) +
((b[off + 5] & 0xFFL) << 16) +
((b[off + 4] & 0xFFL) << 24) +
((b[off + 3] & 0xFFL) << 32) +
((b[off + 2] & 0xFFL) << 40) +
((b[off + 1] & 0xFFL) << 48) +
((b[off + 0] & 0xFFL) << 56);
}
public static double getDouble(byte[] b, int off) {
long j = ((b[off + 7] & 0xFFL) << 0) +
((b[off + 6] & 0xFFL) << 8) +
((b[off + 5] & 0xFFL) << 16) +
((b[off + 4] & 0xFFL) << 24) +
((b[off + 3] & 0xFFL) << 32) +
((b[off + 2] & 0xFFL) << 40) +
((b[off + 1] & 0xFFL) << 48) +
((b[off + 0] & 0xFFL) << 56);
return Double.longBitsToDouble(j);
}
public static double getDouble(byte[] b, int off) {
long j = ((b[off + 7] & 0xFFL) << 0) +
((b[off + 6] & 0xFFL) << 8) +
((b[off + 5] & 0xFFL) << 16) +
((b[off + 4] & 0xFFL) << 24) +
((b[off + 3] & 0xFFL) << 32) +
((b[off + 2] & 0xFFL) << 40) +
((b[off + 1] & 0xFFL) << 48) +
((b[off + 0] & 0xFFL) << 56);
return Double.longBitsToDouble(j);
}
/*
* Methods for packing primitive values into byte arrays starting at given
* offsets.
*/
/*
* Methods for packing primitive values into byte arrays starting at given
* offsets.
*/
public static void putBoolean(byte[] b, int off, boolean val) {
b[off] = (byte) (val ? 1 : 0);
}
public static void putBoolean(byte[] b, int off, boolean val) {
b[off] = (byte)(val ? 1 : 0);
}
public static void putChar(byte[] b, int off, char val) {
b[off + 1] = (byte) (val >>> 0);
b[off + 0] = (byte) (val >>> 8);
}
public static void putChar(byte[] b, int off, char val) {
b[off + 1] = (byte)(val >>> 0);
b[off + 0] = (byte)(val >>> 8);
}
public static void putShort(byte[] b, int off, short val) {
b[off + 1] = (byte) (val >>> 0);
b[off + 0] = (byte) (val >>> 8);
}
public static void putShort(byte[] b, int off, short val) {
b[off + 1] = (byte)(val >>> 0);
b[off + 0] = (byte)(val >>> 8);
}
public static void putInt(byte[] b, int off, int val) {
b[off + 3] = (byte) (val >>> 0);
b[off + 2] = (byte) (val >>> 8);
b[off + 1] = (byte) (val >>> 16);
b[off + 0] = (byte) (val >>> 24);
}
public static void putInt(byte[] b, int off, int val) {
b[off + 3] = (byte)(val >>> 0);
b[off + 2] = (byte)(val >>> 8);
b[off + 1] = (byte)(val >>> 16);
b[off + 0] = (byte)(val >>> 24);
}
public static void putFloat(byte[] b, int off, float val) {
int i = Float.floatToIntBits(val);
b[off + 3] = (byte) (i >>> 0);
b[off + 2] = (byte) (i >>> 8);
b[off + 1] = (byte) (i >>> 16);
b[off + 0] = (byte) (i >>> 24);
}
public static void putFloat(byte[] b, int off, float val) {
int i = Float.floatToIntBits(val);
putInt(b, off, i);
}
public static void putLong(byte[] b, int off, long val) {
b[off + 7] = (byte) (val >>> 0);
b[off + 6] = (byte) (val >>> 8);
b[off + 5] = (byte) (val >>> 16);
b[off + 4] = (byte) (val >>> 24);
b[off + 3] = (byte) (val >>> 32);
b[off + 2] = (byte) (val >>> 40);
b[off + 1] = (byte) (val >>> 48);
b[off + 0] = (byte) (val >>> 56);
}
public static void putLong(byte[] b, int off, long val) {
b[off + 7] = (byte)(val >>> 0);
b[off + 6] = (byte)(val >>> 8);
b[off + 5] = (byte)(val >>> 16);
b[off + 4] = (byte)(val >>> 24);
b[off + 3] = (byte)(val >>> 32);
b[off + 2] = (byte)(val >>> 40);
b[off + 1] = (byte)(val >>> 48);
b[off + 0] = (byte)(val >>> 56);
}
public static void putDouble(byte[] b, int off, double val) {
long j = Double.doubleToLongBits(val);
b[off + 7] = (byte) (j >>> 0);
b[off + 6] = (byte) (j >>> 8);
b[off + 5] = (byte) (j >>> 16);
b[off + 4] = (byte) (j >>> 24);
b[off + 3] = (byte) (j >>> 32);
b[off + 2] = (byte) (j >>> 40);
b[off + 1] = (byte) (j >>> 48);
b[off + 0] = (byte) (j >>> 56);
}
public static void putDouble(byte[] b, int off, double val) {
long j = Double.doubleToLongBits(val);
putLong(b, off, j);
}
}
@@ -13,7 +13,6 @@ import com.intellij.ide.DeleteProvider;
import com.intellij.ide.IdeBundle;
import com.intellij.ide.actions.EditSourceAction;
import com.intellij.ide.dnd.*;
import com.intellij.ide.dnd.aware.DnDAwareTree;
import com.intellij.notification.Notification;
import com.intellij.notification.NotificationAction;
import com.intellij.notification.NotificationType;
@@ -893,8 +892,7 @@ public class ShelvedChangesViewManager implements Disposable {
private @NotNull DnDImage createDraggedImage(@NotNull DnDActionInfo info) {
String imageText = VcsBundle.message("unshelve.changes.action");
Image image = DnDAwareTree.getDragImage(myTree, imageText, null).getFirst();
return new DnDImage(image, new Point(-image.getWidth(null), -image.getHeight(null)));
return ChangesTreeDnDSupport.createDragImage(myTree, imageText);
}
}
@@ -610,11 +610,7 @@ public final class VcsSelectionHistoryDialog extends FrameWrapper implements Dat
@NotNull
private String loadContents(@NotNull VcsFileRevision revision) throws VcsException {
try {
byte[] bytes = revision.loadContent();
if (bytes == null) {
throw new VcsException(VcsBundle.message("history.failed.to.load.content.for.revision.0",
revision.getRevisionNumber().asString()));
}
byte[] bytes = VcsHistoryUtil.loadRevisionContent(revision);
return new String(bytes, myFile.getCharset());
}
catch (IOException e) {
@@ -12,10 +12,8 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.plugins.groovy.GroovyLanguage;
import org.jetbrains.plugins.groovy.intentions.GroovyIntentionsBundle;
import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElementFactory;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression;
import org.jetbrains.plugins.groovy.lang.psi.impl.PsiImplUtil;
import org.jetbrains.plugins.groovy.lang.psi.impl.utils.BoolUtils;
import java.util.function.Supplier;
@@ -88,20 +86,7 @@ public abstract class GrPsiUpdateIntention implements ModCommandAction {
protected static void replaceExpressionWithNegatedExpressionString(@NotNull String newExpression, @NotNull GrExpression expression) throws
IncorrectOperationException {
final GroovyPsiElementFactory factory = GroovyPsiElementFactory.getInstance(expression.getProject());
GrExpression expressionToReplace = expression;
final String expString;
if (BoolUtils.isNegated(expression)) {
expressionToReplace = BoolUtils.findNegation(expression);
expString = newExpression;
}
else {
expString = "!(" + newExpression + ')';
}
final GrExpression newCall = factory.createExpressionFromText(expString, expression.getContext());
assert expressionToReplace != null;
expressionToReplace.replaceWithExpression(newCall, true);
Intention.replaceExpressionWithNegatedExpressionString(newExpression, expression);
}
private String getPrefix() {
final Class<? extends GrPsiUpdateIntention> aClass = getClass();
@@ -44,8 +44,7 @@ public class ResolverProcessorImpl extends ResolverProcessor<GroovyResolveResult
return true;
}
PsiNamedElement namedElement = (PsiNamedElement)element;
PsiSubstitutor substitutor = state.get(PsiSubstitutor.KEY);
if (substitutor == null) substitutor = PsiSubstitutor.EMPTY;
PsiSubstitutor substitutor = MethodResolverProcessor.getSubstitutor(state);
if (myTypeArguments.length > 0 && namedElement instanceof PsiClass) {
substitutor = substitutor.putAll((PsiClass)namedElement, myTypeArguments);
@@ -3,6 +3,7 @@ package org.jetbrains.java.decompiler.modules.decompiler.exps;
import org.jetbrains.java.decompiler.code.CodeConstants;
import org.jetbrains.java.decompiler.main.collectors.BytecodeMappingTracer;
import org.jetbrains.java.decompiler.modules.decompiler.DecHelper;
import org.jetbrains.java.decompiler.modules.decompiler.ExprProcessor;
import org.jetbrains.java.decompiler.modules.decompiler.vars.CheckTypesResult;
import org.jetbrains.java.decompiler.struct.gen.VarType;
@@ -377,10 +378,7 @@ public class FunctionExprent extends Exprent {
@Override
public Exprent copy() {
List<Exprent> lst = new ArrayList<>();
for (Exprent expr : lstOperands) {
lst.add(expr.copy());
}
List<Exprent> lst = DecHelper.copyExprentList(lstOperands);
FunctionExprent func = new FunctionExprent(funcType, lst, bytecode);
func.setImplicitType(implicitType);
@@ -504,31 +504,6 @@ public class MavenRootModelAdapterLegacyImpl implements MavenRootModelAdapterInt
return ExternalProjectSystemRegistry.getInstance().getSourceById(SerializationConstants.MAVEN_EXTERNAL_SOURCE_ID);
}
@Nullable
public static OrderEntry findLibraryEntry(@NotNull Module m, @NotNull MavenArtifact artifact) {
String name = artifact.getLibraryName();
for (OrderEntry each : ModuleRootManager.getInstance(m).getOrderEntries()) {
if (each instanceof LibraryOrderEntry && name.equals(((LibraryOrderEntry)each).getLibraryName())) {
return each;
}
}
return null;
}
@Nullable
public static MavenArtifact findArtifact(@NotNull MavenProject project, @Nullable Library library) {
if (library == null) return null;
String name = library.getName();
if (!MavenArtifact.isMavenLibrary(name)) return null;
for (MavenArtifact each : project.getDependencies()) {
if (each.getLibraryName().equals(name)) return each;
}
return null;
}
@Override
public void setLanguageLevel(LanguageLevel level) {
try {
@@ -37,10 +37,7 @@ public final class CommandsRunner {
}
public static boolean haveCommandsFinishedSuccessfully() {
if (getInstance().actionCallback == null) {
return false;
}
return getInstance().actionCallback.isDone();
return haveCommandsFinished();
}
public static boolean haveCommandsFailed() {
@@ -9,6 +9,7 @@ import com.intellij.codeInsight.daemon.Validator;
import com.intellij.codeInsight.daemon.impl.HighlightInfo;
import com.intellij.codeInsight.daemon.impl.HighlightInfoType;
import com.intellij.codeInsight.daemon.impl.HighlightVisitor;
import com.intellij.codeInsight.daemon.impl.tagTreeHighlighting.XmlTagTreeHighlightingUtil;
import com.intellij.codeInsight.intention.IntentionAction;
import com.intellij.codeInsight.quickfix.UnresolvedReferenceQuickFixUpdater;
import com.intellij.codeInspection.*;
@@ -607,14 +608,7 @@ public class XmlHighlightVisitor extends XmlElementVisitor implements HighlightV
@Override
public boolean suitableForFile(@NotNull final PsiFile file) {
if (file instanceof XmlFile) return true;
for (PsiFile psiFile : file.getViewProvider().getAllFiles()) {
if (psiFile instanceof XmlFile) {
return true;
}
}
return false;
return file instanceof XmlFile || XmlTagTreeHighlightingUtil.hasXmlViewProvider(file);
}
@Override