Пример #1
0
        function setupEditor(editor) {
            // get the functions in this file
            _functionsInFile = Agent.functionsInFile(path).sort(function (a, b) { return a.start.line - b.start.line });

            // add gutter markers showing call counts
            // console.log("gutters", editor._codeMirror.getOption("gutters"));
            var usedLines = {};
            _functionsInFile.forEach(function (node) {
                if (usedLines[node.start.line]) return;
                usedLines[node.start.line] = true;

                var $glyph = $(_svgForGlyph(_nodeGlyph(node.id), "tiny"));
                var $dom = $("<span class='uninitialized uninitialized-exceptions none theseus-call-count' id='" + _domIdForNodeId(node.id) + "' data-node-id='" + node.id + "'><span class='counts'>0 calls</span></span>");
                $dom.append($glyph);
                editor._codeMirror.setGutterMarker(node.start.line - 1, "CodeMirror-linenumbers", $dom.get(0));
            });

            // mark dead functions
            var start = new Date();
            var timeSinceStart = function () { return (new Date() - start) / 1000 };
            var hits = Agent.cachedHitCounts();
            for (var i in _functionsInFile) {
                var node = _functionsInFile[i];
                if (!(node.id in hits)) {
                    var from = { line: node.start.line - 1, ch: node.start.column };
                    var to = { line: node.end.line - 1, ch: node.end.column };
                    var markOptions = {
                        className: 'theseus-dead',
                        inclusiveLeft: false,
                        inclusiveRight: false,
                    };
                    _deadCodeMarks[node.id] = editor._codeMirror.markText(from, to, markOptions);
                }

                if (timeSinceStart() > 1) break;
            }
        }
Пример #2
0
    function _receivedScriptInfo(event, path) {
        if (Agent.couldBeRemotePath(EditorInterface.currentPath(), path)) {
            _editorChanged(undefined, EditorInterface.currentEditor(), EditorInterface.currentEditor(), EditorInterface.currentPath());
        }

        var fileNodes = Agent.functionsInFile(path);
        var nodesToReAdd = [];
        _previouslyLoggedNodes.forEach(function (nodeId) {
            var exists = fileNodes.some(function (node) { return node.id === nodeId });
            var inQuery = _loggedNodes.indexOf(nodeId) !== -1;
            if (exists && !inQuery) {
                nodesToReAdd.push(nodeId);
            }
        });
        if (nodesToReAdd.length > 0) {
            _resetLogQuery();
            nodesToReAdd.forEach(function (nodeId) {
                _loggedNodes.push(nodeId);
                _getNodeMarker(nodeId).toggleClass("set", true);
            });
            Panel.toggle(true);
            _refreshLogQuery();
        }
    }