Search in sources :

Example 1 with FindModel

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

the class GrFindManagerTest method testFindInJavaDocs.

public void testFindInJavaDocs() {
    FindModel findModel = FindManagerTestUtils.configureFindModel("done");
    String text = "/** done done done */";
    FindManagerTestUtils.runFindForwardAndBackward(myFindManager, findModel, text, "groovy");
}
Also used : FindModel(com.intellij.find.FindModel)

Example 2 with FindModel

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

the class GrFindManagerTest method testFindInLiteralToSkipQuotes.

public void testFindInLiteralToSkipQuotes() {
    FindModel findModel = FindManagerTestUtils.configureFindModel("^done$");
    findModel.setRegularExpressions(true);
    findModel.setInStringLiteralsOnly(true);
    findModel.setInCommentsOnly(false);
    String text = "def n = \"\"\"done\"\"\"\n def n = /done/\n def n = \"done\"\n def n = \"done2\"";
    FindManagerTestUtils.runFindForwardAndBackward(myFindManager, findModel, text, "groovy");
}
Also used : FindModel(com.intellij.find.FindModel)

Example 3 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 4 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 5 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