/
IRenameStrategy.java
66 lines (54 loc) · 2.24 KB
/
IRenameStrategy.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/*******************************************************************************
* Copyright (c) 2010 itemis AG (http://www.itemis.eu) and others.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* SPDX-License-Identifier: EPL-2.0
*******************************************************************************/
package org.eclipse.xtext.ui.refactoring;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.ltk.core.refactoring.RefactoringStatus;
import org.eclipse.xtext.ui.refactoring.impl.DefaultRenameStrategyProvider;
import org.eclipse.xtext.ui.refactoring.ui.IRenameElementContext;
import com.google.inject.ImplementedBy;
/**
* Customizable strategy for the text based rename refactoring of a given {@link EObject}.
*
* @author Jan Koehnlein - Initial contribution and API
*/
public interface IRenameStrategy {
String getOriginalName();
RefactoringStatus validateNewName(String newName);
/**
* Applies the declaration change to the semantic model in the given resource set.
*/
void applyDeclarationChange(String newName, ResourceSet resourceSet);
/**
* Reverts the declaration change to the semantic model in the given resource set.
*/
void revertDeclarationChange(ResourceSet resourceSet);
/**
* Creates the document updates and reports them to the updateAcceptor
*/
void createDeclarationUpdates(String newName, ResourceSet resourceSet, IRefactoringUpdateAcceptor updateAcceptor);
@ImplementedBy(DefaultRenameStrategyProvider.class)
interface Provider {
/**
* @return an {@link IRenameStrategy} to rename the given target object
* or null if the element should be skipped (e.g. XtendConstructor)
* @throws NoSuchStrategyException with a reason when refactoring is forbidden.
*/
IRenameStrategy get(EObject targetEObject, IRenameElementContext renameElementContext) throws NoSuchStrategyException;
/**
* @since 2.4
*/
class NoSuchStrategyException extends Exception {
private static final long serialVersionUID = 5167954119728880001L;
public NoSuchStrategyException(String message) {
super(message);
}
}
}
}