mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
notnull
GitOrigin-RevId: 520a991d3f64c48f6a2f68391e06c5b062cf1d23
This commit is contained in:
committed by
intellij-monorepo-bot
parent
39682cb156
commit
83ef9687f8
+1
-1
@@ -39,7 +39,7 @@ class DetectedJavaChangeInfo extends JavaChangeInfoImpl {
|
||||
CanonicalTypes.Type newType,
|
||||
ParameterInfoImpl @NotNull [] newParms,
|
||||
ThrownExceptionInfo[] newExceptions,
|
||||
String newName, String oldName, final boolean delegate) {
|
||||
String newName, @NotNull String oldName, final boolean delegate) {
|
||||
super(newVisibility, method, newName, newType, newParms, newExceptions, delegate, new HashSet<>(), new HashSet<>(), oldName);
|
||||
final PsiParameter[] parameters = method.getParameterList().getParameters();
|
||||
myModifiers = new String[parameters.length];
|
||||
|
||||
@@ -32,6 +32,7 @@ public interface JavaChangeInfo extends ChangeInfo {
|
||||
boolean isExceptionSetOrOrderChanged();
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
PsiMethod getMethod();
|
||||
|
||||
CanonicalTypes.Type getNewReturnType();
|
||||
@@ -65,8 +66,9 @@ public interface JavaChangeInfo extends ChangeInfo {
|
||||
|
||||
PsiExpression getValue(int i, PsiCallExpression callExpression);
|
||||
|
||||
void updateMethod(PsiMethod psiMethod);
|
||||
void updateMethod(@NotNull PsiMethod psiMethod);
|
||||
|
||||
@NotNull
|
||||
Collection<PsiMethod> getMethodsToPropagateParameters();
|
||||
|
||||
default boolean checkUnusedParameter() {
|
||||
|
||||
+14
-9
@@ -38,11 +38,14 @@ public class JavaChangeInfoImpl extends UserDataHolderBase implements JavaChange
|
||||
@PsiModifier.ModifierConstant
|
||||
@NotNull
|
||||
private final String newVisibility;
|
||||
@NotNull
|
||||
private PsiMethod method;
|
||||
@NotNull
|
||||
private final String oldName;
|
||||
private final String oldType;
|
||||
String[] oldParameterNames;
|
||||
String[] oldParameterTypes;
|
||||
@NotNull
|
||||
private final String newName;
|
||||
final CanonicalTypes.Type newReturnType;
|
||||
final ParameterInfoImpl[] newParms;
|
||||
@@ -75,7 +78,7 @@ public class JavaChangeInfoImpl extends UserDataHolderBase implements JavaChange
|
||||
*/
|
||||
public JavaChangeInfoImpl(@PsiModifier.ModifierConstant @NotNull String newVisibility,
|
||||
@NotNull PsiMethod method,
|
||||
String newName,
|
||||
@NotNull String newName,
|
||||
CanonicalTypes.Type newType,
|
||||
ParameterInfoImpl @NotNull [] newParms,
|
||||
ThrownExceptionInfo @Nullable [] newExceptions,
|
||||
@@ -91,14 +94,14 @@ public class JavaChangeInfoImpl extends UserDataHolderBase implements JavaChange
|
||||
*/
|
||||
public JavaChangeInfoImpl(@PsiModifier.ModifierConstant @NotNull String newVisibility,
|
||||
@NotNull PsiMethod method,
|
||||
String newName,
|
||||
@NotNull String newName,
|
||||
CanonicalTypes.Type newType,
|
||||
ParameterInfoImpl @NotNull [] newParms,
|
||||
ThrownExceptionInfo @Nullable [] newExceptions,
|
||||
boolean generateDelegate,
|
||||
@NotNull Set<PsiMethod> propagateParametersMethods,
|
||||
@NotNull Set<PsiMethod> propagateExceptionsMethods,
|
||||
String oldName) {
|
||||
@NotNull String oldName) {
|
||||
PsiElementFactory factory = JavaPsiFacade.getElementFactory(method.getProject());
|
||||
|
||||
this.newVisibility = newVisibility;
|
||||
@@ -288,7 +291,7 @@ public class JavaChangeInfoImpl extends UserDataHolderBase implements JavaChange
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiMethod getMethod() {
|
||||
public @NotNull PsiMethod getMethod() {
|
||||
return method;
|
||||
}
|
||||
|
||||
@@ -298,16 +301,16 @@ public class JavaChangeInfoImpl extends UserDataHolderBase implements JavaChange
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateMethod(PsiMethod method) {
|
||||
public void updateMethod(@NotNull PsiMethod method) {
|
||||
this.method = method;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<PsiMethod> getMethodsToPropagateParameters() {
|
||||
public @NotNull Collection<PsiMethod> getMethodsToPropagateParameters() {
|
||||
return propagateParametersMethods;
|
||||
}
|
||||
|
||||
public ParameterInfoImpl[] getCreatedParmsInfoWithoutVarargs() {
|
||||
public ParameterInfoImpl @NotNull [] getCreatedParmsInfoWithoutVarargs() {
|
||||
List<ParameterInfoImpl> result = new ArrayList<>();
|
||||
for (ParameterInfoImpl newParm : newParms) {
|
||||
if (newParm.oldParameterIndex < 0 && !newParm.isVarargType()) {
|
||||
@@ -341,6 +344,7 @@ public class JavaChangeInfoImpl extends UserDataHolderBase implements JavaChange
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String getNewName() {
|
||||
return newName;
|
||||
}
|
||||
@@ -411,6 +415,7 @@ public class JavaChangeInfoImpl extends UserDataHolderBase implements JavaChange
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String getOldName() {
|
||||
return oldName;
|
||||
}
|
||||
@@ -461,7 +466,7 @@ public class JavaChangeInfoImpl extends UserDataHolderBase implements JavaChange
|
||||
: that.newReturnType != null) {
|
||||
return false;
|
||||
}
|
||||
if (newVisibility != null ? !newVisibility.equals(that.newVisibility) : that.newVisibility != null) return false;
|
||||
if (!newVisibility.equals(that.newVisibility)) return false;
|
||||
if (!oldName.equals(that.oldName)) return false;
|
||||
if (!Arrays.equals(oldParameterNames, that.oldParameterNames)) return false;
|
||||
if (!Arrays.equals(oldParameterTypes, that.oldParameterTypes)) return false;
|
||||
@@ -475,7 +480,7 @@ public class JavaChangeInfoImpl extends UserDataHolderBase implements JavaChange
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = newVisibility != null ? newVisibility.hashCode() : 0;
|
||||
int result = newVisibility.hashCode();
|
||||
if (checkMethodEquality()) {
|
||||
result = 31 * result + method.hashCode();
|
||||
}
|
||||
|
||||
+2
-2
@@ -108,12 +108,12 @@ public class JavaChangeSignatureHandler implements ChangeSignatureHandler {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ParameterInfoImpl> getParameters() {
|
||||
public @NotNull List<ParameterInfoImpl> getParameters() {
|
||||
return Arrays.asList((ParameterInfoImpl[])currentInfo.getNewParameters());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getVisibility() {
|
||||
public @NotNull String getVisibility() {
|
||||
return currentInfo.getNewVisibility();
|
||||
}
|
||||
|
||||
|
||||
+11
-8
@@ -1,11 +1,13 @@
|
||||
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.refactoring.changeSignature;
|
||||
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.PsiMethod;
|
||||
import com.intellij.psi.PsiParameter;
|
||||
import com.intellij.psi.PsiType;
|
||||
import com.intellij.psi.PsiTypeElement;
|
||||
import com.intellij.psi.util.AccessModifier;
|
||||
import com.intellij.psi.util.JavaPsiRecordUtil;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
import com.intellij.util.VisibilityUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -13,9 +15,10 @@ import java.util.List;
|
||||
|
||||
public class JavaMethodDescriptor implements MethodDescriptor<ParameterInfoImpl, String> {
|
||||
|
||||
@NotNull
|
||||
private final PsiMethod myMethod;
|
||||
|
||||
public JavaMethodDescriptor(PsiMethod method) {
|
||||
public JavaMethodDescriptor(@NotNull PsiMethod method) {
|
||||
myMethod = method;
|
||||
}
|
||||
|
||||
@@ -25,7 +28,7 @@ public class JavaMethodDescriptor implements MethodDescriptor<ParameterInfoImpl,
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ParameterInfoImpl> getParameters() {
|
||||
public @NotNull List<ParameterInfoImpl> getParameters() {
|
||||
final ArrayList<ParameterInfoImpl> result = new ArrayList<>();
|
||||
final PsiParameter[] parameters = myMethod.getParameterList().getParameters();
|
||||
for (int i = 0; i < parameters.length; i++) {
|
||||
@@ -38,12 +41,12 @@ public class JavaMethodDescriptor implements MethodDescriptor<ParameterInfoImpl,
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getVisibility() {
|
||||
public @NotNull String getVisibility() {
|
||||
return VisibilityUtil.getVisibilityModifier(myMethod.getModifierList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiMethod getMethod() {
|
||||
public @NotNull PsiMethod getMethod() {
|
||||
return myMethod;
|
||||
}
|
||||
|
||||
@@ -76,7 +79,7 @@ public class JavaMethodDescriptor implements MethodDescriptor<ParameterInfoImpl,
|
||||
}
|
||||
|
||||
@Override
|
||||
public ReadWriteOption canChangeReturnType() {
|
||||
public @NotNull ReadWriteOption canChangeReturnType() {
|
||||
return myMethod.isConstructor() ? ReadWriteOption.None : ReadWriteOption.ReadWrite;
|
||||
}
|
||||
|
||||
|
||||
+3
-2
@@ -28,6 +28,7 @@ import com.intellij.usageView.UsageInfo;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import com.intellij.util.VisibilityUtil;
|
||||
import com.intellij.util.containers.MultiMap;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -41,7 +42,7 @@ public class JavaIntroduceParameterObjectDelegate
|
||||
extends IntroduceParameterObjectDelegate<PsiMethod, ParameterInfoImpl, JavaIntroduceParameterObjectClassDescriptor> {
|
||||
|
||||
@Override
|
||||
public List<ParameterInfoImpl> getAllMethodParameters(PsiMethod sourceMethod) {
|
||||
public List<ParameterInfoImpl> getAllMethodParameters(@NotNull PsiMethod sourceMethod) {
|
||||
return new JavaMethodDescriptor(sourceMethod).getParameters();
|
||||
}
|
||||
|
||||
@@ -157,7 +158,7 @@ public class JavaIntroduceParameterObjectDelegate
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChangeInfo createChangeSignatureInfo(PsiMethod method, List<ParameterInfoImpl> newParameterInfos, boolean delegate) {
|
||||
public ChangeInfo createChangeSignatureInfo(PsiMethod method, List<? extends ParameterInfoImpl> newParameterInfos, boolean delegate) {
|
||||
PsiType returnType = method.getReturnType();
|
||||
return new JavaChangeInfoImpl(VisibilityUtil.getVisibilityModifier(method.getModifierList()),
|
||||
method,
|
||||
|
||||
@@ -74,7 +74,7 @@ public class CopyPasteDelegator implements CopyPasteSupport {
|
||||
return myEditable;
|
||||
}
|
||||
|
||||
private class MyEditable implements CutProvider, CopyProvider, PasteProvider {
|
||||
class MyEditable implements CutProvider, CopyProvider, PasteProvider {
|
||||
@Override
|
||||
public void performCopy(@NotNull DataContext dataContext) {
|
||||
PsiElement[] elements = getValidSelectedElements();
|
||||
@@ -129,7 +129,7 @@ public class CopyPasteDelegator implements CopyPasteSupport {
|
||||
}
|
||||
}
|
||||
|
||||
private boolean performDefaultPaste(final DataContext dataContext) {
|
||||
boolean performDefaultPaste(@NotNull DataContext dataContext) {
|
||||
final boolean[] isCopied = new boolean[1];
|
||||
final PsiElement[] elements = PsiCopyPasteManager.getInstance().getElements(isCopied);
|
||||
if (elements == null) return false;
|
||||
|
||||
+1
-2
@@ -32,7 +32,6 @@ import com.intellij.ui.table.TableView;
|
||||
import com.intellij.ui.treeStructure.Tree;
|
||||
import com.intellij.util.Alarm;
|
||||
import com.intellij.util.Consumer;
|
||||
import com.intellij.util.IJSwingUtilities;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import com.intellij.util.ui.table.JBListTable;
|
||||
@@ -137,7 +136,7 @@ public abstract class ChangeSignatureDialogBase<ParamInfo extends ParameterInfo,
|
||||
});
|
||||
}
|
||||
|
||||
public void setParameterInfos(List<? extends ParamInfo> parameterInfos) {
|
||||
public void setParameterInfos(@NotNull List<? extends ParamInfo> parameterInfos) {
|
||||
myParametersTableModel.setParameterInfos(parameterInfos);
|
||||
updateSignature();
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
package com.intellij.refactoring.changeSignature;
|
||||
|
||||
import com.intellij.psi.PsiElement;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -25,12 +26,15 @@ public interface MethodDescriptor<P extends ParameterInfo, V> {
|
||||
|
||||
String getName();
|
||||
|
||||
@NotNull
|
||||
List<P> getParameters();
|
||||
|
||||
int getParametersCount();
|
||||
|
||||
@NotNull
|
||||
V getVisibility();
|
||||
|
||||
@NotNull
|
||||
PsiElement getMethod();
|
||||
|
||||
boolean canChangeVisibility();
|
||||
@@ -39,5 +43,6 @@ public interface MethodDescriptor<P extends ParameterInfo, V> {
|
||||
|
||||
boolean canChangeName();
|
||||
|
||||
@NotNull
|
||||
ReadWriteOption canChangeReturnType();
|
||||
}
|
||||
|
||||
+2
-1
@@ -12,6 +12,7 @@ import com.intellij.refactoring.ui.StringTableCellEditor;
|
||||
import com.intellij.ui.*;
|
||||
import com.intellij.util.ui.ColumnInfo;
|
||||
import com.intellij.util.ui.ListTableModel;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
@@ -41,7 +42,7 @@ public abstract class ParameterTableModelBase<P extends ParameterInfo, TableItem
|
||||
addRow(createRowItem(null));
|
||||
}
|
||||
|
||||
public void setParameterInfos(List<? extends P> parameterInfos) {
|
||||
public void setParameterInfos(@NotNull List<? extends P> parameterInfos) {
|
||||
List<TableItem> items = new ArrayList<>(parameterInfos.size());
|
||||
for (P parameterInfo : parameterInfos) {
|
||||
items.add(createRowItem(parameterInfo));
|
||||
|
||||
+3
-1
@@ -23,6 +23,7 @@ import com.intellij.refactoring.changeSignature.ParameterInfo;
|
||||
import com.intellij.refactoring.ui.RefactoringDialog;
|
||||
import com.intellij.refactoring.util.AbstractParameterTablePanel;
|
||||
import com.intellij.refactoring.util.AbstractVariableData;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
@@ -33,6 +34,7 @@ public abstract class AbstractIntroduceParameterObjectDialog<M extends PsiNamedE
|
||||
P extends ParameterInfo,
|
||||
C extends IntroduceParameterObjectClassDescriptor<M, P>,
|
||||
V extends AbstractVariableData> extends RefactoringDialog {
|
||||
@NotNull
|
||||
protected M mySourceMethod;
|
||||
private JPanel myWholePanel;
|
||||
private JTextField mySourceMethodTextField;
|
||||
@@ -52,7 +54,7 @@ public abstract class AbstractIntroduceParameterObjectDialog<M extends PsiNamedE
|
||||
return true;
|
||||
}
|
||||
|
||||
public AbstractIntroduceParameterObjectDialog(M method) {
|
||||
public AbstractIntroduceParameterObjectDialog(@NotNull M method) {
|
||||
super(method.getProject(), true);
|
||||
mySourceMethod = method;
|
||||
setTitle(RefactoringBundle.message("refactoring.introduce.parameter.object.title"));
|
||||
|
||||
+2
-2
@@ -72,7 +72,7 @@ public abstract class IntroduceParameterObjectDelegate<M extends PsiNamedElement
|
||||
/**
|
||||
* @return {@link com.intellij.refactoring.changeSignature.MethodDescriptor#getParameters()}
|
||||
*/
|
||||
public abstract List<P> getAllMethodParameters(M sourceMethod);
|
||||
public abstract List<P> getAllMethodParameters(@NotNull M sourceMethod);
|
||||
|
||||
/**
|
||||
* Resulted parameter info should implement {@link ParameterInfo#getActualValue(PsiElement, Object)} so the call site would be updated with actual values.
|
||||
@@ -100,7 +100,7 @@ public abstract class IntroduceParameterObjectDelegate<M extends PsiNamedElement
|
||||
* Pass new parameter infos to the change info constructor which corresponds to the language of this delegate
|
||||
*/
|
||||
public abstract ChangeInfo createChangeSignatureInfo(M method,
|
||||
List<P> newParameterInfos,
|
||||
List<? extends P> newParameterInfos,
|
||||
boolean delegate);
|
||||
|
||||
/**
|
||||
|
||||
+4
-2
@@ -16,8 +16,9 @@
|
||||
|
||||
package com.intellij.refactoring.listeners.impl;
|
||||
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.refactoring.listeners.RefactoringElementListener;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author dsl
|
||||
@@ -27,7 +28,8 @@ public interface RefactoringTransaction {
|
||||
* Returns listener for element (element must belong to set of affected elements).
|
||||
* Refactorings should call appropriate methods of a listener, giving a modified (or new) element.
|
||||
*/
|
||||
RefactoringElementListener getElementListener(PsiElement element);
|
||||
@NotNull
|
||||
RefactoringElementListener getElementListener(@NotNull PsiElement element);
|
||||
|
||||
/**
|
||||
*
|
||||
|
||||
+16
-18
@@ -29,6 +29,7 @@ import com.intellij.usageView.UsageInfo;
|
||||
import com.intellij.usageView.UsageViewDescriptor;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import com.intellij.util.ObjectUtils;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -39,7 +40,7 @@ public class MoveFilesOrDirectoriesProcessor extends BaseRefactoringProcessor {
|
||||
private static final Logger LOG = Logger.getInstance(MoveFilesOrDirectoriesProcessor.class);
|
||||
|
||||
protected final PsiElement[] myElementsToMove;
|
||||
protected final boolean mySearchForReferences;
|
||||
private final boolean mySearchForReferences;
|
||||
protected final boolean mySearchInComments;
|
||||
protected final boolean mySearchInNonJavaFiles;
|
||||
private final PsiDirectory myNewParent;
|
||||
@@ -47,9 +48,9 @@ public class MoveFilesOrDirectoriesProcessor extends BaseRefactoringProcessor {
|
||||
private NonCodeUsageInfo[] myNonCodeUsages;
|
||||
private final Map<PsiFile, List<UsageInfo>> myFoundUsages = new HashMap<>();
|
||||
|
||||
public MoveFilesOrDirectoriesProcessor(Project project,
|
||||
PsiElement[] elements,
|
||||
PsiDirectory newParent,
|
||||
public MoveFilesOrDirectoriesProcessor(@NotNull Project project,
|
||||
PsiElement @NotNull [] elements,
|
||||
@NotNull PsiDirectory newParent,
|
||||
boolean searchInComments,
|
||||
boolean searchInNonJavaFiles,
|
||||
MoveCallback moveCallback,
|
||||
@@ -57,9 +58,9 @@ public class MoveFilesOrDirectoriesProcessor extends BaseRefactoringProcessor {
|
||||
this(project, elements, newParent, true, searchInComments, searchInNonJavaFiles, moveCallback, prepareSuccessfulCallback);
|
||||
}
|
||||
|
||||
public MoveFilesOrDirectoriesProcessor(Project project,
|
||||
PsiElement[] elements,
|
||||
PsiDirectory newParent,
|
||||
public MoveFilesOrDirectoriesProcessor(@NotNull Project project,
|
||||
PsiElement @NotNull [] elements,
|
||||
@NotNull PsiDirectory newParent,
|
||||
boolean searchForReferences,
|
||||
boolean searchInComments,
|
||||
boolean searchInNonJavaFiles,
|
||||
@@ -82,7 +83,7 @@ public class MoveFilesOrDirectoriesProcessor extends BaseRefactoringProcessor {
|
||||
|
||||
@Override
|
||||
protected UsageInfo @NotNull [] findUsages() {
|
||||
ArrayList<UsageInfo> result = new ArrayList<>();
|
||||
List<UsageInfo> result = new ArrayList<>();
|
||||
for (int i = 0; i < myElementsToMove.length; i++) {
|
||||
PsiElement element = myElementsToMove[i];
|
||||
if (mySearchForReferences) {
|
||||
@@ -96,13 +97,13 @@ public class MoveFilesOrDirectoriesProcessor extends BaseRefactoringProcessor {
|
||||
return result.toArray(UsageInfo.EMPTY_ARRAY);
|
||||
}
|
||||
|
||||
private void findElementUsages(ArrayList<? super UsageInfo> result, PsiElement element) {
|
||||
private void findElementUsages(@NotNull List<? super UsageInfo> result, @NotNull PsiElement element) {
|
||||
if (!mySearchForReferences) {
|
||||
return;
|
||||
}
|
||||
if (element instanceof PsiFile) {
|
||||
final List<UsageInfo> usages = MoveFileHandler.forElement((PsiFile)element)
|
||||
.findUsages(((PsiFile)element), myNewParent, mySearchInComments, mySearchInNonJavaFiles);
|
||||
.findUsages((PsiFile)element, myNewParent, mySearchInComments, mySearchInNonJavaFiles);
|
||||
if (usages != null) {
|
||||
result.addAll(usages);
|
||||
myFoundUsages.put((PsiFile)element, usages);
|
||||
@@ -151,10 +152,7 @@ public class MoveFilesOrDirectoriesProcessor extends BaseRefactoringProcessor {
|
||||
}
|
||||
}
|
||||
|
||||
RefactoringElementListener[] listeners =
|
||||
Arrays.stream(myElementsToMove)
|
||||
.map(item -> getTransaction().getElementListener(item))
|
||||
.toArray(RefactoringElementListener[]::new);
|
||||
List<RefactoringElementListener> listeners = ContainerUtil.map(myElementsToMove, item -> getTransaction().getElementListener(item));
|
||||
|
||||
for (int i = 0; i < myElementsToMove.length; i++) {
|
||||
PsiElement element = myElementsToMove[i];
|
||||
@@ -180,7 +178,7 @@ public class MoveFilesOrDirectoriesProcessor extends BaseRefactoringProcessor {
|
||||
}
|
||||
}
|
||||
|
||||
listeners[i].elementMoved(element);
|
||||
listeners.get(i).elementMoved(element);
|
||||
}
|
||||
// sort by offset descending to process correctly several usages in one PsiElement [IDEADEV-33013]
|
||||
CommonRefactoringUtil.sortDepthFirstRightLeftOrder(usages);
|
||||
@@ -243,7 +241,7 @@ public class MoveFilesOrDirectoriesProcessor extends BaseRefactoringProcessor {
|
||||
return data;
|
||||
}
|
||||
|
||||
private static void encodeDirectoryFiles(PsiElement psiElement, Map<PsiFile, FileASTNode> movedFiles) {
|
||||
private static void encodeDirectoryFiles(@NotNull PsiElement psiElement, @NotNull Map<PsiFile, FileASTNode> movedFiles) {
|
||||
if (psiElement instanceof PsiFile) {
|
||||
movedFiles.put((PsiFile)psiElement, ((PsiFile)psiElement).getNode());
|
||||
FileReferenceContextUtil.encodeFileReferences(psiElement);
|
||||
@@ -255,7 +253,7 @@ public class MoveFilesOrDirectoriesProcessor extends BaseRefactoringProcessor {
|
||||
}
|
||||
}
|
||||
|
||||
private static void processDirectoryFiles(Map<PsiFile, FileASTNode> movedFiles, Map<PsiElement, PsiElement> oldToNewMap, PsiElement psiElement) {
|
||||
private static void processDirectoryFiles(@NotNull Map<PsiFile, FileASTNode> movedFiles, @NotNull Map<PsiElement, PsiElement> oldToNewMap, @NotNull PsiElement psiElement) {
|
||||
if (psiElement instanceof PsiFile) {
|
||||
final PsiFile movedFile = (PsiFile)psiElement;
|
||||
movedFiles.put(movedFile, movedFile.getNode());
|
||||
@@ -268,7 +266,7 @@ public class MoveFilesOrDirectoriesProcessor extends BaseRefactoringProcessor {
|
||||
}
|
||||
}
|
||||
|
||||
protected void retargetUsages(UsageInfo[] usages, Map<PsiElement, PsiElement> oldToNewMap) {
|
||||
protected void retargetUsages(UsageInfo @NotNull [] usages, @NotNull Map<PsiElement, PsiElement> oldToNewMap) {
|
||||
final List<NonCodeUsageInfo> nonCodeUsages = new ArrayList<>();
|
||||
for (UsageInfo usageInfo : usages) {
|
||||
if (usageInfo instanceof MyUsageInfo) {
|
||||
|
||||
+6
-6
@@ -39,8 +39,8 @@ import java.util.Objects;
|
||||
* @author Maxim.Medvedev
|
||||
*/
|
||||
public class GrChangeInfoImpl implements JavaChangeInfo {
|
||||
GrMethod method;
|
||||
final String newName;
|
||||
private GrMethod method;
|
||||
private final String newName;
|
||||
@Nullable private final CanonicalTypes.Type returnType;
|
||||
private final String visibilityModifier;
|
||||
private final List<? extends GrParameterInfo> parameters;
|
||||
@@ -64,7 +64,7 @@ public class GrChangeInfoImpl implements JavaChangeInfo {
|
||||
private final String[] myOldParameterNames;
|
||||
private final String[] myOldParameterTypes;
|
||||
|
||||
public GrChangeInfoImpl(GrMethod method,
|
||||
public GrChangeInfoImpl(@NotNull GrMethod method,
|
||||
@Nullable String visibilityModifier,
|
||||
@Nullable CanonicalTypes.Type returnType,
|
||||
String newName,
|
||||
@@ -271,7 +271,7 @@ public class GrChangeInfoImpl implements JavaChangeInfo {
|
||||
}
|
||||
|
||||
@Override
|
||||
public GrMethod getMethod() {
|
||||
public @NotNull GrMethod getMethod() {
|
||||
return method;
|
||||
}
|
||||
|
||||
@@ -353,14 +353,14 @@ public class GrChangeInfoImpl implements JavaChangeInfo {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateMethod(PsiMethod psiMethod) {
|
||||
public void updateMethod(@NotNull PsiMethod psiMethod) {
|
||||
if (psiMethod instanceof GrMethod) {
|
||||
method = (GrMethod)psiMethod;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<PsiMethod> getMethodsToPropagateParameters() {
|
||||
public @NotNull Collection<PsiMethod> getMethodsToPropagateParameters() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
|
||||
+6
-4
@@ -18,6 +18,7 @@ package org.jetbrains.plugins.groovy.refactoring.changeSignature;
|
||||
import com.intellij.psi.PsiClass;
|
||||
import com.intellij.refactoring.changeSignature.MethodDescriptor;
|
||||
import com.intellij.util.VisibilityUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.params.GrParameter;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrMethod;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.types.GrTypeElement;
|
||||
@@ -31,7 +32,7 @@ import java.util.List;
|
||||
public class GrMethodDescriptor implements MethodDescriptor<GrParameterInfo, String> {
|
||||
private final GrMethod myMethod;
|
||||
|
||||
public GrMethodDescriptor(GrMethod method) {
|
||||
public GrMethodDescriptor(@NotNull GrMethod method) {
|
||||
myMethod = method;
|
||||
}
|
||||
|
||||
@@ -41,7 +42,7 @@ public class GrMethodDescriptor implements MethodDescriptor<GrParameterInfo, Str
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GrParameterInfo> getParameters() {
|
||||
public @NotNull List<GrParameterInfo> getParameters() {
|
||||
final ArrayList<GrParameterInfo> result = new ArrayList<>();
|
||||
final GrParameter[] parameters = myMethod.getParameters();
|
||||
for (int i = 0; i < parameters.length; i++) {
|
||||
@@ -58,11 +59,12 @@ public class GrMethodDescriptor implements MethodDescriptor<GrParameterInfo, Str
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getVisibility() {
|
||||
public @NotNull String getVisibility() {
|
||||
return VisibilityUtil.getVisibilityModifier(myMethod.getModifierList());
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public GrMethod getMethod() {
|
||||
return myMethod;
|
||||
}
|
||||
@@ -84,7 +86,7 @@ public class GrMethodDescriptor implements MethodDescriptor<GrParameterInfo, Str
|
||||
}
|
||||
|
||||
@Override
|
||||
public ReadWriteOption canChangeReturnType() {
|
||||
public @NotNull ReadWriteOption canChangeReturnType() {
|
||||
return myMethod.isConstructor() ? ReadWriteOption.None : ReadWriteOption.ReadWrite;
|
||||
}
|
||||
|
||||
|
||||
+3
-2
@@ -19,6 +19,7 @@ import com.intellij.refactoring.util.FixableUsageInfo;
|
||||
import com.intellij.usageView.UsageInfo;
|
||||
import com.intellij.util.VisibilityUtil;
|
||||
import com.intellij.util.containers.MultiMap;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElementFactory;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrArgumentList;
|
||||
@@ -49,7 +50,7 @@ public class GroovyIntroduceParameterObjectDelegate
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GrParameterInfo> getAllMethodParameters(GrMethod sourceMethod) {
|
||||
public List<GrParameterInfo> getAllMethodParameters(@NotNull GrMethod sourceMethod) {
|
||||
return new GrMethodDescriptor(sourceMethod).getParameters();
|
||||
}
|
||||
|
||||
@@ -95,7 +96,7 @@ public class GroovyIntroduceParameterObjectDelegate
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChangeInfo createChangeSignatureInfo(GrMethod method, List<GrParameterInfo> newParameterInfos, boolean delegate) {
|
||||
public ChangeInfo createChangeSignatureInfo(GrMethod method, List<? extends GrParameterInfo> newParameterInfos, boolean delegate) {
|
||||
final PsiType returnType = method.getReturnType();
|
||||
return new GrChangeInfoImpl(method,
|
||||
VisibilityUtil.getVisibilityModifier(method.getModifierList()),
|
||||
|
||||
@@ -208,7 +208,7 @@ public class PyChangeSignatureQuickFix extends LocalQuickFixOnPsiElement {
|
||||
private PyMethodDescriptor createMethodDescriptor(final PyFunction function) {
|
||||
return new PyMethodDescriptor(function) {
|
||||
@Override
|
||||
public List<PyParameterInfo> getParameters() {
|
||||
public @NotNull List<PyParameterInfo> getParameters() {
|
||||
final List<PyParameterInfo> result = new ArrayList<>();
|
||||
final List<PyParameterInfo> originalParams = super.getParameters();
|
||||
final PeekingIterator<Pair<Integer, PyParameterInfo>> extra = Iterators.peekingIterator(myExtraParameters.iterator());
|
||||
|
||||
@@ -21,6 +21,7 @@ import com.jetbrains.python.psi.PyExpression;
|
||||
import com.jetbrains.python.psi.PyFunction;
|
||||
import com.jetbrains.python.psi.PyNamedParameter;
|
||||
import com.jetbrains.python.psi.PyParameter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -32,7 +33,7 @@ import java.util.List;
|
||||
public class PyMethodDescriptor implements MethodDescriptor<PyParameterInfo, String> {
|
||||
private final PyFunction myFunction;
|
||||
|
||||
public PyMethodDescriptor(PyFunction function) {
|
||||
public PyMethodDescriptor(@NotNull PyFunction function) {
|
||||
myFunction = function;
|
||||
}
|
||||
|
||||
@@ -42,7 +43,7 @@ public class PyMethodDescriptor implements MethodDescriptor<PyParameterInfo, Str
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PyParameterInfo> getParameters() {
|
||||
public @NotNull List<PyParameterInfo> getParameters() {
|
||||
List<PyParameterInfo> parameterInfos = new ArrayList<>();
|
||||
PyParameter[] parameters = myFunction.getParameterList().getParameters();
|
||||
for (int i = 0; i < parameters.length; i++) {
|
||||
@@ -75,11 +76,12 @@ public class PyMethodDescriptor implements MethodDescriptor<PyParameterInfo, Str
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getVisibility() {
|
||||
public @NotNull String getVisibility() {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public PyFunction getMethod() {
|
||||
return myFunction;
|
||||
}
|
||||
@@ -100,7 +102,7 @@ public class PyMethodDescriptor implements MethodDescriptor<PyParameterInfo, Str
|
||||
}
|
||||
|
||||
@Override
|
||||
public ReadWriteOption canChangeReturnType() {
|
||||
public @NotNull ReadWriteOption canChangeReturnType() {
|
||||
return ReadWriteOption.None;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user