PrestoSoft Blog :: Home

Sunday, November 27, 2022

ExamDiff Pro 14.0: Matching File Structures for Comparison

ExamDiff Pro 14.0 will introduce a new advanced comparison option: the ability to match file structures (functions, classes, etc.) for comparison. This is a fairly advanced feature that can result in more clear comparison results for programmers.

Like the scope bar introduced in ExamDiff Pro 13.0, structure matching is powered by the open-source TreeSitter library, and will be available for all major programming language doctypes defined in ExamDiff Pro, including C++, C#, Java, JavaScript, and more.

Let's illustrate this feature by showing a couple of examples of situations in which it can be useful.

To start with, here's ExamDiff Pro comparing the before-and-after of simple refactor of a JavaScript function:

This diff looks ugly and doesn't do a good job of capturing what happened — that is, some functionality from the generateIDForObject() function got factored out into a separate function. The problem is that the closing brace of the generateIDForObject() function in the left file is getting matched to the wrong closing brace in the second file. Because there are not a lot of completely identical lines between the two files, ExamDiff Pro's comparison algorithm doesn't have a good way to decide which closing brace in the second file to match to the one in the first file, and it ends up making a match that results in a confusing diff.

Ideally, we would like to match the closing braces of the generateIDForObject() function in each file together. We can do this ourselves using the manual synchronization feature to link these lines together manually. Now the diff looks much clearer:

But drawing links between lines ourselves kind of defeats the purpose of using a file comparison tool. Is there any way that ExamDiff Pro could automatically determine that these lines naturally should be linked together, based on the fact that they correspond to the boundaries of the same function?

This is where the Match file structures for comparison feature comes in. We can open up Options | Text Comparison | Advanced and check the Match file structures for comparison box:

Then re-compare these files, and voila! ExamDiff Pro is able to give us exactly what we want, automatically:

So how does this work? Basically ExamDiff Pro does the same file structure parsing that it does for generating the scope bar, and uses its knowledge of which functions, classes, and other structures correspond to which between the two files to draw "invisible" links between corresponding starting and ending lines of each structure, in a similar way to how fuzzy line matching works. It's as though we went through the files and drew links at the start and end of each matching function, except ExamDiff Pro was nice enough to do all that work for us instead.

In fact, we can even visualize these "invisible" links, using the new "Show fuzzy/structure links" option under Options | Display:

Turning this option on, we can now see structure links (as well as fuzzy-matching links) between lines in the splitter, indicated by a lighter color than manual synchronization links:

Let's try a slightly more complicated example, this time showing a refactor involving overloaded C++ functions. Here's what it looks like without the Match file structures for comparison option:

This diff look a little off and doesn't really indicate what happened in the refactor — namely, one overload of GetNavigatableDiffCount() got deleted and one overload got modified. We would expect to see the GetNavigatableDiffCount(BOOL bUnresolvedConflictsOnly) method definition in the second file be matched with the GetNavigatableDiffCount(BOOL bUnresolvedConflictsOnly, int nPass) definition in the first file, but instead it's being matched with the GetNavigatableDiffCount() definition line. Without structural matching, the best ExamDiff Pro can do in terms of matching heuristically is fuzzy matching individual lines. This often gives the expected result, but here it doesn't, because the GetNavigatableDiffCount(BOOL bUnresolvedConflictsOnly, int nPass) method definition is broken into multiple lines in the first file but is a single line in the second file, so fuzzy matching can't tell that these definitions "belong together".

Fortunately for us, matching file structures comes to the rescue again! If we enable Match file structures for comparison, ExamDiff Pro is able to correctly deduce which function definitions are a closer match and links these functions' start and end lines accordingly:

Labels: , ,

Sunday, August 28, 2022

ExamDiff Pro 13.0 Released

We are pleased to announce that we've released ExamDiff Pro 13.0.

Here's what's new in this version:
  • Improved Table Comparison
  • Scope Bar (Class/Function Detection)
  • Windows 11 support
  • Ability to reset pane layout to default
  • View commands to zoom in/out views
  • Ability to copy HEX dump of data in binary comparison
  • Ability to use advanced diff algorithms in binary comparison
  • Option to show selection check boxes in directory comparison views
  • Suppress dark mode for diff report printing
  • Ability to skip resolved differences
You can find more details about ExamDiff Pro 13.0, as well as a download link, here, and the complete list of changes here.

Labels: , ,

Thursday, April 07, 2022

ExamDiff Pro 13.0 Beta

We are pleased to announce a public beta program for ExamDiff Pro 13.0.
You can download ExamDiff Pro 13.0 Beta for 32-bit Windows and for 64-bit Windows. The upgrade is free for all users who purchased ExamDiff Pro less than 12 months before this release (or more, depending on the number of maintenance years purchased).

Here's what's new in ExamDiff Pro 13.0 (as compared to 12.0):

Improved Table Comparison

