Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function parseCompileError(message: string): ErrorLocation | undefined {
const lines: Array = message.split('\n');
let fileName: string = '';
let lineNumber: number = 0;
let colNumber: number = 0;
for (let i = 0; i < lines.length; i++) {
const line: string = Anser.ansiToText(lines[i]).trim();
if (!line) {
continue;
}
if (!fileName && line.match(filePathRegex)) {
fileName = line;
}
let k = 0;
while (k < lineNumberRegexes.length) {
const match: Array | null = line.match(lineNumberRegexes[k]);
if (match) {
lineNumber = parseInt(match[1], 10);
// colNumber starts with 0 and hence add 1
colNumber = parseInt(match[2], 10) + 1 || 1;
break;
function parseCompileError(message: string): ?ErrorLocation {
const lines: Array = message.split('\n');
let fileName: string = '';
let lineNumber: number = 0;
let colNumber: number = 0;
for (let i = 0; i < lines.length; i++) {
const line: string = Anser.ansiToText(lines[i]).trim();
if (!line) {
continue;
}
if (!fileName && line.match(filePathRegex)) {
fileName = line;
}
let k = 0;
while (k < lineNumberRegexes.length) {
const match: ?Array = line.match(lineNumberRegexes[k]);
if (match) {
lineNumber = parseInt(match[1], 10);
// colNumber starts with 0 and hence add 1
colNumber = parseInt(match[2], 10) + 1 || 1;
break;
function parseCompileError(message: string): ?ErrorLocation {
const lines: Array = message.split('\n');
let fileName: string = '';
let lineNumber: number = 0;
let colNumber: number = 0;
for (let i = 0; i < lines.length; i++) {
const line: string = Anser.ansiToText(lines[i]).trim();
if (!line) {
continue;
}
if (!fileName && line.match(filePathRegex)) {
fileName = line;
}
let k = 0;
while (k < lineNumberRegexes.length) {
const match: ?Array = line.match(lineNumberRegexes[k]);
if (match) {
lineNumber = parseInt(match[1], 10);
// colNumber starts with 0 and hence add 1
colNumber = parseInt(match[2], 10) + 1 || 1;
break;
function parseCompileError(message) {
const lines = message.split('\n');
let fileName = '';
let lineNumber = 0;
let colNumber = 0;
for (let i = 0; i < lines.length; i++) {
const line = Anser.ansiToText(lines[i]).trim();
if (!line) {
continue;
}
if (!fileName && line.match(filePathRegex)) {
fileName = line;
}
let k = 0;
while (k < lineNumberRegexes.length) {
const match = line.match(lineNumberRegexes[k]);
if (match) {
lineNumber = parseInt(match[1], 10);
// colNumber starts with 0 and hence add 1
colNumber = parseInt(match[2], 10) + 1 || 1;
break;
handleClick = () => {
const kernel = this.props.store.kernel;
if (!kernel || !kernel.outputStore) return;
const output = kernel.outputStore.outputs[kernel.outputStore.index];
const copyOutput = this.getOutputText(output);
if (copyOutput) {
atom.clipboard.write(Anser.ansiToText(copyOutput));
atom.notifications.addSuccess("Copied to clipboard");
} else {
atom.notifications.addWarning("Nothing to copy");
}
};
kernel.inspect(replacedText, replacedText.length, ({ found, data }) => {
if (!found || !data["text/plain"]) {
resolve(null);
return;
}
const description = ansiToText(data["text/plain"]);
resolve({
text,
replacementPrefix,
replacedText,
iconHTML,
type,
description
});
});
});