org.eclipse.jdt.core.search.SearchMatch Java Examples
The following examples show how to use
org.eclipse.jdt.core.search.SearchMatch.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RenameNonVirtualMethodProcessor.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 6 votes |
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(); }
Example #2
Source File: RippleMethodFinder2.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private IMethod[] getAllRippleMethods(IProgressMonitor pm, WorkingCopyOwner owner) throws CoreException { IMethod[] rippleMethods= findAllRippleMethods(pm, owner); if (fDeclarationToMatch == null) return rippleMethods; List<IMethod> rippleMethodsList= new ArrayList<IMethod>(Arrays.asList(rippleMethods)); for (Iterator<IMethod> iter= rippleMethodsList.iterator(); iter.hasNext(); ) { Object match= fDeclarationToMatch.get(iter.next()); if (match != null) { iter.remove(); fBinaryRefs.add((SearchMatch) match); } } fDeclarationToMatch= null; return rippleMethodsList.toArray(new IMethod[rippleMethodsList.size()]); }
Example #3
Source File: RenamePackageProcessor.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 6 votes |
/** * @param scope search scope * @param pm mrogress monitor * @return all package fragments in <code>scope</code> with same name as <code>fPackage</code>, excluding fPackage * @throws CoreException if search failed */ private IPackageFragment[] getNamesakePackages(IJavaSearchScope scope, IProgressMonitor pm) throws CoreException { SearchPattern pattern= SearchPattern.createPattern(fPackage.getElementName(), IJavaSearchConstants.PACKAGE, IJavaSearchConstants.DECLARATIONS, SearchPattern.R_EXACT_MATCH | SearchPattern.R_CASE_SENSITIVE); final HashSet<IPackageFragment> packageFragments= new HashSet<>(); SearchRequestor requestor= new SearchRequestor() { @Override public void acceptSearchMatch(SearchMatch match) throws CoreException { IJavaElement enclosingElement= SearchUtils.getEnclosingJavaElement(match); if (enclosingElement instanceof IPackageFragment) { IPackageFragment pack= (IPackageFragment) enclosingElement; if (! fPackage.equals(pack)) { packageFragments.add(pack); } } } }; new SearchEngine().search(pattern, SearchUtils.getDefaultSearchParticipants(), scope, requestor, pm); return packageFragments.toArray(new IPackageFragment[packageFragments.size()]); }
Example #4
Source File: SearchUtils.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 6 votes |
/** * @param match * the search match * @return the enclosing {@link ICompilationUnit} of the given match, or null * iff none */ public static ICompilationUnit getCompilationUnit(SearchMatch match) { IJavaElement enclosingElement = getEnclosingJavaElement(match); if (enclosingElement != null) { if (enclosingElement instanceof ICompilationUnit) { return (ICompilationUnit) enclosingElement; } ICompilationUnit cu = (ICompilationUnit) enclosingElement.getAncestor(IJavaElement.COMPILATION_UNIT); if (cu != null) { return cu; } } IJavaElement jElement = JavaCore.create(match.getResource()); if (jElement != null && jElement.exists() && jElement.getElementType() == IJavaElement.COMPILATION_UNIT) { return (ICompilationUnit) jElement; } return null; }
Example #5
Source File: RenamePackageProcessor.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 6 votes |
/** * 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); } } } }
Example #6
Source File: RenamePackageProcessor.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 6 votes |
/** * 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 } } }
Example #7
Source File: RenameAnalyzeUtil.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 6 votes |
private static void addReferenceShadowedError(ICompilationUnit cu, SearchMatch newMatch, String newElementName, RefactoringStatus result) { //Found a new match with no corresponding old match. //-> The new match is a reference which was pointing to another element, //but that other element has been shadowed //TODO: should not have to filter declarations: if (newMatch instanceof MethodDeclarationMatch || newMatch instanceof FieldDeclarationMatch) { return; } ISourceRange range= getOldSourceRange(newMatch); RefactoringStatusContext context= JavaStatusContext.create(cu, range); String message= Messages.format( RefactoringCoreMessages.RenameAnalyzeUtil_reference_shadowed, new String[] {BasicElementLabels.getFileName(cu), BasicElementLabels.getJavaElementName(newElementName)}); result.addError(message, context); }
Example #8
Source File: RenameTypeProcessor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private void addReferenceUpdates(TextChangeManager manager, IProgressMonitor pm) { pm.beginTask("", fReferences.length); //$NON-NLS-1$ for (int i= 0; i < fReferences.length; i++){ ICompilationUnit cu= fReferences[i].getCompilationUnit(); if (cu == null) continue; String name= RefactoringCoreMessages.RenameTypeRefactoring_update_reference; SearchMatch[] results= fReferences[i].getSearchResults(); for (int j= 0; j < results.length; j++){ SearchMatch match= results[j]; ReplaceEdit replaceEdit= new ReplaceEdit(match.getOffset(), match.getLength(), getNewElementName()); TextChangeCompatibility.addTextEdit(manager.get(cu), name, replaceEdit, CATEGORY_TYPE_RENAME); } pm.worked(1); } }
Example #9
Source File: RenameAnalyzeUtil.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 6 votes |
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; }
Example #10
Source File: RenameAnalyzeUtil.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
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; }
Example #11
Source File: ReferencesInBinaryStatusContextViewer.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
public void setInput(RefactoringStatusContext input) { ContentProvider contentProvider= new ContentProvider(); ReferencesInBinaryContext binariesContext= (ReferencesInBinaryContext) input; List<SearchMatch> matches= binariesContext.getMatches(); for (Iterator<SearchMatch> iter= matches.iterator(); iter.hasNext();) { SearchMatch match= iter.next(); Object element= match.getElement(); if (element != null) contentProvider.add(element); } fTreeViewer.setContentProvider(contentProvider); fTreeViewer.setInput(contentProvider); fLabel.setText(binariesContext.getDescription()); fInput= binariesContext; fButton.setEnabled(!matches.isEmpty()); }
Example #12
Source File: IntroduceFactoryRefactoring.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
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; }
Example #13
Source File: RippleMethodFinder.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 6 votes |
private void findAllDeclarations(IProgressMonitor monitor, WorkingCopyOwner owner) throws CoreException { fDeclarations = new ArrayList<>(); class MethodRequestor extends SearchRequestor { @Override public void acceptSearchMatch(SearchMatch match) throws CoreException { IMethod method = (IMethod) match.getElement(); boolean isBinary = method.isBinary(); if (!isBinary) { fDeclarations.add(method); } } } int limitTo = IJavaSearchConstants.DECLARATIONS | IJavaSearchConstants.IGNORE_DECLARING_TYPE | IJavaSearchConstants.IGNORE_RETURN_TYPE; int matchRule = SearchPattern.R_ERASURE_MATCH | SearchPattern.R_CASE_SENSITIVE; SearchPattern pattern = SearchPattern.createPattern(fMethod, limitTo, matchRule); MethodRequestor requestor = new MethodRequestor(); SearchEngine searchEngine = owner != null ? new SearchEngine(owner) : new SearchEngine(); searchEngine.search(pattern, new SearchParticipant[] { SearchEngine.getDefaultSearchParticipant() }, createSearchScope(), requestor, monitor); }
Example #14
Source File: RefactoringSearchEngine2.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 6 votes |
@Override public final void acceptSearchMatch(final SearchMatch match) throws CoreException { final SearchMatch accepted= fRequestor.acceptSearchMatch(match); if (accepted != null) { fCollectedMatches.add(accepted); final IResource resource= accepted.getResource(); if (!resource.equals(fLastResource)) { if (fBinary) { final IJavaElement element= JavaCore.create(resource); if (!(element instanceof ICompilationUnit)) { final IProject project= resource.getProject(); if (!fGrouping) { fStatus.addEntry(fSeverity, Messages.format(RefactoringCoreMessages.RefactoringSearchEngine_binary_match_ungrouped, BasicElementLabels.getResourceName(project)), null, null, RefactoringStatusEntry.NO_CODE); } else if (!fBinaryResources.contains(resource)) { fStatus.addEntry(fSeverity, Messages.format(RefactoringCoreMessages.RefactoringSearchEngine_binary_match_grouped, BasicElementLabels.getResourceName(project)), null, null, RefactoringStatusEntry.NO_CODE); } fBinaryResources.add(resource); } } if (fInaccurate && accepted.getAccuracy() == SearchMatch.A_INACCURATE && !fInaccurateMatches.contains(accepted)) { fStatus.addEntry(fSeverity, Messages.format(RefactoringCoreMessages.RefactoringSearchEngine_inaccurate_match, BasicElementLabels.getResourceName(resource)), null, null, RefactoringStatusEntry.NO_CODE); fInaccurateMatches.add(accepted); } } } }
Example #15
Source File: SearchResultGroup.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
@Override public String toString() { StringBuffer buf= new StringBuffer(fResouce.getFullPath().toString()); buf.append('\n'); for (int i= 0; i < fSearchMatches.size(); i++) { SearchMatch match= fSearchMatches.get(i); buf.append(" ").append(match.getOffset()).append(", ").append(match.getLength()); //$NON-NLS-1$//$NON-NLS-2$ buf.append(match.getAccuracy() == SearchMatch.A_ACCURATE ? "; acc" : "; inacc"); //$NON-NLS-1$//$NON-NLS-2$ if (match.isInsideDocComment()) buf.append("; inDoc"); //$NON-NLS-1$ if (match.getElement() instanceof IJavaElement) buf.append("; in: ").append(((IJavaElement) match.getElement()).getElementName()); //$NON-NLS-1$ buf.append('\n'); } return buf.toString(); }
Example #16
Source File: ConstructorReferenceFinder.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private static Collection<SearchMatch> getAllSuperConstructorInvocations(IType type) throws JavaModelException { IMethod[] constructors= JavaElementUtil.getAllConstructors(type); CompilationUnit cuNode= new RefactoringASTParser(ASTProvider.SHARED_AST_LEVEL).parse(type.getCompilationUnit(), false); List<SearchMatch> result= new ArrayList<SearchMatch>(constructors.length); for (int i= 0; i < constructors.length; i++) { ASTNode superCall= getSuperConstructorCallNode(constructors[i], cuNode); if (superCall != null) result.add(createSearchResult(superCall, constructors[i])); } return result; }
Example #17
Source File: RenameAnalyzeUtil.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 5 votes |
private static ISourceRange getOldSourceRange(SearchMatch newMatch) { // cannot transfom offset in preview to offset in original -> just show enclosing method IJavaElement newMatchElement= (IJavaElement) newMatch.getElement(); IJavaElement primaryElement= newMatchElement.getPrimaryElement(); ISourceRange range= null; if (primaryElement.exists() && primaryElement instanceof ISourceReference) { try { range= ((ISourceReference) primaryElement).getSourceRange(); } catch (JavaModelException e) { // can live without source range } } return range; }
Example #18
Source File: InlineConstantRefactoring.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
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(); }
Example #19
Source File: RenameAnalyzeUtil.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 5 votes |
private static TextChange getTextChange(SearchMatch searchResult, TextChangeManager manager) { ICompilationUnit cu= SearchUtils.getCompilationUnit(searchResult); if (cu == null) { return null; } return manager.get(cu); }
Example #20
Source File: RenameMethodProcessor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
protected final ReplaceEdit createReplaceEdit(SearchMatch searchResult, ICompilationUnit cu) { if (searchResult.isImplicit()) { // handle Annotation Element references, see bug 94062 StringBuffer sb= new StringBuffer(getNewElementName()); if (JavaCore.INSERT.equals(cu.getJavaProject().getOption(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_ASSIGNMENT_OPERATOR, true))) sb.append(' '); sb.append('='); if (JavaCore.INSERT.equals(cu.getJavaProject().getOption(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_ASSIGNMENT_OPERATOR, true))) sb.append(' '); return new ReplaceEdit(searchResult.getOffset(), 0, sb.toString()); } else { return new ReplaceEdit(searchResult.getOffset(), searchResult.getLength(), getNewElementName()); } }
Example #21
Source File: CuCollectingSearchRequestor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * This is an internal method. Do not call from subclasses! * Use {@link #collectMatch(SearchMatch)} instead. * @param match * @throws CoreException * @deprecated */ @Override public final void acceptSearchMatch(SearchMatch match) throws CoreException { if (filterMatch(match)) return; ICompilationUnit unit= SearchUtils.getCompilationUnit(match); if (unit != null) { acceptSearchMatch(unit, match); } }
Example #22
Source File: TypeSearchRequestor.java From JDeodorant with MIT License | 5 votes |
public void acceptSearchMatch(SearchMatch match) throws CoreException { Object element = match.getElement(); if (match.getElement() instanceof IType) { IType iType = (IType)element; if(!iType.isAnonymous()) { subTypes.add(iType); } } }
Example #23
Source File: RenameAnalyzeUtil.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 5 votes |
private static void addShadowsError(ICompilationUnit cu, SearchMatch oldMatch, RefactoringStatus result) { // Old match not found in new matches -> reference has been shadowed //TODO: should not have to filter declarations: if (oldMatch instanceof MethodDeclarationMatch || oldMatch instanceof FieldDeclarationMatch) { return; } ISourceRange range= new SourceRange(oldMatch.getOffset(), oldMatch.getLength()); RefactoringStatusContext context= JavaStatusContext.create(cu, range); String message= Messages.format(RefactoringCoreMessages.RenameAnalyzeUtil_shadows, BasicElementLabels.getFileName(cu)); result.addError(message, context); }
Example #24
Source File: RenameAnalyzeUtil.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * * @param change * @param oldMatches * @return Map <Integer updatedOffset, SearchMatch oldMatch> */ private static Map<Integer, SearchMatch> getUpdatedChangeOffsets(TextChange change, SearchMatch[] oldMatches) { Map<Integer, SearchMatch> updatedOffsets= new HashMap<Integer, SearchMatch>(); Map<Integer, Integer> oldToUpdatedOffsets= getEditChangeOffsetUpdates(change); for (int i= 0; i < oldMatches.length; i++) { SearchMatch oldMatch= oldMatches[i]; Integer updatedOffset= oldToUpdatedOffsets.get(new Integer(oldMatch.getOffset())); if (updatedOffset == null) updatedOffset= new Integer(-1); //match not updated updatedOffsets.put(updatedOffset, oldMatch); } return updatedOffsets; }
Example #25
Source File: ASTNodeSearchUtil.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public static ASTNode[] getAstNodes(SearchMatch[] searchResults, CompilationUnit cuNode) { List<ASTNode> result= new ArrayList<ASTNode>(searchResults.length); for (int i= 0; i < searchResults.length; i++) { ASTNode node= getAstNode(searchResults[i], cuNode); if (node != null) result.add(node); } return result.toArray(new ASTNode[result.size()]); }
Example #26
Source File: RenameFieldProcessor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private void addReferenceUpdates(IProgressMonitor pm) { pm.beginTask("", fReferences.length); //$NON-NLS-1$ String editName= RefactoringCoreMessages.RenameFieldRefactoring_Update_field_reference; for (int i= 0; i < fReferences.length; i++){ ICompilationUnit cu= fReferences[i].getCompilationUnit(); if (cu == null) continue; SearchMatch[] results= fReferences[i].getSearchResults(); for (int j= 0; j < results.length; j++){ addTextEdit(fChangeManager.get(cu), editName, createTextChange(results[j])); } pm.worked(1); } }
Example #27
Source File: CollectingSearchRequestor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * Returns whether the given match should be filtered out. * The default implementation filters out matches in binaries iff * {@link #CollectingSearchRequestor(ReferencesInBinaryContext)} has been called with a * non-<code>null</code> argument. Accurate binary matches are added to the {@link ReferencesInBinaryContext}. * * @param match the match to test * @return <code>true</code> iff the given match should <em>not</em> be collected * @throws CoreException */ public boolean filterMatch(SearchMatch match) throws CoreException { if (fBinaryRefs == null) return false; if (match.getAccuracy() == SearchMatch.A_ACCURATE && isBinaryElement(match.getElement())) { // binary classpaths are often incomplete -> avoiding false positives from inaccurate matches fBinaryRefs.add(match); return true; } return false; }
Example #28
Source File: ConstructorReferenceFinder.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private SearchResultGroup[] getImplicitConstructorReferences(IProgressMonitor pm, WorkingCopyOwner owner, RefactoringStatus status) throws JavaModelException { pm.beginTask("", 2); //$NON-NLS-1$ List<SearchMatch> searchMatches= new ArrayList<SearchMatch>(); searchMatches.addAll(getImplicitConstructorReferencesFromHierarchy(owner, new SubProgressMonitor(pm, 1))); searchMatches.addAll(getImplicitConstructorReferencesInClassCreations(owner, new SubProgressMonitor(pm, 1), status)); pm.done(); return RefactoringSearchEngine.groupByCu(searchMatches.toArray(new SearchMatch[searchMatches.size()]), status); }
Example #29
Source File: RenameFieldProcessor.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 5 votes |
private void addReferenceUpdates(IProgressMonitor pm) { pm.beginTask("", fReferences.length); //$NON-NLS-1$ String editName= RefactoringCoreMessages.RenameFieldRefactoring_Update_field_reference; for (int i= 0; i < fReferences.length; i++){ ICompilationUnit cu= fReferences[i].getCompilationUnit(); if (cu == null) { continue; } SearchMatch[] results= fReferences[i].getSearchResults(); for (int j= 0; j < results.length; j++){ addTextEdit(fChangeManager.get(cu), editName, createTextChange(results[j])); } pm.worked(1); } }
Example #30
Source File: RenameAnalyzeUtil.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private static void addShadowsError(ICompilationUnit cu, SearchMatch oldMatch, RefactoringStatus result) { // Old match not found in new matches -> reference has been shadowed //TODO: should not have to filter declarations: if (oldMatch instanceof MethodDeclarationMatch || oldMatch instanceof FieldDeclarationMatch) return; ISourceRange range= new SourceRange(oldMatch.getOffset(), oldMatch.getLength()); RefactoringStatusContext context= JavaStatusContext.create(cu, range); String message= Messages.format(RefactoringCoreMessages.RenameAnalyzeUtil_shadows, BasicElementLabels.getFileName(cu)); result.addError(message, context); }