You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There are several steps that this tool will need to go through that I can think of right now:
Get the contents of the files to diff
For standard diffs, this is simple since we just read in the contents of the two files. However, this tool will mostly likely be used in conjunction with a version control system, so we'll need to build in hooks to define how to get the two different versions of the file. I suspect there will be a lot of system-specific code for each VCS we support.
Generate the CST for both files
This is complicated by the fact that CST parsers don't exist for many languages. In addition to that, my understanding is that upgrading an AST parser to a CST parser isn't exactly a trivial process, especially if there's no standard to follow.
We'll need hooks for these parsers based on file extension. We can fall back to a standard text-based diff if we don't have a parser registered for a given file extension.
Some parsers will need to call into other parsers. For example, the HTML parser will want to run <style> content through the CSS parser and <script> content through the JS parser.
Generate the diff from the CSTs
I'm not sure if we'll want to create an object structure that we can transform into the actual diff or if we'll just want to always generate a diff that matches the standard diff format.
Apply syntax highlighting
I'm not sure how many tools exist for applying syntax highlighting to small code snippets. This might be a very difficult problem since you lose so much context when you're applying the highlighting to the individual portions of the diff.
There's probably more that I'm not thinking of. Let's gather ideas here and build out a plan.
The text was updated successfully, but these errors were encountered:
Generating CST parsers from grammars is actually pretty easy. It would be possible to modify the generated parsers so that they could operate on snippets and apply syntax highlighting, but it's probably easier to annotate the CST before the diff and then use those annotations to do the syntax highlighting.
There are several steps that this tool will need to go through that I can think of right now:
Get the contents of the files to diff
For standard diffs, this is simple since we just read in the contents of the two files. However, this tool will mostly likely be used in conjunction with a version control system, so we'll need to build in hooks to define how to get the two different versions of the file. I suspect there will be a lot of system-specific code for each VCS we support.
Generate the CST for both files
This is complicated by the fact that CST parsers don't exist for many languages. In addition to that, my understanding is that upgrading an AST parser to a CST parser isn't exactly a trivial process, especially if there's no standard to follow.
We'll need hooks for these parsers based on file extension. We can fall back to a standard text-based diff if we don't have a parser registered for a given file extension.
Some parsers will need to call into other parsers. For example, the HTML parser will want to run
<style>
content through the CSS parser and<script>
content through the JS parser.Generate the diff from the CSTs
I'm not sure if we'll want to create an object structure that we can transform into the actual diff or if we'll just want to always generate a diff that matches the standard diff format.
Apply syntax highlighting
I'm not sure how many tools exist for applying syntax highlighting to small code snippets. This might be a very difficult problem since you lose so much context when you're applying the highlighting to the individual portions of the diff.
There's probably more that I'm not thinking of. Let's gather ideas here and build out a plan.
The text was updated successfully, but these errors were encountered: