inplace rename: reject new name for variable rename

(cherry picked from commit d0a36e7ecb46b3e7b59f8ab292426db3b734e449)
This commit is contained in:
anna
2011-12-06 10:38:27 +01:00
parent 22e007957e
commit cd0a7303b3
2 changed files with 11 additions and 3 deletions
@@ -252,6 +252,11 @@ public class MemberInplaceRenamer extends VariableInplaceRenamer {
CommandProcessor.getInstance().executeCommand(myProject, runnable, commandName, null);
}
@Override
protected String getNewName(String newName, ResolveSnapshotProvider.ResolveSnapshot snapshot) {
return newName;
}
@Nullable
public PsiElement getSubstituted() {
if (mySubstituted != null && mySubstituted.isValid()) return mySubstituted;
@@ -331,9 +331,7 @@ public class VariableInplaceRenamer {
finish();
TextResult value = templateState.getVariableValue(PRIMARY_VARIABLE_NAME);
if (value != null) {
myNewName = value.toString();
}
myNewName = getNewName(value != null ? value.toString() : null, snapshot);
if (snapshot != null && performAutomaticRename()) {
if (LanguageNamesValidation.INSTANCE.forLanguage(scope1.getLanguage()).isIdentifier(myNewName, myProject)) {
@@ -462,6 +460,11 @@ public class VariableInplaceRenamer {
protected void restoreStateBeforeDialogWouldBeShown() {
}
@Nullable
protected String getNewName(String newName, ResolveSnapshotProvider.ResolveSnapshot snapshot) {
return snapshot != null ? newName : null;
}
@Nullable
protected StartMarkAction startRename() throws StartMarkAction.AlreadyStartedException {
final StartMarkAction[] markAction = new StartMarkAction[1];