Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Location information for tags #87

Open
felixfbecker opened this issue Nov 4, 2016 · 7 comments
Open

Location information for tags #87

felixfbecker opened this issue Nov 4, 2016 · 7 comments

Comments

@felixfbecker
Copy link

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?

@felixfbecker
Copy link
Author

This should easy with PREG_OFFSET_CAPTURE

@jaapio
Copy link
Member

jaapio commented Jul 14, 2017

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
Copy link
Author

felixfbecker commented Jul 14, 2017

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
Copy link
Member

jaapio commented Jul 14, 2017

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
Copy link

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

@jaapio
Copy link
Member

jaapio commented Aug 9, 2018

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
Copy link
Member

ashnazg commented Aug 23, 2018

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
Projects
None yet
Development

No branches or pull requests

4 participants