protected IType[] getTypesReferencedInMovedMembers(final IProgressMonitor monitor) throws JavaModelException { if (fCachedReferencedTypes == null) { final IType[] types= ReferenceFinderUtil.getTypesReferencedIn(fMembersToMove, fOwner, monitor); final List<IType> result= new ArrayList<>(types.length); final List<IMember> members= Arrays.asList(fMembersToMove); for (int index= 0; index < types.length; index++) { if (!members.contains(types[index]) && !types[index].equals(getDeclaringType())) result.add(types[index]); } fCachedReferencedTypes= new IType[result.size()]; result.toArray(fCachedReferencedTypes); } return fCachedReferencedTypes; }
protected IType[] getTypesReferencedInMovedMembers(final IProgressMonitor monitor) throws JavaModelException { if (fCachedReferencedTypes == null) { final IType[] types= ReferenceFinderUtil.getTypesReferencedIn(fMembersToMove, fOwner, monitor); final List result= new ArrayList(types.length); final List members= Arrays.asList(fMembersToMove); for (int index= 0; index < types.length; index++) { if (!members.contains(types[index]) && !types[index].equals(getDeclaringType())) result.add(types[index]); } fCachedReferencedTypes= new IType[result.size()]; result.toArray(fCachedReferencedTypes); } return fCachedReferencedTypes; }
protected IType[] getTypesReferencedInMovedMembers(final IProgressMonitor monitor) throws JavaModelException { if (fCachedReferencedTypes == null) { final IType[] types= ReferenceFinderUtil.getTypesReferencedIn(fMembersToMove, fOwner, monitor); final List<IType> result= new ArrayList<>(types.length); final List<IMember> members= Arrays.asList(fMembersToMove); for (int index= 0; index < types.length; index++) { if (!members.contains(types[index]) && !types[index].equals(getDeclaringType())) result.add(types[index]); } fCachedReferencedTypes= new IType[result.size()]; result.toArray(fCachedReferencedTypes); } return fCachedReferencedTypes; }
public void checkPulledUp() { uncheckAll(); final HierarchyProcessor processor= getPullUpRefactoring().getPullUpProcessor(); fTreeViewer.setCheckedElements(processor.getMembersToMove()); final IType parent= processor.getDeclaringType(); fTreeViewer.setChecked(parent, true); checkAllParents(parent); }
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; }
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; }
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; }
protected RefactoringStatus checkDeclaringType(final IProgressMonitor monitor) throws JavaModelException { try { final IType type= getDeclaringType(); if (type.isEnum()) return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.HierarchyRefactoring_enum_members); if (type.isAnnotation()) return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.HierarchyRefactoring_annotation_members); if (type.isInterface()) return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.HierarchyRefactoring_interface_members); if (type.isBinary()) return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.HierarchyRefactoring_members_of_binary); if (type.isReadOnly()) return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.HierarchyRefactoring_members_of_read_only); return new RefactoringStatus(); } finally { if (monitor != null) monitor.done(); } }
protected RefactoringStatus checkDeclaringType(final IProgressMonitor monitor) throws JavaModelException { try { final IType type= getDeclaringType(); if (type.isEnum()) return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.HierarchyRefactoring_enum_members); if (type.isAnnotation()) return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.HierarchyRefactoring_annotation_members); if (type.isInterface()) return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.HierarchyRefactoring_interface_members); if (type.isBinary()) return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.HierarchyRefactoring_members_of_binary); if (type.isReadOnly()) return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.HierarchyRefactoring_members_of_read_only); return new RefactoringStatus(); } finally { if (monitor != null) monitor.done(); } }
protected RefactoringStatus checkDeclaringType(final IProgressMonitor monitor) throws JavaModelException { final IType type= getDeclaringType(); if (type.isEnum()) return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.HierarchyRefactoring_enum_members); if (type.isAnnotation()) return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.HierarchyRefactoring_annotation_members); if (type.isInterface()) return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.HierarchyRefactoring_interface_members); if (type.isBinary()) return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.HierarchyRefactoring_members_of_binary); if (type.isReadOnly()) return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.HierarchyRefactoring_members_of_read_only); return new RefactoringStatus(); }