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

Inline JavaScript #15

Open
harsimranb opened this issue May 13, 2014 · 6 comments
Open

Inline JavaScript #15

harsimranb opened this issue May 13, 2014 · 6 comments

Comments

@harsimranb
Copy link
Owner

We need to also support JavaScript inside an inline < script / > block.

Michael, any pointers on how I should go about this? We probably want to ad code completion, code folding, errors, code snippets, document highlighting?, and code formatting inside html and cshtml files.

@harsimranb harsimranb added this to the Initial Release milestone May 13, 2014
@harsimranb harsimranb self-assigned this May 13, 2014
@mhutch
Copy link

mhutch commented May 13, 2014

This one is definitely not easy as we don't have a standard system for handling languages embedded inside documents written in other languages.

Syntax highlighting is the easy one, you've seen how the HTML addin does that already.

Beyond that, I think the JS addin would need to provide an API for handling sections of JS inside a larger document, and you'd have to alter the handling of the languages that embed JS (HTML, Razor, ASPX) to use this API to handle JS.

e.g.

public static class EmbeddedJavaScriptHandler
{
    // HTML parser uses this to parse body of <script> tags
    public static JavaScriptFragment Parse (TextReader reader, int start, int length);
    // HTML ParsedDocument uses this to generate foldings within <script> tags
    public static IEnumerable<FoldingRegion> GenerateFoldings (JavaScriptFragment fragment);
    // HTML TextEditorExtension uses this to generate outline children for <script> tags
    public static void GenerateOutline (JavaScriptFragment fragment, Gtk.TreeStore store, Gtk.TreeIter parent);
    // HTML TextEditorExtension uses this to generate completions within <script> tags
    public static CompletionDataList HandleCompletion (IEnumerable<JavaScriptImports> imports, IEnumerable<JavaScriptFragment> documentFragments, TextEditorData editor, int offset);
    // etc ...
}

Obviously you could do this incrementally, e.g. start with a proof of concept that just adds folding support, then work your way down the other features.

@mhutch
Copy link

mhutch commented May 13, 2014

TBH I would put this on hold until you have all the basics working well for JS files.

@harsimranb
Copy link
Owner Author

I agree. I also like the POC.
I'll move this to Polishing Release for now.

@harsimranb
Copy link
Owner Author

@mhutch my idea for the embedded scanning was to do something similar to R#, not sure if its achievable though.

Basically, the inline </script> tag would provide auto-completion members based on the files referenced in <script src=''/>. I'm assuming something like this would require changes to the original add-ins. I guess once we get to this stage, we'll experiment on the simple HTML files first.

@mhutch
Copy link

mhutch commented May 14, 2014

Yeah, the idea with HandleCompletion is that the IEnumerable<JavaScriptImports> would be the URLs from <script src=.../> tags and the IEnumerable<JavaScriptFragment> would be the parsed JS regions from the current file, so the completion engine could complete symbols from them.

@harsimranb
Copy link
Owner Author

Nice. That will make things very easy.

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

2 participants