当前位置: 首页>>代码示例>>Java>>正文


Java RefactoringSearchEngine2.getResults方法代码示例

本文整理汇总了Java中org.eclipse.jdt.internal.corext.refactoring.RefactoringSearchEngine2.getResults方法的典型用法代码示例。如果您正苦于以下问题:Java RefactoringSearchEngine2.getResults方法的具体用法?Java RefactoringSearchEngine2.getResults怎么用?Java RefactoringSearchEngine2.getResults使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.jdt.internal.corext.refactoring.RefactoringSearchEngine2的用法示例。


在下文中一共展示了RefactoringSearchEngine2.getResults方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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();
}
 
开发者ID:eclipse,项目名称:che,代码行数:18,代码来源:InlineConstantRefactoring.java

示例2: 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()]);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:20,代码来源:PushDownRefactoringProcessor.java

示例3: 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;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:18,代码来源:MoveInnerToTopRefactoring.java

示例4: 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;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:23,代码来源:IntroduceFactoryRefactoring.java

示例5: 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[i];
			result.add(SearchUtils.getEnclosingJavaElement(searchResult));
		}
	}
	return result.toArray(new IJavaElement[result.size()]);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:20,代码来源:PushDownRefactoringProcessor.java

示例6: 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();
}
 
开发者ID:eclipse,项目名称:che,代码行数:21,代码来源:MemberVisibilityAdjustor.java

示例7: 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();
}
 
开发者ID:eclipse,项目名称:che,代码行数:23,代码来源:IntroduceFactoryRefactoring.java

示例8: 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;
}
 
开发者ID:eclipse,项目名称:che,代码行数:30,代码来源:IntroduceFactoryRefactoring.java

示例9: 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:eclipse,项目名称:che,代码行数:36,代码来源:CreateCopyOfCompilationUnitChange.java

示例10: getReferences

import org.eclipse.jdt.internal.corext.refactoring.RefactoringSearchEngine2; //导入方法依赖的package包/类
private static SearchResultGroup[] getReferences(IMember member, IProgressMonitor monitor, RefactoringStatus status) throws JavaModelException {
	final RefactoringSearchEngine2 engine= new RefactoringSearchEngine2(SearchPattern.createPattern(member, IJavaSearchConstants.REFERENCES, SearchUtils.GENERICS_AGNOSTIC_MATCH_RULE));
	engine.setFiltering(true, true);
	engine.setScope(RefactoringScopeFactory.create(member));
	engine.setStatus(status);
	engine.searchPattern(new SubProgressMonitor(monitor, 1));
	return (SearchResultGroup[]) engine.getResults();
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:9,代码来源:MoveStaticMembersProcessor.java

示例11: 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();
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:16,代码来源:MemberVisibilityAdjustor.java

示例12: 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();
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:14,代码来源:InlineConstantRefactoring.java

示例13: 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();
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:19,代码来源:IntroduceFactoryRefactoring.java

示例14: 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,代码行数:35,代码来源:CreateCopyOfCompilationUnitChange.java


注:本文中的org.eclipse.jdt.internal.corext.refactoring.RefactoringSearchEngine2.getResults方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。