Created
April 15, 2020 15:18
-
-
Save rodrigo-brito/a9fa7985b39ec262efbe1f167ac4439c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package refdiff.examples; | |
import java.io.File; | |
import refdiff.core.RefDiff; | |
import refdiff.core.diff.CstDiff; | |
import refdiff.core.diff.Relationship; | |
import refdiff.parsers.go.GoPlugin; | |
public class RefDiffExampleGo { | |
public static void main(String[] args) throws Exception { | |
runExample(); | |
} | |
private static void runExample() throws Exception { | |
// This is a temp folder to clone or checkout git repositories. | |
File tempFolder = new File("temp"); | |
// Creates a RefDiff instance configured with the Go plugin. | |
try (GoPlugin goPlugin = new GoPlugin(tempFolder)) { | |
RefDiff refDiff = new RefDiff(goPlugin); | |
File repo = refDiff.cloneGitRepository( | |
new File(tempFolder, "go-refactoring-example.git"), | |
"https://github.com/rodrigo-brito/go-refactoring-example.git"); | |
CstDiff diffForCommit = refDiff.computeDiffForCommit(repo, "e1f5a1f26bf66c33112316549000d9ae01eb84ed"); | |
printRefactorings("Refactorings found in commit e1f5a1f26bf66c33112316549000d9ae01eb84ed", diffForCommit); | |
} | |
} | |
private static void printRefactorings(String headLine, CstDiff diff) { | |
System.out.println(headLine); | |
for (Relationship rel : diff.getRefactoringRelationships()) { | |
System.out.println(rel.getStandardDescription()); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment