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

Function throwUnexpected

lib/assets/javascripts/JSXTransformer.js:5144–5177  ·  view source on GitHub ↗
(token)

Source from the content-addressed store, hash-verified

5142 // Throw an exception because of the token.
5143
5144 function throwUnexpected(token) {
5145 if (token.type === Token.EOF) {
5146 throwError(token, Messages.UnexpectedEOS);
5147 }
5148
5149 if (token.type === Token.NumericLiteral) {
5150 throwError(token, Messages.UnexpectedNumber);
5151 }
5152
5153 if (token.type === Token.StringLiteral || token.type === Token.JSXText) {
5154 throwError(token, Messages.UnexpectedString);
5155 }
5156
5157 if (token.type === Token.Identifier) {
5158 throwError(token, Messages.UnexpectedIdentifier);
5159 }
5160
5161 if (token.type === Token.Keyword) {
5162 if (isFutureReservedWord(token.value)) {
5163 throwError(token, Messages.UnexpectedReserved);
5164 } else if (strict && isStrictModeReservedWord(token.value)) {
5165 throwErrorTolerant(token, Messages.StrictReservedWord);
5166 return;
5167 }
5168 throwError(token, Messages.UnexpectedToken, token.value);
5169 }
5170
5171 if (token.type === Token.Template) {
5172 throwError(token, Messages.UnexpectedTemplate, token.value.raw);
5173 }
5174
5175 // BooleanLiteral, NullLiteral, or Punctuator.
5176 throwError(token, Messages.UnexpectedToken, token.value);
5177 }
5178
5179 // Expect the next token to match the specified punctuator.
5180 // If not, an exception will be thrown.

Callers 15

expectFunction · 0.85
expectKeywordFunction · 0.85
consumeSemicolonFunction · 0.85
parseObjectPropertyFunction · 0.85
parsePrimaryExpressionFunction · 0.85
parseNonComputedPropertyFunction · 0.85
parseObjectTypeFunction · 0.85
parsePrimaryTypeFunction · 0.85
parseVariableIdentifierFunction · 0.85
parseCatchClauseFunction · 0.85
parseStatementFunction · 0.85

Calls 4

throwErrorFunction · 0.85
isFutureReservedWordFunction · 0.85
isStrictModeReservedWordFunction · 0.85
throwErrorTolerantFunction · 0.85

Tested by

no test coverage detected