Skip to content

Location information for tags #87

@felixfbecker

Description

@felixfbecker

I am using this package in the open PHP language server, which provides static analysis for any IDE through the open language server protocol. One of these features is "Go to Definition". This is currently implemented for the actual PHP code through nikic's great PHPParser, where every node has a file start/end offset so I can calculate which node the user clicked. It would be nice to have this feature for types in docblock tags like @var too, but the tags don't have any start/end offset data. Would it be possible to add this?

Activity

felixfbecker

felixfbecker commented on Nov 20, 2016

@felixfbecker
Author

This should easy with PREG_OFFSET_CAPTURE

jaapio

jaapio commented on Jul 14, 2017

@jaapio
Member

The docblock class itself has a location. But tags do not. Since tags we don't use the location of the tags ourselfs. Beside that all other elements of our reflection component have a location. So I don't see any needs to add this at the moment.

I think you want to jump to the actual element which should be posible in combination with our reflection component.

felixfbecker

felixfbecker commented on Jul 14, 2017

@felixfbecker
Author

Of course, for the docblock itself it's trivial. The use case (as described above) is, given an offset, which tag is at that position.

Example:

/**
 * @param ClassA $a
 * @param ClassB $b
 */

The user clicks on ClassA. I can easily find out he clicked inside the docblock, but how do I find out he clicked ClassA?

jaapio

jaapio commented on Jul 14, 2017

@jaapio
Member

Ok, I understand your usecase.

It might work to use the position of a tag in the array returned by getTags + the number of lines in description and summary. That will give you the right position. PREG_OFFSET_CAPTURE will only give you the number of the capture group. So when a description has multiple lines this will give you an invalid offset.

From a phpdocumentor point of view we would implement this in the project itself and not in this library.

razvanphp

razvanphp commented on Aug 9, 2018

@razvanphp

hey, any progress on this one? It's been one year already... can we somehow contribute? thanks

jaapio

jaapio commented on Aug 9, 2018

@jaapio
Member

We will accept a pr for this issue. As I wrote before, from a phpdocumentor perspective this does not have priority.

So it won't be picked up very soon by any member of the team.

ashnazg

ashnazg commented on Aug 23, 2018

@ashnazg
Member

Thinking about this request purely from the ReflectionDocBlock perspective, maybe it would be useful to have this capability in here, since locations inside the docblock are still "metadata about the docblock".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @ashnazg@jaapio@razvanphp@felixfbecker

        Issue actions

          Location information for tags · Issue #87 · phpDocumentor/ReflectionDocBlock