-
Notifications
You must be signed in to change notification settings - Fork 34
/
Copy pathjava.vim
219 lines (161 loc) · 4.87 KB
/
java.vim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
source t/helpers/setup.vim
describe '<Plug>(textobj-function-a)'
before
new
setfiletype java
call PasteSampleCode('java')
end
after
close!
end
it 'selects the next method if there is no method under the cursor'
Expect Select(2, 'af') ==# ['V', 4, 9]
end
it 'selects the method under the cursor'
" At the first line.
Expect Select(4, 'af') ==# ['V', 4, 9]
" At a middle line.
Expect Select(7, 'af') ==# ['V', 4, 9]
" At the last line.
Expect Select(9, 'af') ==# ['V', 4, 9]
end
it 'ignores non-method blocks'
Expect Select(17, 'af') ==# ['V', 11, 21]
end
it 'recognizes methods with one-line prototypes'
Expect Select(26, 'af') ==# ['V', 23, 28]
Expect Select(32, 'af') ==# ['V', 30, 34]
end
it 'recognizes methods with argument lists over multiple lines'
Expect Select(40, 'af') ==# ['V', 36, 42]
Expect Select(47, 'af') ==# ['V', 44, 49]
end
it 'recognizes methods with argument lists placed after method name lines'
Expect Select(57, 'af') ==# ['V', 51, 59]
Expect Select(66, 'af') ==# ['V', 61, 68]
end
it 'fails if there is no appropriate method'
Expect Select(76, 'af') ==# ['v', 76, 76]
end
end
describe '<Plug>(textobj-function-i)'
before
new
setfiletype java
call PasteSampleCode('java')
end
after
close!
end
it 'selects the next method if there is no method under the cursor'
Expect Select(2, 'if') ==# ['V', 6, 8]
end
it 'selects the method under the cursor'
" At the first line.
Expect Select(4, 'if') ==# ['V', 6, 8]
" At a middle line.
Expect Select(7, 'if') ==# ['V', 6, 8]
" At the last line.
Expect Select(9, 'if') ==# ['V', 6, 8]
end
it 'ignores non-method blocks'
Expect Select(17, 'if') ==# ['V', 13, 20]
end
it 'recognizes methods with one-line prototypes'
Expect Select(26, 'if') ==# ['V', 25, 27]
Expect Select(32, 'if') ==# ['V', 31, 33]
end
it 'recognizes methods with argument lists over multiple lines'
Expect Select(40, 'if') ==# ['V', 39, 41]
Expect Select(47, 'if') ==# ['V', 46, 48]
end
it 'recognizes methods with argument lists placed after method name lines'
Expect Select(57, 'if') ==# ['V', 56, 58]
Expect Select(66, 'if') ==# ['V', 65, 67]
end
it 'fails if the target method does not contain any code'
Expect Select(70, 'if') ==# ['v', 70, 70]
Expect Select(74, 'if') ==# ['v', 74, 74]
end
it 'fails if there is no appropriate method'
Expect Select(76, 'if') ==# ['v', 76, 76]
end
end
describe '<Plug>(textobj-function-A)'
before
new
setfiletype java
call PasteSampleCode('java')
end
after
close!
end
it 'selects the next method if there is no method under the cursor'
Expect Select(2, 'aF') ==# ['V', 3, 9]
end
it 'selects the method under the cursor'
" At the first line.
Expect Select(4, 'aF') ==# ['V', 4, 10]
" At a middle line.
Expect Select(7, 'aF') ==# ['V', 4, 10]
" At the last line.
Expect Select(9, 'aF') ==# ['V', 4, 10]
end
it 'ignores non-method blocks'
Expect Select(17, 'aF') ==# ['V', 11, 22]
end
it 'recognizes methods with one-line prototypes'
Expect Select(26, 'aF') ==# ['V', 23, 29]
Expect Select(32, 'aF') ==# ['V', 30, 35]
end
it 'recognizes methods with argument lists over multiple lines'
Expect Select(40, 'aF') ==# ['V', 36, 43]
Expect Select(47, 'aF') ==# ['V', 44, 50]
end
it 'recognizes methods with argument lists placed after method name lines'
Expect Select(57, 'aF') ==# ['V', 51, 60]
Expect Select(66, 'aF') ==# ['V', 61, 69]
end
it 'fails if there is no appropriate method'
Expect Select(76, 'aF') ==# ['v', 76, 76]
end
end
describe '<Plug>(textobj-function-I)'
before
new
setfiletype java
call PasteSampleCode('java')
end
after
close!
end
it 'selects the next method if there is no method under the cursor'
Expect Select(2, 'iF') ==# ['V', 4, 9]
end
it 'selects the method under the cursor'
" At the first line.
Expect Select(4, 'iF') ==# ['V', 4, 9]
" At a middle line.
Expect Select(7, 'iF') ==# ['V', 4, 9]
" At the last line.
Expect Select(9, 'iF') ==# ['V', 4, 9]
end
it 'ignores non-method blocks'
Expect Select(17, 'iF') ==# ['V', 11, 21]
end
it 'recognizes methods with one-line prototypes'
Expect Select(26, 'iF') ==# ['V', 23, 28]
Expect Select(32, 'iF') ==# ['V', 30, 34]
end
it 'recognizes methods with argument lists over multiple lines'
Expect Select(40, 'iF') ==# ['V', 36, 42]
Expect Select(47, 'iF') ==# ['V', 44, 49]
end
it 'recognizes methods with argument lists placed after method name lines'
Expect Select(57, 'iF') ==# ['V', 51, 59]
Expect Select(66, 'iF') ==# ['V', 61, 68]
end
it 'fails if there is no appropriate method'
Expect Select(76, 'iF') ==# ['v', 76, 76]
end
end