本文整理汇总了Java中org.eclipse.jdt.internal.corext.refactoring.RefactoringSearchEngine2.searchPattern方法的典型用法代码示例。如果您正苦于以下问题:Java RefactoringSearchEngine2.searchPattern方法的具体用法?Java RefactoringSearchEngine2.searchPattern怎么用?Java RefactoringSearchEngine2.searchPattern使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jdt.internal.corext.refactoring.RefactoringSearchEngine2
的用法示例。
在下文中一共展示了RefactoringSearchEngine2.searchPattern方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: findReferences
import org.eclipse.jdt.internal.corext.refactoring.RefactoringSearchEngine2; //导入方法依赖的package包/类
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();
}
示例2: hasNonMovedReferences
import org.eclipse.jdt.internal.corext.refactoring.RefactoringSearchEngine2; //导入方法依赖的package包/类
protected boolean hasNonMovedReferences(final IMember member, final IProgressMonitor monitor, final RefactoringStatus status) throws JavaModelException {
if (!fCachedMembersReferences.containsKey(member)) {
final RefactoringSearchEngine2 engine= new RefactoringSearchEngine2(SearchPattern.createPattern(member, IJavaSearchConstants.REFERENCES, SearchUtils.GENERICS_AGNOSTIC_MATCH_RULE));
engine.setFiltering(true, true);
engine.setStatus(status);
engine.setOwner(fOwner);
engine.setScope(RefactoringScopeFactory.create(member));
engine.searchPattern(new SubProgressMonitor(monitor, 1));
fCachedMembersReferences.put(member, engine.getResults());
}
final SearchResultGroup[] groups= (SearchResultGroup[]) fCachedMembersReferences.get(member);
if (groups.length == 0)
return false;
else if (groups.length > 1)
return true;
final ICompilationUnit unit= groups[0].getCompilationUnit();
if (!getDeclaringType().getCompilationUnit().equals(unit))
return true;
final SearchMatch[] matches= groups[0].getSearchResults();
for (int index= 0; index < matches.length; index++) {
if (!isMovedReference(matches[index]))
return true;
}
return false;
}
示例3: getReferencingElementsFromSameClass
import org.eclipse.jdt.internal.corext.refactoring.RefactoringSearchEngine2; //导入方法依赖的package包/类
private static IJavaElement[] getReferencingElementsFromSameClass(IMember member, IProgressMonitor pm, RefactoringStatus status) throws JavaModelException {
Assert.isNotNull(member);
final RefactoringSearchEngine2 engine= new RefactoringSearchEngine2(SearchPattern.createPattern(member, IJavaSearchConstants.REFERENCES, SearchUtils.GENERICS_AGNOSTIC_MATCH_RULE));
engine.setFiltering(true, true);
engine.setScope(SearchEngine.createJavaSearchScope(new IJavaElement[] { member.getDeclaringType() }));
engine.setStatus(status);
engine.searchPattern(new SubProgressMonitor(pm, 1));
SearchResultGroup[] groups= (SearchResultGroup[]) engine.getResults();
Set<IJavaElement> result= new HashSet<IJavaElement>(3);
for (int i= 0; i < groups.length; i++) {
SearchResultGroup group= groups[i];
SearchMatch[] results= group.getSearchResults();
for (int j= 0; j < results.length; j++) {
SearchMatch searchResult= results[j];
result.add(SearchUtils.getEnclosingJavaElement(searchResult));
}
}
return result.toArray(new IJavaElement[result.size()]);
}
示例4: createTypeReferencesMapping
import org.eclipse.jdt.internal.corext.refactoring.RefactoringSearchEngine2; //导入方法依赖的package包/类
private Map<ICompilationUnit, SearchMatch[]> createTypeReferencesMapping(IProgressMonitor pm, RefactoringStatus status) throws JavaModelException {
final RefactoringSearchEngine2 engine= new RefactoringSearchEngine2(SearchPattern.createPattern(fType, IJavaSearchConstants.ALL_OCCURRENCES, SearchUtils.GENERICS_AGNOSTIC_MATCH_RULE));
engine.setFiltering(true, true);
engine.setScope(RefactoringScopeFactory.create(fType));
engine.setStatus(status);
engine.searchPattern(new SubProgressMonitor(pm, 1));
final SearchResultGroup[] groups= (SearchResultGroup[]) engine.getResults();
Map<ICompilationUnit, SearchMatch[]> result= new HashMap<ICompilationUnit, SearchMatch[]>();
for (int i= 0; i < groups.length; i++) {
SearchResultGroup group= groups[i];
ICompilationUnit cu= group.getCompilationUnit();
if (cu == null)
continue;
result.put(cu, group.getSearchResults());
}
return result;
}
示例5: getReferencingCompilationUnits
import org.eclipse.jdt.internal.corext.refactoring.RefactoringSearchEngine2; //导入方法依赖的package包/类
/**
* Computes the compilation units referencing the subtype to replace.
*
* @param type
* the subtype
* @param monitor
* the progress monitor to use
* @param status
* the refactoring status
* @return the referenced compilation units (element type:
* <code><IJavaProject, Collection<SearchResultGroup>></code>)
* @throws JavaModelException
* if an error occurs
*/
protected final Map<IJavaProject, Set<SearchResultGroup>> getReferencingCompilationUnits(final IType type, final IProgressMonitor monitor, final RefactoringStatus status) throws JavaModelException {
try {
monitor.beginTask("", 100); //$NON-NLS-1$
monitor.setTaskName(RefactoringCoreMessages.SuperTypeRefactoringProcessor_creating);
final RefactoringSearchEngine2 engine= new RefactoringSearchEngine2();
engine.setOwner(fOwner);
engine.setFiltering(true, true);
engine.setStatus(status);
engine.setScope(RefactoringScopeFactory.create(type));
engine.setPattern(SearchPattern.createPattern(type, IJavaSearchConstants.REFERENCES, SearchUtils.GENERICS_AGNOSTIC_MATCH_RULE));
engine.searchPattern(new SubProgressMonitor(monitor, 100));
@SuppressWarnings("unchecked")
Map<IJavaProject, Set<SearchResultGroup>> result= (Map<IJavaProject, Set<SearchResultGroup>>) engine.getAffectedProjects();
return result;
} finally {
monitor.done();
}
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:33,代码来源:SuperTypeRefactoringProcessor.java
示例6: findNonPrimaryType
import org.eclipse.jdt.internal.corext.refactoring.RefactoringSearchEngine2; //导入方法依赖的package包/类
private IType findNonPrimaryType(String fullyQualifiedName, IProgressMonitor pm, RefactoringStatus status) throws JavaModelException {
SearchPattern p= SearchPattern.createPattern(fullyQualifiedName, IJavaSearchConstants.TYPE, IJavaSearchConstants.DECLARATIONS, SearchUtils.GENERICS_AGNOSTIC_MATCH_RULE);
final RefactoringSearchEngine2 engine= new RefactoringSearchEngine2(p);
engine.setFiltering(true, true);
engine.setScope(RefactoringScopeFactory.create(fCtorBinding.getJavaElement().getJavaProject()));
engine.setStatus(status);
engine.searchPattern(new SubProgressMonitor(pm, 1));
SearchResultGroup[] groups= (SearchResultGroup[]) engine.getResults();
if (groups.length != 0) {
for(int i= 0; i < groups.length; i++) {
SearchMatch[] matches= groups[i].getSearchResults();
for(int j= 0; j < matches.length; j++) {
if (matches[j].getAccuracy() == SearchMatch.A_ACCURATE)
return (IType) matches[j].getElement();
}
}
}
return null;
}
示例7: getReferencingCompilationUnits
import org.eclipse.jdt.internal.corext.refactoring.RefactoringSearchEngine2; //导入方法依赖的package包/类
/**
* Computes the compilation units referencing the subtype to replace.
*
* @param type
* the subtype
* @param monitor
* the progress monitor to use
* @param status
* the refactoring status
* @return the referenced compilation units (element type:
* <code><IJavaProject, Collection<SearchResultGroup>></code>)
* @throws JavaModelException
* if an error occurs
*/
protected final Map<IJavaProject, Set<SearchResultGroup>> getReferencingCompilationUnits(final IType type, final IProgressMonitor monitor, final RefactoringStatus status) throws JavaModelException {
try {
monitor.beginTask("", 100); //$NON-NLS-1$
monitor.setTaskName(RefactoringCoreMessages.SuperTypeRefactoringProcessor_creating);
final RefactoringSearchEngine2 engine= new RefactoringSearchEngine2();
engine.setOwner(fOwner);
engine.setFiltering(true, true);
engine.setStatus(status);
engine.setScope(RefactoringScopeFactory.create(type));
engine.setPattern(SearchPattern.createPattern(type, IJavaSearchConstants.REFERENCES, SearchUtils.GENERICS_AGNOSTIC_MATCH_RULE));
engine.searchPattern(new SubProgressMonitor(monitor, 100));
return (Map<IJavaProject, Set<SearchResultGroup>>) engine.getAffectedProjects();
} finally {
monitor.done();
}
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:31,代码来源:SuperTypeRefactoringProcessor.java
示例8: findReferences
import org.eclipse.jdt.internal.corext.refactoring.RefactoringSearchEngine2; //导入方法依赖的package包/类
/**
* Finds references to the specified member.
*
* @param member the member
* @param monitor the progress monitor to use
* @return the search result groups
* @throws JavaModelException if an error occurs during search
*/
private SearchResultGroup[] findReferences(final IMember member, final IProgressMonitor monitor)
throws JavaModelException {
final RefactoringSearchEngine2 engine =
new RefactoringSearchEngine2(
SearchPattern.createPattern(
member, IJavaSearchConstants.REFERENCES, SearchUtils.GENERICS_AGNOSTIC_MATCH_RULE));
engine.setOwner(fOwner);
engine.setFiltering(true, true);
engine.setScope(RefactoringScopeFactory.create(member));
engine.searchPattern(new SubProgressMonitor(monitor, 1));
return (SearchResultGroup[]) engine.getResults();
}
示例9: searchForCallsTo
import org.eclipse.jdt.internal.corext.refactoring.RefactoringSearchEngine2; //导入方法依赖的package包/类
/**
* Search for all calls to the given <code>IMethodBinding</code> in the project that contains the
* compilation unit <code>fCUHandle</code>.
*
* @param methodBinding
* @param pm
* @param status
* @return an array of <code>SearchResultGroup</code>'s that identify the search matches
* @throws JavaModelException
*/
private SearchResultGroup[] searchForCallsTo(
IMethodBinding methodBinding, IProgressMonitor pm, RefactoringStatus status)
throws JavaModelException {
IMethod method = (IMethod) methodBinding.getJavaElement();
final RefactoringSearchEngine2 engine =
new RefactoringSearchEngine2(createSearchPattern(method, methodBinding));
engine.setFiltering(true, true);
engine.setScope(createSearchScope(method, methodBinding));
engine.setStatus(status);
engine.searchPattern(new SubProgressMonitor(pm, 1));
return (SearchResultGroup[]) engine.getResults();
}
示例10: findNonPrimaryType
import org.eclipse.jdt.internal.corext.refactoring.RefactoringSearchEngine2; //导入方法依赖的package包/类
private IType findNonPrimaryType(
String fullyQualifiedName, IProgressMonitor pm, RefactoringStatus status)
throws JavaModelException {
SearchPattern p =
SearchPattern.createPattern(
fullyQualifiedName,
IJavaSearchConstants.TYPE,
IJavaSearchConstants.DECLARATIONS,
SearchUtils.GENERICS_AGNOSTIC_MATCH_RULE);
final RefactoringSearchEngine2 engine = new RefactoringSearchEngine2(p);
engine.setFiltering(true, true);
engine.setScope(RefactoringScopeFactory.create(fCtorBinding.getJavaElement().getJavaProject()));
engine.setStatus(status);
engine.searchPattern(new SubProgressMonitor(pm, 1));
SearchResultGroup[] groups = (SearchResultGroup[]) engine.getResults();
if (groups.length != 0) {
for (int i = 0; i < groups.length; i++) {
SearchMatch[] matches = groups[i].getSearchResults();
for (int j = 0; j < matches.length; j++) {
if (matches[j].getAccuracy() == SearchMatch.A_ACCURATE)
return (IType) matches[j].getElement();
}
}
}
return null;
}
示例11: getReferences
import org.eclipse.jdt.internal.corext.refactoring.RefactoringSearchEngine2; //导入方法依赖的package包/类
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();
// Assert.isTrue(results.length <= 1);
// just 1 file or none, but inaccurate matches can play bad here (see
// 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;
}
示例12: getReferences
import org.eclipse.jdt.internal.corext.refactoring.RefactoringSearchEngine2; //导入方法依赖的package包/类
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();
// Assert.isTrue(results.length <= 1);
// just 1 file or none, but inaccurate matches can play bad here (see
// 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;
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:35,代码来源:CreateCopyOfCompilationUnitChange.java
示例13: findReferences
import org.eclipse.jdt.internal.corext.refactoring.RefactoringSearchEngine2; //导入方法依赖的package包/类
/**
* Finds references to the specified member.
* @param member the member
* @param monitor the progress monitor to use
* @return the search result groups
* @throws JavaModelException if an error occurs during search
*/
private SearchResultGroup[] findReferences(final IMember member, final IProgressMonitor monitor) throws JavaModelException {
final RefactoringSearchEngine2 engine= new RefactoringSearchEngine2(SearchPattern.createPattern(member, IJavaSearchConstants.REFERENCES, SearchUtils.GENERICS_AGNOSTIC_MATCH_RULE));
engine.setOwner(fOwner);
engine.setFiltering(true, true);
engine.setScope(RefactoringScopeFactory.create(member));
engine.searchPattern(new SubProgressMonitor(monitor, 1));
return (SearchResultGroup[]) engine.getResults();
}
示例14: adjustVisibility
import org.eclipse.jdt.internal.corext.refactoring.RefactoringSearchEngine2; //导入方法依赖的package包/类
/**
* Adjusts the visibilities of the referenced and referencing elements.
*
* @param monitor the progress monitor to use
* @throws JavaModelException if an error occurs during search
*/
public final void adjustVisibility(final IProgressMonitor monitor) throws JavaModelException {
try {
monitor.beginTask("", 7); //$NON-NLS-1$
monitor.setTaskName(RefactoringCoreMessages.MemberVisibilityAdjustor_checking);
final RefactoringSearchEngine2 engine= new RefactoringSearchEngine2(SearchPattern.createPattern(fReferenced, IJavaSearchConstants.REFERENCES, SearchUtils.GENERICS_AGNOSTIC_MATCH_RULE));
engine.setScope(fScope);
engine.setStatus(fStatus);
engine.setOwner(fOwner);
if (fIncoming) {
// check calls to the referenced (moved) element, adjust element
// visibility if necessary.
engine.searchPattern(new SubProgressMonitor(monitor, 1));
adjustIncomingVisibility((SearchResultGroup[]) engine.getResults(), new SubProgressMonitor(monitor, 1));
engine.clearResults();
// If the moved element is a type: Adjust visibility of members
// of the type if they are accessed outside of the moved type
if (fReferenced instanceof IType) {
final IType type= (IType) fReferenced;
adjustMemberVisibility(type, new SubProgressMonitor(monitor, 1));
}
}
if (fOutgoing) {
/*
* Search for the types, fields, and methods which
* are called/acted upon inside the referenced element (the one
* to be moved) and assure that they are also visible from
* within the referencing element (the destination type (or
* package if move to new type)).
*/
engine.searchReferencedTypes(fReferenced, new SubProgressMonitor(monitor, 1, SubProgressMonitor.SUPPRESS_SUBTASK_LABEL));
engine.searchReferencedFields(fReferenced, new SubProgressMonitor(monitor, 1, SubProgressMonitor.SUPPRESS_SUBTASK_LABEL));
engine.searchReferencedMethods(fReferenced, new SubProgressMonitor(monitor, 1, SubProgressMonitor.SUPPRESS_SUBTASK_LABEL));
adjustOutgoingVisibility((SearchResultGroup[]) engine.getResults(), new SubProgressMonitor(monitor, 1));
}
} finally {
monitor.done();
}
}
示例15: findReferences
import org.eclipse.jdt.internal.corext.refactoring.RefactoringSearchEngine2; //导入方法依赖的package包/类
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();
}