@@ -5,15 +5,15 @@ import modules from './modules'
5
5
import { getWordRangeAtBufferPosition , isValidWordToInspect } from '../misc/words'
6
6
import { getLocalContext } from '../misc/blocks'
7
7
8
- const { refactor : _refactor } = client . import ( [ 'refactor' ] )
8
+ const renamerefactor = client . import ( 'renamerefactor' )
9
9
const wordRegexWithoutDotAccessor = / @ ? [ \u00A0 - \uFFFF \w _ ! ´ ] + /
10
10
11
11
class Refactor {
12
12
activate ( ink ) {
13
13
this . ink = ink
14
14
}
15
15
16
- refactor ( ) {
16
+ renameRefactor ( ) {
17
17
const editor = atom . workspace . getActiveTextEditor ( )
18
18
const bufferPosition = editor . getCursorBufferPosition ( )
19
19
@@ -24,6 +24,9 @@ class Refactor {
24
24
const old = editor . getTextInBufferRange ( range )
25
25
if ( ! isValidWordToInspect ( old ) ) return
26
26
27
+ const rangeFull = getWordRangeAtBufferPosition ( editor , bufferPosition )
28
+ const full = editor . getTextInBufferRange ( rangeFull )
29
+
27
30
this . ink . showBasicModal ( [ {
28
31
name : 'Rename' ,
29
32
defaultText : old ,
@@ -46,8 +49,9 @@ class Refactor {
46
49
const currentModule = modules . current ( )
47
50
const mod = currentModule ? currentModule : 'Main'
48
51
49
- _refactor ( {
52
+ renamerefactor ( {
50
53
old,
54
+ full,
51
55
new : _new ,
52
56
path : editor . getPath ( ) ,
53
57
// local context
@@ -58,15 +62,30 @@ class Refactor {
58
62
// module context
59
63
mod,
60
64
} ) . then ( result => {
61
- if ( result . error ) {
65
+ // local refactoring
66
+ if ( result . text ) {
67
+ editor . setTextInBufferRange ( range , result . text )
68
+ }
69
+ if ( result . info ) {
70
+ atom . notifications . addInfo ( 'Julia Client: Rename Refactor' , {
71
+ description : result . info ,
72
+ dismissable : true
73
+ } )
74
+ }
75
+ if ( result . warning ) {
62
76
atom . notifications . addWarning ( 'Julia Client: Rename Refactor' , {
77
+ description : result . warning
78
+ } )
79
+ }
80
+ if ( result . error ) {
81
+ atom . notifications . addError ( 'Julia Client: Rename Refactor' , {
63
82
description : result . error
64
83
} )
65
- return
66
84
}
67
- // local refactoring
68
- if ( result . text ) {
69
- editor . setTextInBufferRange ( range , result . text )
85
+ if ( result . success ) {
86
+ atom . notifications . addSuccess ( 'Julia Client: Rename Refactor' , {
87
+ description : result . success
88
+ } )
70
89
}
71
90
} )
72
91
} ) . catch ( ( err ) => {
0 commit comments