问题
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.
回答1:
I've been playing with Atomiq, which finds duplicates within a single file. So far it looks to be a decent tool.
回答2:
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.
回答3:
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.
回答4:
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.
回答5:
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.
来源:https://stackoverflow.com/questions/1800634/diff-tool-that-can-compare-sub-sections-of-files