简体   繁体   中英

Diff tool that can compare sub-sections of files

I'm looking for a diff tool that will allow me to compare just a sub-section of a file with a section of another file, or even of itself. Preferably eclipse based but will take all suggestions.

Yes I know I can copy out the two sections into different files and compare those, but that is very tedious when you are trying to do a large amount of refactoring.

Basically I'm trying to remove as much duplicated code as possible from a code base that is suffering from a great deal of ctrl-V 'inheritance' ;-) However the pasted parts have evolved apart a little over time.

I've been playing with Atomiq , which finds duplicates within a single file. So far it looks to be a decent tool.

Try using Diffuse . Just paste the two sub-sections you wish to compare into separate panes and press CTRL-L to re-align them. You could also load the files and manually adjust the alignment to match up the sub-sections of interest.

Two two tools I have used to root out duplicate code are Simian and CopyPasteKiller . Both are useful, although IMO CopyPasteKiller is a little easier to get started with. It appears there is an Eclipse plugin for Simian, although I have not used it myself.

CheckStyle is nicely integrated with Eclipse and will do the job. It will notify to you and error/warning if your code is duplicated, how much times... etc...

http://eclipse-cs.sourceforge.net/

Kdiff3 would be the other choice. Not Eclipse integrated, but a very nice free, cross-platform tool for merging, comparing files etc.

See SD CloneDR , a tool that detects exact and near-miss clones according to language syntax, for a large number of languages (Java, C#, PHP, C++, C, COBOL, Ada, ...). An Eclipse API is being readied at this moment, and is likely available January 1, 2010.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM