Search in sources :

Example 1 with FileSearchResult

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

the class AnnotationManagerTest method testBogusAnnotation.

@Test
public void testBogusAnnotation() throws Exception {
    NewSearchUI.runQueryInForeground(null, fQuery1);
    FileSearchResult result = (FileSearchResult) fQuery1.getSearchResult();
    IFile file = (IFile) result.getElements()[0];
    SearchTestPlugin.openTextEditor(SearchTestPlugin.getDefault().getWorkbench().getWorkbenchWindows()[0].getPages()[0], file);
    result.addMatch(new FileMatch(file));
}
Also used : FileSearchResult(org.eclipse.search.internal.ui.text.FileSearchResult) IFile(org.eclipse.core.resources.IFile) FileMatch(org.eclipse.search.internal.ui.text.FileMatch) Test(org.junit.Test)

Example 2 with FileSearchResult

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

the class FileSearchTests method testReplaceWithLookarounds.

@Test
public void testReplaceWithLookarounds() throws CoreException, IOException {
    IFolder folder = ResourceHelper.createFolder(fProject.getFolder("folder1"));
    IFile file1 = ResourceHelper.createFile(folder, "file1.txt", "1<2<3<4");
    IFile file2 = ResourceHelper.createFile(folder, "file2.txt", "4<5<6<7");
    FileSearchResult searchResult = performSearch(new String[] { "*.txt" }, "(?<=(\\d)\\<)\\d(?=\\<(\\d))");
    performReplace(searchResult, "$0=($1+$2)/2");
    assertFileContent(file1, "1<2=(1+3)/2<3=(2+4)/2<4");
    assertFileContent(file2, "4<5=(4+6)/2<6=(5+7)/2<7");
}
Also used : FileSearchResult(org.eclipse.search.internal.ui.text.FileSearchResult) IFile(org.eclipse.core.resources.IFile) IFolder(org.eclipse.core.resources.IFolder) Test(org.junit.Test)

Example 3 with FileSearchResult

use of org.eclipse.search.internal.ui.text.FileSearchResult 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)

Example 4 with FileSearchResult

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

the class PositionTrackerTest method testInsertInsideMatch.

@Test
public void testInsertInsideMatch() throws Exception {
    NewSearchUI.runQueryInForeground(null, fQuery1);
    FileSearchResult result = (FileSearchResult) fQuery1.getSearchResult();
    Object[] elements = result.getElements();
    try {
        for (int i = 0; i < elements.length; i++) {
            checkInsertInsideMatch(result, (IFile) elements[i]);
        }
    } finally {
        SearchPlugin.getActivePage().closeAllEditors(false);
    }
}
Also used : FileSearchResult(org.eclipse.search.internal.ui.text.FileSearchResult) Test(org.junit.Test)

Example 5 with FileSearchResult

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

the class FileSearchTests method testReplaceRetainCase.

@Test
public void testReplaceRetainCase() throws CoreException, IOException {
    IFolder folder = ResourceHelper.createFolder(fProject.getFolder("folder1"));
    IFile file1 = ResourceHelper.createFile(folder, "file1.txt", "FOO");
    FileSearchResult searchResult = performSearch(new String[] { "*.txt" }, "FOO");
    performReplace(searchResult, "xyz\\Cbar\\Cfar");
    assertFileContent(file1, "xyzBARFAR");
}
Also used : FileSearchResult(org.eclipse.search.internal.ui.text.FileSearchResult) IFile(org.eclipse.core.resources.IFile) IFolder(org.eclipse.core.resources.IFolder) Test(org.junit.Test)

Aggregations

FileSearchResult (org.eclipse.search.internal.ui.text.FileSearchResult)5 Test (org.junit.Test)4 IFile (org.eclipse.core.resources.IFile)3 IFolder (org.eclipse.core.resources.IFolder)2 FileMatch (org.eclipse.search.internal.ui.text.FileMatch)1 FileSearchQuery (org.eclipse.search.internal.ui.text.FileSearchQuery)1 FileTextSearchScope (org.eclipse.search.ui.text.FileTextSearchScope)1