mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
(no message)
This commit is contained in:
@@ -6,6 +6,7 @@ import com.intellij.openapi.application.ModalityState;
|
||||
import com.intellij.openapi.command.CommandProcessor;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.localVcs.impl.LvcsIntegration;
|
||||
import com.intellij.openapi.localVcs.LvcsAction;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.EmptyRunnable;
|
||||
import com.intellij.openapi.util.Factory;
|
||||
@@ -41,11 +42,11 @@ public abstract class BaseRefactoringProcessor {
|
||||
protected Runnable myPrepareSuccessfulSwingThreadCallback = EMPTY_CALLBACK;
|
||||
|
||||
|
||||
public BaseRefactoringProcessor(Project project) {
|
||||
protected BaseRefactoringProcessor(Project project) {
|
||||
this(project, null);
|
||||
}
|
||||
|
||||
public BaseRefactoringProcessor(Project project, Runnable prepareSuccessfulCallback) {
|
||||
protected BaseRefactoringProcessor(Project project, Runnable prepareSuccessfulCallback) {
|
||||
myProject = project;
|
||||
myPrepareSuccessfulSwingThreadCallback = prepareSuccessfulCallback;
|
||||
}
|
||||
@@ -167,7 +168,7 @@ public abstract class BaseRefactoringProcessor {
|
||||
);
|
||||
}
|
||||
|
||||
private UsageViewPresentation createPresentation(UsageViewDescriptor descriptor) {
|
||||
private static UsageViewPresentation createPresentation(UsageViewDescriptor descriptor) {
|
||||
UsageViewPresentation presentation = new UsageViewPresentation();
|
||||
presentation.setTabText("Refactoring preview");
|
||||
presentation.setTargetsNodeText(descriptor.getProcessedElementsHeader());
|
||||
@@ -229,7 +230,7 @@ public abstract class BaseRefactoringProcessor {
|
||||
}
|
||||
};
|
||||
|
||||
final com.intellij.usages.UsageView usageView = viewManager.searchAndShowUsages(targets, searcherFactory, true, false, createPresentation(viewDescriptor));
|
||||
final UsageView usageView = viewManager.searchAndShowUsages(targets, searcherFactory, true, false, createPresentation(viewDescriptor));
|
||||
|
||||
final Runnable refactoringRunnable = new Runnable() {
|
||||
public void run() {
|
||||
@@ -245,7 +246,7 @@ public abstract class BaseRefactoringProcessor {
|
||||
usageView.addPerformOperationAction(refactoringRunnable, getCommandName(), canNotMakeString, "Do Refactor", SystemInfo.isMac ? 0 : 'D');
|
||||
}
|
||||
|
||||
private Set<UsageInfo> getExcludedUsages(final UsageView usageView) {
|
||||
private static Set<UsageInfo> getExcludedUsages(final UsageView usageView) {
|
||||
Set<Usage> usages = usageView.getExcludedUsages();
|
||||
|
||||
Set<UsageInfo> excludedUsageInfos = new HashSet<UsageInfo>();
|
||||
@@ -280,7 +281,7 @@ public abstract class BaseRefactoringProcessor {
|
||||
usages = array.toArray(new UsageInfo[array.size()]);
|
||||
}
|
||||
|
||||
com.intellij.openapi.localVcs.LvcsAction action = LvcsIntegration.checkinFilesBeforeRefactoring(myProject, getCommandName());
|
||||
LvcsAction action = LvcsIntegration.checkinFilesBeforeRefactoring(myProject, getCommandName());
|
||||
|
||||
try {
|
||||
final UsageInfo[] _usages = usages;
|
||||
|
||||
@@ -357,8 +357,7 @@ public class RenameProcessor extends BaseRefactoringProcessor implements RenameD
|
||||
PsiElement element = myElements.get(i);
|
||||
final String newName = myNames.get(i);
|
||||
if (element instanceof PsiDirectory) continue;
|
||||
final UsageInfo[] usages = RenameUtil.findUsages(element, newName,
|
||||
mySearchInComments, mySearchInNonJavaFiles);
|
||||
final UsageInfo[] usages = RenameUtil.findUsages(element, newName, mySearchInComments, mySearchInNonJavaFiles);
|
||||
result.addAll(Arrays.asList(usages));
|
||||
if (element instanceof PsiClass && myShouldRenameVariables) {
|
||||
myRenamers.add(new AutomaticVariableRenamer((PsiClass) element, newName, Arrays.asList(usages)));
|
||||
|
||||
@@ -35,7 +35,7 @@ public class RenameUtil {
|
||||
String newName,
|
||||
boolean searchInStringsAndComments,
|
||||
boolean searchInNonJavaFiles) {
|
||||
final List<UsageInfo> results = new ArrayList<UsageInfo>();
|
||||
final List<UsageInfo> result = new ArrayList<UsageInfo>();
|
||||
|
||||
PsiManager manager = element.getManager();
|
||||
PsiSearchHelper helper = manager.getSearchHelper();
|
||||
@@ -46,13 +46,13 @@ public class RenameUtil {
|
||||
PsiReference[] refs = helper.findReferencesIncludingOverriding(method, projectScope, true);
|
||||
for (int i = 0; i < refs.length; i++) {
|
||||
PsiReference ref = refs[i];
|
||||
results.add(new MoveRenameUsageInfo(ref.getElement(), ref, element));
|
||||
result.add(new MoveRenameUsageInfo(ref.getElement(), ref, element));
|
||||
}
|
||||
|
||||
PsiElement[] overridings = helper.findOverridingMethods(method, projectScope, true);
|
||||
for (int i = 0; i < overridings.length; i++) {
|
||||
PsiElement element1 = overridings[i];
|
||||
results.add(new MoveRenameUsageInfo(element1, null, element));
|
||||
result.add(new MoveRenameUsageInfo(element1, null, element));
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -67,21 +67,21 @@ public class RenameUtil {
|
||||
for (int i = 0; i < refs.length; i++) {
|
||||
PsiReference ref = refs[i];
|
||||
PsiElement referenceElement = ref.getElement();
|
||||
results.add(
|
||||
result.add(
|
||||
new MoveRenameUsageInfo(referenceElement, ref, ref.getRangeInElement().getStartOffset(),
|
||||
ref.getRangeInElement().getEndOffset(), element,
|
||||
referenceElement instanceof XmlElement));
|
||||
if (classCollisionsDetector == null) {
|
||||
addLocalsCollisions(element, referenceElement, newName, results);
|
||||
addLocalsCollisions(element, referenceElement, newName, result);
|
||||
}
|
||||
else {
|
||||
classCollisionsDetector.addClassCollisions(referenceElement, newName, results);
|
||||
classCollisionsDetector.addClassCollisions(referenceElement, newName, result);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
RenameUtil.findUnresolvableLocalsCollisions(element, newName, results);
|
||||
RenameUtil.findUnresolvableMemberCollisions(element, newName, results);
|
||||
RenameUtil.findUnresolvableLocalsCollisions(element, newName, result);
|
||||
RenameUtil.findUnresolvableMemberCollisions(element, newName, result);
|
||||
|
||||
|
||||
if (searchInStringsAndComments && !(element instanceof PsiDirectory)) {
|
||||
@@ -94,7 +94,7 @@ public class RenameUtil {
|
||||
return NonCodeUsageInfo.create(usage.getContainingFile(), start + startOffset, start + endOffset, element, stringToReplace);
|
||||
}
|
||||
};
|
||||
RefactoringUtil.addUsagesInStringsAndComments(element, stringToSearch, results, factory);
|
||||
RefactoringUtil.addUsagesInStringsAndComments(element, stringToSearch, result, factory);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,28 +110,26 @@ public class RenameUtil {
|
||||
return NonCodeUsageInfo.create(usage.getContainingFile(), start + startOffset, start + endOffset, element, stringToReplace);
|
||||
}
|
||||
};
|
||||
RefactoringUtil.addUsagesInNonJavaFiles(element, stringToSearch, projectScope, results, factory);
|
||||
RefactoringUtil.addUsagesInNonJavaFiles(element, stringToSearch, projectScope, result, factory);
|
||||
|
||||
if (element instanceof PsiClass) {
|
||||
final PsiClass aClass = (PsiClass)element;
|
||||
if (aClass.getParent() instanceof PsiClass) {
|
||||
final String dollaredStringToSearch = RefactoringUtil.getInnerClassNameForClassLoader(aClass);
|
||||
final String dollaredStringToReplace =
|
||||
RefactoringUtil.getNewInnerClassName(aClass, dollaredStringToSearch, newName);
|
||||
final String dollaredStringToReplace = RefactoringUtil.getNewInnerClassName(aClass, dollaredStringToSearch, newName);
|
||||
RefactoringUtil.UsageInfoFactory dollaredFactory = new RefactoringUtil.UsageInfoFactory() {
|
||||
public UsageInfo createUsageInfo(PsiElement usage, int startOffset, int endOffset) {
|
||||
int start = usage.getTextRange().getStartOffset();
|
||||
return NonCodeUsageInfo.create(usage.getContainingFile(), start + startOffset, start + endOffset, element, dollaredStringToReplace);
|
||||
}
|
||||
};
|
||||
RefactoringUtil.addUsagesInNonJavaFiles(aClass, dollaredStringToSearch, projectScope, results,
|
||||
dollaredFactory);
|
||||
RefactoringUtil.addUsagesInNonJavaFiles(aClass, dollaredStringToSearch, projectScope, result, dollaredFactory);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return results.toArray(new UsageInfo[results.size()]);
|
||||
return result.toArray(new UsageInfo[result.size()]);
|
||||
}
|
||||
|
||||
public static void buildPackagePrefixChangedMessage(final VirtualFile[] virtualFiles, StringBuffer message, final String qualifiedName) {
|
||||
|
||||
Reference in New Issue
Block a user