上下文感知合并? [英] Context-aware merge?

查看:73
本文介绍了上下文感知合并?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有任何用于编程语言的差异/合并工具,都可以以语法感知的方式工作(例如XML Diff工具),其作用不只是逐行比较(并且可以忽略空白).

Is there any diff/merge tool for programming languages, that works in a syntax-aware way (like XML Diff Tool), doing more than compare line-by-line (and optionally ignoring whitespace).

我对实际上遵循语言语法和分隔符的程序很感兴趣,可以在不破坏语法正确性或不将语句捆绑成多行的情况下提出更改建议.行为示例为:

I'm interested in a program actually following the language syntax and delimeters, suggesting changes without breaking syntactic correctness, or bundling statements separated over multiple lines. Example behavior would be:

*一旦找到引入额外嵌套级别的if(){,则会自动将闭合括号}与下面的几行捆绑在一起.)

*upon finding an if(){ which introduces an extra nesting level automatically bundle the closing brace } several lines below with it.)

*将匹配的语法元素保持在一起,避免像创建一个块这样的愚蠢行为易于创建:

*keep matching syntax elements together, avoid silliness like removing a block tends to create:

 int function_A()
 { 
     int ret;
     ret = something;
     ret += something_else;

      return ret;
  }

  int function_B()
  { 
     if(valid)
     {
         int ret;
         ret = something;
         ret += something_else;

          return ret;
      }

       else return -1;
  }

我个人很想找到能够处理C ++语法的软件,但是了解其他语言的解决方案也会很有趣.

Personally, I'd love to find software capable of handling C++ syntax, but knowing about solutions for other languages would be interesting too.

推荐答案

超越比较可以满足您的要求.它不会一次保持语法正确性或不比较语言块,但可以执行以下操作:

Beyond Compare does some of what you're asking. It doesn't maintain syntactical correctness or compare language blocks at a time, but it can do the following:

  • 对语言语法有一定了解,因此它可以对比较文件进行语法高亮显示,并且还可以识别并有选择地忽略不重要的差异(例如注释,包括多行注释).
  • 支持使用外部转换程序加载和保存数据.开箱即用,它支持使用它在比较XML和HTML之前对其进行美化.您可以在比较两个C文件之前设置GNU Indent以标准化语法.
  • 可选的线粗,可让您为匹配(例如右括号)赋予更高的权重.我没有尝试过此功能.
  • 替换,忽略单个会话,将左侧old_variable_name替换为右侧new_variable_name的每个位置.
  • Some understanding of language syntax, so it can do syntax highlighting of compared files, and it can also recognize and optionally ignore unimportant differences (like comments, including multiline comments).
  • Support for using external conversion programs for loading and saving data. Out of the box, it supports using this to prettify XML and HTML before comparing it. You could set up GNU Indent to standardize syntax before comparing two C files.
  • Optional line weights to let you give a higher weight to matching, e.g., closing braces. I've not tried this feature.
  • Replacements, to ignore for a single session every place where old_variable_name on the left was replaced with new_variable_name on the right.

这是迄今为止我使用过的最好的差异合并工具.它也是跨平台的,价格便宜(标准版为30美元,专业版为50美元),而且评估期非常宽裕,因此值得一试.

It's by far the best diff-and-merge tool that I've used. It's also cross platform, cheap ($30 for standard, $50 for pro), and has a very generous evaluation period, so it's worth a try.

这篇关于上下文感知合并?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