简体   繁体   中英

Generate a collection of changed lines between two revisions of a file using Java

I am writing an eclipse plugin which needs to be able to determine which lines of a file have changed compared to a different version of the same file.

Is there an existing class or library which I can use for this task?

The closest I have found is org.eclipse.compare.internal.merge.DocumentMerger. This can be used to find the information I need but is in an internal package so is not suitable for me to use. I could copy/paste the source of this class and adapt it to my requirements. However, I am hoping there is an existing library to handle textual comparisons.

For textual comparisons, try the google-diff-match-patch library. (I don't know whether Eclipse already has something similar built-in.)

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