mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-92681 Find in path. Can't find all files by pattern
This commit is contained in:
@@ -24,10 +24,12 @@ import com.intellij.testFramework.fixtures.impl.LightTempDirTestFixtureImpl;
|
||||
import com.intellij.usageView.UsageInfo;
|
||||
import com.intellij.usages.Usage;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.CommonProcessors;
|
||||
import com.intellij.util.ThrowableRunnable;
|
||||
import com.intellij.util.WaitFor;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@@ -165,7 +167,10 @@ public class FindManagerTest extends DaemonAnalyzerTestCase {
|
||||
|
||||
private List<UsageInfo> findUsages(final FindModel findModel) {
|
||||
PsiDirectory psiDirectory = FindInProjectUtil.getPsiDirectory(findModel, myProject);
|
||||
return FindInProjectUtil.findUsages(findModel, psiDirectory, myProject);
|
||||
List<UsageInfo> result = new ArrayList<UsageInfo>();
|
||||
final CommonProcessors.CollectProcessor<UsageInfo> collector = new CommonProcessors.CollectProcessor<UsageInfo>(result);
|
||||
FindInProjectUtil.findUsages(findModel, psiDirectory, myProject, true, collector);
|
||||
return result;
|
||||
}
|
||||
|
||||
public void testFindWholeWordsInProperties() throws Exception {
|
||||
|
||||
@@ -198,7 +198,7 @@ public class FindUtil {
|
||||
doSearch(project, editor, caretOffset, true, model, true);
|
||||
}
|
||||
|
||||
public static void find(final Project project, final Editor editor) {
|
||||
public static void find(@NotNull final Project project, @NotNull final Editor editor) {
|
||||
ApplicationManager.getApplication().assertIsDispatchThread();
|
||||
final FindManager findManager = FindManager.getInstance(project);
|
||||
String s = editor.getSelectionModel().getSelectedText();
|
||||
@@ -266,7 +266,7 @@ public class FindUtil {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static List<Usage> findAll(final Project project, final Editor editor, final FindModel findModel) {
|
||||
public static List<Usage> findAll(@NotNull Project project, @NotNull Editor editor, @NotNull FindModel findModel) {
|
||||
final Document document = editor.getDocument();
|
||||
final PsiFile psiFile = PsiDocumentManager.getInstance(project).getPsiFile(document);
|
||||
if (psiFile == null) return null;
|
||||
@@ -664,11 +664,12 @@ public class FindUtil {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static FindResult doSearch(Project project,
|
||||
final Editor editor,
|
||||
private static FindResult doSearch(@NotNull Project project,
|
||||
@NotNull final Editor editor,
|
||||
int offset,
|
||||
boolean toWarn,
|
||||
FindModel model, boolean adjustEditor) {
|
||||
@NotNull FindModel model,
|
||||
boolean adjustEditor) {
|
||||
FindManager findManager = FindManager.getInstance(project);
|
||||
Document document = editor.getDocument();
|
||||
|
||||
|
||||
@@ -22,19 +22,29 @@ import com.intellij.find.FindSettings;
|
||||
import com.intellij.find.FindUtil;
|
||||
import com.intellij.find.impl.FindInProjectUtil;
|
||||
import com.intellij.find.replaceInProject.ReplaceInProjectManager;
|
||||
import com.intellij.navigation.ItemPresentation;
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.actionSystem.PlatformDataKeys;
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.fileEditor.FileEditor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Factory;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.PsiDirectory;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.ui.content.Content;
|
||||
import com.intellij.usageView.UsageInfo;
|
||||
import com.intellij.usageView.UsageViewManager;
|
||||
import com.intellij.usages.*;
|
||||
import com.intellij.util.AdapterProcessor;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import com.intellij.util.Processor;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
public class FindInProjectManager {
|
||||
private final Project myProject;
|
||||
@@ -49,7 +59,7 @@ public class FindInProjectManager {
|
||||
myProject = project;
|
||||
}
|
||||
|
||||
public void findInProject(DataContext dataContext) {
|
||||
public void findInProject(@NotNull DataContext dataContext) {
|
||||
final boolean isOpenInNewTabEnabled;
|
||||
final boolean[] toOpenInNewTab = new boolean[1];
|
||||
Content selectedContent = UsageViewManager.getInstance(myProject).getSelectedContent(true);
|
||||
@@ -73,7 +83,6 @@ public class FindInProjectManager {
|
||||
Editor editor = PlatformDataKeys.EDITOR.getData(dataContext);
|
||||
FindUtil.initStringToFindWithSelection(findModel, editor);
|
||||
|
||||
|
||||
findManager.showFindDialog(findModel, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@@ -95,9 +104,9 @@ public class FindInProjectManager {
|
||||
final boolean showPanelIfOnlyOneUsage = !FindSettings.getInstance().isSkipResultsWithOneUsage();
|
||||
|
||||
FindUsagesProcessPresentation processPresentation = FindInProjectUtil.setupProcessPresentation(myProject, showPanelIfOnlyOneUsage, presentation);
|
||||
|
||||
manager.searchAndShowUsages(
|
||||
new UsageTarget[] { new FindInProjectUtil.StringUsageTarget(findModel.getStringToFind())},
|
||||
UsageTarget usageTarget = StringUtil.isEmpty(findModel.getStringToFind()) ? createFileByTypeTarget(findModel)
|
||||
: new FindInProjectUtil.StringUsageTarget(findModel.getStringToFind());
|
||||
manager.searchAndShowUsages(new UsageTarget[] {usageTarget},
|
||||
new Factory<UsageSearcher>() {
|
||||
@Override
|
||||
public UsageSearcher create() {
|
||||
@@ -108,7 +117,7 @@ public class FindInProjectManager {
|
||||
|
||||
try {
|
||||
FindInProjectUtil.findUsages(findModelCopy, psiDirectory, myProject,
|
||||
new AdapterProcessor<UsageInfo, Usage>(processor, UsageInfo2UsageAdapter.CONVERTER));
|
||||
true, new AdapterProcessor<UsageInfo, Usage>(processor, UsageInfo2UsageAdapter.CONVERTER));
|
||||
}
|
||||
finally {
|
||||
myIsFindInProgress = false;
|
||||
@@ -126,6 +135,90 @@ public class FindInProjectManager {
|
||||
findModel.setOpenInNewTabVisible(false);
|
||||
}
|
||||
|
||||
private static UsageTarget createFileByTypeTarget(@NotNull FindModel model) {
|
||||
final String filter = model.getFileFilter();
|
||||
return new UsageTarget() {
|
||||
@Override
|
||||
public void findUsages() {
|
||||
throw new IncorrectOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void findUsagesInEditor(@NotNull FileEditor editor) {
|
||||
throw new IncorrectOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void highlightUsages(@NotNull PsiFile file, @NotNull Editor editor, boolean clearHighlights) {
|
||||
throw new IncorrectOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isReadOnly() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public VirtualFile[] getFiles() {
|
||||
return VirtualFile.EMPTY_ARRAY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Files with mask \""+filter+"\"";
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public ItemPresentation getPresentation() {
|
||||
return new ItemPresentation() {
|
||||
@Nullable
|
||||
@Override
|
||||
public String getPresentableText() {
|
||||
return getName();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String getLocationString() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Icon getIcon(boolean unused) {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public void navigate(boolean requestFocus) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canNavigate() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canNavigateToSource() {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public boolean isWorkInProgress() {
|
||||
return myIsFindInProgress;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
*
|
||||
@@ -34,7 +33,7 @@ import com.intellij.openapi.fileTypes.FileTypes;
|
||||
import com.intellij.openapi.help.HelpManager;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.module.ModuleManager;
|
||||
import com.intellij.openapi.module.ModuleUtil;
|
||||
import com.intellij.openapi.module.ModuleUtilCore;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.*;
|
||||
import com.intellij.openapi.ui.popup.JBPopup;
|
||||
@@ -58,6 +57,7 @@ import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.Consumer;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
@@ -107,7 +107,7 @@ public class FindDialog extends DialogWrapper {
|
||||
private ScopeChooserCombo myScopeCombo;
|
||||
protected JLabel myReplacePrompt;
|
||||
|
||||
public FindDialog(Project project, FindModel model, Consumer<FindModel> myOkHandler){
|
||||
public FindDialog(@NotNull Project project, @NotNull FindModel model, @NotNull Consumer<FindModel> myOkHandler){
|
||||
super(project, true);
|
||||
myProject = project;
|
||||
myModel = model;
|
||||
@@ -119,7 +119,6 @@ public class FindDialog extends DialogWrapper {
|
||||
init();
|
||||
initByModel();
|
||||
updateReplaceVisibility();
|
||||
//myLivePreviewController = new LivePreviewController(this, new LivePreview(myProject), getContentPane());
|
||||
}
|
||||
|
||||
private void updateTitle() {
|
||||
@@ -148,9 +147,6 @@ public class FindDialog extends DialogWrapper {
|
||||
e.getKey().removeDocumentListener(e.getValue());
|
||||
}
|
||||
myComboBoxListeners.clear();
|
||||
//if (myLivePreviewController != null) {
|
||||
// myLivePreviewController.cleanUp();
|
||||
//}
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@@ -164,6 +160,7 @@ public class FindDialog extends DialogWrapper {
|
||||
return myModel.isReplaceState() ? "replaceTextDialog" : "findTextDialog";
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected Action[] createActions() {
|
||||
if (!myModel.isMultipleFiles() && !myModel.isReplaceState() && myModel.isFindAllEnabled()) {
|
||||
@@ -172,6 +169,7 @@ public class FindDialog extends DialogWrapper {
|
||||
return new Action[] { getOKAction(), getCancelAction(), getHelpAction() };
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private Action getFindAllAction() {
|
||||
return myFindAllAction = new AbstractAction(FindBundle.message("find.all.button")) {
|
||||
@Override
|
||||
@@ -227,13 +225,13 @@ public class FindDialog extends DialogWrapper {
|
||||
myCbPreserveCase.setVisible(myModel.isReplaceState());
|
||||
}
|
||||
|
||||
private void revealWhitespaces(ComboBox comboBox) {
|
||||
private void revealWhitespaces(@NotNull ComboBox comboBox) {
|
||||
ComboBoxEditor comboBoxEditor = new RevealingSpaceComboboxEditor(myProject, comboBox);
|
||||
comboBox.setEditor(comboBoxEditor);
|
||||
comboBox.setRenderer(new EditorComboBoxRenderer(comboBoxEditor));
|
||||
}
|
||||
|
||||
private void initCombobox(final ComboBox comboBox) {
|
||||
private void initCombobox(@NotNull final ComboBox comboBox) {
|
||||
comboBox.setEditable(true);
|
||||
comboBox.setMaximumRowCount(8);
|
||||
|
||||
@@ -270,7 +268,7 @@ public class FindDialog extends DialogWrapper {
|
||||
}
|
||||
}
|
||||
|
||||
private void handleComboBoxValueChanged(final ComboBox comboBox) {
|
||||
private void handleComboBoxValueChanged(@NotNull ComboBox comboBox) {
|
||||
Object item = comboBox.getEditor().getItem();
|
||||
if (item != null && !item.equals(comboBox.getSelectedItem())){
|
||||
int caretPosition = getCaretPosition(comboBox);
|
||||
@@ -280,33 +278,22 @@ public class FindDialog extends DialogWrapper {
|
||||
validateFindButton();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public FindModel getModel() {
|
||||
return myModel;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public FindModel getCurrentModel() {
|
||||
FindModel validateModel = (FindModel)myModel.clone();
|
||||
applyTo(validateModel, false);
|
||||
|
||||
|
||||
if (getValidationInfo(validateModel) == null) {
|
||||
return validateModel;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setOkHandler(Consumer<FindModel> okHandler) {
|
||||
public void setOkHandler(@NotNull Consumer<FindModel> okHandler) {
|
||||
myOkHandler = okHandler;
|
||||
}
|
||||
|
||||
public void setModel(FindModel model) {
|
||||
public void setModel(@NotNull FindModel model) {
|
||||
myModel = model;
|
||||
updateReplaceVisibility();
|
||||
updateTitle();
|
||||
}
|
||||
|
||||
private static int getCaretPosition(JComboBox comboBox) {
|
||||
private static int getCaretPosition(@NotNull JComboBox comboBox) {
|
||||
Component editorComponent = comboBox.getEditor().getEditorComponent();
|
||||
if (editorComponent instanceof JTextField){
|
||||
JTextField textField = (JTextField)editorComponent;
|
||||
@@ -315,7 +302,7 @@ public class FindDialog extends DialogWrapper {
|
||||
return 0;
|
||||
}
|
||||
|
||||
private static void setCaretPosition(JComboBox comboBox, int position) {
|
||||
private static void setCaretPosition(@NotNull JComboBox comboBox, int position) {
|
||||
Component editorComponent = comboBox.getEditor().getEditorComponent();
|
||||
if (editorComponent instanceof JTextField){
|
||||
JTextField textField = (JTextField)editorComponent;
|
||||
@@ -324,18 +311,13 @@ public class FindDialog extends DialogWrapper {
|
||||
}
|
||||
|
||||
private void validateFindButton() {
|
||||
final String toFind = getStringToFind();
|
||||
if (toFind == null || toFind.length() == 0){
|
||||
setOKStatus(false);
|
||||
return;
|
||||
}
|
||||
boolean okStatus = canSearchThisString() ||
|
||||
myRbDirectory != null && myRbDirectory.isSelected() && StringUtil.isEmpty(getDirectory());
|
||||
setOKStatus(okStatus);
|
||||
}
|
||||
|
||||
if (myRbDirectory != null && myRbDirectory.isSelected() &&
|
||||
(getDirectory() == null || getDirectory().length() == 0)){
|
||||
setOKStatus(false);
|
||||
return;
|
||||
}
|
||||
setOKStatus(true);
|
||||
private boolean canSearchThisString() {
|
||||
return !StringUtil.isEmpty(getStringToFind()) || !myModel.isReplaceState() && !myModel.isFindAllEnabled() && getFileTypeMask() != null;
|
||||
}
|
||||
|
||||
private void setOKStatus(boolean value) {
|
||||
@@ -360,7 +342,20 @@ public class FindDialog extends DialogWrapper {
|
||||
topOptionsPanel.setLayout(new GridLayout(1, 2, UIUtil.DEFAULT_HGAP, 0));
|
||||
topOptionsPanel.add(createFindOptionsPanel());
|
||||
optionsPanel.add(topOptionsPanel, gbConstraints);
|
||||
if (!myModel.isMultipleFiles()){
|
||||
if (myModel.isMultipleFiles()) {
|
||||
optionsPanel.add(createGlobalScopePanel(), gbConstraints);
|
||||
gbConstraints.weightx = 1;
|
||||
gbConstraints.weighty = 1;
|
||||
gbConstraints.fill = GridBagConstraints.HORIZONTAL;
|
||||
|
||||
gbConstraints.gridwidth = GridBagConstraints.REMAINDER;
|
||||
optionsPanel.add(createFilterPanel(),gbConstraints);
|
||||
|
||||
myCbToSkipResultsWhenOneUsage = createCheckbox(FindSettings.getInstance().isSkipResultsWithOneUsage(), FindBundle.message("find.options.skip.results.tab.with.one.usage.checkbox"));
|
||||
optionsPanel.add(myCbToSkipResultsWhenOneUsage, gbConstraints);
|
||||
myCbToSkipResultsWhenOneUsage.setVisible(myModel.isReplaceState());
|
||||
}
|
||||
else {
|
||||
if (FindManagerImpl.ourHasSearchInCommentsAndLiterals) {
|
||||
JPanel leftOptionsPanel = new JPanel();
|
||||
leftOptionsPanel.setLayout(new GridLayout(3, 1, 0, 4));
|
||||
@@ -379,19 +374,6 @@ public class FindDialog extends DialogWrapper {
|
||||
bottomOptionsPanel.add(createOriginPanel());
|
||||
}
|
||||
}
|
||||
else{
|
||||
optionsPanel.add(createGlobalScopePanel(), gbConstraints);
|
||||
gbConstraints.weightx = 1;
|
||||
gbConstraints.weighty = 1;
|
||||
gbConstraints.fill = GridBagConstraints.HORIZONTAL;
|
||||
|
||||
gbConstraints.gridwidth = GridBagConstraints.REMAINDER;
|
||||
optionsPanel.add(createFilterPanel(),gbConstraints);
|
||||
|
||||
myCbToSkipResultsWhenOneUsage = createCheckbox(FindSettings.getInstance().isSkipResultsWithOneUsage(), FindBundle.message("find.options.skip.results.tab.with.one.usage.checkbox"));
|
||||
optionsPanel.add(myCbToSkipResultsWhenOneUsage, gbConstraints);
|
||||
myCbToSkipResultsWhenOneUsage.setVisible(myModel.isReplaceState());
|
||||
}
|
||||
|
||||
if (myModel.isOpenInNewTabVisible()){
|
||||
JPanel openInNewTabWindowPanel = new JPanel(new BorderLayout());
|
||||
@@ -406,6 +388,7 @@ public class FindDialog extends DialogWrapper {
|
||||
return optionsPanel;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private JComponent createFilterPanel() {
|
||||
JPanel filterPanel = new JPanel();
|
||||
filterPanel.setLayout(new BorderLayout());
|
||||
@@ -417,11 +400,16 @@ public class FindDialog extends DialogWrapper {
|
||||
filterPanel.add(myUseFileFilter = createCheckbox(FindBundle.message("find.filter.file.mask.checkbox")),BorderLayout.WEST);
|
||||
filterPanel.add(myFileFilter,BorderLayout.CENTER);
|
||||
initFileFilter(myFileFilter, myUseFileFilter);
|
||||
|
||||
myUseFileFilter.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
validateFindButton();
|
||||
}
|
||||
});
|
||||
return filterPanel;
|
||||
}
|
||||
|
||||
public static void initFileFilter(final JComboBox fileFilter, final JCheckBox useFileFilter) {
|
||||
public static void initFileFilter(@NotNull final JComboBox fileFilter, @NotNull final JCheckBox useFileFilter) {
|
||||
fileFilter.setEditable(true);
|
||||
String[] fileMasks = FindSettings.getInstance().getRecentFileMasks();
|
||||
for(int i=fileMasks.length-1; i >= 0; i--) {
|
||||
@@ -433,14 +421,14 @@ public class FindDialog extends DialogWrapper {
|
||||
new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (!useFileFilter.isSelected()) {
|
||||
fileFilter.setEnabled(false);
|
||||
}
|
||||
else {
|
||||
if (useFileFilter.isSelected()) {
|
||||
fileFilter.setEnabled(true);
|
||||
fileFilter.getEditor().selectAll();
|
||||
fileFilter.getEditor().getEditorComponent().requestFocusInWindow();
|
||||
}
|
||||
else {
|
||||
fileFilter.setEnabled(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
@@ -458,13 +446,13 @@ public class FindDialog extends DialogWrapper {
|
||||
ValidationInfo validationInfo = getValidationInfo(validateModel);
|
||||
|
||||
if (validationInfo == null) {
|
||||
|
||||
myModel.copyFrom(validateModel);
|
||||
updateFindSettings();
|
||||
|
||||
super.doOKAction();
|
||||
myOkHandler.consume(myModel);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
String message = validationInfo.message;
|
||||
if (message != null) {
|
||||
Messages.showMessageDialog(
|
||||
@@ -522,7 +510,8 @@ public class FindDialog extends DialogWrapper {
|
||||
return true;
|
||||
}
|
||||
|
||||
private ValidationInfo getValidationInfo(FindModel model) {
|
||||
@Nullable("null means OK")
|
||||
private ValidationInfo getValidationInfo(@NotNull FindModel model) {
|
||||
if (myRbDirectory != null && myRbDirectory.isEnabled() && myRbDirectory.isSelected()) {
|
||||
PsiDirectory directory = FindInProjectUtil.getPsiDirectory(model, myProject);
|
||||
if (directory == null) {
|
||||
@@ -530,12 +519,12 @@ public class FindDialog extends DialogWrapper {
|
||||
}
|
||||
}
|
||||
|
||||
String toFind = (String)myInputComboBox.getSelectedItem();
|
||||
if (toFind != null && toFind.isEmpty()) {
|
||||
if (!canSearchThisString()) {
|
||||
return new ValidationInfo("String to find is empty", myInputComboBox);
|
||||
}
|
||||
|
||||
if (myCbRegularExpressions != null && myCbRegularExpressions.isSelected() && myCbRegularExpressions.isEnabled()) {
|
||||
String toFind = getStringToFind();
|
||||
try {
|
||||
boolean isCaseSensitive = myCbCaseSensitive != null && myCbCaseSensitive.isSelected() && myCbCaseSensitive.isEnabled();
|
||||
Pattern pattern =
|
||||
@@ -549,10 +538,10 @@ public class FindDialog extends DialogWrapper {
|
||||
}
|
||||
}
|
||||
|
||||
final String mask = (myFileFilter == null || !myUseFileFilter.isSelected()) ? null : (String)myFileFilter.getSelectedItem();
|
||||
final String mask = getFileTypeMask();
|
||||
|
||||
if (mask != null) {
|
||||
if (mask.length() == 0) {
|
||||
if (mask.isEmpty()) {
|
||||
return new ValidationInfo(FindBundle.message("find.filter.empty.file.mask.error"), myFileFilter);
|
||||
}
|
||||
else {
|
||||
@@ -588,10 +577,10 @@ public class FindDialog extends DialogWrapper {
|
||||
}
|
||||
|
||||
private boolean isSkipResultsWhenOneUsage() {
|
||||
return myCbToSkipResultsWhenOneUsage!=null &&
|
||||
myCbToSkipResultsWhenOneUsage.isSelected();
|
||||
return myCbToSkipResultsWhenOneUsage!=null && myCbToSkipResultsWhenOneUsage.isSelected();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private JPanel createFindOptionsPanel() {
|
||||
JPanel findOptionsPanel = new JPanel();
|
||||
findOptionsPanel.setBorder(IdeBorderFactory.createTitledBorder(FindBundle.message("find.options.group"), true));
|
||||
@@ -653,11 +642,6 @@ public class FindDialog extends DialogWrapper {
|
||||
myCbCaseSensitive.addActionListener(actionListener);
|
||||
myCbPreserveCase.addActionListener(actionListener);
|
||||
|
||||
// if(isReplaceState) {
|
||||
// myCbPromptOnReplace = new JCheckBox("Prompt on replace", true);
|
||||
// myCbPromptOnReplace.setMnemonic('P');
|
||||
// findOptionsPanel.add(myCbPromptOnReplace);
|
||||
// }
|
||||
return findOptionsPanel;
|
||||
}
|
||||
|
||||
@@ -666,7 +650,7 @@ public class FindDialog extends DialogWrapper {
|
||||
if (myReplaceComboBox != null) updateFileTypeForEditorComponent(myReplaceComboBox);
|
||||
}
|
||||
|
||||
private void updateFileTypeForEditorComponent(final ComboBox inputComboBox) {
|
||||
private void updateFileTypeForEditorComponent(@NotNull ComboBox inputComboBox) {
|
||||
final Component editorComponent = inputComboBox.getEditor().getEditorComponent();
|
||||
|
||||
if (editorComponent instanceof EditorTextField) {
|
||||
@@ -687,20 +671,23 @@ public class FindDialog extends DialogWrapper {
|
||||
private void updateControls() {
|
||||
if (myCbRegularExpressions.isSelected()) {
|
||||
myCbWholeWordsOnly.makeUnselectable(false);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
myCbWholeWordsOnly.makeSelectable();
|
||||
}
|
||||
if (myModel.isReplaceState()) {
|
||||
if (myCbRegularExpressions.isSelected() || myCbCaseSensitive.isSelected()) {
|
||||
myCbPreserveCase.makeUnselectable(false);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
myCbPreserveCase.makeSelectable();
|
||||
}
|
||||
|
||||
if (myCbPreserveCase.isSelected()) {
|
||||
myCbRegularExpressions.makeUnselectable(false);
|
||||
myCbCaseSensitive.makeUnselectable(false);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
myCbRegularExpressions.makeSelectable();
|
||||
myCbCaseSensitive.makeSelectable();
|
||||
}
|
||||
@@ -712,6 +699,7 @@ public class FindDialog extends DialogWrapper {
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private JPanel createDirectionPanel() {
|
||||
JPanel directionPanel = new JPanel();
|
||||
directionPanel.setBorder(IdeBorderFactory.createTitledBorder(FindBundle.message("find.direction.group"), true));
|
||||
@@ -728,6 +716,7 @@ public class FindDialog extends DialogWrapper {
|
||||
return directionPanel;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private JComponent createGlobalScopePanel() {
|
||||
JPanel scopePanel = new JPanel();
|
||||
scopePanel.setLayout(new GridBagLayout());
|
||||
@@ -830,20 +819,15 @@ public class FindDialog extends DialogWrapper {
|
||||
bgScope.add(myRbModule);
|
||||
bgScope.add(myRbCustomScope);
|
||||
|
||||
myRbProject.addActionListener(new ActionListener() {
|
||||
ActionListener validateAll = new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
validateScopeControls();
|
||||
validateFindButton();
|
||||
}
|
||||
});
|
||||
myRbCustomScope.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
validateScopeControls();
|
||||
validateFindButton();
|
||||
}
|
||||
});
|
||||
};
|
||||
myRbProject.addActionListener(validateAll);
|
||||
myRbCustomScope.addActionListener(validateAll);
|
||||
|
||||
myRbDirectory.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
@@ -871,7 +855,6 @@ public class FindDialog extends DialogWrapper {
|
||||
@Override
|
||||
public void consume(final List<VirtualFile> files) {
|
||||
myDirectoryComboBox.setSelectedItem(files.get(0).getPresentableUrl());
|
||||
//validateFindButton();
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -880,13 +863,15 @@ public class FindDialog extends DialogWrapper {
|
||||
return scopePanel;
|
||||
}
|
||||
|
||||
private static StateRestoringCheckBox createCheckbox(String message) {
|
||||
@NotNull
|
||||
private static StateRestoringCheckBox createCheckbox(@NotNull String message) {
|
||||
final StateRestoringCheckBox cb = new StateRestoringCheckBox(message);
|
||||
cb.setFocusable(false);
|
||||
return cb;
|
||||
}
|
||||
|
||||
private static StateRestoringCheckBox createCheckbox(boolean selected, String message) {
|
||||
@NotNull
|
||||
private static StateRestoringCheckBox createCheckbox(boolean selected, @NotNull String message) {
|
||||
final StateRestoringCheckBox cb = new StateRestoringCheckBox(message, selected);
|
||||
cb.setFocusable(false);
|
||||
return cb;
|
||||
@@ -906,6 +891,7 @@ public class FindDialog extends DialogWrapper {
|
||||
myScopeCombo.setEnabled(myRbCustomScope.isSelected());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private JPanel createScopePanel() {
|
||||
JPanel scopePanel = new JPanel();
|
||||
scopePanel.setBorder(IdeBorderFactory.createTitledBorder(FindBundle.message("find.scope.group"), true));
|
||||
@@ -931,6 +917,7 @@ public class FindDialog extends DialogWrapper {
|
||||
return scopePanel;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private JPanel createOriginPanel() {
|
||||
JPanel originPanel = new JPanel();
|
||||
originPanel.setBorder(IdeBorderFactory.createTitledBorder(FindBundle.message("find.origin.group"), true));
|
||||
@@ -947,10 +934,13 @@ public class FindDialog extends DialogWrapper {
|
||||
return originPanel;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private String getStringToFind() {
|
||||
String string = (String)myInputComboBox.getEditor().getItem();
|
||||
return string == null ? "" : string;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private String getStringToReplace() {
|
||||
String item = (String)myReplaceComboBox.getEditor().getItem();
|
||||
return item == null ? "" : item;
|
||||
@@ -960,7 +950,7 @@ public class FindDialog extends DialogWrapper {
|
||||
return (String)myDirectoryComboBox.getSelectedItem();
|
||||
}
|
||||
|
||||
private static void setStringsToComboBox(String[] strings, ComboBox combo, String selected) {
|
||||
private static void setStringsToComboBox(@NotNull String[] strings, @NotNull ComboBox combo, String selected) {
|
||||
if (combo.getItemCount() > 0){
|
||||
combo.removeAllItems();
|
||||
}
|
||||
@@ -973,11 +963,11 @@ public class FindDialog extends DialogWrapper {
|
||||
}
|
||||
}
|
||||
|
||||
private void setDirectories(ArrayList strings, String directoryName) {
|
||||
private void setDirectories(@NotNull List<String> strings, String directoryName) {
|
||||
if (myDirectoryComboBox.getItemCount() > 0){
|
||||
myReplaceComboBox.removeAllItems();
|
||||
}
|
||||
if (directoryName != null && directoryName.length() > 0){
|
||||
if (directoryName != null && !directoryName.isEmpty()){
|
||||
if (strings.contains(directoryName)){
|
||||
strings.remove(directoryName);
|
||||
}
|
||||
@@ -993,8 +983,7 @@ public class FindDialog extends DialogWrapper {
|
||||
|
||||
|
||||
|
||||
private void applyTo(FindModel model, boolean findAll) {
|
||||
|
||||
private void applyTo(@NotNull FindModel model, boolean findAll) {
|
||||
model.setCaseSensitive(myCbCaseSensitive.isSelected());
|
||||
|
||||
if (model.isReplaceState()) {
|
||||
@@ -1008,7 +997,7 @@ public class FindDialog extends DialogWrapper {
|
||||
|
||||
model.setRegularExpressions(myCbRegularExpressions.isSelected());
|
||||
String stringToFind = getStringToFind();
|
||||
if (stringToFind.length() > 0) {
|
||||
if (!stringToFind.isEmpty()) {
|
||||
model.setStringToFind(stringToFind);
|
||||
}
|
||||
|
||||
@@ -1058,12 +1047,17 @@ public class FindDialog extends DialogWrapper {
|
||||
|
||||
model.setFindAll(findAll);
|
||||
|
||||
String mask = getFileTypeMask();
|
||||
model.setFileFilter(mask);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private String getFileTypeMask() {
|
||||
String mask = null;
|
||||
if (myUseFileFilter !=null && myUseFileFilter.isSelected()) {
|
||||
mask = (String)myFileFilter.getSelectedItem();
|
||||
}
|
||||
model.setFileFilter(mask);
|
||||
|
||||
return mask;
|
||||
}
|
||||
|
||||
|
||||
@@ -1081,7 +1075,7 @@ public class FindDialog extends DialogWrapper {
|
||||
if (!StringUtil.isEmptyOrSpaces(dirName)) {
|
||||
VirtualFile dir = LocalFileSystem.getInstance().findFileByPath(dirName);
|
||||
if (dir != null) {
|
||||
Module module = ModuleUtil.findModuleForFile(dir, myProject);
|
||||
Module module = ModuleUtilCore.findModuleForFile(dir, myProject);
|
||||
if (module != null) {
|
||||
myModuleComboBox.setSelectedItem(module.getName());
|
||||
}
|
||||
@@ -1133,7 +1127,7 @@ public class FindDialog extends DialogWrapper {
|
||||
|
||||
myCbWithSubdirectories.setSelected(myModel.isWithSubdirectories());
|
||||
|
||||
if (myModel.getFileFilter()!=null && myModel.getFileFilter().length() > 0) {
|
||||
if (myModel.getFileFilter()!=null && !myModel.getFileFilter().isEmpty()) {
|
||||
myFileFilter.setSelectedItem(myModel.getFileFilter());
|
||||
myFileFilter.setEnabled(true);
|
||||
myUseFileFilter.setSelected(true);
|
||||
@@ -1168,7 +1162,6 @@ public class FindDialog extends DialogWrapper {
|
||||
setStringsToComboBox(FindSettings.getInstance().getRecentReplaceStrings(), myReplaceComboBox, myModel.getStringToReplace());
|
||||
}
|
||||
updateControls();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package com.intellij.find.impl;
|
||||
|
||||
import com.intellij.BundleBase;
|
||||
import com.intellij.find.*;
|
||||
import com.intellij.find.ngrams.TrigramIndex;
|
||||
import com.intellij.navigation.ItemPresentation;
|
||||
@@ -163,19 +164,6 @@ public class FindInProjectUtil {
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static List<UsageInfo> findUsages(@NotNull final FindModel findModel, final PsiDirectory psiDirectory, @NotNull final Project project) {
|
||||
return findUsages(findModel, psiDirectory, project, true);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static List<UsageInfo> findUsages(@NotNull final FindModel findModel, final PsiDirectory psiDirectory, @NotNull final Project project, boolean showWarnings) {
|
||||
final CommonProcessors.CollectProcessor<UsageInfo> collector = new CommonProcessors.CollectProcessor<UsageInfo>();
|
||||
findUsages(findModel, psiDirectory, project, collector, showWarnings);
|
||||
|
||||
return new ArrayList<UsageInfo>(collector.getResults());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static Pattern createFileMaskRegExp(@NotNull FindModel findModel) {
|
||||
final String filter = findModel.getFileFilter();
|
||||
@@ -207,16 +195,8 @@ public class FindInProjectUtil {
|
||||
public static void findUsages(@NotNull final FindModel findModel,
|
||||
final PsiDirectory psiDirectory,
|
||||
@NotNull final Project project,
|
||||
boolean showWarnings,
|
||||
@NotNull final Processor<UsageInfo> consumer) {
|
||||
findUsages(findModel, psiDirectory, project, consumer, true);
|
||||
}
|
||||
|
||||
|
||||
public static void findUsages(@NotNull final FindModel findModel,
|
||||
final PsiDirectory psiDirectory,
|
||||
@NotNull final Project project,
|
||||
@NotNull final Processor<UsageInfo> consumer,
|
||||
boolean showWarnings) {
|
||||
final ProgressIndicator progress = ProgressManager.getInstance().getProgressIndicator();
|
||||
|
||||
final Collection<PsiFile> psiFiles = getFilesToSearchIn(findModel, project, psiDirectory);
|
||||
@@ -317,6 +297,17 @@ public class FindInProjectUtil {
|
||||
private static int processUsagesInFile(@NotNull final PsiFile psiFile,
|
||||
@NotNull final FindModel findModel,
|
||||
@NotNull final Processor<UsageInfo> consumer) {
|
||||
if (findModel.getStringToFind().isEmpty()) {
|
||||
if (!ApplicationManager.getApplication().runReadAction(new Computable<Boolean>() {
|
||||
@Override
|
||||
public Boolean compute() {
|
||||
return consumer.process(new UsageInfo(psiFile,0,0,true));
|
||||
}
|
||||
})) {
|
||||
throw new ProcessCanceledException();
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
final VirtualFile virtualFile = psiFile.getVirtualFile();
|
||||
if (virtualFile == null) return 0;
|
||||
if (virtualFile.getFileType().isBinary()) return 0; // do not decompile .class files
|
||||
@@ -393,7 +384,7 @@ public class FindInProjectUtil {
|
||||
if (psiDirectory == null || findModel.isWithSubdirectories() && fileIndex.isInContent(psiDirectory.getVirtualFile())) {
|
||||
final Pattern fileMaskRegExp = createFileMaskRegExp(findModel);
|
||||
// optimization
|
||||
Pair<Boolean, Collection<PsiFile>> fastWords = getFilesForFastWordSearch(findModel, project, psiDirectory, fileMaskRegExp, module);
|
||||
Pair<Boolean, Collection<PsiFile>> fastWords = getFilesForFastWordSearch(findModel, project, psiDirectory, fileMaskRegExp, module, fileIndex);
|
||||
final Collection<PsiFile> filesForFastWordSearch = fastWords.getSecond();
|
||||
|
||||
if (fastWords.getFirst() && canOptimizeForFastWordSearch(findModel)) return filesForFastWordSearch;
|
||||
@@ -477,9 +468,11 @@ public class FindInProjectUtil {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static Pair<Boolean, Collection<PsiFile>> getFilesForFastWordSearch(@NotNull final FindModel findModel, @NotNull final Project project,
|
||||
@Nullable final PsiDirectory psiDirectory, final Pattern fileMaskRegExp,
|
||||
@Nullable final Module module) {
|
||||
private static Pair<Boolean, Collection<PsiFile>> getFilesForFastWordSearch(@NotNull final FindModel findModel,
|
||||
@NotNull final Project project,
|
||||
@Nullable final PsiDirectory psiDirectory,
|
||||
final Pattern fileMaskRegExp,
|
||||
@Nullable final Module module, FileIndex fileIndex) {
|
||||
if (DumbService.getInstance(project).isDumb()) {
|
||||
return new Pair<Boolean, Collection<PsiFile>>(false, Collections.<PsiFile>emptyList());
|
||||
}
|
||||
@@ -499,11 +492,12 @@ public class FindInProjectUtil {
|
||||
}
|
||||
|
||||
Set<Integer> keys = new THashSet<Integer>(30);
|
||||
Set<PsiFile> resultFiles = new THashSet<PsiFile>();
|
||||
final Set<PsiFile> resultFiles = new THashSet<PsiFile>();
|
||||
boolean fast = false;
|
||||
|
||||
String stringToFind = findModel.getStringToFind();
|
||||
if (TrigramIndex.ENABLED) {
|
||||
TIntHashSet trigrams = TrigramBuilder.buildTrigram(findModel.getStringToFind());
|
||||
TIntHashSet trigrams = TrigramBuilder.buildTrigram(stringToFind);
|
||||
TIntIterator it = trigrams.iterator();
|
||||
while (it.hasNext()) {
|
||||
keys.add(it.next());
|
||||
@@ -527,9 +521,9 @@ public class FindInProjectUtil {
|
||||
// $ is used to separate words when indexing plain-text files but not when indexing
|
||||
// Java identifiers, so we can't consistently break a string containing $ characters into words
|
||||
|
||||
fast |= findModel.isWholeWordsOnly() && findModel.getStringToFind().indexOf('$') < 0;
|
||||
fast |= findModel.isWholeWordsOnly() && stringToFind.indexOf('$') < 0;
|
||||
|
||||
List<String> words = StringUtil.getWordsInStringLongestFirst(findModel.getStringToFind());
|
||||
List<String> words = StringUtil.getWordsInStringLongestFirst(stringToFind);
|
||||
|
||||
for (int i = 0; i < words.size(); i++) {
|
||||
String word = words.get(i);
|
||||
@@ -553,12 +547,28 @@ public class FindInProjectUtil {
|
||||
if (resultFiles.isEmpty()) break;
|
||||
}
|
||||
|
||||
// in case our word splitting is incorrect
|
||||
PsiFile[] allWordsFiles =
|
||||
cacheManager.getFilesWithWord(findModel.getStringToFind(), UsageSearchContext.ANY, scope, findModel.isCaseSensitive());
|
||||
ContainerUtil.addAll(resultFiles, allWordsFiles);
|
||||
if (stringToFind.isEmpty()) {
|
||||
fileIndex.iterateContent(new ContentIterator() {
|
||||
@Override
|
||||
public boolean processFile(VirtualFile file) {
|
||||
if (!file.isDirectory() && fileMaskRegExp.matcher(file.getName()).matches()) {
|
||||
PsiFile psiFile = PsiManager.getInstance(project).findFile(file);
|
||||
if (psiFile != null) {
|
||||
resultFiles.add(psiFile);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
// in case our word splitting is incorrect
|
||||
PsiFile[] allWordsFiles =
|
||||
cacheManager.getFilesWithWord(stringToFind, UsageSearchContext.ANY, scope, findModel.isCaseSensitive());
|
||||
ContainerUtil.addAll(resultFiles, allWordsFiles);
|
||||
|
||||
filterMaskedFiles(resultFiles, fileMaskRegExp);
|
||||
filterMaskedFiles(resultFiles, fileMaskRegExp);
|
||||
}
|
||||
|
||||
return new Pair<Boolean, Collection<PsiFile>>(fast, resultFiles);
|
||||
}
|
||||
@@ -649,9 +659,16 @@ public class FindInProjectUtil {
|
||||
final String scope = getTitleForScope(findModelCopy);
|
||||
final String stringToFind = findModelCopy.getStringToFind();
|
||||
presentation.setScopeText(scope);
|
||||
presentation.setTabText(FindBundle.message("find.usage.view.tab.text", stringToFind));
|
||||
presentation.setToolwindowTitle(FindBundle.message("find.usage.view.toolwindow.title", stringToFind, scope));
|
||||
presentation.setUsagesString(FindBundle.message("find.usage.view.usages.text", stringToFind));
|
||||
if (stringToFind.isEmpty()) {
|
||||
presentation.setTabText("Files");
|
||||
presentation.setToolwindowTitle(BundleBase.format("Files in ''{0}''", scope));
|
||||
presentation.setUsagesString("files");
|
||||
}
|
||||
else {
|
||||
presentation.setTabText(FindBundle.message("find.usage.view.tab.text", stringToFind));
|
||||
presentation.setToolwindowTitle(FindBundle.message("find.usage.view.toolwindow.title", stringToFind, scope));
|
||||
presentation.setUsagesString(FindBundle.message("find.usage.view.usages.text", stringToFind));
|
||||
}
|
||||
presentation.setOpenInNewTab(toOpenInNewTab);
|
||||
presentation.setCodeUsages(false);
|
||||
|
||||
@@ -697,7 +714,7 @@ public class FindInProjectUtil {
|
||||
}
|
||||
};
|
||||
|
||||
public StringUsageTarget(String _stringToFind) {
|
||||
public StringUsageTarget(@NotNull String _stringToFind) {
|
||||
myStringToFind = _stringToFind;
|
||||
}
|
||||
|
||||
|
||||
@@ -186,10 +186,9 @@ public class FindManagerImpl extends FindManager implements PersistentStateCompo
|
||||
@Override
|
||||
public void consume(FindModel findModel) {
|
||||
String stringToFind = findModel.getStringToFind();
|
||||
if (stringToFind.isEmpty()) {
|
||||
return;
|
||||
if (!StringUtil.isEmpty(stringToFind)) {
|
||||
FindSettings.getInstance().addStringToFind(stringToFind);
|
||||
}
|
||||
FindSettings.getInstance().addStringToFind(stringToFind);
|
||||
if (!findModel.isMultipleFiles()) {
|
||||
setFindWasPerformed();
|
||||
}
|
||||
@@ -215,7 +214,8 @@ public class FindManagerImpl extends FindManager implements PersistentStateCompo
|
||||
}
|
||||
};
|
||||
myFindDialog.setModal(false);
|
||||
} else if (myFindDialog.getModel().isReplaceState() != model.isReplaceState()) {
|
||||
}
|
||||
else if (myFindDialog.getModel().isReplaceState() != model.isReplaceState()) {
|
||||
myFindDialog.setModel(model);
|
||||
myFindDialog.setOkHandler(handler);
|
||||
return;
|
||||
|
||||
+1
-1
@@ -442,7 +442,7 @@ public class ReplaceInProjectManager {
|
||||
myIsFindInProgress = true;
|
||||
|
||||
FindInProjectUtil.findUsages(myFindModelCopy, myPsiDirectory, myProject,
|
||||
new AdapterProcessor<UsageInfo, Usage>(processor, UsageInfo2UsageAdapter.CONVERTER));
|
||||
true, new AdapterProcessor<UsageInfo, Usage>(processor, UsageInfo2UsageAdapter.CONVERTER));
|
||||
}
|
||||
finally {
|
||||
myIsFindInProgress = false;
|
||||
|
||||
@@ -22,6 +22,7 @@ import com.intellij.openapi.fileTypes.FileTypeManager;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.module.ModuleManager;
|
||||
import com.intellij.openapi.module.ModuleUtil;
|
||||
import com.intellij.openapi.module.ModuleUtilCore;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.roots.ModuleRootManager;
|
||||
import com.intellij.openapi.util.Computable;
|
||||
@@ -292,7 +293,7 @@ public class IconsReferencesContributor extends PsiReferenceContributor implemen
|
||||
final Module module = ApplicationManager.getApplication().runReadAction(new Computable<Module>() {
|
||||
@Override
|
||||
public Module compute() {
|
||||
return ModuleUtil.findModuleForPsiElement(file);
|
||||
return ModuleUtilCore.findModuleForPsiElement(file);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -306,9 +307,9 @@ public class IconsReferencesContributor extends PsiReferenceContributor implemen
|
||||
model.setCaseSensitive(true);
|
||||
model.setFindAll(true);
|
||||
model.setWholeWordsOnly(true);
|
||||
final List<UsageInfo> usages = FindInProjectUtil.findUsages(model, FindInProjectUtil.getPsiDirectory(model, project), project, false);
|
||||
if (!usages.isEmpty()) {
|
||||
for (final UsageInfo usage : usages) {
|
||||
FindInProjectUtil.findUsages(model, FindInProjectUtil.getPsiDirectory(model, project), project, false, new Processor<UsageInfo>() {
|
||||
@Override
|
||||
public boolean process(final UsageInfo usage) {
|
||||
ApplicationManager.getApplication().runReadAction(new Runnable() {
|
||||
public void run() {
|
||||
final PsiElement element = usage.getElement();
|
||||
@@ -332,8 +333,9 @@ public class IconsReferencesContributor extends PsiReferenceContributor implemen
|
||||
}
|
||||
}
|
||||
});
|
||||
return true;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user