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

Function parsePrimaryType

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

Source from the content-addressed store, hash-verified

6856 // primary types are kind of like primary expressions...they're the
6857 // primitives with which other types are constructed.
6858 function parsePrimaryType() {
6859 var params = null, returnType = null,
6860 marker = markerCreate(), rest = null, tmp,
6861 typeParameters, token, type, isGroupedType = false;
6862
6863 switch (lookahead.type) {
6864 case Token.Identifier:
6865 switch (lookahead.value) {
6866 case 'any':
6867 lex();
6868 return markerApply(marker, delegate.createAnyTypeAnnotation());
6869 case 'bool': // fallthrough
6870 case 'boolean':
6871 lex();
6872 return markerApply(marker, delegate.createBooleanTypeAnnotation());
6873 case 'number':
6874 lex();
6875 return markerApply(marker, delegate.createNumberTypeAnnotation());
6876 case 'string':
6877 lex();
6878 return markerApply(marker, delegate.createStringTypeAnnotation());
6879 }
6880 return markerApply(marker, parseGenericType());
6881 case Token.Punctuator:
6882 switch (lookahead.value) {
6883 case '{':
6884 return markerApply(marker, parseObjectType());
6885 case '[':
6886 return parseTupleType();
6887 case '<':
6888 typeParameters = parseTypeParameterDeclaration();
6889 expect('(');
6890 tmp = parseFunctionTypeParams();
6891 params = tmp.params;
6892 rest = tmp.rest;
6893 expect(')');
6894
6895 expect('=>');
6896
6897 returnType = parseType();
6898
6899 return markerApply(marker, delegate.createFunctionTypeAnnotation(
6900 params,
6901 returnType,
6902 rest,
6903 typeParameters
6904 ));
6905 case '(':
6906 lex();
6907 // Check to see if this is actually a grouped type
6908 if (!match(')') && !match('...')) {
6909 if (lookahead.type === Token.Identifier) {
6910 token = lookahead2();
6911 isGroupedType = token.value !== '?' && token.value !== ':';
6912 } else {
6913 isGroupedType = true;
6914 }
6915 }

Callers 2

parseTypeofTypeFunction · 0.85
parsePostfixTypeFunction · 0.85

Calls 15

markerCreateFunction · 0.85
lexFunction · 0.85
markerApplyFunction · 0.85
parseGenericTypeFunction · 0.85
parseObjectTypeFunction · 0.85
parseTupleTypeFunction · 0.85
expectFunction · 0.85
parseFunctionTypeParamsFunction · 0.85
parseTypeFunction · 0.85
matchFunction · 0.85
lookahead2Function · 0.85

Tested by

no test coverage detected