Java Code Examples for org.eclipse.ltk.core.refactoring.CompositeChange#markAsSynthetic()
The following examples show how to use
org.eclipse.ltk.core.refactoring.CompositeChange#markAsSynthetic() .
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: QualifiedNameSearchResult.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
public Change getSingleChange(IFile[] alreadyTouchedFiles) { Collection<TextChange> values= fChanges.values(); if (values.size() == 0) return null; CompositeChange result= new CompositeChange(RefactoringCoreMessages.QualifiedNameSearchResult_change_name); result.markAsSynthetic(); List<IFile> files= Arrays.asList(alreadyTouchedFiles); for (Iterator<TextChange> iter= values.iterator(); iter.hasNext();) { TextFileChange change= (TextFileChange)iter.next(); if (!files.contains(change.getFile())) { result.add(change); } } return result; }
Example 2
Source File: ReorgPolicyFactory.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 6 votes |
@Override public Change createChange(IProgressMonitor pm, INewNameQueries copyQueries) { NewNameProposer nameProposer= new NewNameProposer(); IPackageFragmentRoot[] roots= getPackageFragmentRoots(); pm.beginTask("", roots.length); //$NON-NLS-1$ CompositeChange composite= new DynamicValidationStateChange(RefactoringCoreMessages.ReorgPolicy_copy_source_folder); composite.markAsSynthetic(); IJavaProject destination= getDestinationJavaProject(); for (int i= 0; i < roots.length; i++) { if (destination == null) { composite.add(createChange(roots[i], (IContainer) getResourceDestination(), nameProposer, copyQueries)); } else { composite.add(createChange(roots[i], destination, nameProposer, copyQueries)); } pm.worked(1); } pm.done(); return composite; }
Example 3
Source File: ReorgPolicyFactory.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 6 votes |
@Override public Change createChange(IProgressMonitor pm, INewNameQueries newNameQueries) throws JavaModelException { NewNameProposer nameProposer= new NewNameProposer(); IPackageFragment[] fragments= getPackages(); pm.beginTask("", fragments.length); //$NON-NLS-1$ CompositeChange composite= new DynamicValidationStateChange(RefactoringCoreMessages.ReorgPolicy_copy_package); composite.markAsSynthetic(); IPackageFragmentRoot root= getDestinationAsPackageFragmentRoot(); for (int i= 0; i < fragments.length; i++) { if (root == null) { composite.add(createChange(fragments[i], (IContainer) getResourceDestination(), nameProposer, newNameQueries)); } else { composite.add(createChange(fragments[i], root, nameProposer, newNameQueries)); } pm.worked(1); } pm.done(); return composite; }
Example 4
Source File: ReorgPolicyFactory.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
public Change createChange(IProgressMonitor pm) throws JavaModelException { IPackageFragment[] fragments= getPackages(); pm.beginTask("", fragments.length); //$NON-NLS-1$ CompositeChange result= new DynamicValidationStateChange(RefactoringCoreMessages.ReorgPolicy_move_package); result.markAsSynthetic(); IPackageFragmentRoot root= getDestinationAsPackageFragmentRoot(); for (int i= 0; i < fragments.length; i++) { if (root == null) { result.add(createChange(fragments[i], (IContainer)getResourceDestination())); } else { result.add(createChange(fragments[i], root)); } pm.worked(1); if (pm.isCanceled()) throw new OperationCanceledException(); } pm.done(); return result; }
Example 5
Source File: ReorgPolicyFactory.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
public Change createChange(IProgressMonitor pm) throws JavaModelException { IPackageFragmentRoot[] roots= getPackageFragmentRoots(); pm.beginTask("", roots.length); //$NON-NLS-1$ CompositeChange composite= new DynamicValidationStateChange(RefactoringCoreMessages.ReorgPolicy_move_source_folder); composite.markAsSynthetic(); IJavaProject destination= getDestinationJavaProject(); for (int i= 0; i < roots.length; i++) { if (destination == null) { composite.add(new MovePackageFragmentRootChange(roots[i], (IContainer) getResourceDestination(), null)); } else { composite.add(createChange(roots[i], destination)); } pm.worked(1); } pm.done(); return composite; }
Example 6
Source File: ReorgPolicyFactory.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 6 votes |
@Override public Change createChange(IProgressMonitor pm) throws JavaModelException { IPackageFragmentRoot[] roots= getPackageFragmentRoots(); pm.beginTask("", roots.length); //$NON-NLS-1$ CompositeChange composite= new DynamicValidationStateChange(RefactoringCoreMessages.ReorgPolicy_move_source_folder); composite.markAsSynthetic(); IJavaProject destination= getDestinationJavaProject(); for (int i= 0; i < roots.length; i++) { if (destination == null) { composite.add(new MovePackageFragmentRootChange(roots[i], (IContainer) getResourceDestination(), null)); } else { composite.add(createChange(roots[i], destination)); } pm.worked(1); } pm.done(); return composite; }
Example 7
Source File: ReorgPolicyFactory.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 6 votes |
@Override public Change createChange(IProgressMonitor pm) throws JavaModelException { IPackageFragment[] fragments= getPackages(); pm.beginTask("", fragments.length); //$NON-NLS-1$ CompositeChange result= new DynamicValidationStateChange(RefactoringCoreMessages.ReorgPolicy_move_package); result.markAsSynthetic(); IPackageFragmentRoot root= getDestinationAsPackageFragmentRoot(); for (int i= 0; i < fragments.length; i++) { if (root == null) { result.add(createChange(fragments[i], (IContainer)getResourceDestination())); } else { result.add(createChange(fragments[i], root)); } pm.worked(1); if (pm.isCanceled()) { throw new OperationCanceledException(); } } pm.done(); return result; }
Example 8
Source File: QualifiedNameSearchResult.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 6 votes |
public Change getSingleChange(IFile[] alreadyTouchedFiles) { Collection<TextChange> values= fChanges.values(); if (values.size() == 0) { return null; } CompositeChange result= new CompositeChange(RefactoringCoreMessages.QualifiedNameSearchResult_change_name); result.markAsSynthetic(); List<IFile> files= Arrays.asList(alreadyTouchedFiles); for (Iterator<TextChange> iter= values.iterator(); iter.hasNext();) { TextFileChange change= (TextFileChange)iter.next(); if (!files.contains(change.getFile())) { result.add(change); } } return result; }
Example 9
Source File: ReorgPolicyFactory.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private Change createSimpleMoveChange(IProgressMonitor pm) { CompositeChange result= new DynamicValidationStateChange(RefactoringCoreMessages.ReorgPolicy_move); result.markAsSynthetic(); IFile[] files= getFiles(); IFolder[] folders= getFolders(); ICompilationUnit[] cus= getCus(); pm.beginTask("", files.length + folders.length + cus.length); //$NON-NLS-1$ for (int i= 0; i < files.length; i++) { result.add(createChange(files[i])); pm.worked(1); } if (pm.isCanceled()) throw new OperationCanceledException(); for (int i= 0; i < folders.length; i++) { result.add(createChange(folders[i])); pm.worked(1); } if (pm.isCanceled()) throw new OperationCanceledException(); for (int i= 0; i < cus.length; i++) { result.add(createChange(cus[i])); pm.worked(1); } pm.done(); return result; }
Example 10
Source File: ReorgPolicyFactory.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
public Change createChange(IProgressMonitor pm, INewNameQueries copyQueries) { NewNameProposer nameProposer= new NewNameProposer(); IPackageFragmentRoot[] roots= getPackageFragmentRoots(); pm.beginTask("", roots.length); //$NON-NLS-1$ CompositeChange composite= new DynamicValidationStateChange(RefactoringCoreMessages.ReorgPolicy_copy_source_folder); composite.markAsSynthetic(); IJavaProject destination= getDestinationJavaProject(); for (int i= 0; i < roots.length; i++) { if (destination == null) { composite.add(createChange(roots[i], (IContainer) getResourceDestination(), nameProposer, copyQueries)); } else { composite.add(createChange(roots[i], destination, nameProposer, copyQueries)); } pm.worked(1); } pm.done(); return composite; }
Example 11
Source File: ReorgPolicyFactory.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
public Change createChange(IProgressMonitor pm, INewNameQueries newNameQueries) throws JavaModelException { NewNameProposer nameProposer= new NewNameProposer(); IPackageFragment[] fragments= getPackages(); pm.beginTask("", fragments.length); //$NON-NLS-1$ CompositeChange composite= new DynamicValidationStateChange(RefactoringCoreMessages.ReorgPolicy_copy_package); composite.markAsSynthetic(); IPackageFragmentRoot root= getDestinationAsPackageFragmentRoot(); for (int i= 0; i < fragments.length; i++) { if (root == null) { composite.add(createChange(fragments[i], (IContainer) getResourceDestination(), nameProposer, newNameQueries)); } else { composite.add(createChange(fragments[i], root, nameProposer, newNameQueries)); } pm.worked(1); } pm.done(); return composite; }
Example 12
Source File: PairedMethodRenameParticipant.java From gwt-eclipse-plugin with Eclipse Public License 1.0 | 5 votes |
private Change createChangeFromMethodsToRefactor() { CompositeChange changes = new CompositeChange( "GWT RPC paired method renames"); changes.markAsSynthetic(); // Traverse the methods to refactor and create a rename change for each // Note: due to the recursive nature, this List could grow through each // iteration while (refactoringContext.toRefactorMethods.size() > 0) { IMethod method = refactoringContext.toRefactorMethods.remove(0); try { // Call to JDT to get a change that renames this method Change change = createChangeForMethodRename(method); if (change != null) { if (ChangeUtilities.mergeParticipantTextChanges(this, change)) { // This change was completely merged into existing changes continue; } // Walk through the created change tree and weave a change that, at // perform-time, will update the text regions ChangeUtilities.acceptOnChange(change, new RegionUpdaterChangeWeavingVisitor( new RenamedElementAstMatcher(pairedMethod.getElementName(), newMethodName), new ReferenceUpdater())); changes.add(change); } } catch (RefactoringException e) { GWTPluginLog.logError("Could not rename method " + method); // TODO: warn } } return (changes.getChildren().length > 0) ? changes : null; }
Example 13
Source File: ReorgPolicyFactory.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private Change createReferenceUpdatingMoveChange(IProgressMonitor pm) throws JavaModelException { pm.beginTask("", 2 + (fUpdateQualifiedNames ? 1 : 0)); //$NON-NLS-1$ try { CompositeChange composite= new DynamicValidationStateChange(RefactoringCoreMessages.ReorgPolicy_move); composite.markAsSynthetic(); // XX workaround for bug 13558 // <workaround> if (fChangeManager == null) { fChangeManager= createChangeManager(new SubProgressMonitor(pm, 1), new RefactoringStatus()); // TODO: non-CU matches silently dropped RefactoringStatus status= Checks.validateModifiesFiles(getAllModifiedFiles(), null); if (status.hasFatalError()) fChangeManager= new TextChangeManager(); } // </workaround> composite.merge(new CompositeChange(RefactoringCoreMessages.MoveRefactoring_reorganize_elements, fChangeManager.getAllChanges())); Change fileMove= createSimpleMoveChange(new SubProgressMonitor(pm, 1)); if (fileMove instanceof CompositeChange) { composite.merge(((CompositeChange) fileMove)); } else { composite.add(fileMove); } return composite; } finally { pm.done(); } }
Example 14
Source File: ReorgPolicyFactory.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public Change createChange(IProgressMonitor pm, INewNameQueries copyQueries) { IFile[] file= getFiles(); IFolder[] folders= getFolders(); ICompilationUnit[] cus= getCus(); pm.beginTask("", cus.length + file.length + folders.length); //$NON-NLS-1$ NewNameProposer nameProposer= new NewNameProposer(); CompositeChange composite= new DynamicValidationStateChange(RefactoringCoreMessages.ReorgPolicy_copy); composite.markAsSynthetic(); for (int i= 0; i < cus.length; i++) { composite.add(createChange(cus[i], nameProposer, copyQueries)); pm.worked(1); } if (pm.isCanceled()) throw new OperationCanceledException(); for (int i= 0; i < file.length; i++) { composite.add(createChange(file[i], nameProposer, copyQueries)); pm.worked(1); } if (pm.isCanceled()) throw new OperationCanceledException(); for (int i= 0; i < folders.length; i++) { composite.add(createChange(folders[i], nameProposer, copyQueries)); pm.worked(1); } pm.done(); return composite; }
Example 15
Source File: ReorgPolicyFactory.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 5 votes |
private Change createSimpleMoveChange(IProgressMonitor pm) { CompositeChange result= new DynamicValidationStateChange(RefactoringCoreMessages.ReorgPolicy_move); result.markAsSynthetic(); IFile[] files= getFiles(); IFolder[] folders= getFolders(); ICompilationUnit[] cus= getCus(); pm.beginTask("", files.length + folders.length + cus.length); //$NON-NLS-1$ for (int i= 0; i < files.length; i++) { result.add(createChange(files[i])); pm.worked(1); } if (pm.isCanceled()) { throw new OperationCanceledException(); } for (int i= 0; i < folders.length; i++) { result.add(createChange(folders[i])); pm.worked(1); } if (pm.isCanceled()) { throw new OperationCanceledException(); } for (int i= 0; i < cus.length; i++) { result.add(createChange(cus[i])); pm.worked(1); } pm.done(); return result; }
Example 16
Source File: ReorgPolicyFactory.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 5 votes |
private Change createReferenceUpdatingMoveChange(IProgressMonitor pm) throws JavaModelException { pm.beginTask("", 2 + (fUpdateQualifiedNames ? 1 : 0)); //$NON-NLS-1$ try { CompositeChange composite= new DynamicValidationStateChange(RefactoringCoreMessages.ReorgPolicy_move); composite.markAsSynthetic(); // XX workaround for bug 13558 // <workaround> if (fChangeManager == null) { fChangeManager= createChangeManager(new SubProgressMonitor(pm, 1), new RefactoringStatus()); // TODO: non-CU matches silently dropped RefactoringStatus status; try { status = Checks.validateModifiesFiles(getAllModifiedFiles(), null, pm); if (status.hasFatalError()) { fChangeManager = new TextChangeManager(); } } catch (CoreException e) { fChangeManager= new TextChangeManager(); } } // </workaround> composite.merge(new CompositeChange(RefactoringCoreMessages.MoveRefactoring_reorganize_elements, fChangeManager.getAllChanges())); Change fileMove= createSimpleMoveChange(new SubProgressMonitor(pm, 1)); if (fileMove instanceof CompositeChange) { composite.merge(((CompositeChange) fileMove)); } else { composite.add(fileMove); } return composite; } finally { pm.done(); } }
Example 17
Source File: ReorgPolicyFactory.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 5 votes |
@Override public Change createChange(IProgressMonitor pm, INewNameQueries copyQueries) { IFile[] file= getFiles(); IFolder[] folders= getFolders(); ICompilationUnit[] cus= getCus(); pm.beginTask("", cus.length + file.length + folders.length); //$NON-NLS-1$ NewNameProposer nameProposer= new NewNameProposer(); CompositeChange composite= new DynamicValidationStateChange(RefactoringCoreMessages.ReorgPolicy_copy); composite.markAsSynthetic(); for (int i= 0; i < cus.length; i++) { composite.add(createChange(cus[i], nameProposer, copyQueries)); pm.worked(1); } if (pm.isCanceled()) { throw new OperationCanceledException(); } for (int i= 0; i < file.length; i++) { composite.add(createChange(file[i], nameProposer, copyQueries)); pm.worked(1); } if (pm.isCanceled()) { throw new OperationCanceledException(); } for (int i= 0; i < folders.length; i++) { composite.add(createChange(folders[i], nameProposer, copyQueries)); pm.worked(1); } pm.done(); return composite; }