예제 #1
0
파일: godiff.go 프로젝트: postfix/go-diff
func showDiffLine(del, ins string) {
	delT, insT := tm.LineToTokens(del), tm.LineToTokens(ins)
	matA, matB := tm.MatchTokens(delT, insT)

	showDelTokens(delT, matA, insT)
	showInsTokens(insT, matB, delT)
}
예제 #2
0
func TestDiffLine(t *testing.T) {
	delT := tm.LineToTokens("func g(src string, dst string) error {")
	insT := tm.LineToTokens("func (m *monitor) g(gsp string) error {")
	_, matA, matB := ed.EditDistanceFFull(len(delT), len(insT), func(iA, iB int) int {
		if delT[iA] == insT[iB] {
			return 0
		} // if
		return len(delT[iA]) + len(insT[iB]) + 1
	}, func(iA int) int {
		if delT[iA] == " " {
			return 0
		} // if
		return len(delT[iA])
	}, func(iB int) int {
		if insT[iB] == " " {
			return 0
		} // if
		return len(insT[iB])
	})
	ShowDelTokens(delT, matA, insT)
	ShowInsTokens(insT, matB, delT)
}