Search in sources :

Example 1 with CuCollectingSearchRequestor

use of org.eclipse.jdt.internal.corext.refactoring.CuCollectingSearchRequestor in project che by eclipse.

the class RenameFieldProcessor method getReferences.

private SearchResultGroup[] getReferences(IProgressMonitor pm, RefactoringStatus status) throws CoreException {
    String binaryRefsDescription = Messages.format(RefactoringCoreMessages.ReferencesInBinaryContext_ref_in_binaries_description, BasicElementLabels.getJavaElementName(getCurrentElementName()));
    ReferencesInBinaryContext binaryRefs = new ReferencesInBinaryContext(binaryRefsDescription);
    SearchResultGroup[] result = RefactoringSearchEngine.search(createSearchPattern(), createRefactoringScope(), new CuCollectingSearchRequestor(binaryRefs), pm, status);
    binaryRefs.addErrorIfNecessary(status);
    return result;
}
Also used : ReferencesInBinaryContext(org.eclipse.jdt.internal.corext.refactoring.base.ReferencesInBinaryContext) CuCollectingSearchRequestor(org.eclipse.jdt.internal.corext.refactoring.CuCollectingSearchRequestor) SearchResultGroup(org.eclipse.jdt.internal.corext.refactoring.SearchResultGroup)

Example 2 with CuCollectingSearchRequestor

use of org.eclipse.jdt.internal.corext.refactoring.CuCollectingSearchRequestor in project che by eclipse.

the class ChangeSignatureProcessor method findOccurrences.

private SearchResultGroup[] findOccurrences(IProgressMonitor pm, ReferencesInBinaryContext binaryRefs, RefactoringStatus status) throws JavaModelException {
    final boolean isConstructor = fMethod.isConstructor();
    CuCollectingSearchRequestor requestor = new CuCollectingSearchRequestor(binaryRefs) {

        @Override
        protected void acceptSearchMatch(ICompilationUnit unit, SearchMatch match) throws CoreException {
            // workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=27236 :
            if (isConstructor && match instanceof MethodReferenceMatch) {
                MethodReferenceMatch mrm = (MethodReferenceMatch) match;
                if (mrm.isSynthetic()) {
                    return;
                }
            }
            collectMatch(match);
        }
    };
    SearchPattern pattern;
    if (isConstructor) {
        //			// workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=226151 : don't find binary refs for constructors for now
        //			return ConstructorReferenceFinder.getConstructorOccurrences(fMethod, pm, status);
        //			SearchPattern occPattern= SearchPattern.createPattern(fMethod, IJavaSearchConstants.ALL_OCCURRENCES, SearchUtils.GENERICS_AGNOSTIC_MATCH_RULE);
        SearchPattern declPattern = SearchPattern.createPattern(fMethod, IJavaSearchConstants.DECLARATIONS, SearchUtils.GENERICS_AGNOSTIC_MATCH_RULE);
        SearchPattern refPattern = SearchPattern.createPattern(fMethod, IJavaSearchConstants.REFERENCES, SearchUtils.GENERICS_AGNOSTIC_MATCH_RULE);
        // workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=226151 : do two searches
        try {
            SearchEngine engine = new SearchEngine();
            engine.search(declPattern, SearchUtils.getDefaultSearchParticipants(), createRefactoringScope(), requestor, new NullProgressMonitor());
            engine.search(refPattern, SearchUtils.getDefaultSearchParticipants(), createRefactoringScope(), requestor, pm);
        } catch (CoreException e) {
            throw new JavaModelException(e);
        }
        return RefactoringSearchEngine.groupByCu(requestor.getResults(), status);
    } else {
        pattern = RefactoringSearchEngine.createOrPattern(fRippleMethods, IJavaSearchConstants.ALL_OCCURRENCES);
    }
    return RefactoringSearchEngine.search(pattern, createRefactoringScope(), requestor, pm, status);
}
Also used : ICompilationUnit(org.eclipse.jdt.core.ICompilationUnit) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) SearchMatch(org.eclipse.jdt.core.search.SearchMatch) JavaModelException(org.eclipse.jdt.core.JavaModelException) MethodReferenceMatch(org.eclipse.jdt.core.search.MethodReferenceMatch) SearchEngine(org.eclipse.jdt.core.search.SearchEngine) RefactoringSearchEngine(org.eclipse.jdt.internal.corext.refactoring.RefactoringSearchEngine) CuCollectingSearchRequestor(org.eclipse.jdt.internal.corext.refactoring.CuCollectingSearchRequestor) CoreException(org.eclipse.core.runtime.CoreException) SearchPattern(org.eclipse.jdt.core.search.SearchPattern)

Aggregations

CuCollectingSearchRequestor (org.eclipse.jdt.internal.corext.refactoring.CuCollectingSearchRequestor)2 CoreException (org.eclipse.core.runtime.CoreException)1 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)1 ICompilationUnit (org.eclipse.jdt.core.ICompilationUnit)1 JavaModelException (org.eclipse.jdt.core.JavaModelException)1 MethodReferenceMatch (org.eclipse.jdt.core.search.MethodReferenceMatch)1 SearchEngine (org.eclipse.jdt.core.search.SearchEngine)1 SearchMatch (org.eclipse.jdt.core.search.SearchMatch)1 SearchPattern (org.eclipse.jdt.core.search.SearchPattern)1 RefactoringSearchEngine (org.eclipse.jdt.internal.corext.refactoring.RefactoringSearchEngine)1 SearchResultGroup (org.eclipse.jdt.internal.corext.refactoring.SearchResultGroup)1 ReferencesInBinaryContext (org.eclipse.jdt.internal.corext.refactoring.base.ReferencesInBinaryContext)1