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;
}
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);
}
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);
}
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());
}
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));
}
Aggregations