Projekt

Obecné

Profil

Stáhnout (4 KB) Statistiky
| Větev: | Revize:
1
"use strict";
2

    
3
exports.__esModule = true;
4
exports.MESSAGES = undefined;
5

    
6
var _stringify = require("babel-runtime/core-js/json/stringify");
7

    
8
var _stringify2 = _interopRequireDefault(_stringify);
9

    
10
exports.get = get;
11
exports.parseArgs = parseArgs;
12

    
13
var _util = require("util");
14

    
15
var util = _interopRequireWildcard(_util);
16

    
17
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; } }
18

    
19
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
20

    
21
var MESSAGES = exports.MESSAGES = {
22
  tailCallReassignmentDeopt: "Function reference has been reassigned, so it will probably be dereferenced, therefore we can't optimise this with confidence",
23
  classesIllegalBareSuper: "Illegal use of bare super",
24
  classesIllegalSuperCall: "Direct super call is illegal in non-constructor, use super.$1() instead",
25
  scopeDuplicateDeclaration: "Duplicate declaration $1",
26
  settersNoRest: "Setters aren't allowed to have a rest",
27
  noAssignmentsInForHead: "No assignments allowed in for-in/of head",
28
  expectedMemberExpressionOrIdentifier: "Expected type MemberExpression or Identifier",
29
  invalidParentForThisNode: "We don't know how to handle this node within the current parent - please open an issue",
30
  readOnly: "$1 is read-only",
31
  unknownForHead: "Unknown node type $1 in ForStatement",
32
  didYouMean: "Did you mean $1?",
33
  codeGeneratorDeopt: "Note: The code generator has deoptimised the styling of $1 as it exceeds the max of $2.",
34
  missingTemplatesDirectory: "no templates directory - this is most likely the result of a broken `npm publish`. Please report to https://github.com/babel/babel/issues",
35
  unsupportedOutputType: "Unsupported output type $1",
36
  illegalMethodName: "Illegal method name $1",
37
  lostTrackNodePath: "We lost track of this node's position, likely because the AST was directly manipulated",
38

    
39
  modulesIllegalExportName: "Illegal export $1",
40
  modulesDuplicateDeclarations: "Duplicate module declarations with the same source but in different scopes",
41

    
42
  undeclaredVariable: "Reference to undeclared variable $1",
43
  undeclaredVariableType: "Referencing a type alias outside of a type annotation",
44
  undeclaredVariableSuggestion: "Reference to undeclared variable $1 - did you mean $2?",
45

    
46
  traverseNeedsParent: "You must pass a scope and parentPath unless traversing a Program/File. Instead of that you tried to traverse a $1 node without passing scope and parentPath.",
47
  traverseVerifyRootFunction: "You passed `traverse()` a function when it expected a visitor object, are you sure you didn't mean `{ enter: Function }`?",
48
  traverseVerifyVisitorProperty: "You passed `traverse()` a visitor object with the property $1 that has the invalid property $2",
49
  traverseVerifyNodeType: "You gave us a visitor for the node type $1 but it's not a valid type",
50

    
51
  pluginNotObject: "Plugin $2 specified in $1 was expected to return an object when invoked but returned $3",
52
  pluginNotFunction: "Plugin $2 specified in $1 was expected to return a function but returned $3",
53
  pluginUnknown: "Unknown plugin $1 specified in $2 at $3, attempted to resolve relative to $4",
54
  pluginInvalidProperty: "Plugin $2 specified in $1 provided an invalid property of $3"
55
};
56

    
57
function get(key) {
58
  for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
59
    args[_key - 1] = arguments[_key];
60
  }
61

    
62
  var msg = MESSAGES[key];
63
  if (!msg) throw new ReferenceError("Unknown message " + (0, _stringify2.default)(key));
64

    
65
  args = parseArgs(args);
66

    
67
  return msg.replace(/\$(\d+)/g, function (str, i) {
68
    return args[i - 1];
69
  });
70
}
71

    
72
function parseArgs(args) {
73
  return args.map(function (val) {
74
    if (val != null && val.inspect) {
75
      return val.inspect();
76
    } else {
77
      try {
78
        return (0, _stringify2.default)(val) || val + "";
79
      } catch (e) {
80
        return util.inspect(val);
81
      }
82
    }
83
  });
84
}
    (1-1/1)