|
|
@ -210,9 +210,9 @@ setFontSize = function(size) |
|
|
|
|
|
|
|
makeGasCostMarker = function(value) { |
|
|
|
var marker = document.createElement("div"); |
|
|
|
marker.style.color = "#822"; |
|
|
|
//marker.style.color = "#822";
|
|
|
|
marker.innerHTML = value; |
|
|
|
marker.className = "CodeMirror-errorannotation-context"; |
|
|
|
marker.className = "CodeMirror-gasCost"; |
|
|
|
return marker; |
|
|
|
}; |
|
|
|
|
|
|
@ -252,8 +252,23 @@ displayGasEstimation = function(show) |
|
|
|
else |
|
|
|
color = colorGradient[colorIndex]; |
|
|
|
var className = "CodeMirror-gasCosts" + i; |
|
|
|
var line = editor.posFromIndex(gasCosts[i].start) |
|
|
|
gasMarkText.push(editor.markText(line, editor.posFromIndex(gasCosts[i].end), { inclusiveLeft: true, inclusiveRight: true, handleMouseEvents: true, className: className, css: "background-color:" + color })); |
|
|
|
var line = editor.posFromIndex(gasCosts[i].start); |
|
|
|
var endChar; |
|
|
|
if (gasCosts[i].payload === "statement") |
|
|
|
{ |
|
|
|
endChar = editor.posFromIndex(gasCosts[i].end); |
|
|
|
gasMarkText.push({ line: line, markText: editor.markText(line, endChar, { inclusiveLeft: true, inclusiveRight: true, handleMouseEvents: true, className: className, css: "background-color:" + color })}); |
|
|
|
} |
|
|
|
else if (gasCosts[i].payload === "function" || gasCosts[i].payload === "constructor") |
|
|
|
{ |
|
|
|
var l = editor.getLine(line.line); |
|
|
|
endChar = { line: line.line, ch: line.ch + l.length }; |
|
|
|
var marker = document.createElement("div"); |
|
|
|
marker.innerHTML = " max execution cost: " + gasCosts[i].gas + " gas"; |
|
|
|
marker.className = "CodeMirror-gasCost"; |
|
|
|
editor.addWidget(endChar, marker, false, "over"); |
|
|
|
gasMarkText.push({ line: line.line, widget: marker }); |
|
|
|
} |
|
|
|
gasMarkRef[className] = { line: line.line, value: gasCosts[i] }; |
|
|
|
} |
|
|
|
} |
|
|
@ -275,7 +290,12 @@ function clearGasMark() |
|
|
|
{ |
|
|
|
if (gasMarkText) |
|
|
|
for (var k in gasMarkText) |
|
|
|
gasMarkText[k].clear(); |
|
|
|
{ |
|
|
|
if (gasMarkText[k] && gasMarkText[k].markText) |
|
|
|
gasMarkText[k].markText.clear(); |
|
|
|
if (gasMarkText[k] && gasMarkText[k].widget) |
|
|
|
gasMarkText[k].widget.remove(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
var gasAnnotation; |
|
|
@ -290,7 +310,7 @@ function listenMouseOver(e) |
|
|
|
gasAnnotation.clear(); |
|
|
|
var cl = getGasCostClass(node); |
|
|
|
var gasTitle = gasMarkRef[cl].value.isInfinite ? "infinite" : gasMarkRef[cl].value.gas; |
|
|
|
gasTitle = gasTitle + " gas"; |
|
|
|
gasTitle = " execution cost: " + gasTitle + " gas"; |
|
|
|
gasAnnotation = editor.addLineWidget(gasMarkRef[cl].line + 1, makeGasCostMarker(gasTitle), { coverGutter: false, above: true }); |
|
|
|
} |
|
|
|
else if (gasAnnotation) |
|
|
|