mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
fix spelling of occurrences in the Java refactoring implementation classes
This commit is contained in:
+4
-4
@@ -20,14 +20,14 @@ import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.refactoring.introduceParameter.AbstractJavaInplaceIntroducer;
|
||||
import com.intellij.refactoring.ui.TypeSelectorManagerImpl;
|
||||
import com.intellij.refactoring.util.occurences.OccurenceManager;
|
||||
import com.intellij.refactoring.util.occurrences.OccurrenceManager;
|
||||
|
||||
/**
|
||||
* User: anna
|
||||
*/
|
||||
public abstract class AbstractInplaceIntroduceFieldPopup extends AbstractJavaInplaceIntroducer {
|
||||
protected final PsiClass myParentClass;
|
||||
protected final OccurenceManager myOccurenceManager;
|
||||
protected final OccurrenceManager myOccurrenceManager;
|
||||
|
||||
private SmartPsiElementPointer<PsiElement> myAnchorElement;
|
||||
private int myAnchorIdx = -1;
|
||||
@@ -45,11 +45,11 @@ public abstract class AbstractInplaceIntroduceFieldPopup extends AbstractJavaInp
|
||||
String title,
|
||||
PsiClass parentClass,
|
||||
final PsiElement anchorElement,
|
||||
final OccurenceManager occurenceManager,
|
||||
final OccurrenceManager occurrenceManager,
|
||||
final PsiElement anchorElementIfAll) {
|
||||
super(project, editor, expr, localVariable, occurrences, typeSelectorManager, title);
|
||||
myParentClass = parentClass;
|
||||
myOccurenceManager = occurenceManager;
|
||||
myOccurrenceManager = occurrenceManager;
|
||||
mySmartPointerManager = SmartPointerManager.getInstance(project);
|
||||
myAnchorElement = anchorElement != null ? mySmartPointerManager.createSmartPsiElementPointer(anchorElement) : null;
|
||||
myAnchorElementIfAll = anchorElementIfAll != null ? mySmartPointerManager.createSmartPsiElementPointer(anchorElementIfAll) : null;
|
||||
|
||||
+12
-12
@@ -64,7 +64,7 @@ import com.intellij.refactoring.rename.RenameJavaVariableProcessor;
|
||||
import com.intellij.refactoring.util.CommonRefactoringUtil;
|
||||
import com.intellij.refactoring.util.EnumConstantsUtil;
|
||||
import com.intellij.refactoring.util.RefactoringUtil;
|
||||
import com.intellij.refactoring.util.occurences.OccurenceManager;
|
||||
import com.intellij.refactoring.util.occurrences.OccurrenceManager;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import com.intellij.util.VisibilityUtil;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
@@ -172,9 +172,9 @@ public abstract class BaseExpressionToFieldHandler extends IntroduceHandlerBase
|
||||
|
||||
if (!CommonRefactoringUtil.checkReadOnlyStatus(project, file)) return true;
|
||||
|
||||
final OccurenceManager occurenceManager = createOccurenceManager(selectedExpr, myParentClass);
|
||||
final PsiExpression[] occurrences = occurenceManager.getOccurences();
|
||||
final PsiElement anchorStatementIfAll = occurenceManager.getAnchorStatementForAll();
|
||||
final OccurrenceManager occurrenceManager = createOccurenceManager(selectedExpr, myParentClass);
|
||||
final PsiExpression[] occurrences = occurrenceManager.getOccurrences();
|
||||
final PsiElement anchorStatementIfAll = occurrenceManager.getAnchorStatementForAll();
|
||||
|
||||
List<RangeHighlighter> highlighters = null;
|
||||
if (editor != null) {
|
||||
@@ -206,7 +206,7 @@ public abstract class BaseExpressionToFieldHandler extends IntroduceHandlerBase
|
||||
|
||||
|
||||
final Runnable runnable =
|
||||
new ConvertToFieldRunnable(settings.getSelectedExpr(), settings, type, settings.getOccurrences(), occurenceManager,
|
||||
new ConvertToFieldRunnable(settings.getSelectedExpr(), settings, type, settings.getOccurrences(), occurrenceManager,
|
||||
anchorStatementIfAll, tempAnchorElement, editor,
|
||||
myParentClass);
|
||||
|
||||
@@ -250,7 +250,7 @@ public abstract class BaseExpressionToFieldHandler extends IntroduceHandlerBase
|
||||
);
|
||||
}
|
||||
|
||||
protected abstract OccurenceManager createOccurenceManager(PsiExpression selectedExpr, PsiClass parentClass);
|
||||
protected abstract OccurrenceManager createOccurenceManager(PsiExpression selectedExpr, PsiClass parentClass);
|
||||
|
||||
protected final PsiClass getParentClass() {
|
||||
return myParentClass;
|
||||
@@ -316,7 +316,7 @@ public abstract class BaseExpressionToFieldHandler extends IntroduceHandlerBase
|
||||
|
||||
private static void addInitializationToSetUp(final PsiExpression initializer,
|
||||
final PsiField field,
|
||||
final OccurenceManager occurenceManager,
|
||||
final OccurrenceManager occurrenceManager,
|
||||
final boolean replaceAll,
|
||||
final PsiClass parentClass) throws IncorrectOperationException {
|
||||
final PsiMethod setupMethod = TestUtil.findOrCreateSetUpMethod(parentClass);
|
||||
@@ -326,7 +326,7 @@ public abstract class BaseExpressionToFieldHandler extends IntroduceHandlerBase
|
||||
PsiElement anchor = null;
|
||||
if (PsiTreeUtil.isAncestor(setupMethod, initializer, true)) {
|
||||
anchor = replaceAll
|
||||
? occurenceManager.getAnchorStatementForAllInScope(setupMethod)
|
||||
? occurrenceManager.getAnchorStatementForAllInScope(setupMethod)
|
||||
: PsiTreeUtil.getParentOfType(initializer, PsiStatement.class);
|
||||
}
|
||||
|
||||
@@ -640,7 +640,7 @@ public abstract class BaseExpressionToFieldHandler extends IntroduceHandlerBase
|
||||
private final PsiType myType;
|
||||
private final PsiExpression[] myOccurrences;
|
||||
private final boolean myReplaceAll;
|
||||
private final OccurenceManager myOccurenceManager;
|
||||
private final OccurrenceManager myOccurrenceManager;
|
||||
private final PsiElement myAnchorStatementIfAll;
|
||||
private final PsiElement myAnchorElementIfOne;
|
||||
private final Boolean myOutOfCodeBlockExtraction;
|
||||
@@ -655,7 +655,7 @@ public abstract class BaseExpressionToFieldHandler extends IntroduceHandlerBase
|
||||
Settings settings,
|
||||
PsiType type,
|
||||
PsiExpression[] occurrences,
|
||||
OccurenceManager occurenceManager,
|
||||
OccurrenceManager occurrenceManager,
|
||||
PsiElement anchorStatementIfAll,
|
||||
PsiElement anchorElementIfOne,
|
||||
Editor editor,
|
||||
@@ -668,7 +668,7 @@ public abstract class BaseExpressionToFieldHandler extends IntroduceHandlerBase
|
||||
myType = type;
|
||||
myOccurrences = occurrences;
|
||||
myReplaceAll = settings.isReplaceAll();
|
||||
myOccurenceManager = occurenceManager;
|
||||
myOccurrenceManager = occurrenceManager;
|
||||
myAnchorStatementIfAll = anchorStatementIfAll;
|
||||
myAnchorElementIfOne = anchorElementIfOne;
|
||||
myOutOfCodeBlockExtraction = selectedExpr.getUserData(ElementToWorkOn.OUT_OF_CODE_BLOCK);
|
||||
@@ -743,7 +743,7 @@ public abstract class BaseExpressionToFieldHandler extends IntroduceHandlerBase
|
||||
addInitializationToConstructors(initializer, myField, enclosingConstructor, myParentClass);
|
||||
}
|
||||
if (initializerPlace == InitializationPlace.IN_SETUP_METHOD && initializer != null) {
|
||||
addInitializationToSetUp(initializer, myField, myOccurenceManager, myReplaceAll, myParentClass);
|
||||
addInitializationToSetUp(initializer, myField, myOccurrenceManager, myReplaceAll, myParentClass);
|
||||
}
|
||||
if (mySelectedExpr.getParent() instanceof PsiParenthesizedExpression) {
|
||||
mySelectedExpr = (PsiExpression)mySelectedExpr.getParent();
|
||||
|
||||
+4
-4
@@ -28,7 +28,7 @@ import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
import com.intellij.refactoring.JavaRefactoringSettings;
|
||||
import com.intellij.refactoring.ui.TypeSelectorManagerImpl;
|
||||
import com.intellij.refactoring.util.occurences.OccurenceManager;
|
||||
import com.intellij.refactoring.util.occurrences.OccurrenceManager;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
@@ -57,9 +57,9 @@ public class InplaceIntroduceConstantPopup extends AbstractInplaceIntroduceField
|
||||
PsiExpression[] occurrences,
|
||||
TypeSelectorManagerImpl typeSelectorManager,
|
||||
PsiElement anchorElement,
|
||||
PsiElement anchorElementIfAll, OccurenceManager occurenceManager) {
|
||||
PsiElement anchorElementIfAll, OccurrenceManager occurrenceManager) {
|
||||
super(project, editor, expr, localVariable, occurrences, typeSelectorManager, IntroduceConstantHandler.REFACTORING_NAME,
|
||||
parentClass, anchorElement, occurenceManager, anchorElementIfAll);
|
||||
parentClass, anchorElement, occurrenceManager, anchorElementIfAll);
|
||||
|
||||
myInitializerText = getExprText(expr, localVariable);
|
||||
|
||||
@@ -239,7 +239,7 @@ public class InplaceIntroduceConstantPopup extends AbstractInplaceIntroduceField
|
||||
else {
|
||||
final BaseExpressionToFieldHandler.ConvertToFieldRunnable convertToFieldRunnable =
|
||||
new BaseExpressionToFieldHandler.ConvertToFieldRunnable(myExpr, settings, settings.getForcedType(),
|
||||
myOccurrences, myOccurenceManager,
|
||||
myOccurrences, myOccurrenceManager,
|
||||
getAnchorElementIfAll(), getAnchorElement(), myEditor, myParentClass);
|
||||
convertToFieldRunnable.run();
|
||||
}
|
||||
|
||||
+4
-9
@@ -27,17 +27,12 @@ import com.intellij.psi.util.PsiExpressionTrimRenderer;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
import com.intellij.refactoring.JavaRefactoringSettings;
|
||||
import com.intellij.refactoring.introduceParameter.AbstractJavaInplaceIntroducer;
|
||||
import com.intellij.refactoring.ui.TypeSelectorManagerImpl;
|
||||
import com.intellij.refactoring.util.occurences.OccurenceManager;
|
||||
import com.intellij.ui.SimpleTextAttributes;
|
||||
import com.intellij.refactoring.util.occurrences.OccurrenceManager;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.annotations.TestOnly;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.ItemEvent;
|
||||
import java.awt.event.ItemListener;
|
||||
|
||||
@@ -63,9 +58,9 @@ public class InplaceIntroduceFieldPopup extends AbstractInplaceIntroduceFieldPop
|
||||
final boolean allowInitInMethod,
|
||||
boolean allowInitInMethodIfAll, final PsiElement anchorElement,
|
||||
final PsiElement anchorElementIfAll,
|
||||
final OccurenceManager occurenceManager, Project project) {
|
||||
final OccurrenceManager occurrenceManager, Project project) {
|
||||
super(project, editor, initializerExpression, localVariable, occurrences, typeSelectorManager,
|
||||
IntroduceFieldHandler.REFACTORING_NAME, parentClass, anchorElement, occurenceManager, anchorElementIfAll);
|
||||
IntroduceFieldHandler.REFACTORING_NAME, parentClass, anchorElement, occurrenceManager, anchorElementIfAll);
|
||||
myStatic = aStatic;
|
||||
myIntroduceFieldPanel =
|
||||
new IntroduceFieldPopupPanel(parentClass, initializerExpression, localVariable, currentMethodConstructor, localVariable != null, aStatic,
|
||||
@@ -230,7 +225,7 @@ public class InplaceIntroduceFieldPopup extends AbstractInplaceIntroduceFieldPop
|
||||
else {
|
||||
final BaseExpressionToFieldHandler.ConvertToFieldRunnable convertToFieldRunnable =
|
||||
new BaseExpressionToFieldHandler.ConvertToFieldRunnable(myExpr, settings, settings.getForcedType(),
|
||||
myOccurrences, myOccurenceManager,
|
||||
myOccurrences, myOccurrenceManager,
|
||||
getAnchorElementIfAll(),
|
||||
getAnchorElement(), myEditor,
|
||||
myParentClass);
|
||||
|
||||
+4
-4
@@ -36,8 +36,8 @@ import com.intellij.refactoring.ui.TypeSelectorManagerImpl;
|
||||
import com.intellij.refactoring.util.CommonRefactoringUtil;
|
||||
import com.intellij.refactoring.util.RefactoringUtil;
|
||||
import com.intellij.refactoring.util.classMembers.ClassMemberReferencesVisitor;
|
||||
import com.intellij.refactoring.util.occurences.ExpressionOccurenceManager;
|
||||
import com.intellij.refactoring.util.occurences.OccurenceManager;
|
||||
import com.intellij.refactoring.util.occurrences.ExpressionOccurrenceManager;
|
||||
import com.intellij.refactoring.util.occurrences.OccurrenceManager;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -216,8 +216,8 @@ public class IntroduceConstantHandler extends BaseExpressionToFieldHandler {
|
||||
return visitor.getElementReference();
|
||||
}
|
||||
|
||||
protected OccurenceManager createOccurenceManager(final PsiExpression selectedExpr, final PsiClass parentClass) {
|
||||
return new ExpressionOccurenceManager(selectedExpr, parentClass, null);
|
||||
protected OccurrenceManager createOccurenceManager(final PsiExpression selectedExpr, final PsiClass parentClass) {
|
||||
return new ExpressionOccurrenceManager(selectedExpr, parentClass, null);
|
||||
}
|
||||
|
||||
private static class IsStaticFinalInitializerExpression extends ClassMemberReferencesVisitor {
|
||||
|
||||
+9
-10
@@ -25,16 +25,15 @@ import com.intellij.psi.util.PsiUtil;
|
||||
import com.intellij.refactoring.HelpID;
|
||||
import com.intellij.refactoring.RefactoringBundle;
|
||||
import com.intellij.refactoring.introduce.inplace.AbstractInplaceIntroducer;
|
||||
import com.intellij.refactoring.introduceParameter.AbstractJavaInplaceIntroducer;
|
||||
import com.intellij.refactoring.ui.TypeSelectorManagerImpl;
|
||||
import com.intellij.refactoring.util.CommonRefactoringUtil;
|
||||
import com.intellij.refactoring.util.occurences.*;
|
||||
import com.intellij.refactoring.util.occurrences.*;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class IntroduceFieldHandler extends BaseExpressionToFieldHandler {
|
||||
|
||||
public static final String REFACTORING_NAME = RefactoringBundle.message("introduce.field.title");
|
||||
private static final MyOccurenceFilter MY_OCCURENCE_FILTER = new MyOccurenceFilter();
|
||||
private static final MyOccurrenceFilter MY_OCCURENCE_FILTER = new MyOccurrenceFilter();
|
||||
private InplaceIntroduceFieldPopup myInplaceIntroduceFieldPopup;
|
||||
|
||||
public IntroduceFieldHandler() {
|
||||
@@ -164,12 +163,12 @@ public class IntroduceFieldHandler extends BaseExpressionToFieldHandler {
|
||||
}
|
||||
|
||||
private static boolean isInSuperOrThis(PsiExpression occurence) {
|
||||
return !NotInSuperCallOccurenceFilter.INSTANCE.isOK(occurence) || !NotInThisCallFilter.INSTANCE.isOK(occurence);
|
||||
return !NotInSuperCallOccurrenceFilter.INSTANCE.isOK(occurence) || !NotInThisCallFilter.INSTANCE.isOK(occurence);
|
||||
}
|
||||
|
||||
protected OccurenceManager createOccurenceManager(final PsiExpression selectedExpr, final PsiClass parentClass) {
|
||||
final OccurenceFilter occurenceFilter = isInSuperOrThis(selectedExpr) ? null : MY_OCCURENCE_FILTER;
|
||||
return new ExpressionOccurenceManager(selectedExpr, parentClass, occurenceFilter, true);
|
||||
protected OccurrenceManager createOccurenceManager(final PsiExpression selectedExpr, final PsiClass parentClass) {
|
||||
final OccurrenceFilter occurrenceFilter = isInSuperOrThis(selectedExpr) ? null : MY_OCCURENCE_FILTER;
|
||||
return new ExpressionOccurrenceManager(selectedExpr, parentClass, occurrenceFilter, true);
|
||||
}
|
||||
|
||||
protected boolean invokeImpl(final Project project, PsiLocalVariable localVariable, final Editor editor) {
|
||||
@@ -192,9 +191,9 @@ public class IntroduceFieldHandler extends BaseExpressionToFieldHandler {
|
||||
return localToFieldHandler.convertLocalToField(localVariable, editor);
|
||||
}
|
||||
|
||||
private static class MyOccurenceFilter implements OccurenceFilter {
|
||||
public boolean isOK(PsiExpression occurence) {
|
||||
return !isInSuperOrThis(occurence);
|
||||
private static class MyOccurrenceFilter implements OccurrenceFilter {
|
||||
public boolean isOK(PsiExpression occurrence) {
|
||||
return !isInSuperOrThis(occurrence);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -56,7 +56,7 @@ import com.intellij.refactoring.ui.NameSuggestionsGenerator;
|
||||
import com.intellij.refactoring.ui.TypeSelectorManagerImpl;
|
||||
import com.intellij.refactoring.util.CommonRefactoringUtil;
|
||||
import com.intellij.refactoring.util.RefactoringUtil;
|
||||
import com.intellij.refactoring.util.occurences.ExpressionOccurenceManager;
|
||||
import com.intellij.refactoring.util.occurrences.ExpressionOccurrenceManager;
|
||||
import com.intellij.ui.ScrollPaneFactory;
|
||||
import com.intellij.ui.components.JBList;
|
||||
import com.intellij.usageView.UsageInfo;
|
||||
@@ -372,7 +372,7 @@ public class IntroduceParameterHandler extends IntroduceHandlerBase implements R
|
||||
|
||||
PsiExpression[] occurences;
|
||||
if (myExpr != null) {
|
||||
occurences = new ExpressionOccurenceManager(myExpr, method, null).findExpressionOccurrences();
|
||||
occurences = new ExpressionOccurrenceManager(myExpr, method, null).findExpressionOccurrences();
|
||||
}
|
||||
else { // local variable
|
||||
occurences = CodeInsightUtil.findReferenceExpressions(method, myLocalVar);
|
||||
|
||||
+7
-7
@@ -41,9 +41,9 @@ import com.intellij.refactoring.RefactoringBundle;
|
||||
import com.intellij.refactoring.changeSignature.ChangeSignatureProcessor;
|
||||
import com.intellij.refactoring.introduceVariable.IntroduceVariableBase;
|
||||
import com.intellij.refactoring.util.*;
|
||||
import com.intellij.refactoring.util.occurences.ExpressionOccurenceManager;
|
||||
import com.intellij.refactoring.util.occurences.LocalVariableOccurenceManager;
|
||||
import com.intellij.refactoring.util.occurences.OccurenceManager;
|
||||
import com.intellij.refactoring.util.occurrences.ExpressionOccurrenceManager;
|
||||
import com.intellij.refactoring.util.occurrences.LocalVariableOccurrenceManager;
|
||||
import com.intellij.refactoring.util.occurrences.OccurrenceManager;
|
||||
import com.intellij.refactoring.util.usageInfo.DefaultConstructorImplicitUsageInfo;
|
||||
import com.intellij.refactoring.util.usageInfo.NoConstructorClassUsageInfo;
|
||||
import com.intellij.usageView.UsageInfo;
|
||||
@@ -190,14 +190,14 @@ public class IntroduceParameterProcessor extends BaseRefactoringProcessor implem
|
||||
}
|
||||
|
||||
protected PsiElement[] getOccurrences() {
|
||||
final OccurenceManager occurenceManager;
|
||||
final OccurrenceManager occurrenceManager;
|
||||
if (myLocalVariable == null) {
|
||||
occurenceManager = new ExpressionOccurenceManager(myExpressionToSearch, myMethodToReplaceIn, null);
|
||||
occurrenceManager = new ExpressionOccurrenceManager(myExpressionToSearch, myMethodToReplaceIn, null);
|
||||
}
|
||||
else {
|
||||
occurenceManager = new LocalVariableOccurenceManager(myLocalVariable, null);
|
||||
occurrenceManager = new LocalVariableOccurrenceManager(myLocalVariable, null);
|
||||
}
|
||||
return occurenceManager.getOccurences();
|
||||
return occurrenceManager.getOccurrences();
|
||||
}
|
||||
|
||||
public boolean hasConflicts() {
|
||||
|
||||
@@ -22,7 +22,7 @@ import com.intellij.psi.PsiVariable;
|
||||
import com.intellij.refactoring.RefactoringBundle;
|
||||
import com.intellij.refactoring.rename.JavaUnresolvableLocalCollisionDetector;
|
||||
import com.intellij.refactoring.util.RefactoringUIUtil;
|
||||
import com.intellij.refactoring.util.occurences.ExpressionOccurenceManager;
|
||||
import com.intellij.refactoring.util.occurrences.ExpressionOccurrenceManager;
|
||||
import com.intellij.util.containers.HashSet;
|
||||
import com.intellij.util.containers.MultiMap;
|
||||
|
||||
@@ -30,7 +30,7 @@ public class InputValidator implements IntroduceVariableBase.Validator {
|
||||
private final Project myProject;
|
||||
private final PsiElement myAnchorStatementIfAll;
|
||||
private final PsiElement myAnchorStatement;
|
||||
private final ExpressionOccurenceManager myOccurenceManager;
|
||||
private final ExpressionOccurrenceManager myOccurenceManager;
|
||||
private final IntroduceVariableBase myIntroduceVariableBase;
|
||||
|
||||
public boolean isOK(IntroduceVariableSettings settings) {
|
||||
@@ -57,7 +57,7 @@ public class InputValidator implements IntroduceVariableBase.Validator {
|
||||
};
|
||||
JavaUnresolvableLocalCollisionDetector.visitLocalsCollisions(anchor, name, scope, anchor, visitor);
|
||||
if (replaceAllOccurrences) {
|
||||
final PsiExpression[] occurences = myOccurenceManager.getOccurences();
|
||||
final PsiExpression[] occurences = myOccurenceManager.getOccurrences();
|
||||
for (PsiExpression occurence : occurences) {
|
||||
IntroduceVariableBase.checkInLoopCondition(occurence, conflicts);
|
||||
}
|
||||
@@ -77,7 +77,7 @@ public class InputValidator implements IntroduceVariableBase.Validator {
|
||||
Project project,
|
||||
PsiElement anchorStatementIfAll,
|
||||
PsiElement anchorStatement,
|
||||
ExpressionOccurenceManager occurenceManager) {
|
||||
ExpressionOccurrenceManager occurenceManager) {
|
||||
myIntroduceVariableBase = introduceVariableBase;
|
||||
myProject = project;
|
||||
myAnchorStatementIfAll = anchorStatementIfAll;
|
||||
|
||||
+6
-6
@@ -59,8 +59,8 @@ import com.intellij.refactoring.util.CommonRefactoringUtil;
|
||||
import com.intellij.refactoring.util.FieldConflictsResolver;
|
||||
import com.intellij.refactoring.util.RefactoringUIUtil;
|
||||
import com.intellij.refactoring.util.RefactoringUtil;
|
||||
import com.intellij.refactoring.util.occurences.ExpressionOccurenceManager;
|
||||
import com.intellij.refactoring.util.occurences.NotInSuperCallOccurenceFilter;
|
||||
import com.intellij.refactoring.util.occurrences.ExpressionOccurrenceManager;
|
||||
import com.intellij.refactoring.util.occurrences.NotInSuperCallOccurrenceFilter;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import com.intellij.util.containers.MultiMap;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
@@ -486,7 +486,7 @@ public abstract class IntroduceVariableBase extends IntroduceHandlerBase impleme
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!NotInSuperCallOccurenceFilter.INSTANCE.isOK(expr)) {
|
||||
if(!NotInSuperCallOccurrenceFilter.INSTANCE.isOK(expr)) {
|
||||
String message = RefactoringBundle.getCannotRefactorMessage(RefactoringBundle.message("cannot.introduce.variable.in.super.constructor.call"));
|
||||
showErrorMessage(project, editor, message);
|
||||
return false;
|
||||
@@ -508,9 +508,9 @@ public abstract class IntroduceVariableBase extends IntroduceHandlerBase impleme
|
||||
}
|
||||
}
|
||||
|
||||
final ExpressionOccurenceManager occurenceManager = new ExpressionOccurenceManager(expr, lastScope,
|
||||
NotInSuperCallOccurenceFilter.INSTANCE);
|
||||
final PsiExpression[] occurrences = occurenceManager.getOccurences();
|
||||
final ExpressionOccurrenceManager occurenceManager = new ExpressionOccurrenceManager(expr, lastScope,
|
||||
NotInSuperCallOccurrenceFilter.INSTANCE);
|
||||
final PsiExpression[] occurrences = occurenceManager.getOccurrences();
|
||||
final PsiElement anchorStatementIfAll = occurenceManager.getAnchorStatementForAll();
|
||||
|
||||
final LinkedHashMap<OccurrencesChooser.ReplaceChoice, List<PsiExpression>> occurrencesMap = Maps.newLinkedHashMap();
|
||||
|
||||
+18
-18
@@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.refactoring.util.occurences;
|
||||
package com.intellij.refactoring.util.occurrences;
|
||||
|
||||
import com.intellij.psi.PsiClass;
|
||||
import com.intellij.psi.PsiElement;
|
||||
@@ -27,45 +27,45 @@ import java.util.ArrayList;
|
||||
/**
|
||||
* @author dsl
|
||||
*/
|
||||
public abstract class BaseOccurenceManager implements OccurenceManager {
|
||||
private PsiExpression[] myOccurences = null;
|
||||
public abstract class BaseOccurrenceManager implements OccurrenceManager {
|
||||
private PsiExpression[] myOccurrences = null;
|
||||
private PsiElement myAnchorStatement = null;
|
||||
protected final OccurenceFilter myFilter;
|
||||
protected final OccurrenceFilter myFilter;
|
||||
|
||||
public BaseOccurenceManager(OccurenceFilter filter) {
|
||||
public BaseOccurrenceManager(OccurrenceFilter filter) {
|
||||
myFilter = filter;
|
||||
}
|
||||
|
||||
public PsiExpression[] getOccurences() {
|
||||
if(myOccurences == null) {
|
||||
myOccurences = findOccurences();
|
||||
public PsiExpression[] getOccurrences() {
|
||||
if(myOccurrences == null) {
|
||||
myOccurrences = findOccurrences();
|
||||
|
||||
if(myFilter != null) {
|
||||
ArrayList<PsiExpression> result = new ArrayList<PsiExpression>();
|
||||
for (PsiExpression occurence : myOccurences) {
|
||||
if (myFilter.isOK(occurence)) result.add(occurence);
|
||||
for (PsiExpression occurrence : myOccurrences) {
|
||||
if (myFilter.isOK(occurrence)) result.add(occurrence);
|
||||
}
|
||||
if (result.isEmpty()) {
|
||||
myOccurences = defaultOccurences();
|
||||
myOccurrences = defaultOccurrences();
|
||||
}
|
||||
else {
|
||||
myOccurences = result.toArray(new PsiExpression[result.size()]);
|
||||
myOccurrences = result.toArray(new PsiExpression[result.size()]);
|
||||
}
|
||||
}
|
||||
|
||||
if (getAnchorStatementForAll() == null) {
|
||||
myOccurences = defaultOccurences();
|
||||
myOccurrences = defaultOccurrences();
|
||||
}
|
||||
}
|
||||
return myOccurences;
|
||||
return myOccurrences;
|
||||
}
|
||||
|
||||
protected abstract PsiExpression[] defaultOccurences();
|
||||
protected abstract PsiExpression[] defaultOccurrences();
|
||||
|
||||
protected abstract PsiExpression[] findOccurences();
|
||||
protected abstract PsiExpression[] findOccurrences();
|
||||
|
||||
public boolean isInFinalContext() {
|
||||
return needToDeclareFinal(myOccurences);
|
||||
return needToDeclareFinal(myOccurrences);
|
||||
}
|
||||
|
||||
public PsiElement getAnchorStatementForAll() {
|
||||
@@ -76,7 +76,7 @@ public abstract class BaseOccurenceManager implements OccurenceManager {
|
||||
|
||||
}
|
||||
public PsiElement getAnchorStatementForAllInScope(PsiElement scope) {
|
||||
return RefactoringUtil.getAnchorElementForMultipleExpressions(myOccurences, scope);
|
||||
return RefactoringUtil.getAnchorElementForMultipleExpressions(myOccurrences, scope);
|
||||
}
|
||||
|
||||
private static boolean needToDeclareFinal(PsiExpression[] occurrences) {
|
||||
+8
-8
@@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.refactoring.util.occurences;
|
||||
package com.intellij.refactoring.util.occurrences;
|
||||
|
||||
import com.intellij.codeInsight.CodeInsightUtil;
|
||||
import com.intellij.find.FindManager;
|
||||
@@ -30,22 +30,22 @@ import java.util.*;
|
||||
/**
|
||||
* @author dsl
|
||||
*/
|
||||
public class ExpressionOccurenceManager extends BaseOccurenceManager {
|
||||
public class ExpressionOccurrenceManager extends BaseOccurrenceManager {
|
||||
private PsiExpression myMainOccurence;
|
||||
private final PsiElement myScope;
|
||||
private final boolean myMaintainStaticContext;
|
||||
|
||||
public ExpressionOccurenceManager(PsiExpression mainOccurence, PsiElement scope, OccurenceFilter filter) {
|
||||
public ExpressionOccurrenceManager(PsiExpression mainOccurence, PsiElement scope, OccurrenceFilter filter) {
|
||||
this(mainOccurence, scope, filter, false);
|
||||
}
|
||||
|
||||
public ExpressionOccurenceManager(PsiExpression mainOccurence, PsiElement scope, OccurenceFilter filter, boolean maintainStaticContext) {
|
||||
public ExpressionOccurrenceManager(PsiExpression mainOccurence, PsiElement scope, OccurrenceFilter filter, boolean maintainStaticContext) {
|
||||
super(filter);
|
||||
myMainOccurence = mainOccurence;
|
||||
myScope = scope;
|
||||
myMaintainStaticContext = maintainStaticContext;
|
||||
}
|
||||
protected PsiExpression[] defaultOccurences() {
|
||||
protected PsiExpression[] defaultOccurrences() {
|
||||
return new PsiExpression[]{myMainOccurence};
|
||||
}
|
||||
|
||||
@@ -53,12 +53,12 @@ public class ExpressionOccurenceManager extends BaseOccurenceManager {
|
||||
return myMainOccurence;
|
||||
}
|
||||
|
||||
protected PsiExpression[] findOccurences() {
|
||||
protected PsiExpression[] findOccurrences() {
|
||||
if("null".equals(myMainOccurence.getText())) {
|
||||
return defaultOccurences();
|
||||
return defaultOccurrences();
|
||||
}
|
||||
if(myFilter != null && !myFilter.isOK(myMainOccurence)) {
|
||||
return defaultOccurences();
|
||||
return defaultOccurrences();
|
||||
}
|
||||
final PsiExpression[] expressionOccurrences = findExpressionOccurrences();
|
||||
final PsiClass scopeClass = PsiTreeUtil.getNonStrictParentOfType(myScope, PsiClass.class);
|
||||
+5
-5
@@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.refactoring.util.occurences;
|
||||
package com.intellij.refactoring.util.occurrences;
|
||||
|
||||
import com.intellij.codeInsight.CodeInsightUtil;
|
||||
import com.intellij.psi.PsiExpression;
|
||||
@@ -23,19 +23,19 @@ import com.intellij.refactoring.util.RefactoringUtil;
|
||||
/**
|
||||
* @author dsl
|
||||
*/
|
||||
public class LocalVariableOccurenceManager extends BaseOccurenceManager {
|
||||
public class LocalVariableOccurrenceManager extends BaseOccurrenceManager {
|
||||
private final PsiLocalVariable myLocalVariable;
|
||||
|
||||
public LocalVariableOccurenceManager(PsiLocalVariable localVariable, OccurenceFilter filter) {
|
||||
public LocalVariableOccurrenceManager(PsiLocalVariable localVariable, OccurrenceFilter filter) {
|
||||
super(filter);
|
||||
myLocalVariable = localVariable;
|
||||
}
|
||||
|
||||
public PsiExpression[] defaultOccurences() {
|
||||
public PsiExpression[] defaultOccurrences() {
|
||||
return PsiExpression.EMPTY_ARRAY;
|
||||
}
|
||||
|
||||
public PsiExpression[] findOccurences() {
|
||||
public PsiExpression[] findOccurrences() {
|
||||
return CodeInsightUtil.findReferenceExpressions(RefactoringUtil.getVariableScope(myLocalVariable), myLocalVariable);
|
||||
}
|
||||
|
||||
+3
-3
@@ -13,15 +13,15 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.refactoring.util.occurences;
|
||||
package com.intellij.refactoring.util.occurrences;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @author dsl
|
||||
*/
|
||||
public class NotInSuperCallOccurenceFilter extends NotInSuperOrThisCallFilterBase {
|
||||
public static final OccurenceFilter INSTANCE = new NotInSuperCallOccurenceFilter();
|
||||
public class NotInSuperCallOccurrenceFilter extends NotInSuperOrThisCallFilterBase {
|
||||
public static final OccurrenceFilter INSTANCE = new NotInSuperCallOccurrenceFilter();
|
||||
|
||||
protected String getKeywordText() {
|
||||
return "super";
|
||||
+4
-4
@@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.refactoring.util.occurences;
|
||||
package com.intellij.refactoring.util.occurrences;
|
||||
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiExpression;
|
||||
@@ -24,9 +24,9 @@ import org.jetbrains.annotations.NonNls;
|
||||
/**
|
||||
* @author dsl
|
||||
*/
|
||||
public abstract class NotInSuperOrThisCallFilterBase implements OccurenceFilter {
|
||||
public boolean isOK(PsiExpression occurence) {
|
||||
PsiElement parent = occurence.getParent();
|
||||
public abstract class NotInSuperOrThisCallFilterBase implements OccurrenceFilter {
|
||||
public boolean isOK(PsiExpression occurrence) {
|
||||
PsiElement parent = occurrence.getParent();
|
||||
while(parent instanceof PsiExpression) {
|
||||
parent = parent.getParent();
|
||||
}
|
||||
+1
-1
@@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.refactoring.util.occurences;
|
||||
package com.intellij.refactoring.util.occurrences;
|
||||
|
||||
/**
|
||||
* @author dsl
|
||||
+3
-3
@@ -13,10 +13,10 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.refactoring.util.occurences;
|
||||
package com.intellij.refactoring.util.occurrences;
|
||||
|
||||
import com.intellij.psi.*;
|
||||
|
||||
public interface OccurenceFilter {
|
||||
boolean isOK(PsiExpression occurence);
|
||||
public interface OccurrenceFilter {
|
||||
boolean isOK(PsiExpression occurrence);
|
||||
}
|
||||
+3
-3
@@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.refactoring.util.occurences;
|
||||
package com.intellij.refactoring.util.occurrences;
|
||||
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiExpression;
|
||||
@@ -21,8 +21,8 @@ import com.intellij.psi.PsiExpression;
|
||||
/**
|
||||
* @author dsl
|
||||
*/
|
||||
public interface OccurenceManager {
|
||||
PsiExpression[] getOccurences();
|
||||
public interface OccurrenceManager {
|
||||
PsiExpression[] getOccurrences();
|
||||
boolean isInFinalContext();
|
||||
PsiElement getAnchorStatementForAll();
|
||||
|
||||
@@ -16,12 +16,11 @@ import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiExpression;
|
||||
import com.intellij.psi.PsiLocalVariable;
|
||||
import com.intellij.psi.PsiMethod;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.refactoring.introduceField.ElementToWorkOn;
|
||||
import com.intellij.refactoring.introduceParameter.IntroduceParameterHandler;
|
||||
import com.intellij.refactoring.introduceParameter.IntroduceParameterProcessor;
|
||||
import com.intellij.refactoring.introduceParameter.Util;
|
||||
import com.intellij.refactoring.util.occurences.ExpressionOccurenceManager;
|
||||
import com.intellij.refactoring.util.occurrences.ExpressionOccurrenceManager;
|
||||
import com.intellij.testFramework.LightCodeInsightTestCase;
|
||||
import com.intellij.testFramework.TestDataPath;
|
||||
import gnu.trove.TIntArrayList;
|
||||
@@ -360,7 +359,7 @@ public class IntroduceParameterTest extends LightCodeInsightTestCase {
|
||||
}
|
||||
else {
|
||||
initializer = expr;
|
||||
occurences = new ExpressionOccurenceManager(expr, method, null).findExpressionOccurrences();
|
||||
occurences = new ExpressionOccurrenceManager(expr, method, null).findExpressionOccurrences();
|
||||
}
|
||||
TIntArrayList parametersToRemove = removeUnusedParameters ? Util.findParametersToRemove(method, initializer, occurences) : new TIntArrayList();
|
||||
new IntroduceParameterProcessor(
|
||||
|
||||
+9
-9
@@ -35,9 +35,9 @@ import com.intellij.psi.util.PsiFormatUtil;
|
||||
import com.intellij.psi.util.PsiFormatUtilBase;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.refactoring.introduceField.IntroduceConstantHandler;
|
||||
import com.intellij.refactoring.util.occurences.BaseOccurenceManager;
|
||||
import com.intellij.refactoring.util.occurences.OccurenceFilter;
|
||||
import com.intellij.refactoring.util.occurences.OccurenceManager;
|
||||
import com.intellij.refactoring.util.occurrences.BaseOccurrenceManager;
|
||||
import com.intellij.refactoring.util.occurrences.OccurrenceFilter;
|
||||
import com.intellij.refactoring.util.occurrences.OccurrenceManager;
|
||||
import com.intellij.ui.DocumentAdapter;
|
||||
import com.intellij.util.CommonProcessors;
|
||||
import com.intellij.util.Function;
|
||||
@@ -313,18 +313,18 @@ public class DuplicateStringLiteralInspection extends BaseLocalInspectionTool {
|
||||
}
|
||||
final PsiExpression[] expressionArray = expressions.toArray(new PsiExpression[expressions.size()]);
|
||||
final IntroduceConstantHandler handler = new IntroduceConstantHandler() {
|
||||
protected OccurenceManager createOccurenceManager(PsiExpression selectedExpr, PsiClass parentClass) {
|
||||
final OccurenceFilter filter = new OccurenceFilter() {
|
||||
public boolean isOK(PsiExpression occurence) {
|
||||
protected OccurrenceManager createOccurenceManager(PsiExpression selectedExpr, PsiClass parentClass) {
|
||||
final OccurrenceFilter filter = new OccurrenceFilter() {
|
||||
public boolean isOK(PsiExpression occurrence) {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
return new BaseOccurenceManager(filter) {
|
||||
protected PsiExpression[] defaultOccurences() {
|
||||
return new BaseOccurrenceManager(filter) {
|
||||
protected PsiExpression[] defaultOccurrences() {
|
||||
return expressionArray;
|
||||
}
|
||||
|
||||
protected PsiExpression[] findOccurences() {
|
||||
protected PsiExpression[] findOccurrences() {
|
||||
return expressionArray;
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user