From ecdf859b6ce481abfd530425dcf6f0f764bd0001 Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Tue, 28 Dec 2021 03:01:00 +0000 Subject: CTAN sync 202112280300 --- graphics/asymptote/errormsg.h | 40 ++++++++++++++++++++++++++++++---------- 1 file changed, 30 insertions(+), 10 deletions(-) (limited to 'graphics/asymptote/errormsg.h') diff --git a/graphics/asymptote/errormsg.h b/graphics/asymptote/errormsg.h index 180c2309f7..eb03faa5cb 100644 --- a/graphics/asymptote/errormsg.h +++ b/graphics/asymptote/errormsg.h @@ -9,15 +9,17 @@ #define ERRORMSG_H #include +#include #include "common.h" #include "settings.h" +#include "symbolmaps.h" using std::ostream; -struct handled_error {}; // Exception to process next file. -struct interrupted {}; // Exception to interrupt execution. -struct quit {}; // Exception to quit current operation. -struct eof {}; // Exception to exit interactive mode. +struct handled_error : std::exception {}; // Exception to process next file. +struct interrupted : std::exception {}; // Exception to interrupt execution. +struct quit : std::exception {}; // Exception to quit current operation. +struct eof : std::exception {}; // Exception to exit interactive mode. class fileinfo : public gc { string filename; @@ -81,21 +83,24 @@ public: } } - string filename() const - { + string filename() const { return file ? file->name() : ""; } - size_t Line() const - { + size_t Line() const { return line; } - size_t Column() const - { + size_t Column() const { return column; } + position shift(unsigned int offset) const { + position P=*this; + P.line -= offset; + return P; + } + std::pairLineColumn() const { return std::pair(line,column); } @@ -119,6 +124,21 @@ public: friend ostream& operator << (ostream& out, const position& pos); + typedef std::pair posInFile; + typedef std::pair filePos; + + explicit operator AsymptoteLsp::filePos() + { + return std::make_pair((std::string) file->name().c_str(),LineColumn()); + } + + void print(ostream& out) const + { + if (file) { + out << file->name() << ":" << line << "." << column; + } + } + // Write out just the module name and line number. void printTerse(ostream& out) const { -- cgit v1.2.3