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 202763 - Add support for {@inheritdoc}
Summary: Add support for {@inheritdoc}
Status: RESOLVED FIXED
Alias: None
Product: php
Classification: Unclassified
Component: Editor (show other bugs)
Version: 8.0.1
Hardware: All All
: P3 normal with 35 votes (vote)
Assignee: Tomas Mysik
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-09-28 06:36 UTC by pulzaraider
Modified: 2016-03-15 18:13 UTC (History)
11 users (show)

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments
No support for inheritdoc in current version (22.51 KB, image/png)
2011-09-28 06:36 UTC, pulzaraider
Details
Sample project for testing inheritdoc support (2.43 KB, application/x-zip-compressed)
2011-09-28 06:37 UTC, pulzaraider
Details
prototype image (67.10 KB, image/png)
2016-02-01 05:36 UTC, junichi11
Details
prototype patch (40.02 KB, patch)
2016-02-05 05:51 UTC, junichi11
Details | Diff
prototype patch v2 (41.26 KB, patch)
2016-02-08 05:31 UTC, junichi11
Details | Diff
prototype patch v3 (35.21 KB, patch)
2016-02-11 14:35 UTC, junichi11
Details | Diff
prototype patch v3 (43.32 KB, patch)
2016-02-11 15:01 UTC, junichi11
Details | Diff
prototype patch v4 (43.36 KB, patch)
2016-02-12 05:16 UTC, junichi11
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description pulzaraider 2011-09-28 06:36:59 UTC
Created attachment 111263 [details]
No support for inheritdoc in current version

Pleasae add support for {@inheritdoc}. In current version (Netbeans 7.0.1) is not supported.

More about {@inheritdoc}: http://manual.phpdoc.org/HTMLSmartyConverter/HandS/phpDocumentor/tutorial_tags.inlineinheritdoc.pkg.html
Comment 1 pulzaraider 2011-09-28 06:37:53 UTC
Created attachment 111264 [details]
Sample project for testing inheritdoc support
Comment 2 jewome62 2014-04-08 08:41:52 UTC
Not supported in Netbeans 8.0 ...
Comment 3 khaperets 2014-04-08 17:46:34 UTC
How to implement this feature myself?
Comment 4 Tomas Mysik 2014-04-09 06:09:43 UTC
(In reply to khaperets from comment #3)
> How to implement this feature myself?

The best you can do is to provide a patch. Here [1] you can find information about NetBeans sources and how to work with them; the module you are interested in is in the "php.editor" directory.

Thanks.
[1] http://wiki.netbeans.org/WorkingWithNetBeansSources
Comment 5 dferbr 2014-08-10 22:14:39 UTC
One really bad thing is that Netbeans does not find the class in autocompletion options list when the class contains the {@inheritdoc} annotation. Since it does not see the class in that case it does not even provide the autocompletion mechanism for anything (variables, methods) regarding that class. 
An example would be ArrayCollection class in Doctrine2 framework. 
Using Netbeans 8.0 on Mac OS 10.10 (did not work on 10.9 either).
Comment 6 pzegardlo 2014-10-03 10:47:31 UTC
Please, implement it in next version, thanks.
Comment 7 ndm 2014-10-07 20:27:29 UTC
Actually, this become a defect because all auto completions are breack for method or class using @inheritdoc
Comment 8 Ondrej Brejla 2014-10-07 20:45:21 UTC
Definitely not this issue. Defect was reported and was confirmed as fixed for 8.0.1 patch.
Comment 9 ndm 2014-10-07 21:13:05 UTC
Could you please details where is the patch , beacause even on the dev version i have the problem
Comment 10 ndm 2014-10-07 21:50:31 UTC
OK, after install the last version this works with 8.0.1 and auto completion isn't break now. 

Many thanks for this enhancement :)

The last part is that the comments aren't the parent comments and just show the docblock as it. An example with the Doctrine\Common\Collections\ArrayCollection::toArray method : 

vendor/doctrine/collections/lib/Doctrine/Common/Collections/ArrayCollection.php
toArray