Among the new features coming to ExamDiff Pro 13.0 is improved support for comparing tabular data - that is, files that are delimited by commas, tabs, or other characters. This version introduces a brand-new Table Comparison mode, with built-in functionality to sort and ignore columns and the ability to differentiate columns by color to better view tabular data.

For more information, see our blog entry about table comparison.

Scope Bar (Class/Function Detection)

ExamDiff Pro 13.0 introduces an exciting and long-awaited new feature: the ability to navigate through classes, functions, and other code blocks, via a new scope bar. This feature is powered by the open-source TreeSitter library, and is available for all major programming language doctypes defined in ExamDiff Pro, including C++, C#, Java, JavaScript, and more.

For more information, see our blog entry about scope bar.

Other Additions In ExamDiff Pro 13.0
  • Windows 11 support
  • Ability to reset pane layout to default
  • View commands to zoom in/out views
  • Ability to copy HEX dump of data in binary comparison
  • Ability to use advanced diff algorithms in binary comparison
  • Option to show selection check boxes in directory comparison views
  • Suppress dark mode for diff report printing
  • Ability to skip resolved differences

Labels: , ,

Saturday, December 04, 2021

ExamDiff Pro 13.0: Improved Table Comparison

Among the new features coming to ExamDiff Pro 13.0 is improved support for comparing tabular data - that is, files that are delimited by commas, tabs, or other characters.

If you're a regular reader of our blog, you'll recall that you can already compare tabular data in ExamDiff Pro, by using a custom plugin to sort columns and the Ignore Column Ranges option to ignore unwanted columns.

ExamDiff Pro 13.0 builds on this functionality and introduces a brand-new Table Comparison mode, with built-in functionality to sort and ignore columns and the ability to differentiate columns by color to better view tabular data.

Let's try it out, using the same CSV files as in the previous blog post on table comparison.

Comparing these files as plain-old text files with no special options gives us the same mess that we ran into last time:

But let's see what happens if we switch to Table Comparison mode.

Actually, before we do that, let's set the table comparison options that we need. We want to sort these files by their first column (BusinessEntityID) and ignore the 5th column (ModifiedDate). So, we go to the new Table Comparison options panel and enable Sort Columns for column 1 and Ignore Columns for column 5:

Now, armed with our desired table comparison options, we switch to Table Comparison mode from Files | Compare As:



Wow, very nice! Not only does Table Comparison mode put all of these features in one convenient place, without the need for any plugins, but it also provides a nice coloring scheme, so we can easily see what column each cell belongs to. (This coloring can be disabled in the same Table Comparison options panel, and is always superceded by diff colors within diff blocks.)

What's more, we aren't limited to comma-separated files anymore! By default, Table Comparison works on CSV (comma-separated) and TSV (tab-separated) files, but you can define any tabular file type with any delimiters that you want, in the Table file types section of the Table Comparison options panel:

File types that are registered as "Table file types" will be compared in Table Comparison mode by default. You can also choose which mode to compare them in from the Compare Dialog by clicking on the new Compare drop-down mode selector button:

And since Table Comparison is treated as a separate comparison mode, just like Text and Binary Comparison, you can easily toggle these table comparison features on and off, simply by switching between Table and Text comparison modes.

Labels: , ,

Thursday, December 02, 2021

ExamDiff Pro 13.0: Scope Bar

ExamDiff Pro 13.0 will introduce an exciting and long-awaited new feature: the ability to navigate through classes, functions, and other code blocks, via a new scope bar.

This feature is powered by the open-source TreeSitter library, and will be available for all major programming language doctypes defined in ExamDiff Pro, including C++, C#, Java, JavaScript, and more.

As an example, let's compare two C# files:

When we navigate inside a class or function, the new scope bar control at the top of the diff pane displays where we are, through a series of "breadcrumbs".

Clicking on a breadcrumb opens a nested scope explorer. Scopes that are different (added, changed, or removed) between the two files are highlighted in bold. We can click on any of the scope names here to jump to the corresponding part of the file:



The scope bar automatically updates itself whenever the file changes. For example, we can rename this property, and the scope bar quickly changes to reflect this:

You can control visibility of scope bars by using the View | Scope Bars menu command:

Note that the scope bars will only appear for document types supported by the scope parser (this includes most built-in doctypes in the Document Types options dialog). If a file extension isn't recognized by default, you can use the Set Document Type feature manually to enable all doctype-related features (scope bar, syntax highlighting, etc).

For example, in the screenshot below, the JavaScript files being merged wouldn't be recognized as JavaScript by default because they do not have the expected *.js file extension. But after clicking Set Document Type | JavaScript in one pane's context menu, we override the doctype for all panes to be JavaScript, causing scope bars (as well as syntax highlighting) to appear everywhere:

This new scope bar functionality will make navigating through source code easier than ever in ExamDiff Pro.

Labels: , ,