@@ -30,14 +30,31 @@ fun! TestCase_complete_classes_from_tags()
30
30
call SetUp ()
31
31
32
32
" set tags to a fixture
33
- exe ' :set tags=' .expand (' %:p:h' ).' /' .' fixtures/CompleteClassName/tags'
33
+ let tags_path = expand (' %:p:h' ).' /' .' fixtures/CompleteClassName/tags'
34
+ let old_style_tags_path = expand (' %:p:h' ).' /' .' fixtures/CompleteClassName/old_style_tags'
35
+ exe ' :set tags=' .tags_path
34
36
35
37
" open an empty file so no 'local' class will be picked up
36
38
let path = expand (' %:p:h' )." /" .' fixtures/CompleteClassName/empty.php'
37
39
below 1 new
38
40
exe " :silent! edit " .path
39
41
42
+ let res = phpcomplete#CompleteClassName (' T' , [' c' , ' i' ], ' \' , {})
43
+ call VUAssertEquals ([
44
+ \ {' word' : ' TagClass' , ' menu' : ' fixtures/CompleteClassName/tagclass.php' , ' info' : ' fixtures/CompleteClassName/tagclass.php' , ' kind' : ' c' }],
45
+ \ res )
46
+ let res = phpcomplete#CompleteClassName (' B' , [' i' ], ' \' , {})
47
+ call VUAssertEquals ([
48
+ \ {' word' : ' BarInterface' , ' menu' : ' fixtures/CompleteClassName/foo.class.php' , ' info' : ' fixtures/CompleteClassName/foo.class.php' , ' kind' : ' i' }],
49
+ \ res , " should find only interfaces" )
50
+ let res = phpcomplete#CompleteClassName (' B' , [' c' , ' i' ], ' \' , {})
51
+ call VUAssertEquals ([
52
+ \ {' word' : ' BarClass' , ' menu' : ' fixtures/CompleteClassName/foo.class.php' , ' info' : ' fixtures/CompleteClassName/foo.class.php' , ' kind' : ' c' },
53
+ \ {' word' : ' BarInterface' , ' menu' : ' fixtures/CompleteClassName/foo.class.php' , ' info' : ' fixtures/CompleteClassName/foo.class.php' , ' kind' : ' i' }],
54
+ \ res , " should find both classes and interfaces in tags" )
40
55
56
+ " should work just the same with old ctags generated tag files
57
+ exe ' :set tags=' .old_style_tags_path
41
58
let res = phpcomplete#CompleteClassName (' T' , [' c' , ' i' ], ' \' , {})
42
59
call VUAssertEquals ([
43
60
\ {' word' : ' TagClass' , ' menu' : ' fixtures/CompleteClassName/tagclass.php' , ' info' : ' fixtures/CompleteClassName/tagclass.php' , ' kind' : ' c' }],
@@ -51,6 +68,7 @@ fun! TestCase_complete_classes_from_tags()
51
68
\ {' word' : ' BarClass' , ' menu' : ' fixtures/CompleteClassName/foo.class.php' , ' info' : ' fixtures/CompleteClassName/foo.class.php' , ' kind' : ' c' },
52
69
\ {' word' : ' BarInterface' , ' menu' : ' fixtures/CompleteClassName/foo.class.php' , ' info' : ' fixtures/CompleteClassName/foo.class.php' , ' kind' : ' i' }],
53
70
\ res , " should find both classes and interfaces in tags" )
71
+
54
72
silent ! bw ! %
55
73
endf
56
74
@@ -137,7 +155,9 @@ fun! TestCase_filters_class_names_with_the_namespaces_typed_in_base()
137
155
call SetUp ()
138
156
139
157
" set tags to a fixture
140
- exe ' :set tags=' .expand (' %:p:h' ).' /' .' fixtures/CompleteClassName/tags'
158
+ let tags_path = expand (' %:p:h' ).' /' .' fixtures/CompleteClassName/tags'
159
+ let old_style_tags_path = expand (' %:p:h' ).' /' .' fixtures/CompleteClassName/old_style_tags'
160
+ exe ' :set tags=' .tags_path
141
161
142
162
let res = phpcomplete#CompleteClassName (' NS1\N' , [' c' ], ' \' , {})
143
163
call VUAssertEquals ([
@@ -148,13 +168,49 @@ fun! TestCase_filters_class_names_with_the_namespaces_typed_in_base()
148
168
call VUAssertEquals ([
149
169
\ {' word' : ' NS1\NameSpacedFooInterface' , ' menu' : ' fixtures/CompleteClassName/namespaced.foo.php' , ' info' : ' fixtures/CompleteClassName/namespaced.foo.php' , ' kind' : ' i' }],
150
170
\ res )
171
+
172
+ " with old style ctags, just complete every classame that matches the
173
+ " string after the last \
174
+ exe ' :set tags=' .old_style_tags_path
175
+
176
+ let res = phpcomplete#CompleteClassName (' NS1\N' , [' c' ], ' \' , {})
177
+ call VUAssertEquals ([
178
+ \ {' word' : ' NS1\NameSpacedFoo' , ' menu' : ' fixtures/CompleteClassName/namespaced.foo.php' , ' info' : ' fixtures/CompleteClassName/namespaced.foo.php' , ' kind' : ' c' }],
179
+ \ res )
180
+ let res = phpcomplete#CompleteClassName (' NS1\N' , [' i' ], ' \' , {})
181
+ call VUAssertEquals ([
182
+ \ {' word' : ' NS1\NameSpacedFooInterface' , ' menu' : ' fixtures/CompleteClassName/namespaced.foo.php' , ' info' : ' fixtures/CompleteClassName/namespaced.foo.php' , ' kind' : ' i' }],
183
+ \ res )
184
+
185
+ " test for when there are namespaces in the matched tags the non-namespaced
186
+ " matches are thrown out
187
+ exe ' :set tags=' .old_style_tags_path.' ,' .tags_path
188
+ let res = phpcomplete#CompleteClassName (' NS1\NameSpacedF' , [' c' ], ' \' , {})
189
+ call VUAssertEquals ([
190
+ \ {' word' : ' NS1\NameSpacedFoo' , ' menu' : ' fixtures/CompleteClassName/namespaced.foo.php' , ' info' : ' fixtures/CompleteClassName/namespaced.foo.php' , ' kind' : ' c' }],
191
+ \ res )
151
192
endf
152
193
153
194
fun ! TestCase_filters_class_names_with_the_current_namespace_but_doesnt_add_the_current_namespace_to_the_completion_word ()
154
195
call SetUp ()
155
196
197
+ let tags_path = expand (' %:p:h' ).' /' .' fixtures/CompleteClassName/tags'
198
+ let old_style_tags_path = expand (' %:p:h' ).' /' .' fixtures/CompleteClassName/old_style_tags'
156
199
" set tags to a fixture
157
- exe ' :set tags=' .expand (' %:p:h' ).' /' .' fixtures/CompleteClassName/tags'
200
+ exe ' :set tags=' .tags_path
201
+
202
+ let res = phpcomplete#CompleteClassName (' N' , [' c' ], ' NS1' , {})
203
+ call VUAssertEquals ([
204
+ \ {' word' : ' NameSpacedFoo' , ' menu' : ' fixtures/CompleteClassName/namespaced.foo.php' , ' info' : ' fixtures/CompleteClassName/namespaced.foo.php' , ' kind' : ' c' }],
205
+ \ res )
206
+
207
+ let res = phpcomplete#CompleteClassName (' N' , [' i' ], ' NS1' , {})
208
+ call VUAssertEquals ([
209
+ \ {' word' : ' NameSpacedFooInterface' , ' menu' : ' fixtures/CompleteClassName/namespaced.foo.php' , ' info' : ' fixtures/CompleteClassName/namespaced.foo.php' , ' kind' : ' i' }],
210
+ \ res )
211
+
212
+ " old style tags
213
+ exe ' :set tags=' .old_style_tags_path
158
214
159
215
let res = phpcomplete#CompleteClassName (' N' , [' c' ], ' NS1' , {})
160
216
call VUAssertEquals ([
@@ -184,8 +240,11 @@ endf
184
240
fun ! TestCase_completes_class_names_from_imported_namespaces_via_tags ()
185
241
call SetUp ()
186
242
243
+ let tags_path = expand (' %:p:h' ).' /' .' fixtures/common/namespaced_foo_tags'
244
+ let old_style_tags_path = expand (' %:p:h' ).' /' .' fixtures/common/old_style_namespaced_foo_tags'
245
+
187
246
" set tags to a fixture
188
- exe ' :set tags=' .expand ( ' %:p:h ' ). ' / ' . ' fixtures/common/namespaced_foo_tags '
247
+ exe ' :set tags=' .tags_path
189
248
190
249
" comlete classes from imported namespace
191
250
let res = phpcomplete#CompleteClassName (' SUBNS\F' , [' c' ], ' \' , {' SUBNS' : {' name' : ' NS1\SUBNS' , ' kind' : ' n' , ' builtin' : 0 ,}})
@@ -204,4 +263,16 @@ fun! TestCase_completes_class_names_from_imported_namespaces_via_tags()
204
263
call VUAssertEquals ([
205
264
\ {' word' : ' \NS1\SUBNS\FooSub' , ' menu' : ' fixtures/common/namespaced_foo.php' , ' info' : ' fixtures/common/namespaced_foo.php' , ' kind' : ' c' }],
206
265
\ res )
266
+
267
+ " set old tags to a fixture
268
+ exe ' :set tags=' .old_style_tags_path
269
+
270
+ " without namespaces in tags, every classname that matches word after the
271
+ " last \ will be returned
272
+ let res = phpcomplete#CompleteClassName (' SUBNS\F' , [' c' ], ' \' , {' SUBNS' : {' name' : ' NS1\SUBNS' , ' kind' : ' n' , ' builtin' : 0 ,}})
273
+ call VUAssertEquals ([
274
+ \ {' word' : ' SUBNS\Foo' , ' menu' : ' fixtures/common/fixtures/common/namespaced_foo.php' , ' info' : ' fixtures/common/fixtures/common/namespaced_foo.php' , ' kind' : ' c' },
275
+ \ {' word' : ' SUBNS\FooSub' , ' menu' : ' fixtures/common/fixtures/common/namespaced_foo.php' , ' info' : ' fixtures/common/fixtures/common/namespaced_foo.php' , ' kind' : ' c' },
276
+ \ {' word' : ' SUBNS\FooSubSub' , ' menu' : ' fixtures/common/fixtures/common/namespaced_foo.php' , ' info' : ' fixtures/common/fixtures/common/namespaced_foo.php' , ' kind' : ' c' }],
277
+ \ res )
207
278
endf
0 commit comments