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

Symbols Navigation #11

Open
devalnor opened this issue Apr 18, 2017 · 29 comments
Open

Symbols Navigation #11

devalnor opened this issue Apr 18, 2017 · 29 comments

Comments

@devalnor
Copy link

It will be great to have symbols navigation :)

I made a quick search about it and I found that it was easy with Sublime Text
https://github.com/SublimeText/ColdFusion/blob/master/Symbol%20List.tmPreferences

But probably will not work with vscode. Not deeply tested yet.

Otherwise PHP community solve it
https://github.com/ly95/vsc.php-symbols

Thanks for this extension btw.
Mx

@lmajano
Copy link

lmajano commented Jul 24, 2017

I would be willing to sponsor this feature! @ilich Would you be interested?

@ilich
Copy link
Owner

ilich commented Jul 26, 2017

Sounds good, @lmajano. Could you send me a private message on Twitter, and we will discuss the project. I would like to keep working on the project.

@ilich
Copy link
Owner

ilich commented Sep 7, 2017

It seems we will have to create a language server for CFML to support those features.

Is there any official CFML language specification similar to ECMASscript or C# specification?

Do you think we should use https://cfdocs.org/ as the starting point? I think this project might be useful to generate TextMate Language definitions and snippets.

Does anybody know any good CFML parser? I found https://github.com/cfparser/cfparser that supports ANTLR4 and I hope to generate JavaScript code and may be even TypeScript code from it.

I also found https://github.com/denuno/cfml.parsing/tree/master/antlr, but it seems to be outdated.

@lmajano
Copy link

lmajano commented Sep 8, 2017 via email

@tdhatcher
Copy link

I think VS Code has some real potential to become the best editor for CF.

This could also be an opportunity to add some "intellisense" beyond what can only be derived from within the contents or path of a open file in the editor. Perhaps some metadata or config file present to help provide the editor with some context to take advantage of other IDE features that seem to lack in all other CF IDE/Editors. Analysis of the entire project directory and config files with Javascript/TypeScript.

"Language servers let you create a dedicated process for your extension."

https://code.visualstudio.com/docs/extensions/example-language-server
https://code.visualstudio.com/docs/editor/intellisense#_troubleshooting

@lmajano
Copy link

lmajano commented Sep 13, 2017

@ilich You can use this for a parser: https://github.com/foundeo/cfmlparser

Remember like @tdhatcher mentioned, we can use a language server in the background. We can use an instance of CommandBox to achieve this. So we can even have a running CFML engine at the OS level

@ilich
Copy link
Owner

ilich commented Sep 13, 2017

@lmajano You are right. We have to build a language server to support any intellisense, refactoring, etc. Users will have to have ColdFusion/Lucee installed locally to be able to run it, won't they? Is there any lightweight option to run CFML script?

I know several developers who have ColdFusion running on the server, and they just code locally and upload files over FTP. That's why I was thinking about ANTLR4. It is capable to generate a JavaScript parser. In this case language server might be built in TypeScript that is available out of the box with VSCode. What do you think?

PS Of course, if we cannot find ANTLR4 syntax, let's build the server in pure CFML. I assume that most of developers have Lucee or ColdFusion locally anyway.

@lmajano
Copy link

lmajano commented Sep 13, 2017

You can use CommandBox for this. www.ortussolutions.com/products/commandbox. It allows you to execute cfml at the operating system with no server. The sublime extension also uses this. This allows you to leverage CFML like php or nodejs but at the OS level.

@KamasamaK
Copy link

KamasamaK commented Sep 13, 2017

Regarding parsing, CFParser is the best one I know of, but I'm not sure it is performant enough. The primary maintainers on it are @ryaneberly and @denuno. It is the parser that is used for CFEclipse and CFLint.

Creating a language server goes beyond even VS Code and is currently the best possible solution for the widest support. GitHub recently announced Atom-IDE, which utilizes language servers. There is also a Sublime Text 3 LSP package.

@lmajano
Copy link

lmajano commented Sep 14, 2017

What about this one: https://github.com/foundeo/cfmlparser

@denuno
Copy link

denuno commented Sep 15, 2017

That one doesn't do cfscript AFAIK.

CFParser is the best and fastest that I know of. CFEclipse runs it after every change and it's zippy enough in general. I think it's the only complete 3rd party parsing solution.

I think we're going to be adding a more generic model, right now it handles both tags and script but they're basically separate models.

That'd be your only real issue using a JavaScript ANTLR target for the lexer/parser based off of the existing grammar -- it'd only handle script, as the tags are handled by Jericho (an HTML parser)... A couple of us have tried to write ANTLR grammers for the tag stuff too, but so far they've been too brittle to handle all the real-world crazyness valid CFML can be. Jericho is geared for exactly that kind of thing.

