in src/executable-code/executable-fragment.js [569:631]
showDiagnostics(diagnostics) {
this.removeStyles();
if (diagnostics === undefined) {
return;
}
diagnostics.forEach((diagnostic) => {
const interval = diagnostic.interval;
if (interval == undefined) {
return;
}
interval.start = this.recalculatePosition(interval.start);
interval.end = this.recalculatePosition(interval.end);
const errorMessage = unEscapeString(diagnostic.message);
const severity = diagnostic.severity;
const containsSuggestions =
!!diagnostic.imports && diagnostic.imports.length !== 0;
this.arrayClasses.push(
this.codemirror.markText(interval.start, interval.end, {
className: 'cm__' + diagnostic.className,
title: errorMessage,
}),
);
// contains suggestions => red underline
if (containsSuggestions) {
this.importsSuggestions.push({
interval: interval,
imports: diagnostic.imports,
});
this.arrayClasses.push(
this.codemirror.markText(interval.start, interval.end, {
className: 'cm__IMPORT',
}),
);
}
if (
this.codemirror.lineInfo(interval.start.line) != null &&
this.codemirror.lineInfo(interval.start.line).gutterMarkers == null
) {
const gutter = document.createElement('div');
gutter.className = severity + SELECTORS.GUTTER;
gutter.setAttribute(SELECTORS.LABEL, errorMessage);
this.codemirror.setGutterMarker(
interval.start.line,
SELECTORS.ERROR_AND_WARNING_GUTTER,
gutter,
);
} else {
const gutter = this.codemirror.lineInfo(interval.start.line)
.gutterMarkers[SELECTORS.ERROR_AND_WARNING_GUTTER];
gutter.setAttribute(
SELECTORS.LABEL,
gutter.getAttribute(SELECTORS.LABEL) + `\n${errorMessage}`,
);
if (gutter.className.indexOf(SELECTORS.ERROR_GUTTER) === -1) {
gutter.className = severity + SELECTORS.GUTTER;
}
}
});
}