Eclipse PDT and custom PHPDoc annotations
Asked Answered
S

1

7

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.

Sancha answered 7/2, 2011 at 11:11 Comment(2)
I'm not exactly following what it is you're looking for here in Eclipse PDT... please clarify, maybe with a more explained example.Selsyn
When I make PHPDoc comment for the elemnt, I want to see in autocomplete not only standard tags (@author, @package, @deprecated, @returns, etc.) but also my custom annotations (e.g, @depends). How I can add such annotations?Sancha
E
14

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

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

enter image description here

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.

enter image description here

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).

Excursive answered 8/2, 2011 at 12:4 Comment(2)
this worked for me very well. I have one question. Is there a way I could enumerate the possible values for a variable in the template itself. lets say I have a template @Column(name="${name}", type="${type}") Here the possible values for "type" are limited. So I am looking for a way to define it like a list of possible values say ["integer","string"]...Pathogenic
@Pathogenic tbh, I dont know. Check the help file linked in my answer. If it's possible it should be in there.Excursive

© 2022 - 2024 — McMap. All rights reserved.