Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

syntax aware diff tools? [closed]

Tags:

Are there any (ideally GUI) diff tools that are aware of syntax?

As an example of the kind of thing I'm looking for, I keep finding that my current tool miss aligns repetitive code:

Foo  = { 'hello': 'world',    |  Foo  = { 'hello': 'world',
         'goodnight': 'moon'  |           'goodnight': 'moon'  
       }                      <
                              <
Bar  = { 'picture': 1000,     <
       }                      |         }

I'd like a tool that would try and make matching braces on one side align with matching braces on the other.


Edit: I'm looking for a tool that can automatically spot that condition and correct it's alignment.

like image 472
BCS Avatar asked Aug 10 '10 15:08

BCS


1 Answers

Not GUI based, but completely syntax driven: my company's Smart Differencer tools for many langauges (incluiding Java, C#, C++, PHP, Python, JavaScript, HTML, XML, COBOL,...)

The Smart Differencer parses the source text like the compiler, so it understands that language syntax and structures the way the compiler does. It compares these structures (using ASTs) to determine the "least edit distance" in terms of edit actions (move, copy, delete, replace, rename-identifier-in-block) on these structures and report them.

In your example, it would know the curly brace on the right belongs to foo, not bar, and would tell you that the entire statement involving bar was simply deleted.

The output style is diff-like if you want to feed the result to another tool, or more human readable if you want to examine it directly.

like image 81
Ira Baxter Avatar answered Oct 06 '22 03:10

Ira Baxter