Search in sources :

Example 11 with FileTextSearchScope

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

the class FileSearchQuery method searchInFile.

/**
 * @param result all result are added to this search result
 * @param monitor the progress monitor to use
 * @param file the file to search in
 * @return returns the status of the operation
 */
public IStatus searchInFile(final AbstractTextSearchResult result, final IProgressMonitor monitor, IFile file) {
    // $NON-NLS-1$
    FileTextSearchScope scope = FileTextSearchScope.newSearchScope(new IResource[] { file }, new String[] { "*" }, true);
    Pattern searchPattern = getSearchPattern();
    TextSearchResultCollector collector = new TextSearchResultCollector(result, isFileNameSearch(), fSearchInBinaries);
    return TextSearchEngine.create().search(scope, collector, searchPattern, monitor);
}
Also used : Pattern(java.util.regex.Pattern) FileTextSearchScope(org.eclipse.search.ui.text.FileTextSearchScope)

Example 12 with FileTextSearchScope

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

the class FileSearchTests method performSearch.

private TestResult[] performSearch(TestResultCollector collector, String[] fileNamePatterns, Pattern searchPattern) {
    collector.reset();
    FileTextSearchScope scope = FileTextSearchScope.newSearchScope(new IResource[] { fProject }, fileNamePatterns, false);
    TextSearchEngine.create().search(scope, collector, searchPattern, null);
    return collector.getResults();
}
Also used : FileTextSearchScope(org.eclipse.search.ui.text.FileTextSearchScope)

Example 13 with FileTextSearchScope

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

the class FileSearchTests method testWildCards3.

private void testWildCards3(TestResultCollector collector) throws Exception {
    IProject project = fgJUnitSource.getStandardProject();
    IFile openFile1 = (IFile) project.findMember("junit/framework/TestCase.java");
    IFile openFile2 = (IFile) project.findMember("junit/extensions/ExceptionTestCase.java");
    IFile openFile3 = (IFile) project.findMember("junit/framework/Assert.java");
    IFile openFile4 = (IFile) project.findMember("junit/samples/money/MoneyTest.java");
    IWorkbenchPage activePage = SearchPlugin.getActivePage();
    try {
        SearchTestPlugin.openTextEditor(activePage, openFile1);
        SearchTestPlugin.openTextEditor(activePage, openFile2);
        SearchTestPlugin.openTextEditor(activePage, openFile3);
        SearchTestPlugin.openTextEditor(activePage, openFile4);
        long start = System.currentTimeMillis();
        Pattern searchPattern = PatternConstructor.createPattern("\\w*\\(\\)", false, true);
        // search in Junit sources
        FileTextSearchScope scope = FileTextSearchScope.newSearchScope(new IResource[] { project }, (String[]) null, false);
        TextSearchEngine.create().search(scope, collector, searchPattern, null);
        TestResult[] results = collector.getResults();
        assertEquals("Number of total results", 748, results.length);
        long end = System.currentTimeMillis();
        System.out.println("time= " + (end - start));
    } finally {
        activePage.closeAllEditors(false);
    }
}
Also used : Pattern(java.util.regex.Pattern) IFile(org.eclipse.core.resources.IFile) FileTextSearchScope(org.eclipse.search.ui.text.FileTextSearchScope) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) IProject(org.eclipse.core.resources.IProject)

Example 14 with FileTextSearchScope

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

the class LineAnnotationManagerTest method setUp.

@Before
public void setUp() throws Exception {
    EditorAnnotationManager.debugSetHighlighterType(EditorAnnotationManager.HIGHLIGHTER_ANNOTATION);
    String[] fileNamePatterns = { "*.java" };
    FileTextSearchScope scope = FileTextSearchScope.newWorkspaceScope(fileNamePatterns, false);
    fLineQuery = new LineBasedFileSearch(scope, false, true, "Test");
}
Also used : FileTextSearchScope(org.eclipse.search.ui.text.FileTextSearchScope) Before(org.junit.Before)

Example 15 with FileTextSearchScope

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

the class ResultUpdaterTest method setUp.

@Before
public void setUp() throws Exception {
    // create a own project to make modifications
    fProject = ResourceHelper.createJUnitSourceProject(PROJECT_TO_MODIFY);
    String[] fileNamePatterns = { "*.java" };
    FileTextSearchScope scope = FileTextSearchScope.newSearchScope(new IResource[] { fProject }, fileNamePatterns, false);
    fQuery1 = 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)

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