MCPcopy Index your code
hub / github.com/nodejs/node / getJsxNamespace

Function getJsxNamespace

test/fixtures/snapshot/typescript.js:48920–48968  ·  view source on GitHub ↗
(location)

Source from the content-addressed store, hash-verified

48918 initializeTypeChecker();
48919 return checker;
48920 function getJsxNamespace(location) {
48921 if (location) {
48922 var file = ts.getSourceFileOfNode(location);
48923 if (file) {
48924 if (ts.isJsxOpeningFragment(location)) {
48925 if (file.localJsxFragmentNamespace) {
48926 return file.localJsxFragmentNamespace;
48927 }
48928 var jsxFragmentPragma = file.pragmas.get("jsxfrag");
48929 if (jsxFragmentPragma) {
48930 var chosenPragma = ts.isArray(jsxFragmentPragma) ? jsxFragmentPragma[0] : jsxFragmentPragma;
48931 file.localJsxFragmentFactory = ts.parseIsolatedEntityName(chosenPragma.arguments.factory, languageVersion);
48932 ts.visitNode(file.localJsxFragmentFactory, markAsSynthetic);
48933 if (file.localJsxFragmentFactory) {
48934 return file.localJsxFragmentNamespace = ts.getFirstIdentifier(file.localJsxFragmentFactory).escapedText;
48935 }
48936 }
48937 var entity = getJsxFragmentFactoryEntity(location);
48938 if (entity) {
48939 file.localJsxFragmentFactory = entity;
48940 return file.localJsxFragmentNamespace = ts.getFirstIdentifier(entity).escapedText;
48941 }
48942 }
48943 else {
48944 var localJsxNamespace = getLocalJsxNamespace(file);
48945 if (localJsxNamespace) {
48946 return file.localJsxNamespace = localJsxNamespace;
48947 }
48948 }
48949 }
48950 }
48951 if (!_jsxNamespace) {
48952 _jsxNamespace = "React";
48953 if (compilerOptions.jsxFactory) {
48954 _jsxFactoryEntity = ts.parseIsolatedEntityName(compilerOptions.jsxFactory, languageVersion);
48955 ts.visitNode(_jsxFactoryEntity, markAsSynthetic);
48956 if (_jsxFactoryEntity) {
48957 _jsxNamespace = ts.getFirstIdentifier(_jsxFactoryEntity).escapedText;
48958 }
48959 }
48960 else if (compilerOptions.reactNamespace) {
48961 _jsxNamespace = ts.escapeLeadingUnderscores(compilerOptions.reactNamespace);
48962 }
48963 }
48964 if (!_jsxFactoryEntity) {
48965 _jsxFactoryEntity = ts.factory.createQualifiedName(ts.factory.createIdentifier(ts.unescapeLeadingUnderscores(_jsxNamespace)), "createElement");
48966 }
48967 return _jsxNamespace;
48968 }
48969 function getLocalJsxNamespace(file) {
48970 if (file.localJsxNamespace) {
48971 return file.localJsxNamespace;

Callers 4

createTypeCheckerFunction · 0.85
getJsxNamespaceAtFunction · 0.85
getJsxFactoryEntityFunction · 0.85

Calls 3

getLocalJsxNamespaceFunction · 0.85
getMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…