cst
Version:
JavaScript CST Implementation
97 lines (74 loc) • 3.77 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
var _getPrototypeOf = require('babel-runtime/core-js/object/get-prototype-of');
var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf);
var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
var _createClass2 = require('babel-runtime/helpers/createClass');
var _createClass3 = _interopRequireDefault(_createClass2);
var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn');
var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
var _inherits2 = require('babel-runtime/helpers/inherits');
var _inherits3 = _interopRequireDefault(_inherits2);
var _ModuleDeclaration2 = require('../ModuleDeclaration');
var _ModuleDeclaration3 = _interopRequireDefault(_ModuleDeclaration2);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var ExportNamedDeclaration = function (_ModuleDeclaration) {
(0, _inherits3.default)(ExportNamedDeclaration, _ModuleDeclaration);
function ExportNamedDeclaration(childNodes) {
(0, _classCallCheck3.default)(this, ExportNamedDeclaration);
return (0, _possibleConstructorReturn3.default)(this, (ExportNamedDeclaration.__proto__ || (0, _getPrototypeOf2.default)(ExportNamedDeclaration)).call(this, 'ExportNamedDeclaration', childNodes));
}
(0, _createClass3.default)(ExportNamedDeclaration, [{
key: '_acceptChildren',
value: function _acceptChildren(children) {
children.passToken('Keyword', 'export');
children.skipNonCode();
var declaration = null;
var specifiers = [];
var source = null;
if (children.isNode('VariableDeclaration') || children.isNode('FunctionDeclaration') || children.isNode('ClassDeclaration')) {
declaration = children.passStatement();
} else {
// es2015 exports
if (children.isToken('Punctuator', '{')) {
children.passToken('Punctuator', '{');
children.skipNonCode();
while (!children.isToken('Punctuator', '}')) {
specifiers.push(children.passModuleSpecifier());
children.skipNonCode();
if (children.isToken('Punctuator', ',')) {
children.moveNext();
children.skipNonCode();
}
}
children.passToken('Punctuator', '}');
} else {
// es2016 export from
specifiers.push(children.passModuleSpecifier());
}
children.skipNonCode();
if (children.isToken('Identifier', 'from')) {
children.passToken('Identifier', 'from');
children.skipNonCode();
source = children.passNode('StringLiteral');
if (!children.isEnd) {
children.skipNonCode();
children.passToken('Punctuator', ';');
}
} else if (!children.isEnd) {
children.passToken('Punctuator', ';');
}
}
children.assertEnd();
this.declaration = declaration;
this.specifiers = specifiers;
this.source = source;
}
}]);
return ExportNamedDeclaration;
}(_ModuleDeclaration3.default);
exports.default = ExportNamedDeclaration;
//# sourceMappingURL=ExportNamedDeclaration.js.map