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.

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. Commented Feb 7, 2011 at 19:26
  • 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? Commented Feb 7, 2011 at 19:44

1 Answer 1

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

Sign up to request clarification or add additional context in comments.

2 Comments

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"]...
@Broncha tbh, I dont know. Check the help file linked in my answer. If it's possible it should be in there.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.