本文整理汇总了Java中org.eclipse.jdt.internal.corext.refactoring.SearchResultGroup.getSearchResults方法的典型用法代码示例。如果您正苦于以下问题:Java SearchResultGroup.getSearchResults方法的具体用法?Java SearchResultGroup.getSearchResults怎么用?Java SearchResultGroup.getSearchResults使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jdt.internal.corext.refactoring.SearchResultGroup
的用法示例。
在下文中一共展示了SearchResultGroup.getSearchResults方法的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();
}
示例2: 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;
}
示例3: 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);
}
}
}
}
示例4: 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
}
}
}
示例5: 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()]);
}
示例6: 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()]);
}
示例7: 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;
}
示例8: 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:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:26,代码来源:RenamePackageProcessor.java
示例9: existsInNewOccurrences
import org.eclipse.jdt.internal.corext.refactoring.SearchResultGroup; //导入方法依赖的package包/类
private static boolean existsInNewOccurrences(SearchMatch searchResult, SearchResultGroup[] newOccurrences, TextChangeManager manager) {
SearchResultGroup newGroup= findOccurrenceGroup(searchResult.getResource(), newOccurrences);
if (newGroup == null)
return false;
IRegion oldEditRange= getCorrespondingEditChangeRange(searchResult, manager);
if (oldEditRange == null)
return false;
SearchMatch[] newSearchResults= newGroup.getSearchResults();
int oldRangeOffset = oldEditRange.getOffset();
for (int i= 0; i < newSearchResults.length; i++) {
if (newSearchResults[i].getOffset() == oldRangeOffset)
return true;
}
return false;
}
示例10: 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);
}
}
}
}
示例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[i];
result.add(SearchUtils.getEnclosingJavaElement(searchResult));
}
}
return result.toArray(new IJavaElement[result.size()]);
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:20,代码来源:PushDownRefactoringProcessor.java
示例12: 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:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:19,代码来源:RenameNonVirtualMethodProcessor.java
示例13: adjustOutgoingVisibility
import org.eclipse.jdt.internal.corext.refactoring.SearchResultGroup; //导入方法依赖的package包/类
/**
* Adjusts the visibilities of the outgoing references from the member represented by the
* specified search result groups.
*
* @param groups the search result groups representing the references
* @param monitor the progress monitor to us
* @throws JavaModelException if the visibility could not be determined
*/
private void adjustOutgoingVisibility(
final SearchResultGroup[] groups, final IProgressMonitor monitor) throws JavaModelException {
try {
monitor.beginTask("", groups.length); // $NON-NLS-1$
monitor.setTaskName(RefactoringCoreMessages.MemberVisibilityAdjustor_checking);
IJavaElement element = null;
SearchMatch[] matches = null;
SearchResultGroup group = null;
for (int index = 0; index < groups.length; index++) {
group = groups[index];
element = JavaCore.create(group.getResource());
if (element instanceof ICompilationUnit) {
matches = group.getSearchResults();
for (int offset = 0; offset < matches.length; offset++)
adjustOutgoingVisibility(matches[offset], new SubProgressMonitor(monitor, 1));
} // else if (element != null)
// fStatus.merge(RefactoringStatus.createStatus(fFailureSeverity,
// RefactoringCoreMessages.getFormattedString
// ("MemberVisibilityAdjustor.binary.outgoing.project", new String[] {
// element.getJavaProject().getElementName(), getLabel
// (fReferenced)}), null, null, RefactoringStatusEntry.NO_CODE, null)); //$NON-NLS-1$
// else if (group.getResource() != null)
// fStatus.merge(RefactoringStatus.createStatus(fFailureSeverity,
// RefactoringCoreMessages.getFormattedString
// ("MemberVisibilityAdjustor.binary.outgoing.resource", new String[] {
// group.getResource().getName(), getLabel
// (fReferenced)}), null, null, RefactoringStatusEntry.NO_CODE, null)); //$NON-NLS-1$
// TW: enable when bug 78387 is fixed
monitor.worked(1);
}
} finally {
monitor.done();
}
}
示例14: removeReferences
import org.eclipse.jdt.internal.corext.refactoring.SearchResultGroup; //导入方法依赖的package包/类
private void removeReferences(Set<TextMatch> matches, SearchResultGroup group) {
SearchMatch[] searchResults = group.getSearchResults();
for (int r = 0; r < searchResults.length; r++) {
// int start= searchResults[r].getStart(); // doesn't work for pack.ReferencedType
int unqualifiedStart =
searchResults[r].getOffset() + searchResults[r].getLength() - fCurrentNameLength;
for (Iterator<TextMatch> iter = matches.iterator(); iter.hasNext(); ) {
TextMatch element = iter.next();
if (element.getStartPosition() == unqualifiedStart) iter.remove();
}
}
}
示例15: existsInNewOccurrences
import org.eclipse.jdt.internal.corext.refactoring.SearchResultGroup; //导入方法依赖的package包/类
private static boolean existsInNewOccurrences(
SearchMatch searchResult, SearchResultGroup[] newOccurrences, TextChangeManager manager) {
SearchResultGroup newGroup = findOccurrenceGroup(searchResult.getResource(), newOccurrences);
if (newGroup == null) return false;
IRegion oldEditRange = getCorrespondingEditChangeRange(searchResult, manager);
if (oldEditRange == null) return false;
SearchMatch[] newSearchResults = newGroup.getSearchResults();
int oldRangeOffset = oldEditRange.getOffset();
for (int i = 0; i < newSearchResults.length; i++) {
if (newSearchResults[i].getOffset() == oldRangeOffset) return true;
}
return false;
}