use of org.eclipse.jdt.internal.corext.refactoring.IRefactoringSearchRequestor in project che by eclipse.
the class CreateCopyOfCompilationUnitChange method getReferences.
private static SearchResultGroup getReferences(final ICompilationUnit copy, IProgressMonitor monitor) throws JavaModelException {
final ICompilationUnit[] copies = new ICompilationUnit[] { copy };
IJavaSearchScope scope = SearchEngine.createJavaSearchScope(copies);
final IType type = copy.findPrimaryType();
if (type == null)
return null;
SearchPattern pattern = createSearchPattern(type);
final RefactoringSearchEngine2 engine = new RefactoringSearchEngine2(pattern);
engine.setScope(scope);
engine.setWorkingCopies(copies);
engine.setRequestor(new IRefactoringSearchRequestor() {
TypeOccurrenceCollector fTypeOccurrenceCollector = new TypeOccurrenceCollector(type);
public SearchMatch acceptSearchMatch(SearchMatch match) {
try {
return fTypeOccurrenceCollector.acceptSearchMatch2(copy, match);
} catch (CoreException e) {
JavaPlugin.log(e);
return null;
}
}
});
engine.searchPattern(monitor);
final Object[] results = engine.getResults();
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=106127)
for (int index = 0; index < results.length; index++) {
SearchResultGroup group = (SearchResultGroup) results[index];
if (group.getCompilationUnit().equals(copy))
return group;
}
return null;
}
use of org.eclipse.jdt.internal.corext.refactoring.IRefactoringSearchRequestor in project che by eclipse.
the class InlineConstantRefactoring method findReferences.
private SearchResultGroup[] findReferences(IProgressMonitor pm, RefactoringStatus status) throws JavaModelException {
final RefactoringSearchEngine2 engine = new RefactoringSearchEngine2(SearchPattern.createPattern(fField, IJavaSearchConstants.REFERENCES));
engine.setFiltering(true, true);
engine.setScope(RefactoringScopeFactory.create(fField));
engine.setStatus(status);
engine.setRequestor(new IRefactoringSearchRequestor() {
public SearchMatch acceptSearchMatch(SearchMatch match) {
return match.isInsideDocComment() ? null : match;
}
});
engine.searchPattern(new SubProgressMonitor(pm, 1));
return (SearchResultGroup[]) engine.getResults();
}
Aggregations