]>
Commit | Line | Data |
---|---|---|
1b2798f6 EK |
1 | /******************************************************************************* |
2 | * Copyright (c) 2000, 2011 IBM Corporation and others. | |
3 | * All rights reserved. This program and the accompanying materials | |
4 | * are made available under the terms of the Eclipse Public License v1.0 | |
5 | * which accompanies this distribution, and is available at | |
6 | * http://www.eclipse.org/legal/epl-v10.html | |
7 | * | |
8 | * Contributors: | |
9 | * IBM Corporation - initial API and implementation | |
10 | *******************************************************************************/ | |
11 | package org.eclipse.jdt.internal.corext.refactoring.rename; | |
12 | ||
13 | import org.eclipse.core.runtime.Assert; | |
14 | import org.eclipse.core.runtime.CoreException; | |
15 | import org.eclipse.core.runtime.IProgressMonitor; | |
16 | import org.eclipse.core.runtime.OperationCanceledException; | |
17 | ||
18 | import org.eclipse.core.resources.IFile; | |
19 | import org.eclipse.core.resources.mapping.IResourceChangeDescriptionFactory; | |
20 | ||
21 | import org.eclipse.ltk.core.refactoring.RefactoringStatus; | |
22 | import org.eclipse.ltk.core.refactoring.participants.CheckConditionsContext; | |
23 | import org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant; | |
24 | import org.eclipse.ltk.core.refactoring.participants.RenameProcessor; | |
25 | import org.eclipse.ltk.core.refactoring.participants.RenameRefactoring; | |
26 | import org.eclipse.ltk.core.refactoring.participants.ResourceChangeChecker; | |
27 | import org.eclipse.ltk.core.refactoring.participants.SharableParticipants; | |
28 | ||
29 | import org.eclipse.jdt.internal.corext.refactoring.tagging.INameUpdating; | |
30 | ||
31 | import org.eclipse.jdt.ui.refactoring.RefactoringSaveHelper; | |
32 | import org.eclipse.jdt.ui.refactoring.RenameSupport; | |
33 | ||
34 | ||
35 | public abstract class JavaRenameProcessor extends RenameProcessor implements INameUpdating { | |
36 | ||
37 | private String fNewElementName; | |
38 | RenameModifications fRenameModifications; | |
39 | ||
40 | @Override | |
41 | public final RefactoringParticipant[] loadParticipants(RefactoringStatus status, SharableParticipants shared) throws CoreException { | |
42 | return fRenameModifications.loadParticipants(status, this, getAffectedProjectNatures(), shared); | |
43 | } | |
44 | ||
45 | @Override | |
46 | public final RefactoringStatus checkFinalConditions(IProgressMonitor pm, CheckConditionsContext context) throws CoreException, OperationCanceledException { | |
47 | ResourceChangeChecker checker= (ResourceChangeChecker) context.getChecker(ResourceChangeChecker.class); | |
48 | IResourceChangeDescriptionFactory deltaFactory= checker.getDeltaFactory(); | |
49 | RefactoringStatus result= doCheckFinalConditions(pm, context); | |
50 | if (result.hasFatalError()) | |
51 | return result; | |
52 | IFile[] changed= getChangedFiles(); | |
53 | for (int i= 0; i < changed.length; i++) { | |
54 | deltaFactory.change(changed[i]); | |
55 | } | |
56 | fRenameModifications= computeRenameModifications(); | |
57 | fRenameModifications.generated_4002115254936343318(context, deltaFactory); | |
58 | return result; | |
59 | } | |
60 | ||
61 | protected abstract RenameModifications computeRenameModifications() throws CoreException; | |
62 | ||
63 | protected abstract RefactoringStatus doCheckFinalConditions(IProgressMonitor pm, CheckConditionsContext context) throws CoreException, OperationCanceledException; | |
64 | ||
65 | protected abstract IFile[] getChangedFiles() throws CoreException; | |
66 | ||
67 | protected abstract String[] getAffectedProjectNatures() throws CoreException; | |
68 | ||
69 | public void setNewElementName(String newName) { | |
70 | Assert.isNotNull(newName); | |
71 | fNewElementName= newName; | |
72 | } | |
73 | ||
74 | public String getNewElementName() { | |
75 | return fNewElementName; | |
76 | } | |
77 | ||
78 | /** | |
79 | * @return a save mode from {@link RefactoringSaveHelper} | |
80 | * | |
81 | * @see RefactoringSaveHelper | |
82 | */ | |
83 | public abstract int getSaveMode(); | |
84 | ||
85 | public void generated_3626528223419611633(RenameSupport renamesupport, String newName, int flags) { | |
86 | renamesupport.fRefactoring= new RenameRefactoring(this); | |
87 | RenameSupport.initialize(this, newName, flags); | |
88 | } | |
89 | ||
90 | } |