use of com.intellij.refactoring.rename.naming.AutomaticRenamerFactory in project intellij-community by JetBrains.
the class RenameDialog method createCheckboxes.
protected void createCheckboxes(JPanel panel, GridBagConstraints gbConstraints) {
gbConstraints.insets = JBUI.insetsBottom(4);
gbConstraints.gridwidth = 1;
gbConstraints.gridx = 0;
gbConstraints.weighty = 0;
gbConstraints.weightx = 1;
gbConstraints.fill = GridBagConstraints.BOTH;
myCbSearchInComments = new NonFocusableCheckBox();
myCbSearchInComments.setText(RefactoringBundle.getSearchInCommentsAndStringsText());
myCbSearchInComments.setSelected(true);
panel.add(myCbSearchInComments, gbConstraints);
gbConstraints.insets = JBUI.insetsBottom(4);
gbConstraints.gridwidth = GridBagConstraints.REMAINDER;
gbConstraints.gridx = 1;
gbConstraints.weightx = 1;
gbConstraints.fill = GridBagConstraints.BOTH;
myCbSearchTextOccurrences = new NonFocusableCheckBox();
myCbSearchTextOccurrences.setText(RefactoringBundle.getSearchForTextOccurrencesText());
myCbSearchTextOccurrences.setSelected(true);
panel.add(myCbSearchTextOccurrences, gbConstraints);
if (!TextOccurrencesUtil.isSearchTextOccurencesEnabled(myPsiElement)) {
myCbSearchTextOccurrences.setEnabled(false);
myCbSearchTextOccurrences.setSelected(false);
myCbSearchTextOccurrences.setVisible(false);
}
for (AutomaticRenamerFactory factory : Extensions.getExtensions(AutomaticRenamerFactory.EP_NAME)) {
if (factory.isApplicable(myPsiElement) && factory.getOptionName() != null) {
gbConstraints.insets = JBUI.insetsBottom(4);
gbConstraints.gridwidth = myAutoRenamerFactories.size() % 2 == 0 ? 1 : GridBagConstraints.REMAINDER;
gbConstraints.gridx = myAutoRenamerFactories.size() % 2;
gbConstraints.weightx = 1;
gbConstraints.fill = GridBagConstraints.BOTH;
JCheckBox checkBox = new NonFocusableCheckBox();
checkBox.setText(factory.getOptionName());
checkBox.setSelected(factory.isEnabled());
panel.add(checkBox, gbConstraints);
myAutoRenamerFactories.put(factory, checkBox);
}
}
}
use of com.intellij.refactoring.rename.naming.AutomaticRenamerFactory in project intellij-community by JetBrains.
the class RenameProcessor method findUsages.
@Override
@NotNull
public UsageInfo[] findUsages() {
myRenamers.clear();
ArrayList<UsageInfo> result = new ArrayList<>();
List<PsiElement> elements = new ArrayList<>(myAllRenames.keySet());
//noinspection ForLoopReplaceableByForEach
for (int i = 0; i < elements.size(); i++) {
PsiElement element = elements.get(i);
if (element == null) {
LOG.error("primary: " + myPrimaryElement + "; renamers: " + myRenamers);
continue;
}
final String newName = myAllRenames.get(element);
final UsageInfo[] usages = RenameUtil.findUsages(element, newName, mySearchInComments, mySearchTextOccurrences, myAllRenames);
final List<UsageInfo> usagesList = Arrays.asList(usages);
result.addAll(usagesList);
for (AutomaticRenamerFactory factory : myRenamerFactories) {
if (factory.isApplicable(element)) {
myRenamers.add(factory.createRenamer(element, newName, usagesList));
}
}
for (AutomaticRenamerFactory factory : Extensions.getExtensions(AutomaticRenamerFactory.EP_NAME)) {
if (factory.getOptionName() == null && factory.isApplicable(element)) {
myRenamers.add(factory.createRenamer(element, newName, usagesList));
}
}
}
UsageInfo[] usageInfos = result.toArray(new UsageInfo[result.size()]);
usageInfos = UsageViewUtil.removeDuplicatedUsages(usageInfos);
return usageInfos;
}
use of com.intellij.refactoring.rename.naming.AutomaticRenamerFactory in project intellij-community by JetBrains.
the class AbstractJavaFXRenameTest method doRenameWithAutomaticRenamers.
protected void doRenameWithAutomaticRenamers(PsiElement elementAtCaret, String newName) {
final RenameProcessor processor = new RenameProcessor(getProject(), elementAtCaret, newName, false, false);
for (AutomaticRenamerFactory factory : Extensions.getExtensions(AutomaticRenamerFactory.EP_NAME)) {
processor.addRenamerFactory(factory);
}
processor.run();
}
Aggregations