shawncplus / phpcomplete.vim

Improved PHP omnicompletion
http://www.vim.org/scripts/script.php?script_id=3171
595 stars 110 forks source link

Can't get function list #33

Closed markwu closed 11 years ago

markwu commented 11 years ago

I merge recent commits of phpcomplete.vim, I just found I can't get autcomplete work for class methos, just only variable.

After some testings, I found this commit https://github.com/shawncplus/phpcomplete.vim/commit/7cf86a8ea4b351b65a18d623a7bc8ec03f41fcad cause this problem.

I don't know what's going on ...

When revert to this commit https://github.com/shawncplus/phpcomplete.vim/commit/80c9a5ab40b73028d6745f106f55ccf833d2eaeb , everything works.

Mark

complex857 commented 11 years ago

Thank you for bisecting the code to a commit. Can you send me a code example that illustrates this issue?

I'm not sure if i get what's not working exactly, my hastily improvised tests seem to work as expected as unit tests attached to the function of that merge (later molded into this file).

markwu commented 11 years ago

Sorry, I paste the wrong commit, it is this commit https://github.com/shawncplus/phpcomplete.vim/commit/3f9d1a71bb253963c225258a3e8af80c18e1a904 cause problem. I will prepare a example for you.

markwu commented 11 years ago

Hi @complex857

I prepared a example, you can download here. https://db.tt/QzP5dfJe

It is the lifetype-1.2 repository with patched ctags file.

The testing steps:

  1. Extract the tar.gz file
  2. Make sure use the phpcomplete.vim master branch
  3. Open index.php, in the end of file before ?>, try to type Info:: , you will see nothing popup
  4. Then, switch to phpcomplete.vim commit https://github.com/shawncplus/phpcomplete.vim/commit/80c9a5ab40b73028d6745f106f55ccf833d2eaeb
  5. Try step 3 again, you will see function list popups for autocomplete without problems.
  6. Then, switch to phpcomplete.vim commit https://github.com/shawncplus/phpcomplete.vim/commit/3f9d1a71bb253963c225258a3e8af80c18e1a904
  7. Try step 3 again, you will nothing popup again ... that's why I guess https://github.com/shawncplus/phpcomplete.vim/commit/3f9d1a71bb253963c225258a3e8af80c18e1a904 this commit cause problem.

* My Vim version is 7.4 with 1-52 patch under ubuntu 13.04 * I use YouCompleteMe for autocompletion

Regards, Mark

complex857 commented 11 years ago

Thanks for the example, I think I've successfully fixed your issue. Previously we've forgot to consider the case when g:phpcomplete_relax_static_constraint is enabled and the functions in the class we trying to collect completions for have no modifiers at all. These can be called so they should be shown as completion.

I've found it extremely hard to reason about the regexp for the function matching with this added case on top of the others, so I've redid the part where the modifiers are evaluated against the access context (private or public) and staticness and added a testcase for this kind of functions too in user_extended.class.php fixture.

Let me know, if it's still not behave as expected.

markwu commented 11 years ago

Wow, It works very well, thanks for this fix.

Mark