/** * @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) { FileTextSearchScope scope = FileTextSearchScope.newSearchScope( new IResource[] {file}, new String[] {"*"}, true); // $NON-NLS-1$ Pattern searchPattern = this.getSearchPattern(); boolean isFileSearchOnly = searchPattern.pattern().length() == 0; TextSearchResultCollector collector = new TextSearchResultCollector(result, isFileSearchOnly, true); return new AptanaTextEngine().search(scope, collector, searchPattern, monitor); }
private static boolean haveGroupsDependency(ICompilationUnit[] units) { List resources = new ArrayList(); for (int i = 0; i < units.length; i++) { try { resources.add(units[i].getCorrespondingResource()); } catch (JavaModelException jmex) {; } } IResource[] scopeResources = (IResource[]) resources.toArray(new IResource[resources.size()]); ISearchQuery query = new FileSearchQuery( "@Test\\(.*\\s*dependsOnGroups\\s*=.*", true /*regexp*/, true /*casesensitive*/, FileTextSearchScope.newSearchScope(scopeResources, new String[] {"*.java"}, false)); query.run(new NullProgressMonitor()); FileSearchResult result = (FileSearchResult) query.getSearchResult(); Object[] elements = result.getElements(); return elements != null && elements.length > 0; }
/** * Uses the Eclipse search support to look for @Test annotation and decide if the compliance level * should be set to JDK or JAVADOC. */ private static String getQuickComplianceLevel(IType[] types) { List resources = new ArrayList(); for (int i = 0; i < types.length; i++) { try { resources.add(types[i].getCompilationUnit().getCorrespondingResource()); } catch (JavaModelException jmex) {; } } IResource[] scopeResources = (IResource[]) resources.toArray(new IResource[resources.size()]); ISearchQuery query = new FileSearchQuery( "@(Test|Before|After|Factory)(\\(.+)?", true /*regexp*/, true /*casesensitive*/, FileTextSearchScope.newSearchScope(scopeResources, getJavaLikeExtensions(), false)); query.run(new NullProgressMonitor()); FileSearchResult result = (FileSearchResult) query.getSearchResult(); Object[] elements = result.getElements(); return elements != null && elements.length > 0 ? TestNG.JDK_ANNOTATION_TYPE : TestNG.JAVADOC_ANNOTATION_TYPE; }
/* (non-Javadoc) * @see org.eclipse.search.ui.text.TextSearchQueryProvider#createQuery(java.lang.String, org.eclipse.ui.IWorkingSet[]) */ public ISearchQuery createQuery(String selectedText, IWorkingSet[] ws) { FileTextSearchScope scope = FileTextSearchScope.newSearchScope(ws, getPreviousFileNamePatterns(), false); return new FileSearchQuery(selectedText, false, true, scope); }
/* (non-Javadoc) * @see org.eclipse.search.ui.text.TextSearchQueryProvider#createQuery(java.lang.String, org.eclipse.core.resources.IResource[]) */ public ISearchQuery createQuery(String selectedText, IResource[] resources) { FileTextSearchScope scope = FileTextSearchScope.newSearchScope(resources, getPreviousFileNamePatterns(), false); return new FileSearchQuery(selectedText, false, true, scope); }
/* (non-Javadoc) * @see org.eclipse.search.ui.text.TextSearchQueryProvider#createQuery(java.lang.String) */ public ISearchQuery createQuery(String searchForString) { FileTextSearchScope scope = FileTextSearchScope.newWorkspaceScope(getPreviousFileNamePatterns(), false); return new FileSearchQuery(searchForString, false, true, scope); }