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


Java SearchResultGroup类代码示例

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


SearchResultGroup类属于org.eclipse.jdt.internal.corext.refactoring包,在下文中一共展示了SearchResultGroup类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addReferenceUpdates

import org.eclipse.jdt.internal.corext.refactoring.SearchResultGroup; //导入依赖的package包/类
private void addReferenceUpdates(TextChangeManager manager, IProgressMonitor pm) {
  SearchResultGroup[] grouped = getOccurrences();
  for (int i = 0; i < grouped.length; i++) {
    SearchResultGroup group = grouped[i];
    SearchMatch[] results = group.getSearchResults();
    ICompilationUnit cu = group.getCompilationUnit();
    TextChange change = manager.get(cu);
    for (int j = 0; j < results.length; j++) {
      SearchMatch match = results[j];
      if (!(match instanceof MethodDeclarationMatch)) {
        ReplaceEdit replaceEdit = createReplaceEdit(match, cu);
        String editName = RefactoringCoreMessages.RenamePrivateMethodRefactoring_update;
        addTextEdit(change, editName, replaceEdit);
      }
    }
  }
  pm.done();
}
 
开发者ID:eclipse,项目名称:che,代码行数:19,代码来源:RenameNonVirtualMethodProcessor.java

示例2: getReferences

import org.eclipse.jdt.internal.corext.refactoring.SearchResultGroup; //导入依赖的package包/类
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;
}
 
开发者ID:eclipse,项目名称:che,代码行数:20,代码来源:RenameFieldProcessor.java

示例3: TextMatchUpdater

import org.eclipse.jdt.internal.corext.refactoring.SearchResultGroup; //导入依赖的package包/类
private TextMatchUpdater(
    TextChangeManager manager,
    IJavaSearchScope scope,
    String currentName,
    String currentQualifier,
    String newName,
    SearchResultGroup[] references,
    boolean onlyQualified) {
  Assert.isNotNull(manager);
  Assert.isNotNull(scope);
  Assert.isNotNull(references);
  fManager = manager;
  fScope = scope;
  fReferences = references;
  fOnlyQualified = onlyQualified;

  fNewName = newName;
  fCurrentNameLength = currentName.length();
  fScanner = new RefactoringScanner(currentName, currentQualifier);
}
 
开发者ID:eclipse,项目名称:che,代码行数:21,代码来源:TextMatchUpdater.java

示例4: perform

import org.eclipse.jdt.internal.corext.refactoring.SearchResultGroup; //导入依赖的package包/类
static void perform(
    IProgressMonitor pm,
    IJavaSearchScope scope,
    ITextUpdating processor,
    TextChangeManager manager,
    SearchResultGroup[] references)
    throws JavaModelException {
  new TextMatchUpdater(
          manager,
          scope,
          processor.getCurrentElementName(),
          processor.getCurrentElementQualifier(),
          processor.getNewElementName(),
          references,
          false)
      .updateTextMatches(pm);
}
 
开发者ID:eclipse,项目名称:che,代码行数:18,代码来源:TextMatchUpdater.java

示例5: analyzeRenameChanges

import org.eclipse.jdt.internal.corext.refactoring.SearchResultGroup; //导入依赖的package包/类
static RefactoringStatus analyzeRenameChanges(
    TextChangeManager manager,
    SearchResultGroup[] oldOccurrences,
    SearchResultGroup[] newOccurrences) {
  RefactoringStatus result = new RefactoringStatus();
  for (int i = 0; i < oldOccurrences.length; i++) {
    SearchResultGroup oldGroup = oldOccurrences[i];
    SearchMatch[] oldSearchResults = oldGroup.getSearchResults();
    ICompilationUnit cunit = oldGroup.getCompilationUnit();
    if (cunit == null) continue;
    for (int j = 0; j < oldSearchResults.length; j++) {
      SearchMatch oldSearchResult = oldSearchResults[j];
      if (!RenameAnalyzeUtil.existsInNewOccurrences(oldSearchResult, newOccurrences, manager)) {
        addShadowsError(cunit, oldSearchResult, result);
      }
    }
  }
  return result;
}
 
开发者ID:eclipse,项目名称:che,代码行数:20,代码来源:RenameAnalyzeUtil.java

示例6: addTypeImports

import org.eclipse.jdt.internal.corext.refactoring.SearchResultGroup; //导入依赖的package包/类
/**
 * Add new imports to types in <code>typeReferences</code> with package <code>fPackage</code>.
 *
 * @param typeReferences type references
 * @throws CoreException should not happen
 */
