MCPcopy Index your code
hub / github.com/reactjs/react-rails / parseExportDeclaration

Function parseExportDeclaration

lib/assets/javascripts/JSXTransformer.js:7196–7305  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

7194 }
7195
7196 function parseExportDeclaration() {
7197 var declaration = null,
7198 possibleIdentifierToken, sourceElement,
7199 isExportFromIdentifier,
7200 src = null, specifiers = [],
7201 marker = markerCreate();
7202
7203 expectKeyword('export');
7204
7205 if (matchKeyword('default')) {
7206 // covers:
7207 // export default ...
7208 lex();
7209 if (matchKeyword('function') || matchKeyword('class')) {
7210 possibleIdentifierToken = lookahead2();
7211 if (isIdentifierName(possibleIdentifierToken)) {
7212 // covers:
7213 // export default function foo () {}
7214 // export default class foo {}
7215 sourceElement = parseSourceElement();
7216 return markerApply(marker, delegate.createExportDeclaration(true, sourceElement, [sourceElement.id], null));
7217 }
7218 // covers:
7219 // export default function () {}
7220 // export default class {}
7221 switch (lookahead.value) {
7222 case 'class':
7223 return markerApply(marker, delegate.createExportDeclaration(true, parseClassExpression(), [], null));
7224 case 'function':
7225 return markerApply(marker, delegate.createExportDeclaration(true, parseFunctionExpression(), [], null));
7226 }
7227 }
7228
7229 if (matchContextualKeyword('from')) {
7230 throwError({}, Messages.UnexpectedToken, lookahead.value);
7231 }
7232
7233 // covers:
7234 // export default {};
7235 // export default [];
7236 if (match('{')) {
7237 declaration = parseObjectInitialiser();
7238 } else if (match('[')) {
7239 declaration = parseArrayInitialiser();
7240 } else {
7241 declaration = parseAssignmentExpression();
7242 }
7243 consumeSemicolon();
7244 return markerApply(marker, delegate.createExportDeclaration(true, declaration, [], null));
7245 }
7246
7247 // non-default export
7248 if (lookahead.type === Token.Keyword || matchContextualKeyword('type')) {
7249 // covers:
7250 // export var f = 1;
7251 switch (lookahead.value) {
7252 case 'type':
7253 case 'let':

Callers 2

parseSourceElementFunction · 0.85
parseProgramElementFunction · 0.85

Calls 15

markerCreateFunction · 0.85
expectKeywordFunction · 0.85
matchKeywordFunction · 0.85
lexFunction · 0.85
lookahead2Function · 0.85
isIdentifierNameFunction · 0.85
parseSourceElementFunction · 0.85
markerApplyFunction · 0.85
parseClassExpressionFunction · 0.85
parseFunctionExpressionFunction · 0.85
matchContextualKeywordFunction · 0.85
throwErrorFunction · 0.85

Tested by

no test coverage detected