This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 212932 - Fix Uses function ignore Symfony2 Annotations
Summary: Fix Uses function ignore Symfony2 Annotations
Alias: None
Product: php
Classification: Unclassified
Component: Editor (show other bugs)
Version: 8.0.2
Hardware: All All
: P2 normal with 1 vote (vote)
Assignee: Ondrej Brejla
: 214939 215107 (view as bug list)
Depends on:
Reported: 2012-05-24 08:39 UTC by abogomolov
Modified: 2015-02-06 06:25 UTC (History)
1 user (show)

See Also:
Exception Reporter:

Screenshot (41.85 KB, image/png)
2012-05-24 08:39 UTC, abogomolov
Inconsistent use statement usage detection (143.55 KB, image/png)
2015-02-05 17:49 UTC, gnat

Note You need to log in before you can comment on or make changes to this bug.
Description abogomolov 2012-05-24 08:39:46 UTC
Created attachment 119803 [details]

When I use the function "Fix Uses" NetBeans remove needed entries defined/used in annotations.
Comment 1 Ondrej Brejla 2012-05-24 08:41:37 UTC
Symfony Annotations are special cases and this feature wasn't designed to handle that (and it can't do that simply in this PHPDoc parser implementation). It's an enhancement for next release.
Comment 2 abogomolov 2012-05-24 08:49:06 UTC
Thank you for your reply.
Comment 3 abogomolov 2012-05-24 11:27:40 UTC
Is it possible to exclude some use statements from being deleted? (Simple Blacklist)
So NetBeans don't need to parse annotations. (It would always be error-prone because of aliases.)

For example:
use Symfony\Component\Validator\Constraints as Assert;

class Author {
     * @Assert\NotBlank()
    public $name;

Thanks a lot!
Comment 4 Ondrej Brejla 2012-05-24 11:31:38 UTC
Unfortunately not now. It's a first implementation of this feature and that Doctrine style is really awful. That an annotation name (which is just a Comment, so NO build-in language support) is driven by use statements, which are a common language constructs. Really ugly...but we will think about that in next version. "Black list" is one of possibilities.
Comment 5 Ondrej Brejla 2012-06-29 06:33:40 UTC
*** Bug 214939 has been marked as a duplicate of this bug. ***
Comment 6 Ondrej Brejla 2012-07-03 06:50:08 UTC
*** Bug 215107 has been marked as a duplicate of this bug. ***
Comment 7 ccomer 2012-07-29 09:47:54 UTC
I was, and still am, very excited about the addition of Doctrine 2 annotations support into the editor. However, with the current implementation, this feature will more than likely go unused on almost every Doctrine 2 project due to the use statement convention mentioned here. Zend Framework 2 also recently implemented an annotation manager to assist with building forms that follows a similar methodology

I can definitely understand the sentiment about utilizing a language construct to assist with annotations but this seems to be the consensus as far as implementation goes for most PHP projects, which means the beautiful work that has been done getting these annotations supported in the editor may never see the light of day for most users unless something can be done to recognize these use statements and identify their usage within comment blocks. Not only would the editor need to recognize their validity but in order for code completion to work it would need to identify the alias of the use statement and be able to provide hints and suggestions when the user typed the alias for that annotation set. 

eg. use Doctrine\ORM\Mapping as ORM;

If I can't start typing @ORM and get a list of suggested annotations that Doctrine 2 supports, I can't imagine how much this feature will be getting used. This is probably further complicated by individuals who use a different alias in their use statement as the editor would need to be smart enough to identify the use statement, grab the alias, prefix all of the Doctrine 2 annotations with the alias, and then provide suggestions when the prefix was typed in a comment block. 

I'm really looking forward to a future release where this functionality can be enhanced as I think this is extremely fantastic work and greatly improves quality of life for many large projects utilizing these frameworks.
Comment 8 ianfp 2012-07-30 15:35:58 UTC
Just to clarify: I think @ccomer is talking about auto-completion for annotations. That would be cool, but this issue is simply about not marking "use" statements as unused if they are actually used to support annotations. A separate issue from annotation auto-completion, probably easier to implement, and (in my opinion) more important.
Comment 9 Ondrej Brejla 2012-07-31 07:47:32 UTC
ccomer's use case is another enhancement issue, this one is about matching use statements with right annotation names.
Comment 10 Ondrej Brejla 2012-07-31 13:47:52 UTC
A filled a new issue #216200 which tracks that CC problem of "typed annotations" as a reminder for me.
Comment 11 Ondrej Brejla 2012-08-14 08:03:48 UTC
Custom annotation parsers are implemented in dev build.
Comment 12 ianfp 2012-12-19 23:26:34 UTC
Seems to be working great as of 7.3 beta 2. Good work!
Comment 13 gnat 2015-02-05 17:48:06 UTC
So for some reason *some* annotations are marked as unused whereas others are properly detected. I really have no idea what the difference is between them.
Comment 14 gnat 2015-02-05 17:49:32 UTC
Created attachment 151836 [details]
Inconsistent use statement usage detection
Comment 15 Ondrej Brejla 2015-02-05 18:55:15 UTC
Probably some new annotations which were not available during implementation.

Please, file it as a new P3 bug, thanks.