]> git.uio.no Git - ifi-stolz-refaktor.git/blame - case-study/jdt-after/core refactoring/org/eclipse/jdt/internal/corext/refactoring/rename/JavaRenameProcessor.java
Case Study: adding data and statistics
[ifi-stolz-refaktor.git] / case-study / jdt-after / core refactoring / org / eclipse / jdt / internal / corext / refactoring / rename / JavaRenameProcessor.java
CommitLineData
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 *******************************************************************************/
11package org.eclipse.jdt.internal.corext.refactoring.rename;
12
13import org.eclipse.core.runtime.Assert;
14import org.eclipse.core.runtime.CoreException;
15import org.eclipse.core.runtime.IProgressMonitor;
16import org.eclipse.core.runtime.OperationCanceledException;
17
18import org.eclipse.core.resources.IFile;
19import org.eclipse.core.resources.mapping.IResourceChangeDescriptionFactory;
20
21import org.eclipse.ltk.core.refactoring.RefactoringStatus;
22import org.eclipse.ltk.core.refactoring.participants.CheckConditionsContext;
23import org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant;
24import org.eclipse.ltk.core.refactoring.participants.RenameProcessor;
25import org.eclipse.ltk.core.refactoring.participants.RenameRefactoring;
26import org.eclipse.ltk.core.refactoring.participants.ResourceChangeChecker;
27import org.eclipse.ltk.core.refactoring.participants.SharableParticipants;
28
29import org.eclipse.jdt.internal.corext.refactoring.tagging.INameUpdating;
30
31import org.eclipse.jdt.ui.refactoring.RefactoringSaveHelper;
32import org.eclipse.jdt.ui.refactoring.RenameSupport;
33
34
35public 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}