private void addTypeImports(SearchResultGroup typeReferences) throws CoreException {
  SearchMatch[] searchResults = typeReferences.getSearchResults();
  for (int i = 0; i < searchResults.length; i++) {
    SearchMatch result = searchResults[i];
    IJavaElement enclosingElement = SearchUtils.getEnclosingJavaElement(result);
    if (!(enclosingElement instanceof IImportDeclaration)) {
      String reference = getNormalizedTypeReference(result);
      if (!reference.startsWith(fPackage.getElementName())) {
        // is unqualified
        reference = cutOffInnerTypes(reference);
        ImportChange importChange =
            fImportsManager.getImportChange(typeReferences.getCompilationUnit());
        importChange.addImport(fPackage.getElementName() + '.' + reference);
      }
    }
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:24,代码来源:RenamePackageProcessor.java

示例7: updateTypeImports

import org.eclipse.jdt.internal.corext.refactoring.SearchResultGroup; //导入依赖的package包/类
/**
 * Add new imports to types in <code>typeReferences</code> with package <code>fNewElementName
 * </code> and remove old import with <code>fPackage</code>.
 *
 * @param typeReferences type references
 * @throws CoreException should not happen
 */
private void updateTypeImports(SearchResultGroup typeReferences) throws CoreException {
  SearchMatch[] searchResults = typeReferences.getSearchResults();
  for (int i = 0; i < searchResults.length; i++) {
    SearchMatch result = searchResults[i];
    IJavaElement enclosingElement = SearchUtils.getEnclosingJavaElement(result);
    if (enclosingElement instanceof IImportDeclaration) {
      IImportDeclaration importDeclaration = (IImportDeclaration) enclosingElement;
      updateImport(
          typeReferences.getCompilationUnit(),
          importDeclaration,
          getUpdatedImport(importDeclaration));
    } else {
      String reference = getNormalizedTypeReference(result);
      if (!reference.startsWith(fPackage.getElementName())) {
        reference = cutOffInnerTypes(reference);
        ImportChange importChange =
            fImportsManager.getImportChange(typeReferences.getCompilationUnit());
        importChange.removeImport(fPackage.getElementName() + '.' + reference);
        importChange.addImport(getNewPackageName() + '.' + reference);
      } // else: already found & updated with package reference search
    }
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:31,代码来源:RenamePackageProcessor.java

示例8: findReferences

import org.eclipse.jdt.internal.corext.refactoring.SearchResultGroup; //导入依赖的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

示例9: getReferences

import org.eclipse.jdt.internal.corext.refactoring.SearchResultGroup; //导入依赖的package包/类
private static SearchResultGroup[] getReferences(
    ICompilationUnit unit, IProgressMonitor pm, RefactoringStatus status) throws CoreException {
  final SearchPattern pattern =
      RefactoringSearchEngine.createOrPattern(unit.getTypes(), IJavaSearchConstants.REFERENCES);
  if (pattern != null) {
    String binaryRefsDescription =
        Messages.format(
            RefactoringCoreMessages.ReferencesInBinaryContext_ref_in_binaries_description,
            BasicElementLabels.getFileName(unit));
    ReferencesInBinaryContext binaryRefs = new ReferencesInBinaryContext(binaryRefsDescription);
    Collector requestor = new Collector(((IPackageFragment) unit.getParent()), binaryRefs);
    IJavaSearchScope scope = RefactoringScopeFactory.create(unit, true, false);

    SearchResultGroup[] result =
        RefactoringSearchEngine.search(
            pattern, scope, requestor, new SubProgressMonitor(pm, 1), status);
    binaryRefs.addErrorIfNecessary(status);
    return result;
  }
  return new SearchResultGroup[] {};
}
 
开发者ID:eclipse,项目名称:che,代码行数:22,代码来源:MoveCuUpdateCreator.java

示例10: hasNonMovedReferences

import org.eclipse.jdt.internal.corext.refactoring.SearchResultGroup; //导入依赖的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;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:26,代码来源:HierarchyProcessor.java

示例11: getReferencingElementsFromSameClass

import org.eclipse.jdt.internal.corext.refactoring.SearchResultGroup; //导入依赖的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

示例12: createTypeReferencesMapping

import org.eclipse.jdt.internal.corext.refactoring.SearchResultGroup; //导入依赖的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

示例13: removeUnrealReferences

import org.eclipse.jdt.internal.corext.refactoring.SearchResultGroup; //导入依赖的package包/类
private SearchResultGroup[] removeUnrealReferences(SearchResultGroup[] groups) {
	List<SearchResultGroup> result= new ArrayList<SearchResultGroup>(groups.length);
	for (int i= 0; i < groups.length; i++) {
		SearchResultGroup group= groups[i];
		ICompilationUnit cu= group.getCompilationUnit();
		if (cu == null)
			continue;
		CompilationUnit cuNode= new RefactoringASTParser(ASTProvider.SHARED_AST_LEVEL).parse(cu, false);
		SearchMatch[] allSearchResults= group.getSearchResults();
		List<SearchMatch> realConstructorReferences= new ArrayList<SearchMatch>(Arrays.asList(allSearchResults));
		for (int j= 0; j < allSearchResults.length; j++) {
			SearchMatch searchResult= allSearchResults[j];
			if (! isRealConstructorReferenceNode(ASTNodeSearchUtil.getAstNode(searchResult, cuNode)))
				realConstructorReferences.remove(searchResult);
		}
		if (! realConstructorReferences.isEmpty())
			result.add(new SearchResultGroup(group.getResource(), realConstructorReferences.toArray(new SearchMatch[realConstructorReferences.size()])));
	}
	return result.toArray(new SearchResultGroup[result.size()]);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:21,代码来源:ConstructorReferenceFinder.java

示例14: getImplicitConstructorReferencesInClassCreations

import org.eclipse.jdt.internal.corext.refactoring.SearchResultGroup; //导入依赖的package包/类
private List<SearchMatch> getImplicitConstructorReferencesInClassCreations(WorkingCopyOwner owner, IProgressMonitor pm, RefactoringStatus status) throws JavaModelException {
	//XXX workaround for jdt core bug 23112
	SearchPattern pattern= SearchPattern.createPattern(fType, IJavaSearchConstants.REFERENCES, SearchUtils.GENERICS_AGNOSTIC_MATCH_RULE);
	IJavaSearchScope scope= RefactoringScopeFactory.create(fType);
	SearchResultGroup[] refs= RefactoringSearchEngine.search(pattern, owner, scope, pm, status);
	List<SearchMatch> result= new ArrayList<SearchMatch>();
	for (int i= 0; i < refs.length; i++) {
		SearchResultGroup group= refs[i];
		ICompilationUnit cu= group.getCompilationUnit();
		if (cu == null)
			continue;
		CompilationUnit cuNode= new RefactoringASTParser(ASTProvider.SHARED_AST_LEVEL).parse(cu, false);
		SearchMatch[] results= group.getSearchResults();
		for (int j= 0; j < results.length; j++) {
			SearchMatch searchResult= results[j];
			ASTNode node= ASTNodeSearchUtil.getAstNode(searchResult, cuNode);
			if (isImplicitConstructorReferenceNodeInClassCreations(node))
				result.add(searchResult);
		}
	}
	return result;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:23,代码来源:ConstructorReferenceFinder.java

示例15: computeMethodReferences

import org.eclipse.jdt.internal.corext.refactoring.SearchResultGroup; //导入依赖的package包/类
/**
 * Searches for references to the original method.
 *
 * @param monitor
 *            the progress monitor to use
 * @param status
 *            the refactoring status to use
 * @return the array of search result groups
 * @throws CoreException
 *             if an error occurred during search
 */
protected SearchResultGroup[] computeMethodReferences(final IProgressMonitor monitor, final RefactoringStatus status) throws CoreException {
	Assert.isNotNull(monitor);
	Assert.isNotNull(status);
	try {
		monitor.beginTask("", 1); //$NON-NLS-1$
		monitor.setTaskName(RefactoringCoreMessages.MoveInstanceMethodProcessor_checking);
		SearchPattern pattern= SearchPattern.createPattern(fMethod, IJavaSearchConstants.REFERENCES, SearchUtils.GENERICS_AGNOSTIC_MATCH_RULE);
		IJavaSearchScope scope= RefactoringScopeFactory.create(fMethod, true, false);

		String binaryRefsDescription= Messages.format(RefactoringCoreMessages.ReferencesInBinaryContext_ref_in_binaries_description , BasicElementLabels.getJavaElementName(fMethod.getElementName()));
		ReferencesInBinaryContext binaryRefs= new ReferencesInBinaryContext(binaryRefsDescription);
		CollectingSearchRequestor requestor= new CollectingSearchRequestor(binaryRefs);
		SearchResultGroup[] result= RefactoringSearchEngine.search(pattern, scope, requestor, new SubProgressMonitor(monitor, 1), status);
		binaryRefs.addErrorIfNecessary(status);

		return result;
	} finally {
		monitor.done();
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:32,代码来源:MoveInstanceMethodProcessor.java


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