mixin-base.js
970 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
'use strict';
const Mixin = require('../../utils/mixin');
class ErrorReportingMixinBase extends Mixin {
constructor(host, opts) {
super(host);
this.posTracker = null;
this.onParseError = opts.onParseError;
}
_setErrorLocation(err) {
err.startLine = err.endLine = this.posTracker.line;
err.startCol = err.endCol = this.posTracker.col;
err.startOffset = err.endOffset = this.posTracker.offset;
}
_reportError(code) {
const err = {
code: code,
startLine: -1,
startCol: -1,
startOffset: -1,
endLine: -1,
endCol: -1,
endOffset: -1
};
this._setErrorLocation(err);
this.onParseError(err);
}
_getOverriddenMethods(mxn) {
return {
_err(code) {
mxn._reportError(code);
}
};
}
}
module.exports = ErrorReportingMixinBase;