You could use CommandBox as a language server, and run CFParser or CFLint to generate the document model, or say to heck with tags and use the javascript targets from the ANTLR grammar and basically plug it in the same way the PHP folks did their tokens, or revisit the tag ANTLR grammar and try to support tags that way.

A lot depends on what you want to do, and where you want to go. If all you need is function tokens, you can do that with a couple regular expressions, basically. But soon you want arguments, and then better yet references, so you can do a "replace all occurrences" on a variable and have it not change things that are strings or a different variable with the same name, etc..

If there's stuff we can do for CFParser that will make it easier for other tools, we're all ears. I'm doing stuff for CFEclipse and sorta kinda keeping Sublime in mind. We could all try to define a good document model and then use that, so implementations could vary. (Language committee type stuff I reckon, really, but at this point I think the tools folks are as good as any to create a standard.)

Anyhow, I've played with VS Code and I like it, and I'm always happy to get better CFML support wherever it's needed-- Plus I'm probably one of the world's foremost experts on CFML IDE integration don't cha know! -- so feel free to pick my brain. :-)

@lmajano
Copy link

lmajano commented Sep 15, 2017 via email

@WebVeteran
Copy link
Contributor

@ilich ,
As with @lmajano I would be willing to co/sponsor the upgrade of CFML support in VSC. It's the only thing keeping me from using VSC... so I am in Sublime Text 3 for now, which has better CFML support but is lacking in many other areas.

@ilich
Copy link
Owner

ilich commented Sep 18, 2017

@WebVeteran Thank you very much!

@WebVeteran
Copy link
Contributor

You're welcome. I am super duper eager. Whatever I can do to get this going, let me know! Email is in my profile.

@denuno
Copy link

denuno commented Sep 21, 2017

It looks like https://github.com/eclipse/lsp4j is probably the way to go. I don't think we'd need a running server per se. (Seems like it handles that aspect-- you just implement the guts.)

We could probably kind of mirror what JDT does, and create a generic CFML project model/interface, and that way the implementation could be anything, really, thought right now CFParser is the only one that comes close to giving a useful parse.

I like the idea of a standard for this stuff. It'd be cool if it handled highlighting and whatnot too, but MS considers that a client-side issue I guess. Not a small task though.

@ilich
Copy link
Owner

ilich commented Sep 22, 2017

@denuno Thank you for the link. I will take a look. You cannot use a parser or language server for syntax highlighting because it will cause performance problems. More information is available on https://code.visualstudio.com/blogs/2017/02/08/syntax-highlighting-optimizations post. Unfortunately we will have to use TextMate regular expressions, and it seems to be complex in case of CFML language because people mix HTML, CFML, cfscript and SQL inn one file. I am still looking a way to say VSCode that particular chunk should be parsed by SQL parser, etc (if it is even possible).

@WebVeteran
Copy link
Contributor

Would it be possible to port over https://packagecontrol.io/packages/CFML ? It does a great job, at least in what I use it for. Does that package do what you're looking to solve above?

@denuno
Copy link

denuno commented Oct 5, 2017

That Sublime package is awesome! I think parts of it are already ported here, and soon in CFEclipse too actually. (The TextMate/Sublime syntax file @ilich mentioned (with the mix of stuff) above.)

We could use the TextMate bit to tokenize things I think... that's not quite the same as a real model, but it would probably get a Language Server ("LS") going, ish. An interesting idea for sure! Maybe plug tm4e into lsp4j? Something tells me if it were that easy it'd exist out there already. Plus, it'd be cool to have a decent model, versus just knowing where generic tokens are.

After taking a hard look at how both Eclipse and IntelliJ IDEA do their Java stuff (arguably their best language editors, neh?)-- man, doing it really well is not super easy! Those are some deep models, with lots of caching, etc..

So, I dunno, maybe we don't do it really really well. 😃 Or maybe we grab one of those and tweak 'em to suit our needs. Or maybe tweak the Groovy LS (less complicated model at first glance at least). FWIW, I'm currently leaning towards maybe putting what I saw into a middle-of-the-road interface+implementation, and then using that in an LS.

