@@ -23,10 +23,10 @@ function renamerefactor(
23
23
mod = getmodule (mod)
24
24
25
25
# check on dot accessor
26
- modnote = if (obj = first (split (full, ' .' ))) != old
27
- if (parent = getfield′ (mod, obj)) isa Module
28
- if parent != mod
29
- modulenote (old, parent )
26
+ moddesc = if (obj = first (split (full, ' .' ))) != old
27
+ if (parentmod = getfield′ (mod, obj)) isa Module
28
+ if parentmod != mod
29
+ moduledescription (old, parentmod )
30
30
else
31
31
" "
32
32
end
@@ -66,19 +66,19 @@ function renamerefactor(
66
66
# catch global refactoring not on definition, e.g.: on a call site
67
67
if bind === nothing || old ≠ bind. name
68
68
# TODO : `goto` uri
69
- return Dict (:info => contextnote (old, mod, context))
69
+ return Dict (:info => contextdescription (old, mod, context))
70
70
end
71
71
72
72
kind, desc = globalrefactor (old, new, mod, expr)
73
73
74
74
# make description
75
75
if kind === :success
76
- # update modnote
77
- if isempty (modnote ) && applicable (parentmodule, val) && (parent = parentmodule (val)) ≠ mod
78
- modnote = modulenote (old, parent )
76
+ # update modesc
77
+ if isempty (moddesc ) && applicable (parentmodule, val) && (parentmod = parentmodule (val)) ≠ mod
78
+ moddesc = moduledescription (old, parentmod )
79
79
end
80
80
81
- desc = join ((" _Global_ rename refactoring `$old ` ⟹ `$new ` succeeded." , modnote , desc), " \n\n " )
81
+ desc = join ((" _Global_ rename refactoring `$old ` ⟹ `$new ` succeeded." , moddesc , desc), " \n\n " )
82
82
end
83
83
84
84
return Dict (kind => desc)
@@ -89,18 +89,6 @@ function renamerefactor(
89
89
return Dict (:error => " Rename refactoring `$old ` ⟹ `$new ` failed" )
90
90
end
91
91
92
- modulenote (old, parentmod) = """
93
- **NOTE**: `$old ` is defined in `$parentmod `
94
- -- you may need the same rename refactorings in that module as well.
95
- """
96
-
97
- contextnote (old, mod, context) = """
98
- `$old ` isn't found in local bindings in the current context:
99
- <details><summary>Context</summary><pre><code>$(strip (context)) </code></p></details>
100
-
101
- If you want a global rename refactoring on `$mod .$old `, you need to call from its definition.
102
- """
103
-
104
92
# local refactor
105
93
# --------------
106
94
@@ -164,9 +152,32 @@ function refactorfiles(old, new, mod, files, expr)
164
152
@info " Finish global rename refactoring" progress= 1 _id= id
165
153
166
154
return if ! isempty (refactoredfiles)
167
- filelist = (" - [$file ]($(uriopen (file)) )" for file in refactoredfiles)
168
- (:success , string (" Refactored files (all in `$mod ` module):\n\n " , join (filelist, ' \n ' )))
155
+ (:success , filedescription (mod, refactoredfiles))
169
156
else
170
157
(:warning , " No rename refactoring occured on `$old ` in `$mod ` module." )
171
158
end
172
159
end
160
+
161
+ # descriptions
162
+ # ------------
163
+
164
+ moduledescription (old, parentmod) = """
165
+ **NOTE**: `$old ` is defined in `$parentmod `
166
+ -- you may need the same rename refactorings in that module as well.
167
+ """
168
+
169
+ contextdescription (old, mod, context) = """
170
+ `$old ` isn't found in local bindings in the current context:
171
+ <details><summary>Context</summary><pre><code>$(strip (context)) </code></p></details>
172
+
173
+ If you want a global rename refactoring on `$mod .$old `, you need to call from its definition.
174
+ """
175
+
176
+ function filedescription (mod, files)
177
+ filelist = join ((" <li>[$file ]($(uriopen (file)) )</li>" for file in files), ' \n ' )
178
+ """
179
+ <details><summary>
180
+ Refactored files (all in `$mod ` module):
181
+ </summary><ul>$(filelist) </ul></details>
182
+ """
183
+ end
0 commit comments