2020-09-12 17:38:55 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2020, Itamar S. <itamar8910@gmail.com>
|
|
|
|
*
|
2021-04-22 08:24:48 +00:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-09-12 17:38:55 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2022-12-04 18:02:33 +00:00
|
|
|
#include <AK/DeprecatedString.h>
|
2023-06-24 01:13:50 +00:00
|
|
|
#include <AK/StringView.h>
|
2020-09-12 17:38:55 +00:00
|
|
|
#include <AK/Vector.h>
|
|
|
|
|
|
|
|
namespace Diff {
|
|
|
|
|
|
|
|
struct HunkLocation {
|
|
|
|
size_t original_start_line { 0 };
|
|
|
|
size_t original_length { 0 };
|
|
|
|
size_t target_start_line { 0 };
|
|
|
|
size_t target_length { 0 };
|
|
|
|
|
|
|
|
enum class LocationType {
|
|
|
|
Original,
|
|
|
|
Target,
|
|
|
|
Both
|
|
|
|
};
|
|
|
|
void apply_offset(size_t offset, LocationType);
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Hunk {
|
|
|
|
size_t original_start_line { 0 };
|
|
|
|
size_t target_start_line { 0 };
|
2022-12-04 18:02:33 +00:00
|
|
|
Vector<DeprecatedString> removed_lines;
|
|
|
|
Vector<DeprecatedString> added_lines;
|
2020-09-12 17:38:55 +00:00
|
|
|
};
|
|
|
|
|
2023-06-24 01:13:50 +00:00
|
|
|
ErrorOr<Vector<Hunk>> parse_hunks(StringView diff);
|
2023-06-24 00:40:15 +00:00
|
|
|
HunkLocation parse_hunk_location(StringView location_line);
|
2020-09-12 17:38:55 +00:00
|
|
|
};
|