first commit
This commit is contained in:
109
build/node_modules/prepack/lib/debugger/PerFileBreakpointMap.js
generated
vendored
Normal file
109
build/node_modules/prepack/lib/debugger/PerFileBreakpointMap.js
generated
vendored
Normal file
@@ -0,0 +1,109 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.PerFileBreakpointMap = 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 _Breakpoint = require("./Breakpoint.js");
|
||||
|
||||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||||
|
||||
// Storage for all the breakpoints in one source file
|
||||
// Each source file will be associated with one PerFileBreakpointMap
|
||||
var PerFileBreakpointMap = exports.PerFileBreakpointMap = function () {
|
||||
function PerFileBreakpointMap(filePath) {
|
||||
_classCallCheck(this, PerFileBreakpointMap);
|
||||
|
||||
this.filePath = filePath;
|
||||
this.breakpoints = new Map();
|
||||
}
|
||||
|
||||
//map of line:column to Breakpoint objects
|
||||
|
||||
|
||||
_createClass(PerFileBreakpointMap, [{
|
||||
key: "addBreakpoint",
|
||||
value: function addBreakpoint(line) {
|
||||
var column = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
||||
var temporary = arguments[2];
|
||||
var enabled = arguments[3];
|
||||
|
||||
var breakpoint = new _Breakpoint.Breakpoint(this.filePath, line, column, temporary, enabled);
|
||||
var key = this._getKey(line, column);
|
||||
this.breakpoints[key] = breakpoint;
|
||||
}
|
||||
}, {
|
||||
key: "getBreakpoint",
|
||||
value: function getBreakpoint(line) {
|
||||
var column = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
||||
|
||||
//check for a column breakpoint first, then line breakpoint
|
||||
if (column !== 0) {
|
||||
var key = this._getKey(line, column);
|
||||
if (key in this.breakpoints) {
|
||||
return this.breakpoints[key];
|
||||
} else {
|
||||
key = this._getKey(line, 0);
|
||||
if (key in this.breakpoints) {
|
||||
return this.breakpoints[key];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
var _key = this._getKey(line, 0);
|
||||
if (_key in this.breakpoints) {
|
||||
return this.breakpoints[_key];
|
||||
}
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
}, {
|
||||
key: "removeBreakpoint",
|
||||
value: function removeBreakpoint(line) {
|
||||
var column = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
||||
|
||||
var key = this._getKey(line, column);
|
||||
if (key in this.breakpoints) {
|
||||
delete this.breakpoints[key];
|
||||
}
|
||||
}
|
||||
}, {
|
||||
key: "enableBreakpoint",
|
||||
value: function enableBreakpoint(line) {
|
||||
var column = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
||||
|
||||
var key = this._getKey(line, column);
|
||||
if (key in this.breakpoints) {
|
||||
this.breakpoints[key].enabled = true;
|
||||
}
|
||||
}
|
||||
}, {
|
||||
key: "disableBreakpoint",
|
||||
value: function disableBreakpoint(line) {
|
||||
var column = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
||||
|
||||
var key = this._getKey(line, column);
|
||||
if (key in this.breakpoints) {
|
||||
this.breakpoints[key].enabled = false;
|
||||
}
|
||||
}
|
||||
}, {
|
||||
key: "_getKey",
|
||||
value: function _getKey(line, column) {
|
||||
return line + ":" + column;
|
||||
}
|
||||
}]);
|
||||
|
||||
return PerFileBreakpointMap;
|
||||
}();
|
||||
//# sourceMappingURL=PerFileBreakpointMap.js.map
|
||||
Reference in New Issue
Block a user