Hirse / brackets-outline-list

Extension for Brackets and Phoenix to display a list of the functions or definitions in the currently opened document.
MIT License
79 stars 30 forks source link

PHP parser improvements #78

Closed pelatx closed 7 years ago

pelatx commented 7 years ago

This PR fixes the problem with the implementation of multiple interfaces by detecting the ',' in the class declaration.

It also improves #73 and #74 solution through a new feature: detection of strings within the code. Both in single and double quotation marks. This prevents errors with other reserved words that may appear in strings ('function', 'extends' ...) and avoid the dirty fix of putting a space behind 'class'.

@Hirse, you told me to look if you forgot any test. One that is missing is for the fix of anonymous functions within other functions that was in my previous PR. If you write it, you will realize that it fails. Within a class, the subsequent function to a function containing an anonymous one, loses the namespace. I'm on it. But I think is best to send you these changes while I try to fix it.

Hirse commented 7 years ago

Thanks for these improvements. Could you also activate the multiple interfaces test by changing xit to it?

pelatx commented 7 years ago

No problem. Committed.

Hirse commented 7 years ago

Thanks again. And thanks especially for the test cases.

I am ok to merge this as is, but I am wondering if myFunc::function is the best way to display nested functions. In JS, the extension has the concept of levels to express the nesting depth. Do you think that is possible to add to PHP too?

pelatx commented 7 years ago

You're welcome.

I was going to ask precisely for that, since I do not think it's the best way either. In fact, I tried it out that way first. But in the end, I discarded it seeing that in PHP Lexer there is no indentation for the rest.

Could you elaborate a bit on how it should be implemented?

pelatx commented 7 years ago

Sorry, I wanted to say how it should look.

Hirse commented 7 years ago

In a simplified way, every time the namespace is expanded the level would be incremented and when it is reduced, decremented.

For how it should look, you could have a look the the nested functions testcase, unfortunately not yet in object notation.

In PHP also the classes could be regarded of course.

pelatx commented 7 years ago

Thanks.

I like the idea of issue #67, but without the properties appearing. Do you think it would be a good way for PHP outline list?

I will fix the anonymous functions and maybe then try something like that if I have some time.

Hirse commented 7 years ago

Absolutely agree. Classes and functions should be sufficient.

Let me know when you think this is ready to merge and thanks for your great work.

pelatx commented 7 years ago

No problem. :-)

pelatx commented 7 years ago

Ups! A check fails. I'll look at it as soon as I can, I do not have time now.

pelatx commented 7 years ago

I think it's ready.

The indentation is implemented and classes (highlighted) are also shown.

I modified the existing tests to reflect the changes and added one for the indentation.

Hirse commented 7 years ago

Great work, thanks. Will play around with it a bit and then release a new version.

EmbDclic commented 6 years ago

@pelatx

I like the idea of issue #67, but without the properties appearing.

Having properties listed too would be very useful. Is there a technical difficulty preventing it? Thanks!

Hirse commented 6 years ago

@EmbDclic No, I think it should be technically possible. It was just never really in scope for this extension. Since this PR, I have switched to using php-parser instead of the code added here, but that should only make it easier.

If you would like to have that functionality, please open an issue so we can track the progress. Or try to add it yourself, contributions are very welcome.