Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
onOver={node => {
if (!isNode(node)) {
return false
}
current = node
decorations = model.deltaDecorations(decorations, [
{
range: new monaco.Range(
node.StartPos.Line,
node.StartPos.Column + 1,
node.EndPos.Line,
node.EndPos.Column + 2
),
options: {
inlineClassName: 'highlighted'
}
},
]);
return true
}}
onLeave={node => {
Editor.prototype.onEditorLinkLine = function (editorId, lineNum, columnNum, reveal) {
if (Number(editorId) === this.id) {
if (reveal && lineNum) this.editor.revealLineInCenter(lineNum);
this.decorations.linkedCode = lineNum === -1 || !lineNum ? [] : [{
range: new monaco.Range(lineNum, 1, lineNum, 1),
options: {
isWholeLine: true,
linesDecorationsClassName: 'linked-code-decoration-margin',
className: 'linked-code-decoration-line'
}
}];
if (lineNum > 0 && columnNum !== -1) {
this.decorations.linkedCode.push({
range: new monaco.Range(lineNum, columnNum, lineNum, columnNum + 1),
options: {
isWholeLine: false,
inlineClassName: 'linked-code-decoration-column'
}
});
}
if (this.fadeTimeoutId !== -1) {
clearTimeout(this.fadeTimeoutId);
}
this.fadeTimeoutId = setTimeout(_.bind(function () {
this.clearLinkedLine();
this.fadeTimeoutId = -1;
}, this), 5000);
this.updateDecorations();
this.decorations.tags = _.map(widgets, function (tag) {
return {
range: new monaco.Range(tag.startLineNumber, tag.startColumn, tag.startLineNumber + 1, 1),
options: {
isWholeLine: false,
inlineClassName: "error-code"
}
};
}, this);
this.updateDecorations();
function lineAt (model, lineNumber) {
const lineContent = model.getLineContent(lineNumber)
const lineCount = model.getLineCount()
const range = new monaco.Range(lineNumber, 0, lineNumber, lineContent.length)
const firstNonWhitespaceCharacterIndex = /^(\s*)/.exec(lineContent)[1].length
const line = {
lineNumber,
text: lineContent,
range,
rangeIncludingLineBreak: lineNumber < lineCount - 1
? new monaco.Range(lineNumber, 0, lineNumber + 1, 0)
: range,
firstNonWhitespaceCharacterIndex,
isEmptyOrWhitespace: firstNonWhitespaceCharacterIndex === lineContent.length
}
return line
}
messages.map(failure => {
const line = failure.pos.line + 1;
const character = failure.pos.character + 1;
return {
range: new Range(line, character, line, character + failure.length),
options: {
className: failure.level === LogLevel.Error ? '' : 'warn-content',
inlineClassName: failure.level === LogLevel.Error ? 'decoration-link' : '',
stickiness: 1,
hoverMessage: {
value: failure.message + (failure.url ? ` [more](${failure.url})` : '')
}
}
};
})
);
function lineAt (model, lineNumber) {
const lineContent = model.getLineContent(lineNumber)
const lineCount = model.getLineCount()
const range = new monaco.Range(lineNumber, 0, lineNumber, lineContent.length)
const firstNonWhitespaceCharacterIndex = /^(\s*)/.exec(lineContent)[1].length
const line = {
lineNumber,
text: lineContent,
range,
rangeIncludingLineBreak: lineNumber < lineCount - 1
? new monaco.Range(lineNumber, 0, lineNumber + 1, 0)
: range,
firstNonWhitespaceCharacterIndex,
isEmptyOrWhitespace: firstNonWhitespaceCharacterIndex === lineContent.length
}
return line
}
commonAncestors: match.commonAncestors.map((currentTokenLine, index, commonAncestors) => {
const nextTokenLine = commonAncestors[index + 1] || match.splitter
return {
header: currentTokenLine.range,
decoratorContent: new monaco.Range(
currentTokenLine.rangeIncludingLineBreak.endLineNumber,
currentTokenLine.rangeIncludingLineBreak.endColumn,
...shiftBackOneCharacter(
model,
{
lineNumber: nextTokenLine.range.startLineNumber,
column: nextTokenLine.range.startColumn,
},
{
lineNumber: currentTokenLine.rangeIncludingLineBreak.endLineNumber,
column: currentTokenLine.rangeIncludingLineBreak.endColumn,
}
)
),
content: new monaco.Range(
currentTokenLine.rangeIncludingLineBreak.endLineNumber,
export const mapEditorErrorToMonacoDecoration = (e: EditorError) =>
({
range: new monaco.Range(e.row + 1, 1, e.row + 1, 1000),
options: {
className: 'monacoError',
isWholeLine: true,
minimap: {
color: Colors.red[0],
position: 1,
},
hoverMessage: [
{
value: e.text,
},
],
glyphMarginHoverMessage: {
value: e.text,
},
glyphMarginClassName: 'monacoMarginError',
_.mapObject(results, function (value, key) {
var linenumber = Number(key);
var className = value.reduce(function (acc, x) {
if (x.optType === "Missed" || acc === "Missed") {
return "Missed";
} else if (x.optType === "Passed" || acc === "Passed") {
return "Passed";
}
return x.optType;
}, "");
var contents = _.map(value, this.getDisplayableOpt, this);
opt.push({
range: new monaco.Range(linenumber, 1, linenumber, Infinity),
options: {
isWholeLine: true,
glyphMarginClassName: "opt-decoration." + className.toLowerCase(),
hoverMessage: contents,
glyphMarginHoverMessage: contents
}
});
}, this);