"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.StepOverStepper = exports.StepIntoStepper = exports.Stepper = 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 _is = require("./../../methods/is.js"); var _babelTypes = require("babel-types"); var _invariant = require("./../common/invariant.js"); var _invariant2 = _interopRequireDefault(_invariant); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } var Stepper = exports.Stepper = function () { function Stepper(filePath, line, column) { _classCallCheck(this, Stepper); this._stepStartData = { filePath: filePath, line: line, column: column }; } _createClass(Stepper, [{ key: "isComplete", value: function isComplete(ast, currentStackSize) { (0, _invariant2.default)(false, "Abstract method, please override"); } }, { key: "isAstLocationChanged", value: function isAstLocationChanged(ast) { // we should only step to statements if (!(0, _is.IsStatement)(ast)) return false; var loc = ast.loc; if (!loc) return false; var filePath = loc.source; var line = loc.start.line; var column = loc.start.column; if (!filePath) return false; if (this._stepStartData) { if (filePath === this._stepStartData.filePath && line === this._stepStartData.line && column === this._stepStartData.column) { return false; } } else { return false; } return true; } }]); return Stepper; }(); var StepIntoStepper = exports.StepIntoStepper = function (_Stepper) { _inherits(StepIntoStepper, _Stepper); function StepIntoStepper(filePath, line, column) { _classCallCheck(this, StepIntoStepper); return _possibleConstructorReturn(this, (StepIntoStepper.__proto__ || Object.getPrototypeOf(StepIntoStepper)).call(this, filePath, line, column)); } // Override _createClass(StepIntoStepper, [{ key: "isComplete", value: function isComplete(ast, currentStackSize) { return this.isAstLocationChanged(ast); } }]); return StepIntoStepper; }(Stepper); var StepOverStepper = exports.StepOverStepper = function (_Stepper2) { _inherits(StepOverStepper, _Stepper2); function StepOverStepper(filePath, line, column, stackSize) { _classCallCheck(this, StepOverStepper); var _this2 = _possibleConstructorReturn(this, (StepOverStepper.__proto__ || Object.getPrototypeOf(StepOverStepper)).call(this, filePath, line, column)); _this2._startStackSize = stackSize; return _this2; } _createClass(StepOverStepper, [{ key: "isComplete", value: function isComplete(ast, currentStackSize) { if (!this.isAstLocationChanged(ast)) return false; if (currentStackSize <= this._startStackSize) { // two cases here: // if current stack length < starting stack length, the program must have // hit an exception so this stepper is no longer relevant // if current stack length === starting stack length, the program returned // to the same stack depth, so a step over is complete return true; } return false; } }]); return StepOverStepper; }(Stepper); //# sourceMappingURL=Stepper.js.map