()
| 191 | } |
| 192 | |
| 193 | func (g *hunksGenerator) Generate() []*hunk { |
| 194 | for i, chunk := range g.chunks { |
| 195 | lines := splitLines(chunk.Content()) |
| 196 | nLines := len(lines) |
| 197 | |
| 198 | switch chunk.Type() { |
| 199 | case Equal: |
| 200 | g.fromLine += nLines |
| 201 | g.toLine += nLines |
| 202 | g.processEqualsLines(lines, i) |
| 203 | case Delete: |
| 204 | if nLines != 0 { |
| 205 | g.fromLine++ |
| 206 | } |
| 207 | |
| 208 | g.processHunk(i, chunk.Type()) |
| 209 | g.fromLine += nLines - 1 |
| 210 | g.current.AddOp(chunk.Type(), lines...) |
| 211 | case Add: |
| 212 | if nLines != 0 { |
| 213 | g.toLine++ |
| 214 | } |
| 215 | g.processHunk(i, chunk.Type()) |
| 216 | g.toLine += nLines - 1 |
| 217 | g.current.AddOp(chunk.Type(), lines...) |
| 218 | } |
| 219 | |
| 220 | if i == len(g.chunks)-1 && g.current != nil { |
| 221 | g.hunks = append(g.hunks, g.current) |
| 222 | } |
| 223 | } |
| 224 | |
| 225 | return g.hunks |
| 226 | } |
| 227 | |
| 228 | func (g *hunksGenerator) processHunk(i int, op Operation) { |
| 229 | if g.current != nil { |
no test coverage detected