ponylang / ponyc

Pony is an open-source, actor-model, capabilities-secure, high performance programming language
http://www.ponylang.io
BSD 2-Clause "Simplified" License
5.7k stars 415 forks source link

Built in code completion #1145

Open Triangle345 opened 8 years ago

Triangle345 commented 8 years ago

This feature request is definitely a "nice to have" so I'm not expecting people to jump on this.

Currently pony has several syntax highlighting supported editors. Highlighting is nice but a statically typed language really benefits from an IDE/Editor that has code completion/assistance.

One such way of pushing this is to offer built in code completion mechanics by the compiler itself such as the way Nim Language does:

http://nim-lang.org/docs/idetools.html

I assume the underlying mechanism is simply parsing of the AST on demand.

Having built in code completion would further language adoption and make writing additional libraries much more pleasant for people. It would also take pressure away from giving out a full blown IDE and let the community create one.

SeanTAllen commented 8 years ago

@Triangle345 thanks for the pointer to how Nim is doing this.

chalcolith commented 8 years ago

Microsoft Common Language Protocol: https://code.visualstudio.com/blogs/2016/06/27/common-language-protocol

SeanTAllen commented 8 years ago

We discussed this during the sync call. Anyone who wants to take this one, we are happy to assist as we can but this isn't something that any of the committers is currently hankering to take on. We'd suggest opening a RFC so you get feedback on your approach and assure that your idea and hard work would be something that would be merged.

aturley commented 8 years ago

Hey @Triangle345, I don't know if you've seen it or not, but you can run the compiler with the --ast flag to produce a representation of the program's AST, which you could then parse with a separate tool to produce something like IDE autocomplete information. The format of the AST output is kind of like s-expressions, so it should be reasonably easy to parse (certainly easier that trying to parse Pony yourself). Doing it this way would get around the need to build this into the compiler itself.

Triangle345 commented 8 years ago

Let me take a look at the -ast flag and see what I can come up with. Thanks!

On Wed, Aug 31, 2016 at 3:49 PM, Andrew Turley notifications@github.com wrote:

Hey @Triangle345 https://github.com/Triangle345, I don't know if you've seen it or not, but you can run the compiler with the --ast flag to produce a representation of the program's AST, which you could then parse with a separate tool to produce something like IDE autocomplete information. The format of the AST output is kind of like s-expressions, so it should be reasonably easy to parse (certainly easier that trying to parse Pony yourself). Doing it this way would get around the need to build this into the compiler itself.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/ponylang/ponyc/issues/1145#issuecomment-243879585, or mute the thread https://github.com/notifications/unsubscribe-auth/AEEHvoy8MQADW63Jw8mf6hf-sx1AvRxTks5qldrhgaJpZM4Jpubi .

Triangle345 commented 8 years ago

So after looking into the compiler AST output...

Use "--astpackage" instead of "--ast" because "--ast" is the AST of the entire program which takes a while to generate and is too much. It is also a subset of all the objects included.

The following command could be ran for each file to determine its AST: ponyc.exe --pass=parse --astpackage --verbose=0

The following can be ran on a project to determine what files need parsing: ponyc.exe --pass=expr--files --verbose=0

The idea here is to run ponyc in the background as a separate process for each required package/module. Since we are skipping the parsing phase, it will not give us syntax warnings for incomplete syntax.

However; the issue i'm up against at this point is the limited way to create and run process for windows in ponyc. ProcessMonitor seems to be the only way to do it for linux but no batteries included for windows. ProcessMonitor also seems a bit overkill for this task.

One could also use direct sys calls to C to spawn a process but I feel as if pony needs a simple command runner like they have in almost every other language.

I guess the next step would be to patch ProcessMonitor and add windows sys calls to before I can start this.

malthe commented 8 years ago

Facebook's Flow code checker is smart about just checking the diff from a previous check which makes it efficient and provides very quick feedback.

kcrimson commented 7 years ago

@Triangle345 I think current ast format is fine, I am playing with Atom package with auto-completion (back after months of procrastination :) ), the thing that is missing is buffer coordinates in AST output. It would be pretty easy to add them, just modify ast.c:print family of methods. At least this would be easy then for Atom to digest this input :)

binary132 commented 6 years ago

Has anyone had eyes on this recently?

mfelsche commented 6 years ago

Not really, though there is https://github.com/patroclos/pony_intellisense_vscode now. but i don't know the current status of it.

Akiyamka commented 2 years ago

I am ready to change my favorite editor to any that would support pony code completion. Must have feature for newbie