Skip to content

Commit

Permalink
Improve completion for built-in interface names
Browse files Browse the repository at this point in the history
The plugin now provides the name for the built-in interfaces as found in
the docs instead of a lowercased one.
  • Loading branch information
dudu committed Mar 20, 2014
1 parent ee2b5d5 commit b5a015b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
2 changes: 1 addition & 1 deletion autoload/phpcomplete.vim
Expand Up @@ -921,7 +921,7 @@ function! phpcomplete#CompleteClassName(base, kinds, current_namespace, imports)
if index(kinds, 'i') != -1
let builtin_interfaces = filter(keys(copy(g:php_builtin_interfaces)), 'v:val =~? "^'.substitute(a:base, '\\', '', 'g').'"')
for interfacename in builtin_interfaces
call add(res, {'word': leading_slash.interfacename, 'kind': 'i', 'menu': ''})
call add(res, {'word': leading_slash.g:php_builtin_interfaces[interfacename]['name'], 'kind': 'i', 'menu': ''})
endfor
endif
endif
Expand Down
18 changes: 14 additions & 4 deletions tests/CompleteClassName_test.vim
Expand Up @@ -104,9 +104,8 @@ fun! TestCase_complete_classes_from_built_in_classes()

" set up example built-in list
let g:php_builtin_interfaces = {
\'Traversable': {
\ 'methods': {
\ },
\'traversable': {
\ 'name': 'Traversable'
\ },
\}

Expand All @@ -115,12 +114,23 @@ fun! TestCase_complete_classes_from_built_in_classes()
\ {'word': 'Traversable', 'menu': '', 'kind': 'i'}],
\ res)

" user typed \ and hits <c-x><c-o> in a file starting with "namespace NS1;"
" user typed \T and hits <c-x><c-o> in a file starting with "namespace NS1;"
let res = phpcomplete#CompleteClassName('\T', ['i'], 'NS1', {})
call VUAssertEquals([
\ {'word': '\Traversable', 'menu': '', 'kind': 'i'}],
\ res)

let g:php_builtin_interfaces = {
\'traversable': {
\ 'name': 'FindMeFoo'
\ },
\}
" the completion should give the value of the 'name' property regardeless
" of the outer dictionary keys
let res = phpcomplete#CompleteClassName('tra', ['i'], '\', {})
call VUAssertEquals([
\ {'word': 'FindMeFoo', 'menu': '', 'kind': 'i'}],
\ res)

silent! bw! %
endf
Expand Down

0 comments on commit b5a015b

Please sign in to comment.