lean2/src/library/error_handling/error_handling.h
Leonardo de Moura 9cf93c8299 feat(library/error_handling): add helpers classes for creating WARNING and INFO annotations for flycheck
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-07-31 17:41:39 -07:00

44 lines
1.5 KiB
C++

/*
Copyright (c) 2013 Microsoft Corporation. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Author: Leonardo de Moura
*/
#pragma once
#include "util/exception.h"
#include "kernel/pos_info_provider.h"
#include "library/io_state_stream.h"
namespace lean {
/** \brief Auxiliary object for "inserting" delimiters for flycheck */
class flycheck_scope {
io_state_stream const & m_ios;
bool m_use_flycheck;
public:
flycheck_scope(io_state_stream const & ios, char const * kind);
~flycheck_scope();
};
struct flycheck_error : public flycheck_scope {
flycheck_error(io_state_stream const & ios):flycheck_scope(ios, "ERROR") {}
};
struct flycheck_warning : public flycheck_scope {
flycheck_warning(io_state_stream const & ios):flycheck_scope(ios, "WARNING") {}
};
struct flycheck_info : public flycheck_scope {
flycheck_info(io_state_stream const & ios):flycheck_scope(ios, "INFO") {}
};
/**
\brief Display position information associated with \c e (IF avaiable).
If it is not available, it just displays "error:"
*/
void display_error_pos(io_state_stream const & ios, pos_info_provider const * p, expr const & e);
/**
\brief Display exception in the regular stream of \c ios, using the configuration options and formatter from \c ios.
Exceptions that contain expressions use the given \c pos_info_provider (if available) to retrieve line number information.
*/
void display_error(io_state_stream const & ios, pos_info_provider const * p, exception const & ex);
}