Eclipse PDT and custom PHPDoc annotations

混江龙づ霸主 提交于 2019-12-04 11:51:51

问题


Is there any way to add custom phpdoc annotation for Eclipse PDT? For example, I want to see @depends (for PHPUnit) in autocomplete list for comments, but now I can see there only standard annotations (for example, @deprecated) .

Thanks in advance.


回答1:


I assumed there would be a configuration file somewhere, but looking through the various folders in my Zend Studio installation didnt give me the results I was hoping for. Searching Eclipse.org for Content Assist yielded

  • http://help.eclipse.org/helios/topic/org.eclipse.platform.doc.isv/guide/editors_contentassist.htm

So I guess the "real" way to add a new Content Assist Context would be to extend Eclipse.

Alternative: Using Templates

The other way to get the annotations would be to add them via Templates. Follow these steps:

  • Go to Window > Preferences > PHP > Editor > Templates.
  • Click New, fill in the dialogue and confirm everything to get back to your editor

The template is now setup to appear when in the context of a PHP Comment. Go to a UnitTest DocBlock and type @. If Content Assist does not open automatically, hit Ctrl+Space. There should be an option to select @depends now.

Confirm as you would confirm any other suggestion. This should write @depends and put your cursor right next to it (so you can insert the name of the test).



来源:https://stackoverflow.com/questions/4920593/eclipse-pdt-and-custom-phpdoc-annotations

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!