{@inheritDoc}.
Comment 11 MyCo 2014-10-26 22:19:56 UTC
(In reply to ndm from comment #10)
> OK, after install the last version this works with 8.0.1 and auto completion
> isn't break now. 

Doesn't look like it is fixed in the current release version.

From the About dialog:
Product Version: NetBeans IDE 8.0.1 (Build 201408251540)
Updates: NetBeans IDE is updated to version NetBeans 8.0.1 Patch 1.1
Comment 12 ua.oleg 2016-01-27 11:47:52 UTC
Why it has version 8.0.1 if it is not fixed even in 8.1.0?
Comment 13 Tomas Mysik 2016-01-27 12:55:41 UTC
(In reply to ua.oleg from comment #12)
> Why it has version 8.0.1 if it is not fixed even in 8.1.0?

Because it has been reported for the given version of NetBeans. The Target Milestone field contains information in which version of NetBeans issue is fixed (enhancement is implemented).
Comment 14 ua.oleg 2016-01-27 14:20:16 UTC
So it means that it would be implemented somewhere in the future, right?
Comment 15 Tomas Mysik 2016-01-28 06:41:22 UTC
(In reply to ua.oleg from comment #14)
> So it means that it would be implemented somewhere in the future, right?

Well, we hope so. But to be fair, we have _many_ tasks to do and the number of NetBeans developers is limited, unfortunately :) The best what can be done is when someone from our users (maybe you? ;) is skilled enough and creates a patch for any issue/enhancement which can be then applied/used by us. But that is not so easy, I am afraid (one needs to know Java and NetBeans is not a simple project, of course).

Thanks for understanding.
Comment 16 junichi11 2016-02-01 05:36:00 UTC
Created attachment 158324 [details]
prototype image

I'm trying it. I'm going to apply the inline {@inheritdoc} to PhpDoc descriptions for class, method, @param tag. If I'm wrong, just let me know. I cannot attach a patch yet, sorry.

e.g. 
/**
 * Header of ChildClass.
 *
 * {@inheritdoc} ChildClass Description.
 */
class ChildClass extends BaseClass {
}

/**
 * This is the foo method of ChildClass.
 *  
 * {@inheritdoc} ChildClass foo method description.
 * @param string $a ChildClass a param Description. {@inheritdoc}
 * @param string $b ChildClass b param Description
 * @return string Description.
 */
public function foo($a, $b) {
}

Thanks.
Comment 17 Tomas Mysik 2016-02-01 11:19:44 UTC
(In reply to junichi11 from comment #16)
> Created attachment 158324 [details]
> prototype image

Seems fine to me. Thanks a lot for working on it, Junichi!
Comment 18 junichi11 2016-02-05 05:51:45 UTC
Created attachment 158383 [details]
prototype patch

Tomas, could you please review it when you can make time?

Changes:
1. Separate the process to get ASTNode
2. Parser is used multiple times to get parent comments. (I don't have another idea...)
3. If @param or @return are missing in the method comment, detect parent tags.
4. @property's description(also similar tags) is not shown in the document window, so I also fix it.

Thanks!
Comment 19 junichi11 2016-02-08 05:31:54 UTC
Created attachment 158406 [details]
prototype patch v2

> 2. Parser is used multiple times to get parent comments. (I don't have another idea...)

I changed this part. I got comments using a lexer.

Thanks.
Comment 20 Tomas Mysik 2016-02-11 07:58:33 UTC
@junichi11: Junichi, it seems to me that INLINE_INHERITDOC_PATTERN does not need to be a regular expression at all - am I right? If I am, simpler (and faster) String.contains() etc. methods could be used.

Thanks.
Comment 21 Tomas Mysik 2016-02-11 08:33:49 UTC
@junichi11: Junichi, just want to verify - index is called only if {@inheritdoc} tag is present, right?

Thanks.
Comment 22 junichi11 2016-02-11 11:07:25 UTC
(In reply to Tomas Mysik from comment #20)
> @junichi11: Junichi, it seems to me that INLINE_INHERITDOC_PATTERN does not
> need to be a regular expression at all - am I right? If I am, simpler (and
> faster) String.contains() etc. methods could be used.

I think you are right. Should I try fixing there at first?

(In reply to Tomas Mysik from comment #21)
> @junichi11: Junichi, just want to verify - index is called only if
> {@inheritdoc} tag is present, right?

It is always called in my current code if the element is a class, interface or method. But the tag should be checked before it is called. So I'll fix it.

Thanks!
Comment 23 Tomas Mysik 2016-02-11 12:11:11 UTC
Perfect, will wait for new version of your patch.

Thanks!
Comment 24 junichi11 2016-02-11 14:35:19 UTC
Created attachment 158463 [details]
prototype patch v3

Only DocRenderer.java, Test is the same as v2. (If I should attach all files, I'll recreate a patch.)

Changes
- replaceInlineInheritdoc() : modified
- hasInlineInheritdoc() : modified
- getInheritedElements() : modified
- needInheritedElements() : added

instead of a regex : I tried it, but if you know a better way, could you fix there?

Thanks!
Comment 25 Tomas Mysik 2016-02-11 14:51:26 UTC
(In reply to junichi11 from comment #24)
> Only DocRenderer.java, Test is the same as v2. (If I should attach all
> files, I'll recreate a patch.)

Yes, please. Always attach a complete patch (and deprecate the previous ones) so it is (later) clear what is going to be done here.

> instead of a regex : I tried it, but if you know a better way, could you fix
> there?

I can be wrong, of course! :) Will have a look at it once you attach a complete patch.

Thanks!
Comment 26 junichi11 2016-02-11 15:01:39 UTC
Created attachment 158464 [details]
prototype patch v3

> Yes, please. Always attach a complete patch (and deprecate the previous ones) so it is (later) clear what is going to be done here.

Oh, I see, sorry. 

Thanks.
Comment 27 Tomas Mysik 2016-02-11 15:19:41 UTC
Will have a look at it tomorrow.

Regarding regex - String.replace() etc. internally uses regular expressions as well so I was wrong here, sorry. However, checking whether the tag is present in the given PHPDoc is useful since calling index is expensive.

Thanks and sorry for confusion!
Comment 28 junichi11 2016-02-11 15:37:44 UTC
(In reply to Tomas Mysik from comment #27)
> Will have a look at it tomorrow.
> 
> Regarding regex - String.replace() etc. internally uses regular expressions
> as well so I was wrong here, sorry. However, checking whether the tag is
> present in the given PHPDoc is useful since calling index is expensive.

No problem :) Thank you always for reviewing!
Comment 29 junichi11 2016-02-12 05:16:23 UTC
Created attachment 158469 [details]
prototype patch v4

Fixed the following cases:

1. the tag has spaces
/**
 * The summary.
 * {@inheritdoc }
 * /

2. only the tag
/**
 * {@inheritdoc}
 * /

Thanks.
Comment 30 Tomas Mysik 2016-02-12 06:35:05 UTC
Patch applied, thanks a lot for it, Junichi!

http://hg.netbeans.org/web-main/rev/4674e01e5113
Comment 31 junichi11 2016-02-12 12:44:43 UTC
Thanks a lot for reviewing it!
Comment 32 Quality Engineering 2016-02-13 03:17:15 UTC
Integrated into 'main-silver', will be available in build *201602130002* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/4674e01e5113
User: Tomas Mysik <tmysik@netbeans.org>
Log: #202763 - Add support for {@inheritdoc}

Patch contributed by junichi11@netbeans.org.
Comment 33 twifty 2016-02-16 08:18:54 UTC
@junichi11 Thanks for taking the time to create this patch. I, and many others, have been waiting years for it.
Comment 34 junichi11 2016-02-16 22:09:20 UTC
(In reply to twifty from comment #33)
> @junichi11 Thanks for taking the time to create this patch. I, and many
> others, have been waiting years for it.

You are welcome :) It would be great if it is tested by php users in a development build version[1] (201602160002 or later).

Thanks.

[1] http://bits.netbeans.org/download/trunk/nightly/latest/
Comment 35 Philzen 2016-03-12 21:06:22 UTC
Just tested with latest nightly - unfortunately it doesn't work for class members (yet) :(

class BaseClass {
    /**
     * Really complicated configuration stuff explanation
     */
    protected $configArray = [ 'key1' => 'value1', ...]
}

class ChildClass extends BaseClass {
    /**
     * {@inheritdoc}
     */
    protected $configArray = [ 'key1' => 'childvalue', ...]

}

Can confirm however that it works as expected in a similar fashion for class and method PHPDOC.

Thanks heaps for working on this guys, really yearning for this feature for quite a while now.
Comment 36 junichi11 2016-03-12 23:28:37 UTC
@Philzen
Thanks for reporting it. Please submit it as a new issue.