summaryrefslogtreecommitdiff
path: root/graphics/asymptote/errormsg.h
diff options
context:
space:
mode:
Diffstat (limited to 'graphics/asymptote/errormsg.h')
-rw-r--r--graphics/asymptote/errormsg.h40
1 files changed, 30 insertions, 10 deletions
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 <iostream>
+#include <exception>
#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::pair<size_t,size_t>LineColumn() const {
return std::pair<size_t,size_t>(line,column);
}
@@ -119,6 +124,21 @@ public:
friend ostream& operator << (ostream& out, const position& pos);
+ typedef std::pair<size_t, size_t> posInFile;
+ typedef std::pair<std::string, posInFile> 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
{