BVB Source Codes

reactide Show statements.js Source code

Return Download reactide: download statements.js Source code - Download reactide Source code - Type:.js
  1. "use strict";
  2.  
  3. exports.__esModule = true;
  4. exports.ThrowStatement = exports.BreakStatement = exports.ReturnStatement = exports.ContinueStatement = exports.ForAwaitStatement = exports.ForOfStatement = exports.ForInStatement = undefined;
  5.  
  6. var _getIterator2 = require("babel-runtime/core-js/get-iterator");
  7.  
  8. var _getIterator3 = _interopRequireDefault(_getIterator2);
  9.  
  10. exports.WithStatement = WithStatement;
  11. exports.IfStatement = IfStatement;
  12. exports.ForStatement = ForStatement;
  13. exports.WhileStatement = WhileStatement;
  14. exports.DoWhileStatement = DoWhileStatement;
  15. exports.LabeledStatement = LabeledStatement;
  16. exports.TryStatement = TryStatement;
  17. exports.CatchClause = CatchClause;
  18. exports.SwitchStatement = SwitchStatement;
  19. exports.SwitchCase = SwitchCase;
  20. exports.DebuggerStatement = DebuggerStatement;
  21. exports.VariableDeclaration = VariableDeclaration;
  22. exports.VariableDeclarator = VariableDeclarator;
  23.  
  24. var _babelTypes = require("babel-types");
  25.  
  26. var t = _interopRequireWildcard(_babelTypes);
  27.  
  28. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
  29.  
  30. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  31.  
  32. function WithStatement(node) {
  33.   this.word("with");
  34.   this.space();
  35.   this.token("(");
  36.   this.print(node.object, node);
  37.   this.token(")");
  38.   this.printBlock(node);
  39. }
  40.  
  41. function IfStatement(node) {
  42.   this.word("if");
  43.   this.space();
  44.   this.token("(");
  45.   this.print(node.test, node);
  46.   this.token(")");
  47.   this.space();
  48.  
  49.   var needsBlock = node.alternate && t.isIfStatement(getLastStatement(node.consequent));
  50.   if (needsBlock) {
  51.     this.token("{");
  52.     this.newline();
  53.     this.indent();
  54.   }
  55.  
  56.   this.printAndIndentOnComments(node.consequent, node);
  57.  
  58.   if (needsBlock) {
  59.     this.dedent();
  60.     this.newline();
  61.     this.token("}");
  62.   }
  63.  
  64.   if (node.alternate) {
  65.     if (this.endsWith("}")) this.space();
  66.     this.word("else");
  67.     this.space();
  68.     this.printAndIndentOnComments(node.alternate, node);
  69.   }
  70. }
  71.  
  72. function getLastStatement(statement) {
  73.   if (!t.isStatement(statement.body)) return statement;
  74.   return getLastStatement(statement.body);
  75. }
  76.  
  77. function ForStatement(node) {
  78.   this.word("for");
  79.   this.space();
  80.   this.token("(");
  81.  
  82.   this.inForStatementInitCounter++;
  83.   this.print(node.init, node);
  84.   this.inForStatementInitCounter--;
  85.   this.token(";");
  86.  
  87.   if (node.test) {
  88.     this.space();
  89.     this.print(node.test, node);
  90.   }
  91.   this.token(";");
  92.  
  93.   if (node.update) {
  94.     this.space();
  95.     this.print(node.update, node);
  96.   }
  97.  
  98.   this.token(")");
  99.   this.printBlock(node);
  100. }
  101.  
  102. function WhileStatement(node) {
  103.   this.word("while");
  104.   this.space();
  105.   this.token("(");
  106.   this.print(node.test, node);
  107.   this.token(")");
  108.   this.printBlock(node);
  109. }
  110.  
  111. var buildForXStatement = function buildForXStatement(op) {
  112.   return function (node) {
  113.     this.word("for");
  114.     this.space();
  115.     if (op === "await") {
  116.       this.word("await");
  117.       this.space();
  118.     }
  119.     this.token("(");
  120.  
  121.     this.print(node.left, node);
  122.     this.space();
  123.     this.word(op === "await" ? "of" : op);
  124.     this.space();
  125.     this.print(node.right, node);
  126.     this.token(")");
  127.     this.printBlock(node);
  128.   };
  129. };
  130.  
  131. var ForInStatement = exports.ForInStatement = buildForXStatement("in");
  132. var ForOfStatement = exports.ForOfStatement = buildForXStatement("of");
  133. var ForAwaitStatement = exports.ForAwaitStatement = buildForXStatement("await");
  134.  
  135. function DoWhileStatement(node) {
  136.   this.word("do");
  137.   this.space();
  138.   this.print(node.body, node);
  139.   this.space();
  140.   this.word("while");
  141.   this.space();
  142.   this.token("(");
  143.   this.print(node.test, node);
  144.   this.token(")");
  145.   this.semicolon();
  146. }
  147.  
  148. function buildLabelStatement(prefix) {
  149.   var key = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "label";
  150.  
  151.   return function (node) {
  152.     this.word(prefix);
  153.  
  154.     var label = node[key];
  155.     if (label) {
  156.       this.space();
  157.  
  158.       var terminatorState = this.startTerminatorless();
  159.       this.print(label, node);
  160.       this.endTerminatorless(terminatorState);
  161.     }
  162.  
  163.     this.semicolon();
  164.   };
  165. }
  166.  
  167. var ContinueStatement = exports.ContinueStatement = buildLabelStatement("continue");
  168. var ReturnStatement = exports.ReturnStatement = buildLabelStatement("return", "argument");
  169. var BreakStatement = exports.BreakStatement = buildLabelStatement("break");
  170. var ThrowStatement = exports.ThrowStatement = buildLabelStatement("throw", "argument");
  171.  
  172. function LabeledStatement(node) {
  173.   this.print(node.label, node);
  174.   this.token(":");
  175.   this.space();
  176.   this.print(node.body, node);
  177. }
  178.  
  179. function TryStatement(node) {
  180.   this.word("try");
  181.   this.space();
  182.   this.print(node.block, node);
  183.   this.space();
  184.  
  185.   if (node.handlers) {
  186.     this.print(node.handlers[0], node);
  187.   } else {
  188.     this.print(node.handler, node);
  189.   }
  190.  
  191.   if (node.finalizer) {
  192.     this.space();
  193.     this.word("finally");
  194.     this.space();
  195.     this.print(node.finalizer, node);
  196.   }
  197. }
  198.  
  199. function CatchClause(node) {
  200.   this.word("catch");
  201.   this.space();
  202.   this.token("(");
  203.   this.print(node.param, node);
  204.   this.token(")");
  205.   this.space();
  206.   this.print(node.body, node);
  207. }
  208.  
  209. function SwitchStatement(node) {
  210.   this.word("switch");
  211.   this.space();
  212.   this.token("(");
  213.   this.print(node.discriminant, node);
  214.   this.token(")");
  215.   this.space();
  216.   this.token("{");
  217.  
  218.   this.printSequence(node.cases, node, {
  219.     indent: true,
  220.     addNewlines: function addNewlines(leading, cas) {
  221.       if (!leading && node.cases[node.cases.length - 1] === cas) return -1;
  222.     }
  223.   });
  224.  
  225.   this.token("}");
  226. }
  227.  
  228. function SwitchCase(node) {
  229.   if (node.test) {
  230.     this.word("case");
  231.     this.space();
  232.     this.print(node.test, node);
  233.     this.token(":");
  234.   } else {
  235.     this.word("default");
  236.     this.token(":");
  237.   }
  238.  
  239.   if (node.consequent.length) {
  240.     this.newline();
  241.     this.printSequence(node.consequent, node, { indent: true });
  242.   }
  243. }
  244.  
  245. function DebuggerStatement() {
  246.   this.word("debugger");
  247.   this.semicolon();
  248. }
  249.  
  250. function variableDeclarationIdent() {
  251.   this.token(",");
  252.   this.newline();
  253.   if (this.endsWith("\n")) for (var i = 0; i < 4; i++) {
  254.     this.space(true);
  255.   }
  256. }
  257.  
  258. function constDeclarationIdent() {
  259.   this.token(",");
  260.   this.newline();
  261.   if (this.endsWith("\n")) for (var i = 0; i < 6; i++) {
  262.     this.space(true);
  263.   }
  264. }
  265.  
  266. function VariableDeclaration(node, parent) {
  267.   this.word(node.kind);
  268.   this.space();
  269.  
  270.   var hasInits = false;
  271.  
  272.   if (!t.isFor(parent)) {
  273.     for (var _iterator = node.declarations, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : (0, _getIterator3.default)(_iterator);;) {
  274.       var _ref;
  275.  
  276.       if (_isArray) {
  277.         if (_i >= _iterator.length) break;
  278.         _ref = _iterator[_i++];
  279.       } else {
  280.         _i = _iterator.next();
  281.         if (_i.done) break;
  282.         _ref = _i.value;
  283.       }
  284.  
  285.       var declar = _ref;
  286.  
  287.       if (declar.init) {
  288.         hasInits = true;
  289.       }
  290.     }
  291.   }
  292.  
  293.   var separator = void 0;
  294.   if (hasInits) {
  295.     separator = node.kind === "const" ? constDeclarationIdent : variableDeclarationIdent;
  296.   }
  297.  
  298.   this.printList(node.declarations, node, { separator: separator });
  299.  
  300.   if (t.isFor(parent)) {
  301.     if (parent.left === node || parent.init === node) return;
  302.   }
  303.  
  304.   this.semicolon();
  305. }
  306.  
  307. function VariableDeclarator(node) {
  308.   this.print(node.id, node);
  309.   this.print(node.id.typeAnnotation, node);
  310.   if (node.init) {
  311.     this.space();
  312.     this.token("=");
  313.     this.space();
  314.     this.print(node.init, node);
  315.   }
  316. }
downloadstatements.js Source code - Download reactide Source code
Related Source Codes/Software:
rkt - rkt is a pod-native container engine for Linux. It... 2017-06-11
uWebSockets - Tiny WebSockets https://for... 2017-06-11
realworld - TodoMVC for the RealWorld - Exemplary fullstack Me... 2017-06-11
goreplay - GoReplay is an open-source tool for capturing and ... 2017-06-10
pyenv - Simple Python version management 2017-06-10
postal - 2017-06-11
CRYENGINE - CRYENGINE is a powerful real-time game development... 2017-06-11
reactide - Reactide is the first dedicated IDE for React web ... 2017-06-11
redux-saga - An alternative side effect model for Redux apps ... 2017-06-10
angular-starter - 2017-06-10

 Back to top