124 lines
8.4 KiB
JavaScript
124 lines
8.4 KiB
JavaScript
"use strict";
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports.BreakpointManager = undefined;
|
|
|
|
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); /**
|
|
* Copyright (c) 2017-present, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*/
|
|
|
|
var _PerFileBreakpointMap = require("./PerFileBreakpointMap.js");
|
|
|
|
var _Breakpoint = require("./Breakpoint.js");
|
|
|
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
|
|
// Storing BreakpointStores for all source files
|
|
var BreakpointManager = exports.BreakpointManager = function () {
|
|
function BreakpointManager() {
|
|
_classCallCheck(this, BreakpointManager);
|
|
|
|
this._breakpointMaps = new Map();
|
|
}
|
|
|
|
_createClass(BreakpointManager, [{
|
|
key: "addBreakpointMulti",
|
|
value: function addBreakpointMulti(breakpoints) {
|
|
this._doBreakpointsAction(breakpoints, this._addBreakpoint.bind(this));
|
|
}
|
|
}, {
|
|
key: "_addBreakpoint",
|
|
value: function _addBreakpoint(bp) {
|
|
if (!(bp.filePath in this._breakpointMaps)) {
|
|
this._breakpointMaps[bp.filePath] = new _PerFileBreakpointMap.PerFileBreakpointMap(bp.filePath);
|
|
}
|
|
var breakpointMap = this._breakpointMaps[bp.filePath];
|
|
breakpointMap.addBreakpoint(bp.line, bp.column);
|
|
}
|
|
}, {
|
|
key: "getBreakpoint",
|
|
value: function getBreakpoint(filePath, lineNum) {
|
|
var columnNum = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
|
|
|
if (filePath in this._breakpointMaps) {
|
|
var breakpointMap = this._breakpointMaps[filePath];
|
|
return breakpointMap.getBreakpoint(lineNum, columnNum);
|
|
}
|
|
return undefined;
|
|
}
|
|
}, {
|
|
key: "removeBreakpointMulti",
|
|
value: function removeBreakpointMulti(breakpoints) {
|
|
this._doBreakpointsAction(breakpoints, this._removeBreakpoint.bind(this));
|
|
}
|
|
}, {
|
|
key: "_removeBreakpoint",
|
|
value: function _removeBreakpoint(bp) {
|
|
if (bp.filePath in this._breakpointMaps) {
|
|
this._breakpointMaps[bp.filePath].removeBreakpoint(bp.line, bp.column);
|
|
}
|
|
}
|
|
}, {
|
|
key: "enableBreakpointMulti",
|
|
value: function enableBreakpointMulti(breakpoints) {
|
|
this._doBreakpointsAction(breakpoints, this._enableBreakpoint.bind(this));
|
|
}
|
|
}, {
|
|
key: "_enableBreakpoint",
|
|
value: function _enableBreakpoint(bp) {
|
|
if (bp.filePath in this._breakpointMaps) {
|
|
this._breakpointMaps[bp.filePath].enableBreakpoint(bp.line, bp.column);
|
|
}
|
|
}
|
|
}, {
|
|
key: "disableBreakpointMulti",
|
|
value: function disableBreakpointMulti(breakpoints) {
|
|
this._doBreakpointsAction(breakpoints, this._disableBreakpoint.bind(this));
|
|
}
|
|
}, {
|
|
key: "_disableBreakpoint",
|
|
value: function _disableBreakpoint(bp) {
|
|
if (bp.filePath in this._breakpointMaps) {
|
|
this._breakpointMaps[bp.filePath].disableBreakpoint(bp.line, bp.column);
|
|
}
|
|
}
|
|
}, {
|
|
key: "_doBreakpointsAction",
|
|
value: function _doBreakpointsAction(breakpoints, action) {
|
|
var _iteratorNormalCompletion = true;
|
|
var _didIteratorError = false;
|
|
var _iteratorError = undefined;
|
|
|
|
try {
|
|
for (var _iterator = breakpoints[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
var bp = _step.value;
|
|
|
|
action(bp);
|
|
}
|
|
} catch (err) {
|
|
_didIteratorError = true;
|
|
_iteratorError = err;
|
|
} finally {
|
|
try {
|
|
if (!_iteratorNormalCompletion && _iterator.return) {
|
|
_iterator.return();
|
|
}
|
|
} finally {
|
|
if (_didIteratorError) {
|
|
throw _iteratorError;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}]);
|
|
|
|
return BreakpointManager;
|
|
}();
|
|
//# sourceMappingURL=BreakpointManager.js.map
|