Search in sources :

Example 11 with FindModel

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

the class SelectOccurrencesActionHandler method getFindModel.

protected static FindModel getFindModel(String text, boolean wholeWords) {
    FindModel model = new FindModel();
    model.setStringToFind(text);
    model.setCaseSensitive(true);
    model.setWholeWordsOnly(wholeWords);
    return model;
}
Also used : FindModel(com.intellij.find.FindModel)

Example 12 with FindModel

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

the class FindResultTest method testFindResultHasCorrectCompare.

public void testFindResultHasCorrectCompare() throws IOException {
    VirtualFile file = createTempFile("txt", null, "xxxx", CharsetToolkit.UTF8_CHARSET);
    PsiFile psiFile = getPsiManager().findFile(file);
    FindResultUsageInfo info1 = new FindResultUsageInfo(FindManager.getInstance(myProject), psiFile, 1, new FindModel(), new FindResultImpl(1, 2));
    FindResultUsageInfo info2 = new FindResultUsageInfo(FindManager.getInstance(myProject), psiFile, 2, new FindModel(), new FindResultImpl(2, 3));
    assertTrue("result: " + info1.compareToByStartOffset(info2), info1.compareToByStartOffset(info2) < 0);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) FindModel(com.intellij.find.FindModel) PsiFile(com.intellij.psi.PsiFile)

Example 13 with FindModel

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

the class SearchInLibsTest method testFindInPathInLibraryDirActuallySearchesInTheirSourcesToo.

public void testFindInPathInLibraryDirActuallySearchesInTheirSourcesToo() 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);
    model.setStringToFind("LibraryClass1");
    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);
    assertSize(2, usages);
}
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)

Example 14 with FindModel

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

the class SearchInLibsTest method testFindInPathInLibrarySourceDirShouldSearchJustInThisDirectoryOnly.

public void testFindInPathInLibrarySourceDirShouldSearchJustInThisDirectoryOnly() throws Exception {
    FindModel model = new FindModel();
    final PsiClass aClass = myJavaFacade.findClass("x.X");
    assertNotNull(aClass);
    String classDirPath = aClass.getContainingFile().getContainingDirectory().getVirtualFile().getPath();
    String sourceDirPath = ((PsiFile) aClass.getContainingFile().getNavigationElement()).getContainingDirectory().getVirtualFile().getPath();
    assertFalse(classDirPath.equals(sourceDirPath));
    model.setDirectoryName(sourceDirPath);
    model.setCaseSensitive(true);
    model.setCustomScope(false);
    model.setStringToFind("xxx");
    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);
    UsageInfo info = assertOneElement(usages);
    assertEquals("X.java", info.getFile().getName());
}
Also used : FindModel(com.intellij.find.FindModel) FindUsagesProcessPresentation(com.intellij.usages.FindUsagesProcessPresentation) PsiClass(com.intellij.psi.PsiClass) PsiFile(com.intellij.psi.PsiFile) CommonProcessors(com.intellij.util.CommonProcessors) UsageInfo(com.intellij.usageView.UsageInfo)

Example 15 with FindModel

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

the class UsageViewManagerTest method testScopeCreatedForFindInDirectory.

public void testScopeCreatedForFindInDirectory() {
    VirtualFile dir = getProject().getBaseDir();
    FindModel findModel = new FindModel();
    findModel.setDirectoryName(dir.getPath());
    findModel.setWithSubdirectories(true);
    findModel.setProjectScope(false);
    UsageTarget target = new FindInProjectUtil.StringUsageTarget(getProject(), findModel);
    UsageViewManagerImpl manager = (UsageViewManagerImpl) UsageViewManager.getInstance(getProject());
    SearchScope scope = manager.getMaxSearchScopeToWarnOfFallingOutOf(new UsageTarget[] { target });
    assertEquals(scope, GlobalSearchScopesCore.directoryScope(getProject(), dir, true));
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) FindModel(com.intellij.find.FindModel) SearchScope(com.intellij.psi.search.SearchScope) UsageTarget(com.intellij.usages.UsageTarget)

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