@ilich Being able to edit mixed languages is something that VSCode/the LS Protocol will have to support eventually (I winced looking at the tickets relating to it -- not going to link because man it's long enough already -- but vscode issue 670 is a place to start to find a couple potential routes).

As for the coloring, it seems like TextMate/Sublime is sort of the standard, and so I tossed the same tmLanguage into CFEclipse, and used the tm4e plugin, which I think actually uses the (at least optimized) stuff you linked too. I like the idea of everyone being able to use a standard for colorizing, but it is a monster syntax file.

I can see why you'd want to do the rendering on the client, but I don't see why we couldn't somehow use the same model for both doing stuff to/finding stuff in the code, and colorizing it.... probably just not thinking clearly because they all seem to use (basically) regex for the coloring, while keeping the model separate-- maybe it's fastest or something? (though with the cache... (hmm. meh. le shrug :-) ) )

@WebVeteran
Copy link
Contributor

If VSC's cfml matched what is in sublime, I'd move over to VSC. It's the only thing stopping me.
I don't want to sound like an a-hole talking about money - but I'd pay to get it ported over sooner rather than later. Definitely not as much as it's worth... I don't pretend to know the effort involved. Still it's important to my workflow and business, so the value is there, and I would happily contribute something. If anyone is interested, please get in touch with me.

@denuno
Copy link

denuno commented Oct 6, 2017

I don't know about other people, but I find money motivating,and you the opposite of an a-hole. :-) I think we could get the CFML to match what's in Sublime, but if you're looking for the multi-language editing that Sublime has, this will have to be addressed: microsoft/vscode#1751

@WebVeteran
Copy link
Contributor

Aren't so many of these editors based on Electron? Why/how do they all work differently? I don't understand why ST3 handles this so well but VSC can't.
Also I'm bewildered by Atom being 500MB!

@KamasamaK
Copy link

KamasamaK commented Oct 6, 2017

While proper language injection would be nice, it's not absolutely necessary. For right now at least, you can enable Emmet to work with the language and get some help that way, though I found it annoying especially in CFC files where you wouldn't have those things.

With a language server, though, if you can determine in what ranges each language is applicable, you should be able to delegate those requests to the appropriate other language server yourself -- HTML and CSS -- and have your language server act as a proxy in those instances. In order for the document to be properly parsed by that language server, I suppose you would have to strip out any CFML before passing it off and account for those changes when constructing your response. It could get tricky in the case of cfoutput and variables used in the structure of the document.

As for client-side support, there seems to be support to some extent but I haven't been able to find details on how beyond microsoft/vscode#11081 existing. Microsoft's own html grammar or php grammar could probably analyzed as well, but I'm just not familiar enough with the format. If you use the Developer: Inspect TM Scopes command on the respective files, you can see it transitions appropriately.

@WebVeteran
Copy link
Contributor

I'm starting to feel like VSC won't be my future website IDE. The ability to handle multiple languages in a single file is crucial. CFML being the most important to me.
Coda does it but has many bugs in other areas.
Sublime does it but the gui and overall community is lacking.
Its frustrating to think I'll have to spend $ on ST3 and the SFTP plugin and still be unsatisfied - whereas VSC is where I'd rather invest but seems to be a dead end.
Dreamweaver won't install.
Eclipse/aptana/cfbuilder are complete messes.
...
TGIF

@WebVeteran
Copy link
Contributor

Silly question maybe... VSC does html+css+js mixed just fine. Why cant we (excluding me) copy the html syntax and add all the cfml elements? Then we'd only be left with the challenges of SQL mixed, and cfscript mixed. I'm like that client you have that has no idea what he's talking about but makes it sound easy =)

@ilich ilich added this to the 1.0.0 milestone Nov 20, 2017
@ilich
Copy link
Owner

ilich commented Nov 24, 2017

I have checked different possibilities and decided to go the longer path and implement CFML language server based on CFParser. The source code will be available at https://github.com/ilich/vscode-languageserver-coldfusion repository. I also found out that Atom supports LSP as well. This is good since we will be able to port the extension for Atom as well. I know that that editor is also quite popular.

@ilich ilich removed this from the 1.0.0 milestone Nov 24, 2017
This was referenced Mar 22, 2018
@randy-johnson
Copy link

@ilich, any movement on this?

@flowt-au
Copy link

Editing a lot of old CF code ...
Does this issue imply that command+R would display the cffunction names in the CFC ? At present it says "No symbol information for the file"

@msis-adrian
Copy link

msis-adrian commented Feb 24, 2023

I got it to work....kinda using
https://marketplace.visualstudio.com/items?itemName=KamasamaK.vscode-cfml

The problem is that having this installed, you lose the syntax code suggestions in cfscript tags and .cfc files.

So I'm not sure if this is a vscode issue with conflicting extensions. I'm having to choose what's more efficient for me. If anyone knows of a full solution, please let me know.

If you were brought here by google, like me, you probably didn't see the readme where it says this project is no longer active and to use the extension listed above.
Documenting this for others.

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

10 participants