#pragma once
#include <libsolutil/AnsiColorized.h>
#include <liblangutil/SourceLocation.h>
#include <liblangutil/CharStreamProvider.h>
#include <algorithm>
#include <utility>
namespace solidity::tools
{
class UpgradeChange
{
public:
enum class Level
{
Safe,
Unsafe
};
UpgradeChange(
Level _level,
langutil::SourceLocation _location,
std::string _patch
):
m_location(_location),
m_patch(std::move(_patch)),
m_level(_level)
{}
~UpgradeChange() {}
langutil::SourceLocation const& location() const { return m_location; }
std::string patch() const { return m_patch; }
Level level() const { return m_level; }
std::string apply(std::string _source) const;
void log(langutil::CharStreamProvider const& _charStreamProvider, bool const _shorten = true) const;
private:
langutil::SourceLocation m_location;
std::string m_patch;
Level m_level;
static std::string shortenSource(std::string const& _source);
};
}