@@ -36,15 +36,14 @@ namespace CodeRefactor.Commands
36
36
{
37
37
class Move : RefactorCommand < IDictionary < string , List < SearchMatch > > >
38
38
{
39
-
40
39
public Dictionary < string , string > OldPathToNewPath ;
41
40
public bool OutputResults ;
42
- private bool renaming ;
41
+ private readonly bool renaming ;
42
+ private readonly bool updatePackages ;
43
43
private List < MoveTargetHelper > targets ;
44
44
private List < string > filesToReopen ;
45
45
private int currentTargetIndex ;
46
46
private ASResult currentTargetResult ;
47
-
48
47
private bool targetsOutsideClasspath ;
49
48
50
49
#region Constructors
@@ -56,15 +55,32 @@ public Move(Dictionary<string, string>oldPathToNewPath) : this(oldPathToNewPath,
56
55
{
57
56
}
58
57
58
+ /// <summary>
59
+ /// A new Move refactoring command.
60
+ /// </summary>
61
+ /// <param name="outputResults">If true, will send the found results to the trace log and results panel</param>
59
62
public Move ( Dictionary < string , string > oldPathToNewPath , bool outputResults ) : this ( oldPathToNewPath , outputResults , false )
60
63
{
61
64
}
62
65
63
- public Move ( Dictionary < string , string > oldPathToNewPath , bool outputResults , bool renaming )
66
+ /// <summary>
67
+ /// A new Move refactoring command.
68
+ /// </summary>
69
+ /// <param name="outputResults">If true, will send the found results to the trace log and results panel</param>
70
+ public Move ( Dictionary < string , string > oldPathToNewPath , bool outputResults , bool renaming ) : this ( oldPathToNewPath , outputResults , renaming , false )
71
+ {
72
+ }
73
+
74
+ /// <summary>
75
+ /// A new Move refactoring command.
76
+ /// </summary>
77
+ /// <param name="outputResults">If true, will send the found results to the trace log and results panel</param>
78
+ public Move ( Dictionary < string , string > oldPathToNewPath , bool outputResults , bool renaming , bool updatePackages )
64
79
{
65
80
OldPathToNewPath = oldPathToNewPath ;
66
81
OutputResults = outputResults ;
67
82
this . renaming = renaming ;
83
+ this . updatePackages = updatePackages ;
68
84
Results = new Dictionary < string , List < SearchMatch > > ( ) ;
69
85
}
70
86
@@ -82,35 +98,43 @@ protected override void ExecutionImplementation()
82
98
RegisterDocumentHelper ( AssociatedDocumentHelper ) ;
83
99
84
100
CreateListOfMoveTargets ( ) ;
85
-
101
+ DialogResult dialogResult ;
86
102
if ( targetsOutsideClasspath )
87
103
{
88
- msg = TextHelper . GetString ( "Info.MovingOutsideClasspath" ) ;
89
- title = TextHelper . GetString ( "FlashDevelop.Title.WarningDialog" ) ;
90
- if ( MessageBox . Show ( msg , title , MessageBoxButtons . YesNo , MessageBoxIcon . Question ) == DialogResult . Yes )
104
+ if ( updatePackages ) dialogResult = DialogResult . Yes ;
105
+ else
106
+ {
107
+ msg = TextHelper . GetString ( "Info.MovingOutsideClasspath" ) ;
108
+ title = TextHelper . GetString ( "FlashDevelop.Title.WarningDialog" ) ;
109
+ dialogResult = MessageBox . Show ( msg , title , MessageBoxButtons . YesNo , MessageBoxIcon . Question ) ;
110
+ }
111
+ if ( dialogResult == DialogResult . Yes )
91
112
{
92
113
MoveTargets ( ) ;
93
114
ReopenInitialFiles ( ) ;
94
115
}
95
116
FireOnRefactorComplete ( ) ;
96
117
return ;
97
118
}
98
-
99
- if ( renaming )
119
+ if ( updatePackages ) dialogResult = DialogResult . Yes ;
120
+ else
100
121
{
101
- msg = TextHelper . GetString ( "Info.RenamingDirectory" ) ;
102
- foreach ( string path in OldPathToNewPath . Keys )
122
+ if ( renaming )
103
123
{
104
- title = string . Format ( TextHelper . GetString ( "Title.RenameDialog" ) , Path . GetFileName ( path ) ) ;
105
- break ;
124
+ msg = TextHelper . GetString ( "Info.RenamingDirectory" ) ;
125
+ foreach ( string path in OldPathToNewPath . Keys )
126
+ {
127
+ title = string . Format ( TextHelper . GetString ( "Title.RenameDialog" ) , Path . GetFileName ( path ) ) ;
128
+ break ;
129
+ }
106
130
}
131
+ else
132
+ {
133
+ msg = TextHelper . GetString ( "Info.MovingFile" ) ;
134
+ title = TextHelper . GetString ( "Title.MoveDialog" ) ;
135
+ }
136
+ dialogResult = MessageBox . Show ( msg , title , MessageBoxButtons . YesNoCancel ) ;
107
137
}
108
- else
109
- {
110
- msg = TextHelper . GetString ( "Info.MovingFile" ) ;
111
- title = TextHelper . GetString ( "Title.MoveDialog" ) ;
112
- }
113
- var dialogResult = MessageBox . Show ( msg , title , MessageBoxButtons . YesNoCancel ) ;
114
138
if ( dialogResult == DialogResult . Cancel )
115
139
{
116
140
FireOnRefactorComplete ( ) ;
@@ -150,11 +174,11 @@ private void CreateListOfMoveTargets()
150
174
{
151
175
string oldPath = item . Key ;
152
176
string newPath = item . Value ;
153
- ITabbedDocument doc ;
154
177
if ( File . Exists ( oldPath ) )
155
178
{
156
179
newPath = Path . Combine ( newPath , Path . GetFileName ( oldPath ) ) ;
157
180
181
+ ITabbedDocument doc ;
158
182
if ( AssociatedDocumentHelper . InitiallyOpenedFiles . TryGetValue ( oldPath , out doc ) )
159
183
{
160
184
doc . Save ( ) ;
0 commit comments