@sasjs/utils 4.2.0 → 4.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/logs/sasLog.d.ts +53 -14
- package/logs/sasLog.js +226 -51
- package/logs/sasLog.js.map +1 -1
- package/package.json +1 -1
package/logs/sasLog.d.ts
CHANGED
|
@@ -2,34 +2,44 @@
|
|
|
2
2
|
* SAS log parsing.
|
|
3
3
|
*
|
|
4
4
|
* A SAS log is a stream of statements and messages, and only the messages
|
|
5
|
-
* matter to a reader looking for trouble:
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
5
|
+
* matter to a reader looking for trouble: the ones SAS prints at the start of a
|
|
6
|
+
* line as `ERROR`, `WARNING` or `NOTE`. This module finds those messages and
|
|
7
|
+
* reports where they are, as line and column indexes into the text it was given,
|
|
8
|
+
* so a host can underline them without re-scanning the log and without rewriting
|
|
9
|
+
* it.
|
|
10
10
|
*
|
|
11
|
-
* What is recognised:
|
|
11
|
+
* What is recognised - the marker in capitals, beginning the line:
|
|
12
12
|
*
|
|
13
13
|
* ERROR: Libref X is not assigned.
|
|
14
|
+
* ERROR Libref Y is not assigned.
|
|
14
15
|
* ERROR 22-322: Syntax error, expecting one of the following: ;, CANCEL,
|
|
15
16
|
* RUN, QUIT.
|
|
16
17
|
* WARNING 1-322: Assuming the symbol Y was misspelled.
|
|
17
18
|
* NOTE: Variable x is uninitialized.
|
|
18
19
|
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
20
|
+
* An error or a warning needs a colon, or a space, after the marker; `ERROR` on
|
|
21
|
+
* its own is not a message, and neither is every line that happens to begin with
|
|
22
|
+
* the word. The numeric code between the marker and the colon is SAS's own
|
|
23
|
+
* message identifier and is reported separately, so a host can group by it.
|
|
21
24
|
*
|
|
22
25
|
* NOTES are reported only when they are the ones the log-checking literature
|
|
23
|
-
* flags - see NOTE_KEYWORDS
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
+
* flags - see NOTE_KEYWORDS - and only in their colon form, because the notes
|
|
27
|
+
* stream is endless and the notable ones are a closed list. A coded note
|
|
28
|
+
* (`NOTE 49-169:`) is one of them and keeps its code. INFO lines are not
|
|
29
|
+
* reported at all.
|
|
30
|
+
*
|
|
31
|
+
* {@link isSasLog} answers the different question a host asks before publishing
|
|
32
|
+
* anything: whether this file is a SAS log at all. A Python log and a shell build
|
|
33
|
+
* log both write `ERROR:` at the start of a line, so the marker alone does not
|
|
34
|
+
* say so - the banner SAS prints about itself does, and so do its message codes
|
|
35
|
+
* and its padded step numbers.
|
|
26
36
|
*
|
|
27
37
|
* Lines SAS wrapped are folded into the message they belong to, so one problem
|
|
28
38
|
* is one issue rather than one issue per wrapped line, and the keyword search
|
|
29
39
|
* runs on the folded message - a note whose keyword lands on the second line is
|
|
30
|
-
* still found.
|
|
31
|
-
*
|
|
32
|
-
* quoting another log, out of the results.
|
|
40
|
+
* still found. Nothing indented counts as a marker, and neither does a marker in
|
|
41
|
+
* lower case: the real one starts the line, which keeps a print of a data set,
|
|
42
|
+
* or a message quoting another log, out of the results.
|
|
33
43
|
*
|
|
34
44
|
* ODS HTML logs wrap every line in markup. A tag sequence before the marker is
|
|
35
45
|
* skipped and tags are stripped from the reported message, so the same parse
|
|
@@ -64,6 +74,30 @@ export interface LogIssue {
|
|
|
64
74
|
}
|
|
65
75
|
/** Direction of travel for {@link nextIssue}. */
|
|
66
76
|
export declare type IssueDirection = 'next' | 'previous';
|
|
77
|
+
/**
|
|
78
|
+
* Whether a text is a SAS log rather than somebody else's log file.
|
|
79
|
+
*
|
|
80
|
+
* A marker alone does not say so: Python's logging writes `ERROR:root:boom` and
|
|
81
|
+
* a shell build log writes `ERROR: Command failed with exit code 1`, both at the
|
|
82
|
+
* start of a line. Nor does the word SAS - build logs of this estate's own
|
|
83
|
+
* repositories mention it in prose - so the test is SAS's own vocabulary: the
|
|
84
|
+
* banner it prints about itself, its message codes, and its padded step numbers.
|
|
85
|
+
* Each of those is written by SAS and by nothing else.
|
|
86
|
+
*
|
|
87
|
+
* This is a heuristic, and one way only: a true answer means SAS wrote the text,
|
|
88
|
+
* while a false answer does not prove it did not - a trimmed excerpt of a log,
|
|
89
|
+
* pasted with only its `ERROR:` lines, carries none of the three and reads as
|
|
90
|
+
* somebody else's. A host that publishes diagnostics should therefore treat false
|
|
91
|
+
* as "not obviously SAS" rather than "not SAS".
|
|
92
|
+
*
|
|
93
|
+
* Counting marker lines instead was considered and rejected: two `ERROR:` lines is
|
|
94
|
+
* what a Python log is made of, so it would readmit exactly the files this
|
|
95
|
+
* predicate exists to keep out.
|
|
96
|
+
*
|
|
97
|
+
* The check is deliberately cheap and runs before a host publishes anything, so
|
|
98
|
+
* a `.log` from another tool is left alone.
|
|
99
|
+
*/
|
|
100
|
+
export declare const isSasLog: (text: string) => boolean;
|
|
67
101
|
/** Whether a note's message is one of the notable ones. */
|
|
68
102
|
export declare const isNotableNote: (message: string) => boolean;
|
|
69
103
|
/**
|
|
@@ -74,6 +108,11 @@ export declare const isNotableNote: (message: string) => boolean;
|
|
|
74
108
|
* directly. A host that wants errors only filters on `severity`; nothing is
|
|
75
109
|
* behind an option, because a notable note is worth reporting wherever the log
|
|
76
110
|
* is shown.
|
|
111
|
+
*
|
|
112
|
+
* The text is never split into lines: a log is often megabytes, and a pass that
|
|
113
|
+
* builds an array of its lines costs more than the scan and hands the collector
|
|
114
|
+
* a million strings. One global match walks the text, the line number is counted
|
|
115
|
+
* forward from the previous match, and only the lines a message needs are sliced.
|
|
77
116
|
*/
|
|
78
117
|
export declare const parseLog: (text: string) => LogIssue[];
|
|
79
118
|
/**
|
package/logs/sasLog.js
CHANGED
|
@@ -3,34 +3,44 @@
|
|
|
3
3
|
* SAS log parsing.
|
|
4
4
|
*
|
|
5
5
|
* A SAS log is a stream of statements and messages, and only the messages
|
|
6
|
-
* matter to a reader looking for trouble:
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
6
|
+
* matter to a reader looking for trouble: the ones SAS prints at the start of a
|
|
7
|
+
* line as `ERROR`, `WARNING` or `NOTE`. This module finds those messages and
|
|
8
|
+
* reports where they are, as line and column indexes into the text it was given,
|
|
9
|
+
* so a host can underline them without re-scanning the log and without rewriting
|
|
10
|
+
* it.
|
|
11
11
|
*
|
|
12
|
-
* What is recognised:
|
|
12
|
+
* What is recognised - the marker in capitals, beginning the line:
|
|
13
13
|
*
|
|
14
14
|
* ERROR: Libref X is not assigned.
|
|
15
|
+
* ERROR Libref Y is not assigned.
|
|
15
16
|
* ERROR 22-322: Syntax error, expecting one of the following: ;, CANCEL,
|
|
16
17
|
* RUN, QUIT.
|
|
17
18
|
* WARNING 1-322: Assuming the symbol Y was misspelled.
|
|
18
19
|
* NOTE: Variable x is uninitialized.
|
|
19
20
|
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
21
|
+
* An error or a warning needs a colon, or a space, after the marker; `ERROR` on
|
|
22
|
+
* its own is not a message, and neither is every line that happens to begin with
|
|
23
|
+
* the word. The numeric code between the marker and the colon is SAS's own
|
|
24
|
+
* message identifier and is reported separately, so a host can group by it.
|
|
22
25
|
*
|
|
23
26
|
* NOTES are reported only when they are the ones the log-checking literature
|
|
24
|
-
* flags - see NOTE_KEYWORDS
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
+
* flags - see NOTE_KEYWORDS - and only in their colon form, because the notes
|
|
28
|
+
* stream is endless and the notable ones are a closed list. A coded note
|
|
29
|
+
* (`NOTE 49-169:`) is one of them and keeps its code. INFO lines are not
|
|
30
|
+
* reported at all.
|
|
31
|
+
*
|
|
32
|
+
* {@link isSasLog} answers the different question a host asks before publishing
|
|
33
|
+
* anything: whether this file is a SAS log at all. A Python log and a shell build
|
|
34
|
+
* log both write `ERROR:` at the start of a line, so the marker alone does not
|
|
35
|
+
* say so - the banner SAS prints about itself does, and so do its message codes
|
|
36
|
+
* and its padded step numbers.
|
|
27
37
|
*
|
|
28
38
|
* Lines SAS wrapped are folded into the message they belong to, so one problem
|
|
29
39
|
* is one issue rather than one issue per wrapped line, and the keyword search
|
|
30
40
|
* runs on the folded message - a note whose keyword lands on the second line is
|
|
31
|
-
* still found.
|
|
32
|
-
*
|
|
33
|
-
* quoting another log, out of the results.
|
|
41
|
+
* still found. Nothing indented counts as a marker, and neither does a marker in
|
|
42
|
+
* lower case: the real one starts the line, which keeps a print of a data set,
|
|
43
|
+
* or a message quoting another log, out of the results.
|
|
34
44
|
*
|
|
35
45
|
* ODS HTML logs wrap every line in markup. A tag sequence before the marker is
|
|
36
46
|
* skipped and tags are stripped from the reported message, so the same parse
|
|
@@ -42,14 +52,77 @@
|
|
|
42
52
|
* from the same parse.
|
|
43
53
|
*/
|
|
44
54
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
45
|
-
exports.nextIssue = exports.parseLog = exports.isNotableNote = void 0;
|
|
55
|
+
exports.nextIssue = exports.parseLog = exports.isNotableNote = exports.isSasLog = void 0;
|
|
56
|
+
/**
|
|
57
|
+
* A marker at the start of a line: SAS writes `ERROR:` and `WARNING:` with a
|
|
58
|
+
* colon, and also writes them with no colon at all - `ERROR Libref X is not
|
|
59
|
+
* assigned.` - so a run of whitespace ends those two as well. The marker is
|
|
60
|
+
* uppercase and begins the line, which is what keeps a print of a data set, or a
|
|
61
|
+
* quotation of another log, out of the results.
|
|
62
|
+
*
|
|
63
|
+
* `NOTE` is a separate shape inside the same expression because it only counts
|
|
64
|
+
* with its colon: matching any line that begins NOTE would put the whole notes
|
|
65
|
+
* stream into the results. A coded note is a note - `NOTE 49-169:` carries the
|
|
66
|
+
* same kind of identifier an error does, and two of the notable keywords are
|
|
67
|
+
* written for coded notes.
|
|
68
|
+
*
|
|
69
|
+
* The tags of an ODS HTML log may lead the marker, with or without padding after
|
|
70
|
+
* them - they are markup the reader never sees, and the marker still begins the
|
|
71
|
+
* line's text. Padding without markup is not allowed: an indented marker is text
|
|
72
|
+
* in a listing, not a message. The prefix is captured so the marker's column is
|
|
73
|
+
* exact, and the code and message are captured separately.
|
|
74
|
+
*
|
|
75
|
+
* The spaces either side of a message code are a character class, not `\s`: the
|
|
76
|
+
* expression now runs over the whole text, where `\s` would let a match swallow
|
|
77
|
+
* the line break and read the next line as this message's code.
|
|
78
|
+
*/
|
|
79
|
+
const MARKER = /^((?:<[^>]*>)+[ \t]*|)(?:(ERROR|WARNING)(?:[ \t]+(\d+-\d+))?(:[ \t]?|[ \t]+)|(NOTE)(?:[ \t]+(\d+-\d+))?:[ \t]?)(.*)$/;
|
|
46
80
|
/**
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
81
|
+
* The shapes only SAS writes, tested over the whole text in one pass so no line
|
|
82
|
+
* array is built: a coded marker (`ERROR 22-322:`), or a line SAS numbers at the
|
|
83
|
+
* start followed by a statement - one that begins with a macro call, a comment,
|
|
84
|
+
* or ends in the semicolon SAS statement syntax requires. The padded number alone
|
|
85
|
+
* is not evidence: `1 item` is a numbered list in somebody else's output.
|
|
86
|
+
*
|
|
87
|
+
* The statement tail is `[^\n;]*` rather than `[^;]*` because a negated class
|
|
88
|
+
* matches a newline, and a shape match must not span two lines. A semicolon alone
|
|
89
|
+
* does not make a statement - `12 Building target;` is a numbered list in output
|
|
90
|
+
* that is not SAS - so the line also has to begin with a statement keyword or
|
|
91
|
+
* carry an assignment or a call before its semicolon.
|
|
92
|
+
*/
|
|
93
|
+
const SAS_SHAPE = /^(?:(?:<[^>]*>)+[ \t]*|)(?:(?:ERROR|WARNING|NOTE) +\d+-\d+|\d+ {2,}(?:[%*/]|(?:by|data|filename|footnote|format|if|infile|input|libname|merge|ods|options|output|proc|put|quit|run|set|title|where)\b|[^\n;]*[=(][^\n;]*;))/m;
|
|
94
|
+
/**
|
|
95
|
+
* The phrases SAS prints about itself, and nothing else does: the version banner,
|
|
96
|
+
* the licence note, the platform note, the work-area conversion warning, the page
|
|
97
|
+
* header of a listing and the step footer. Every SAS log carries at least one;
|
|
98
|
+
* a log that has lost its head usually keeps the step footer.
|
|
51
99
|
*/
|
|
52
|
-
const
|
|
100
|
+
const SAS_BANNER = /(?:The SAS System|^You are running SAS \d|^NOTE: (?:SAS|Copyright .*\bSAS Institute|This session is executing|DATA statement used))/m;
|
|
101
|
+
/**
|
|
102
|
+
* Whether a text is a SAS log rather than somebody else's log file.
|
|
103
|
+
*
|
|
104
|
+
* A marker alone does not say so: Python's logging writes `ERROR:root:boom` and
|
|
105
|
+
* a shell build log writes `ERROR: Command failed with exit code 1`, both at the
|
|
106
|
+
* start of a line. Nor does the word SAS - build logs of this estate's own
|
|
107
|
+
* repositories mention it in prose - so the test is SAS's own vocabulary: the
|
|
108
|
+
* banner it prints about itself, its message codes, and its padded step numbers.
|
|
109
|
+
* Each of those is written by SAS and by nothing else.
|
|
110
|
+
*
|
|
111
|
+
* This is a heuristic, and one way only: a true answer means SAS wrote the text,
|
|
112
|
+
* while a false answer does not prove it did not - a trimmed excerpt of a log,
|
|
113
|
+
* pasted with only its `ERROR:` lines, carries none of the three and reads as
|
|
114
|
+
* somebody else's. A host that publishes diagnostics should therefore treat false
|
|
115
|
+
* as "not obviously SAS" rather than "not SAS".
|
|
116
|
+
*
|
|
117
|
+
* Counting marker lines instead was considered and rejected: two `ERROR:` lines is
|
|
118
|
+
* what a Python log is made of, so it would readmit exactly the files this
|
|
119
|
+
* predicate exists to keep out.
|
|
120
|
+
*
|
|
121
|
+
* The check is deliberately cheap and runs before a host publishes anything, so
|
|
122
|
+
* a `.log` from another tool is left alone.
|
|
123
|
+
*/
|
|
124
|
+
const isSasLog = (text) => SAS_BANNER.test(text) || SAS_SHAPE.test(text);
|
|
125
|
+
exports.isSasLog = isSasLog;
|
|
53
126
|
/**
|
|
54
127
|
* The notes worth reporting, matched case-insensitively against the folded
|
|
55
128
|
* message. Each is a message SAS prints when something has gone wrong quietly -
|
|
@@ -95,24 +168,83 @@ const NOTE_KEYWORDS = [
|
|
|
95
168
|
'not positive definite',
|
|
96
169
|
'The SAS System stopped processing this step because of errors'
|
|
97
170
|
];
|
|
98
|
-
|
|
171
|
+
/** `RegExp`-escaping, so a keyword added later cannot change the meaning of the pattern. */
|
|
172
|
+
const escape = (text) => text.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
173
|
+
/**
|
|
174
|
+
* The keyword list as one case-insensitive expression. Testing 30 keywords with
|
|
175
|
+
* `includes` meant lowercasing every note and up to 30 scans of it; a log holds
|
|
176
|
+
* thousands of notes and this is the second hottest function in the module.
|
|
177
|
+
*/
|
|
178
|
+
const NOTABLE_NOTE = new RegExp(NOTE_KEYWORDS.map(escape).join('|'), 'i');
|
|
99
179
|
/** How many wrapped lines one message may absorb, so a malformed log cannot run away. */
|
|
100
180
|
const MAX_WRAPPED_LINES = 10;
|
|
101
181
|
/** Whether a note's message is one of the notable ones. */
|
|
102
|
-
const isNotableNote = (message) =>
|
|
103
|
-
const lower = message.toLowerCase();
|
|
104
|
-
return NOTABLE_NOTE_KEYWORDS.some((keyword) => lower.includes(keyword));
|
|
105
|
-
};
|
|
182
|
+
const isNotableNote = (message) => NOTABLE_NOTE.test(message);
|
|
106
183
|
exports.isNotableNote = isNotableNote;
|
|
107
|
-
/**
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
184
|
+
/**
|
|
185
|
+
* The pointer line SAS prints under the token it complains about: a run of
|
|
186
|
+
* dashes, or the column number on its own.
|
|
187
|
+
*/
|
|
188
|
+
const POINTER_LINE = /^\s*(?:[-_]+\s*$|\d+\s*$)/;
|
|
189
|
+
/**
|
|
190
|
+
* A line SAS wrapped: indented, and neither a pointer line nor a marker.
|
|
191
|
+
*
|
|
192
|
+
* The marker test is {@link MARKER} itself, applied to the trimmed line, so a
|
|
193
|
+
* continuation is excluded exactly when the line would have been a marker had it
|
|
194
|
+
* begun the line - the markup-prefixed form included. A second, subtly different
|
|
195
|
+
* expression is how an indented marker ends up belonging to neither the message
|
|
196
|
+
* above nor the issue list. Such a marker is dropped rather than reported, which
|
|
197
|
+
* is the rule the parser states: a message begins the line.
|
|
198
|
+
*/
|
|
199
|
+
const isWrappedLine = (line) => /^\s+\S/.test(line) && !POINTER_LINE.test(line) && !MARKER.test(line.trim());
|
|
200
|
+
/**
|
|
201
|
+
* Whether a character code is printable ASCII and not a space. The fast path in
|
|
202
|
+
* {@link clean} is limited to ASCII at both ends, so a message carrying one of
|
|
203
|
+
* the non-ASCII spaces the slow path collapses still takes the slow path.
|
|
204
|
+
*/
|
|
205
|
+
const isPlainCode = (code) => code > 32 && code < 127;
|
|
206
|
+
/**
|
|
207
|
+
* Removes markup and collapses the whitespace a wrapped message carries.
|
|
208
|
+
*
|
|
209
|
+
* Most messages need neither: a single line with no markup and no run of spaces
|
|
210
|
+
* is returned as it is, which keeps three passes off the common path - this is
|
|
211
|
+
* the hottest function in the module on a large log.
|
|
212
|
+
*/
|
|
213
|
+
const clean = (text) => {
|
|
214
|
+
const plain = isPlainCode(text.charCodeAt(0)) &&
|
|
215
|
+
isPlainCode(text.charCodeAt(text.length - 1)) &&
|
|
216
|
+
text.indexOf('<') < 0 &&
|
|
217
|
+
text.indexOf('\t') < 0 &&
|
|
218
|
+
text.indexOf(' ') < 0;
|
|
219
|
+
return plain
|
|
220
|
+
? text
|
|
221
|
+
: text
|
|
222
|
+
.replace(/<[^>]*>/g, '')
|
|
223
|
+
.replace(/\s+/g, ' ')
|
|
224
|
+
.trim();
|
|
225
|
+
};
|
|
226
|
+
/**
|
|
227
|
+
* Finds every ERROR and WARNING in a SAS log, and every notable note.
|
|
228
|
+
*
|
|
229
|
+
* The issue list is in log order. `line` and `column` address the text as
|
|
230
|
+
* supplied, so a caller can offset a decoration or a diagnostic by them
|
|
231
|
+
* directly. A host that wants errors only filters on `severity`; nothing is
|
|
232
|
+
* behind an option, because a notable note is worth reporting wherever the log
|
|
233
|
+
* is shown.
|
|
234
|
+
*/
|
|
235
|
+
/**
|
|
236
|
+
* The marker expression with the multiline flags, so one call walks the whole
|
|
237
|
+
* text. `exec` on a line at a time costs a call per line - half a million on a
|
|
238
|
+
* 16 MB log - where one pass over the string costs a fraction of that, and the
|
|
239
|
+
* line and column indexes are recovered from the match offsets instead.
|
|
240
|
+
*/
|
|
241
|
+
const SCAN = new RegExp(MARKER.source, 'gm');
|
|
242
|
+
/** The index of the line break that ends the line starting at `from`, or -1. */
|
|
243
|
+
const lineEnd = (text, from) => text.indexOf('\n', from);
|
|
244
|
+
/** A slice of the text with the carriage return of a CRLF line ending removed. */
|
|
245
|
+
const withoutCr = (text, from, to) => to > from && text.charCodeAt(to - 1) === 13
|
|
246
|
+
? text.slice(from, to - 1)
|
|
247
|
+
: text.slice(from, to);
|
|
116
248
|
/**
|
|
117
249
|
* Finds every ERROR and WARNING in a SAS log, and every notable note.
|
|
118
250
|
*
|
|
@@ -121,40 +253,83 @@ const clean = (text) => text
|
|
|
121
253
|
* directly. A host that wants errors only filters on `severity`; nothing is
|
|
122
254
|
* behind an option, because a notable note is worth reporting wherever the log
|
|
123
255
|
* is shown.
|
|
256
|
+
*
|
|
257
|
+
* The text is never split into lines: a log is often megabytes, and a pass that
|
|
258
|
+
* builds an array of its lines costs more than the scan and hands the collector
|
|
259
|
+
* a million strings. One global match walks the text, the line number is counted
|
|
260
|
+
* forward from the previous match, and only the lines a message needs are sliced.
|
|
124
261
|
*/
|
|
125
262
|
const parseLog = (text) => {
|
|
126
263
|
var _a;
|
|
127
264
|
if (!text) {
|
|
128
265
|
return [];
|
|
129
266
|
}
|
|
130
|
-
const lines = text.split(/\r?\n/);
|
|
131
267
|
const issues = [];
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
268
|
+
let line = 0;
|
|
269
|
+
let countedTo = 0;
|
|
270
|
+
let match;
|
|
271
|
+
SCAN.lastIndex = 0;
|
|
272
|
+
while ((match = SCAN.exec(text)) !== null) {
|
|
273
|
+
const markerStart = match.index;
|
|
274
|
+
// Lines between the last block and this marker.
|
|
275
|
+
for (let index = text.indexOf('\n', countedTo); index !== -1 && index < markerStart; index = text.indexOf('\n', index + 1)) {
|
|
276
|
+
line++;
|
|
136
277
|
}
|
|
278
|
+
const markerEnd = lineEnd(text, markerStart);
|
|
279
|
+
const endIndex = markerEnd === -1 ? text.length : markerEnd;
|
|
137
280
|
const markerLine = line;
|
|
138
|
-
|
|
281
|
+
let message = clean(match[7]);
|
|
139
282
|
let endLine = markerLine;
|
|
283
|
+
let cursor = endIndex + 1;
|
|
140
284
|
let wrapped = 0;
|
|
141
|
-
while (wrapped < MAX_WRAPPED_LINES
|
|
142
|
-
|
|
143
|
-
|
|
285
|
+
while (cursor <= text.length && wrapped < MAX_WRAPPED_LINES) {
|
|
286
|
+
const nextEnd = lineEnd(text, cursor);
|
|
287
|
+
const sliceEnd = nextEnd === -1 ? text.length : nextEnd;
|
|
288
|
+
const candidate = withoutCr(text, cursor, sliceEnd);
|
|
289
|
+
if (!isWrappedLine(candidate)) {
|
|
290
|
+
break;
|
|
291
|
+
}
|
|
292
|
+
const part = clean(candidate);
|
|
293
|
+
if (part !== '') {
|
|
294
|
+
message = message === '' ? part : `${message} ${part}`;
|
|
295
|
+
}
|
|
144
296
|
endLine++;
|
|
145
297
|
wrapped++;
|
|
146
|
-
|
|
298
|
+
cursor = sliceEnd + 1;
|
|
147
299
|
}
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
line = endLine;
|
|
300
|
+
// The lines folded into this message belong to it whether or not it is
|
|
301
|
+
// reported, so the scan resumes after them either way.
|
|
302
|
+
SCAN.lastIndex = cursor;
|
|
303
|
+
countedTo = cursor;
|
|
304
|
+
line = endLine + 1;
|
|
305
|
+
// A marker with nothing after it is not a message: SAS does not print a bare
|
|
306
|
+
// `ERROR` or `ERROR:` line, and an empty issue would reach a host as a blank
|
|
307
|
+
// line in its problem list.
|
|
308
|
+
if (message === '') {
|
|
309
|
+
continue;
|
|
310
|
+
}
|
|
311
|
+
const severity = match[2]
|
|
312
|
+
? match[2] === 'ERROR'
|
|
313
|
+
? 'error'
|
|
314
|
+
: 'warning'
|
|
315
|
+
: 'note';
|
|
153
316
|
if (severity === 'note' && !(0, exports.isNotableNote)(message)) {
|
|
154
317
|
continue;
|
|
155
318
|
}
|
|
156
|
-
const code = match[3];
|
|
157
|
-
|
|
319
|
+
const code = (_a = match[3]) !== null && _a !== void 0 ? _a : match[6];
|
|
320
|
+
const issue = {
|
|
321
|
+
line: markerLine,
|
|
322
|
+
endLine,
|
|
323
|
+
column: match[1].length,
|
|
324
|
+
// The whole match is the line's text: `$` stops before the `\r` of a CRLF.
|
|
325
|
+
endColumn: match[0].length,
|
|
326
|
+
severity,
|
|
327
|
+
message
|
|
328
|
+
};
|
|
329
|
+
if (code) {
|
|
330
|
+
issue.code = code;
|
|
331
|
+
}
|
|
332
|
+
issues.push(issue);
|
|
158
333
|
}
|
|
159
334
|
return issues;
|
|
160
335
|
};
|
package/logs/sasLog.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sasLog.js","sourceRoot":"","sources":["../../src/logs/sasLog.ts"],"names":[],"mappings":";AAAA
|
|
1
|
+
{"version":3,"file":"sasLog.js","sourceRoot":"","sources":["../../src/logs/sasLog.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;;;AA6BH;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,MAAM,GACV,sHAAsH,CAAA;AAExH;;;;;;;;;;;;GAYG;AACH,MAAM,SAAS,GACb,8NAA8N,CAAA;AAEhO;;;;;GAKG;AACH,MAAM,UAAU,GACd,sIAAsI,CAAA;AAExI;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACI,MAAM,QAAQ,GAAG,CAAC,IAAY,EAAW,EAAE,CAChD,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,SA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