use of org.eclipse.search.ui.text.FileTextSearchScope in project eclipse.platform.text by eclipse.
the class FileSearchTests method testFileOpenInEditor.
private void testFileOpenInEditor(TestResultCollector collector) throws Exception {
StringBuilder buf = new StringBuilder();
buf.append("File1\n");
buf.append("hello\n");
buf.append("more hello\n");
buf.append("world\n");
IFolder folder = ResourceHelper.createFolder(fProject.getFolder("folder1"));
IFile file1 = ResourceHelper.createFile(folder, "file1", buf.toString());
IFile file2 = ResourceHelper.createFile(folder, "file2", buf.toString());
try {
SearchTestPlugin.openTextEditor(SearchPlugin.getActivePage(), file2);
Pattern searchPattern = PatternConstructor.createPattern("hello", false, true);
FileTextSearchScope scope = FileTextSearchScope.newSearchScope(new IResource[] { fProject }, (String[]) null, false);
TextSearchEngine.create().search(scope, collector, searchPattern, null);
TestResult[] results = collector.getResults();
assertEquals("Number of total results", 4, results.length);
assertMatches(results, 2, file1, buf.toString(), "hello");
assertMatches(results, 2, file2, buf.toString(), "hello");
} finally {
SearchPlugin.getActivePage().closeAllEditors(false);
}
}
use of org.eclipse.search.ui.text.FileTextSearchScope in project eclipse.platform.text by eclipse.
the class FileSearchTests method testWholeWord.
private void testWholeWord(TestResultCollector collector) throws Exception {
StringBuilder buf = new StringBuilder();
// nothing after
// nothing before
buf.append("hell\n");
// nothing before
buf.append("hill\n");
// non-word char before
buf.append("$hell\n");
// word char before
buf.append("shell\n");
// non-word char after
// nothing before
buf.append("hell.freeze()\n");
// non-word char before
buf.append("freeze(hell)\n");
// word char before
buf.append("shell-script\n");
// word char after
// nothing before
buf.append("hello\n");
// non-word char before
buf.append("world.hello()\n");
// word char before
buf.append("shilling\n");
// nothing before
buf.append("holler\n");
IFolder folder = ResourceHelper.createFolder(fProject.getFolder("folder1"));
ResourceHelper.createFile(folder, "file1", buf.toString());
ResourceHelper.createFile(folder, "file2", buf.toString());
TextSearchEngine engine = TextSearchEngine.create();
FileTextSearchScope scope = FileTextSearchScope.newSearchScope(new IResource[] { fProject }, (String[]) null, false);
{
// wildcards, whole word = false: match all lines
Pattern searchPattern = PatternConstructor.createPattern("h?ll", false, true, false, false);
collector.reset();
engine.search(scope, collector, searchPattern, null);
assertEquals("Number of partial-word results", 22, collector.getNumberOfResults());
}
{
// wildcards, whole word = true: match only nothing and non-word chars before and after
Pattern searchPattern = PatternConstructor.createPattern("h?ll", false, true, false, true);
collector.reset();
engine.search(scope, collector, searchPattern, null);
assertEquals("Number of whole-word results", 10, collector.getNumberOfResults());
}
{
// regexp, whole word = false: match all lines
Pattern searchPattern = PatternConstructor.createPattern("h[eio]ll", true, true, false, false);
collector.reset();
engine.search(scope, collector, searchPattern, null);
assertEquals("Number of partial-word results", 22, collector.getNumberOfResults());
}
}
use of org.eclipse.search.ui.text.FileTextSearchScope in project eclipse.platform.text by eclipse.
the class FileSearchTests method testWildCards1.
private void testWildCards1(TestResultCollector collector) throws Exception {
StringBuilder buf = new StringBuilder();
buf.append("File1\n");
buf.append("no more\n");
buf.append("mornings\n");
buf.append("more hello\n");
buf.append("world\n");
IFolder folder = ResourceHelper.createFolder(fProject.getFolder("folder1"));
ResourceHelper.createFile(folder, "file1", buf.toString());
ResourceHelper.createFile(folder, "file2", buf.toString());
Pattern searchPattern = PatternConstructor.createPattern("mor*", false, false);
FileTextSearchScope scope = FileTextSearchScope.newSearchScope(new IResource[] { fProject }, (String[]) null, false);
TextSearchEngine.create().search(scope, collector, searchPattern, null);
TestResult[] results = collector.getResults();
assertEquals("Number of total results", 6, results.length);
}
use of org.eclipse.search.ui.text.FileTextSearchScope in project eclipse.platform.text by eclipse.
the class PositionTrackerTest method setUp.
@Before
public void setUp() throws Exception {
String[] fileNamePatterns = { "*.java" };
FileTextSearchScope scope = FileTextSearchScope.newWorkspaceScope(fileNamePatterns, false);
fQuery1 = new FileSearchQuery("Test", false, true, scope);
}
use of org.eclipse.search.ui.text.FileTextSearchScope in project eclipse.platform.text by eclipse.
the class SortingTest method setUp.
@Before
public void setUp() throws Exception {
String[] fileNamePatterns = { "*.java" };
FileTextSearchScope scope = FileTextSearchScope.newWorkspaceScope(fileNamePatterns, false);
fQuery1 = new FileSearchQuery("Test", false, true, scope);
}
Aggregations