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

Project motivation / VS Code / IDE support? #351

Open
mindplay-dk opened this issue Feb 23, 2021 · 7 comments
Open

Project motivation / VS Code / IDE support? #351

mindplay-dk opened this issue Feb 23, 2021 · 7 comments

Comments

@mindplay-dk
Copy link

I was wondering, could you speak to the motivation or near/long-term goals of this project?

When first I saw this project emerge, I thought, "great, a company with real resources is finally putting some force behind PHP IDE support" - my hope or assumption was that this would be a first, important step towards proper language support in VS Code, which seemed natural, given the timing and the relative vacuum of useful IDE support for PHP.

Nothing more happened though? I've looked time and again to see which packages depend on this one, and still the only attempt there's been at IDE support is this one-man project:

https://github.com/felixfbecker/php-language-server

It looked promising, but it's a hobby project, and there's been no real activity on it for a couple of years now.

Other static analysis tools have tried to repurpose themselves, or third party contributors have attempted it, and the results are pretty mixed. (For one, they don't have an error tolerant parser, and they were largely designed with offline processing in mind.)

PHP support in VS Code remains on par with bad PHP tools at best. There's essentially only one IDE on the market that provides any meaningful IDE support for PHP today - I don't think I need to name it.

So the bar is relatively low or high, depending on whether you're looking at PHP IDEs at large, or the one IDE that actually "understands" PHP.

Does Microsoft have any plans to eventually do something in the PHP IDE space, like actually leverage this package for language server support for PHP? Or is that all up to the community?

Who or what is this package for, if the goal is not to achieve IDE support at some point in the future? While anyone is still interested in PHP. 😏

@roblourens
Copy link
Member

Thanks for reaching out @mindplay-dk. I have to admit that I haven't been able to put the time into this project that it deserved. I would like to keep it moving forward, and we have had a couple active contributors whose work I really appreciate. I would like to keep managing PRs, but I am pulled in multiple directions in my work and don't have the time to write a lot of code for it myself. So making any real progress here will require community effort.

We worked with the author of php-language-server awhile back, and my understanding was that it was actually used by Sourcegraph. I'm not sure whether they stopped using and developing it or just stopped open-sourcing it. Reached out to the author recently but haven't heard back.

And I wish we could do better with PHP but currently there is no plan to put more resources into it. Sorry that I don't have a better answer for you.

@TysonAndre
Copy link
Contributor

I'm one of the contributors - This is currently used by http://github.com/phan/phan as a fallback parser for parsing files that have syntax errors (I'm one of Phan's maintainers)

Does Microsoft have any plans to eventually do something in the PHP IDE space, like actually leverage this package for language server support for PHP? Or is that all up to the community?

E.g. this is used for the syntax error tolerance of the Phan language server client for vs code https://github.com/tysonandre/vscode-php-phan#error-detection-tolerating-syntax-errors (as well as a fallback if the PECL https://github.com/nikic/php-ast/ is not installed)

I'd asked maintainers of other static analyzers (that also included language server implementations)

  • The last time I checked was years ago - at the time, this did a better job than https://github.com/nikic/PHP-Parser/ at tolerating method bodies with incomplete closing braces and properly parsing the rest of the methods, but this may have changed
  • Currently, there are some open bugs in tolerant-php-parser for rare edge cases that are inconvenient - if someone had time to make a working PR it'd likely get reviewed, though
  • Switching from parser implementations to others is a lot of work and a backwards incompatible change, so existing projects tend not to do this - approaches such as https://github.com/TysonAndre/tolerant-php-parser-to-php-ast can be used but make parsing take longer and require work to implement/support/test for combinations of parsers

@mindplay-dk
Copy link
Author

@TysonAndre I've actually been rethinking this a bit. If an IDE only gets new type information when the syntax is valid, that's probably fine if it's able to track line history in the editor while the code is invalid. That is, if you insert/remove lines (etc.) is the editor able to maintain associations to information produced by the analysis engine. The editor would have to treat syntax errors and other metadata as two different entities - only the syntax information would update continuously while you're making a change, while the metadata would simply get remapped to existing line identities and wouldn't actually update until there are no syntax errors. This would probably work just fine, as syntax errors are usually very temporary - and generally get dealt with before making any other changes to the code.

@roblourens
Copy link
Member

Maybe I don't fully understand the point you're making, but I think that being able to get type information in files with syntax errors is important in the typical editing scenario, and is most important right next to the actual syntax errors, because this is where you are actively editing.

@mindplay-dk
Copy link
Author

Maybe this is dependent on someone's personal work style, but I don't normally have more than one syntax error in a file at any given time - and it's usually at the site where I'm currently editing. Syntax errors are the first thing you have to fix, otherwise you can't run your program at all, right? So if only the first syntax error gets highlighted, that's probably fine. If other problems (type-checking errors etc.) only get updated when the syntax is valid, that's probably fine.

I guess I'm wondering how big a problem it really is. Again, this is assuming the IDE treats syntax and other analysis errors as separate entities, updates them individually, and maintains associations to the most recent analysis errors during edits.

I don't know, no big point here really, just wondering how critical error-tolerance really is to IDE support.

@roblourens
Copy link
Member

Getting type info from incomplete code is also important for other language features like intellisense, which you need right at the cursor, where code is invalid.

@mindplay-dk
Copy link
Author

Getting type info from incomplete code is also important for other language features like intellisense, which you need right at the cursor, where code is invalid.

For auto-completion, yeah, I see what you mean.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants