Search in sources :

Example 21 with FindModel

use of com.intellij.find.FindModel in project intellij-community by JetBrains.

the class SwitchToFind method actionPerformed.

@Override
public void actionPerformed(AnActionEvent e) {
    if (KeymapUtil.isEmacsKeymap()) {
        // Emacs users are accustomed to the editor that executes 'find next' on subsequent pressing of shortcut that
        // activates 'incremental search'. Hence, we do the similar hack here for them.
        ActionManager.getInstance().getAction(IdeActions.ACTION_FIND_NEXT).actionPerformed(e);
        return;
    }
    EditorSearchSession search = e.getRequiredData(EditorSearchSession.SESSION_KEY);
    final FindModel findModel = search.getFindModel();
    FindUtil.configureFindModel(false, e.getData(CommonDataKeys.EDITOR_EVEN_IF_INACTIVE), findModel, false);
    search.getComponent().getSearchTextComponent().selectAll();
}
Also used : FindModel(com.intellij.find.FindModel) EditorSearchSession(com.intellij.find.EditorSearchSession)

Example 22 with FindModel

use of com.intellij.find.FindModel in project intellij-community by JetBrains.

the class TogglePreserveCaseAction method update.

@Override
public void update(AnActionEvent e) {
    super.update(e);
    EditorSearchSession search = e.getData(EditorSearchSession.SESSION_KEY);
    FindModel findModel = search != null ? search.getFindModel() : null;
    e.getPresentation().setEnabled(findModel != null && !findModel.isRegularExpressions());
}
Also used : FindModel(com.intellij.find.FindModel) EditorSearchSession(com.intellij.find.EditorSearchSession)

Example 23 with FindModel

use of com.intellij.find.FindModel in project intellij-community by JetBrains.

the class SearchResults method repairCursorFromStack.

private boolean repairCursorFromStack() {
    if (myCursorPositions.size() >= 2) {
        final Pair<FindModel, FindResult> oldPosition = myCursorPositions.get(myCursorPositions.size() - 2);
        if (oldPosition.first.equals(myFindModel)) {
            FindResult newCursor;
            if ((newCursor = findOccurrenceEqualTo(oldPosition.second)) != null) {
                myCursorPositions.pop();
                myCursor = newCursor;
                return true;
            }
        }
    }
    return false;
}
Also used : FindModel(com.intellij.find.FindModel) FindResult(com.intellij.find.FindResult)

Example 24 with FindModel

use of com.intellij.find.FindModel in project intellij-community by JetBrains.

the class HighlightHandlerBase method setupFindModel.

static void setupFindModel(final Project project) {
    final FindManager findManager = FindManager.getInstance(project);
    FindModel model = findManager.getFindNextModel();
    if (model == null) {
        model = findManager.getFindInFileModel();
    }
    model.setSearchHighlighters(true);
    findManager.setFindWasPerformed();
    findManager.setFindNextModel(model);
}
Also used : FindManager(com.intellij.find.FindManager) FindModel(com.intellij.find.FindModel)

Example 25 with FindModel

use of com.intellij.find.FindModel in project intellij-community by JetBrains.

the class SearchInLibsTest method testFindInPathInLibrariesIsNotBrokenAgain.

public void testFindInPathInLibrariesIsNotBrokenAgain() throws Exception {
    FindModel model = new FindModel();
    final PsiClass aClass = myJavaFacade.findClass("LibraryClass1");
    assertNotNull(aClass);
    model.setDirectoryName(aClass.getContainingFile().getContainingDirectory().getVirtualFile().getPath());
    model.setCaseSensitive(true);
    model.setCustomScope(false);
    // to defeat trigram index
    model.setStringToFind(/*LibraryClas*/
    "s1");
    model.setProjectScope(false);
    List<UsageInfo> usages = Collections.synchronizedList(new ArrayList<>());
    CommonProcessors.CollectProcessor<UsageInfo> consumer = new CommonProcessors.CollectProcessor<>(usages);
    FindUsagesProcessPresentation presentation = FindInProjectUtil.setupProcessPresentation(getProject(), false, FindInProjectUtil.setupViewPresentation(false, model));
    FindInProjectUtil.findUsages(model, getProject(), consumer, presentation);
    assertEquals(3, usages.size());
}
Also used : FindModel(com.intellij.find.FindModel) FindUsagesProcessPresentation(com.intellij.usages.FindUsagesProcessPresentation) PsiClass(com.intellij.psi.PsiClass) CommonProcessors(com.intellij.util.CommonProcessors) UsageInfo(com.intellij.usageView.UsageInfo)

Aggregations

FindModel (com.intellij.find.FindModel)31 FindManager (com.intellij.find.FindManager)8 Project (com.intellij.openapi.project.Project)7 UsageInfo (com.intellij.usageView.UsageInfo)6 FindUsagesProcessPresentation (com.intellij.usages.FindUsagesProcessPresentation)5 EditorSearchSession (com.intellij.find.EditorSearchSession)4 Editor (com.intellij.openapi.editor.Editor)4 VirtualFile (com.intellij.openapi.vfs.VirtualFile)4 FindResult (com.intellij.find.FindResult)3 StatusBar (com.intellij.openapi.wm.StatusBar)3 HighlightManager (com.intellij.codeInsight.highlighting.HighlightManager)2 Application (com.intellij.openapi.application.Application)2 EditorColorsManager (com.intellij.openapi.editor.colors.EditorColorsManager)2 EditorColorsScheme (com.intellij.openapi.editor.colors.EditorColorsScheme)2 TextAttributes (com.intellij.openapi.editor.markup.TextAttributes)2 FileEditorManager (com.intellij.openapi.fileEditor.FileEditorManager)2 Module (com.intellij.openapi.module.Module)2 WindowManager (com.intellij.openapi.wm.WindowManager)2 PsiClass (com.intellij.psi.PsiClass)2 PsiElement (com.intellij.psi.PsiElement)2