Search in sources :

Example 1 with FileTextSearchScope

use of org.eclipse.search.ui.text.FileTextSearchScope in project eclipse.platform.text by eclipse.

the class DefaultTextSearchQueryProvider method createQuery.

@Override
public ISearchQuery createQuery(TextSearchInput input) {
    FileTextSearchScope scope = input.getScope();
    String text = input.getSearchText();
    boolean regEx = input.isRegExSearch();
    boolean caseSensitive = input.isCaseSensitiveSearch();
    boolean wholeWord = input.isWholeWordSearch();
    boolean searchInBinaries = input.searchInBinaries();
    Assert.isLegal(!(wholeWord && regEx));
    return new FileSearchQuery(text, regEx, caseSensitive, wholeWord, searchInBinaries, scope);
}
Also used : FileSearchQuery(org.eclipse.search.internal.ui.text.FileSearchQuery) FileTextSearchScope(org.eclipse.search.ui.text.FileTextSearchScope)

Example 2 with FileTextSearchScope

use of org.eclipse.search.ui.text.FileTextSearchScope in project eclipse.platform.text by eclipse.

the class AnnotationManagerTest method setUp.

@Before
public void setUp() {
    SearchTestPlugin.ensureWelcomePageClosed();
    EditorAnnotationManager.debugSetHighlighterType(EditorAnnotationManager.HIGHLIGHTER_ANNOTATION);
    String[] fileNamePattern = { "*.java" };
    FileTextSearchScope scope = FileTextSearchScope.newWorkspaceScope(fileNamePattern, false);
    // $NON-NLS-1$//$NON-NLS-2$
    fQuery1 = new FileSearchQuery("Test", false, true, scope);
    // $NON-NLS-1$//$NON-NLS-2$
    fQuery2 = new FileSearchQuery("Test", false, true, scope);
}
Also used : FileSearchQuery(org.eclipse.search.internal.ui.text.FileSearchQuery) FileTextSearchScope(org.eclipse.search.ui.text.FileTextSearchScope) Before(org.junit.Before)

Example 3 with FileTextSearchScope

use of org.eclipse.search.ui.text.FileTextSearchScope in project eclipse.platform.text by eclipse.

the class FileSearchTests method testSimpleFiles.

private void testSimpleFiles(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());
    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");
}
Also used : Pattern(java.util.regex.Pattern) IFile(org.eclipse.core.resources.IFile) FileTextSearchScope(org.eclipse.search.ui.text.FileTextSearchScope) IFolder(org.eclipse.core.resources.IFolder)

Example 4 with FileTextSearchScope

use of org.eclipse.search.ui.text.FileTextSearchScope in project eclipse.platform.text by eclipse.

the class FileSearchTests method testWildCards2.

private void testWildCards2(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("mo?e", 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", 4, results.length);
}
Also used : Pattern(java.util.regex.Pattern) FileTextSearchScope(org.eclipse.search.ui.text.FileTextSearchScope) IFolder(org.eclipse.core.resources.IFolder)

Example 5 with FileTextSearchScope

use of org.eclipse.search.ui.text.FileTextSearchScope in project eclipse.platform.text by eclipse.

the class FileSearchTests method performSearch.

private FileSearchResult performSearch(String[] fileNamePatterns, String pattern) {
    FileTextSearchScope scope = FileTextSearchScope.newSearchScope(new IResource[] { fProject }, fileNamePatterns, false);
    FileSearchQuery query = new FileSearchQuery(pattern, true, true, scope);
    query.run(null);
    return (FileSearchResult) query.getSearchResult();
}
Also used : FileSearchQuery(org.eclipse.search.internal.ui.text.FileSearchQuery) FileSearchResult(org.eclipse.search.internal.ui.text.FileSearchResult) FileTextSearchScope(org.eclipse.search.ui.text.FileTextSearchScope)

Aggregations

FileTextSearchScope (org.eclipse.search.ui.text.FileTextSearchScope)16 Pattern (java.util.regex.Pattern)7 FileSearchQuery (org.eclipse.search.internal.ui.text.FileSearchQuery)7 Before (org.junit.Before)6 IFolder (org.eclipse.core.resources.IFolder)5 IFile (org.eclipse.core.resources.IFile)3 IProject (org.eclipse.core.resources.IProject)1 TextSearchEngine (org.eclipse.search.core.text.TextSearchEngine)1 FileSearchResult (org.eclipse.search.internal.ui.text.FileSearchResult)1 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)1