Code coverage report for sc/lang/compiler/marker/marker.js

Statements: 100% (40 / 40)      Branches: 100% (21 / 21)      Functions: 100% (7 / 7)      Lines: 100% (40 / 40)      Ignored: 2 branches     

All files » sc/lang/compiler/marker/ » marker.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 891     1   1 1107 1107 1107     1 4328   4328 3221     1107 10   1097 1097     1107     1 793   793 4   789   793   793     1 830   830 2     828 736 736 699   37     736 736     736 736                         828     1   2263     2180       1    
(function(sc) {
  "use strict";
 
  require("../compiler");
 
  function Marker(lexer, locItems) {
    this.lexer = lexer;
    this.startLocItems = locItems;
    this.endLocItems   = null;
  }
 
  Marker.create = function(lexer, node) {
    var locItems;
 
    if (!lexer.opts.loc && !lexer.opts.range) {
      return nopMarker;
    }
 
    if (node) {
      locItems = [ node.range[0], node.loc.start.line, node.loc.start.column ];
    } else {
      lexer.skipComment();
      locItems = lexer.getLocItems();
    }
 
    return new Marker(lexer, locItems);
  };
 
  Marker.prototype.update = function(node) {
    var locItems;
 
    if (node) {
      locItems = [ node.range[1], node.loc.end.line, node.loc.end.column ];
    } else {
      locItems = this.lexer.getLocItems();
    }
    this.endLocItems = locItems;
 
    return this;
  };
 
  Marker.prototype.apply = function(node, force) {
    var startLocItems, endLocItems;
 
    if (Array.isArray(node)) {
      return node;
    }
 
    if (force || !node.range || !node.loc) {
      startLocItems = this.startLocItems;
      if (this.endLocItems) {
        endLocItems = this.endLocItems;
      } else {
        endLocItems = this.startLocItems;
      }
      /* istanbul ignore else */
      Eif (this.lexer.opts.range) {
        node.range = [ startLocItems[0], endLocItems[0] ];
      }
      /* istanbul ignore else */
      Eif (this.lexer.opts.loc) {
        node.loc = {
          start: {
            line: startLocItems[1],
            column: startLocItems[2]
          },
          end: {
            line: endLocItems[1],
            column: endLocItems[2]
          }
        };
      }
    }
 
    return node;
  };
 
  var nopMarker = {
    apply: function(node) {
      return node;
    },
    update: function() {
      return this;
    }
  };
 
  sc.lang.compiler.Marker = Marker;
})(sc);