-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fill in rename refactoring for everything but [DefOf] Fields
- Loading branch information
Showing
2 changed files
with
118 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
src/dotnet/ReSharperPlugin.RimworldDev/Refactoring/RenameHelper.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
using System; | ||
using System.Linq; | ||
using JetBrains.Application.Parts; | ||
using JetBrains.ReSharper.Feature.Services.Refactorings; | ||
using JetBrains.ReSharper.Feature.Services.Refactorings.Specific.Rename; | ||
using JetBrains.ReSharper.Psi; | ||
using JetBrains.ReSharper.Psi.Xml; | ||
using JetBrains.ReSharper.Refactorings.Rename; | ||
|
||
namespace ReSharperPlugin.RimworldDev.Refactoring; | ||
|
||
[Language(typeof(XmlLanguage), Instantiation.DemandAnyThread)] | ||
[Serializable] | ||
public class RenameHelper : RenameHelperBase | ||
{ | ||
public override bool IsLanguageSupported => true; | ||
|
||
public override IRefactoringPage GetInitialPage(IRenameWorkflow renameWorkflow) | ||
{ | ||
if (renameWorkflow is not RenameWorkflow workflow) return base.GetInitialPage(renameWorkflow); | ||
|
||
var initialName = workflow.DataModel.InitialName; | ||
if (!initialName.Contains("/")) return base.GetInitialPage(renameWorkflow); | ||
|
||
workflow.DataModel.InitialName = initialName.Split('/').Last(); | ||
|
||
return base.GetInitialPage(renameWorkflow); | ||
} | ||
} |