use of com.intellij.find.FindManager in project intellij-community by JetBrains.
the class EscapeHandler method execute.
@Override
public void execute(Editor editor, DataContext dataContext) {
editor.setHeaderComponent(null);
Project project = CommonDataKeys.PROJECT.getData(dataContext);
if (project != null) {
HighlightManagerImpl highlightManager = (HighlightManagerImpl) HighlightManager.getInstance(project);
if (highlightManager != null && highlightManager.hideHighlights(editor, HighlightManager.HIDE_BY_ESCAPE | HighlightManager.HIDE_BY_ANY_KEY)) {
StatusBar statusBar = WindowManager.getInstance().getStatusBar(project);
if (statusBar != null) {
statusBar.setInfo("");
}
FindManager findManager = FindManager.getInstance(project);
if (findManager != null) {
FindModel model = findManager.getFindNextModel(editor);
if (model != null) {
model.setSearchHighlighters(false);
findManager.setFindNextModel(model);
}
}
return;
}
}
myOriginalHandler.execute(editor, dataContext);
}
use of com.intellij.find.FindManager in project intellij-community by JetBrains.
the class FindInProjectManager method findInProject.
public void findInProject(@NotNull DataContext dataContext) {
final boolean isOpenInNewTabEnabled;
final boolean toOpenInNewTab;
Content selectedContent = UsageViewManager.getInstance(myProject).getSelectedContent(true);
if (selectedContent != null && selectedContent.isPinned()) {
toOpenInNewTab = true;
isOpenInNewTabEnabled = false;
} else {
toOpenInNewTab = FindSettings.getInstance().isShowResultsInSeparateView();
isOpenInNewTabEnabled = UsageViewManager.getInstance(myProject).getReusableContentsCount() > 0;
}
final FindManager findManager = FindManager.getInstance(myProject);
final FindModel findModel = findManager.getFindInProjectModel().clone();
findModel.setReplaceState(false);
findModel.setOpenInNewTabVisible(true);
findModel.setOpenInNewTabEnabled(isOpenInNewTabEnabled);
findModel.setOpenInNewTab(toOpenInNewTab);
initModel(findModel, dataContext);
findManager.showFindDialog(findModel, () -> {
findModel.setOpenInNewTabVisible(false);
if (isOpenInNewTabEnabled) {
FindSettings.getInstance().setShowResultsInSeparateView(findModel.isOpenInNewTab());
}
startFindInProject(findModel);
//todo check it in both cases: dialog & popup
findModel.setOpenInNewTabVisible(false);
});
}
use of com.intellij.find.FindManager in project intellij-community by JetBrains.
the class SearchAgainAction method actionPerformed.
@Override
public void actionPerformed(final AnActionEvent e) {
final Project project = e.getData(CommonDataKeys.PROJECT);
final FileEditor editor = e.getData(PlatformDataKeys.FILE_EDITOR);
if (editor == null || project == null)
return;
CommandProcessor commandProcessor = CommandProcessor.getInstance();
commandProcessor.executeCommand(project, () -> {
PsiDocumentManager.getInstance(project).commitAllDocuments();
IdeDocumentHistory.getInstance(project).includeCurrentCommandAsNavigation();
FindManager findManager = FindManager.getInstance(project);
if (!findManager.selectNextOccurrenceWasPerformed() && findManager.findNextUsageInEditor(editor)) {
return;
}
FindUtil.searchAgain(project, editor, e.getDataContext());
}, IdeBundle.message("command.find.next"), null);
}
use of com.intellij.find.FindManager in project intellij-community by JetBrains.
the class SearchResults method findInRange.
private void findInRange(TextRange r, Editor editor, FindModel findModel, ArrayList<FindResult> results) {
VirtualFile virtualFile = FileDocumentManager.getInstance().getFile(editor.getDocument());
CharSequence charSequence = editor.getDocument().getCharsSequence();
int offset = r.getStartOffset();
int maxOffset = Math.min(r.getEndOffset(), charSequence.length());
FindManager findManager = FindManager.getInstance(getProject());
while (true) {
FindResult result;
try {
CharSequence bombedCharSequence = StringUtil.newBombedCharSequence(charSequence, 3000);
result = findManager.findString(bombedCharSequence, offset, findModel, virtualFile);
} catch (PatternSyntaxException | ProcessCanceledException e) {
result = null;
}
if (result == null || !result.isStringFound())
break;
int newOffset = result.getEndOffset();
if (result.getEndOffset() > maxOffset)
break;
if (offset == newOffset) {
if (offset < maxOffset - 1) {
offset++;
} else {
results.add(result);
break;
}
} else {
offset = newOffset;
}
results.add(result);
}
}
use of com.intellij.find.FindManager in project android by JetBrains.
the class SearchInBuildFilesHyperlink method searchInBuildFiles.
public static void searchInBuildFiles(@NotNull String text, @NotNull final Project project) {
FindManager findManager = FindManager.getInstance(project);
UsageViewManager usageViewManager = UsageViewManager.getInstance(project);
FindModel findModel = findManager.getFindInProjectModel().clone();
findModel.setStringToFind(text);
findModel.setReplaceState(false);
findModel.setOpenInNewTabVisible(true);
findModel.setOpenInNewTabEnabled(true);
findModel.setOpenInNewTab(true);
findModel.setFileFilter(SdkConstants.FN_BUILD_GRADLE);
findManager.getFindInProjectModel().copyFrom(findModel);
final FindModel findModelCopy = findModel.clone();
UsageViewPresentation presentation = setupViewPresentation(findModel.isOpenInNewTabEnabled(), findModelCopy);
boolean showPanelIfOnlyOneUsage = !FindSettings.getInstance().isSkipResultsWithOneUsage();
final FindUsagesProcessPresentation processPresentation = setupProcessPresentation(project, showPanelIfOnlyOneUsage, presentation);
UsageTarget usageTarget = new StringUsageTarget(project, findModel);
usageViewManager.searchAndShowUsages(new UsageTarget[] { usageTarget }, new Factory<UsageSearcher>() {
@Override
public UsageSearcher create() {
return new UsageSearcher() {
@Override
public void generate(@NotNull final Processor<Usage> processor) {
AdapterProcessor<UsageInfo, Usage> consumer = new AdapterProcessor<UsageInfo, Usage>(processor, UsageInfo2UsageAdapter.CONVERTER);
findUsages(findModelCopy, project, consumer, processPresentation);
}
};
}
}, processPresentation, presentation, null);
}
Aggregations