MCPcopy Create free account
hub / github.com/ChromeDevTools/devtools-frontend / getExperimentNameEnum

Function getExperimentNameEnum

scripts/check_experiments.js:70–89  ·  view source on GitHub ↗

* Extract the enum Root.ExperimentNames.ExperimentName to a map

(mainImplFile)

Source from the content-addressed store, hash-verified

68 * Extract the enum Root.ExperimentNames.ExperimentName to a map
69 */
70function getExperimentNameEnum(mainImplFile) {
71 const mainAST = espree.parse(mainImplFile, parseOptions);
72
73 let experimentNameEnum;
74 for (const node of mainAST.body) {
75 if (isEnumDeclaration(node, 'ExperimentName')) {
76 experimentNameEnum = node;
77 break;
78 }
79 }
80
81 const map = new Map();
82 if (!experimentNameEnum) {
83 return map;
84 }
85 for (const member of experimentNameEnum.declaration.members) {
86 map.set(member.id.name, member.initializer.value);
87 }
88 return map;
89}
90
91/**
92 * Determine if node is of the form Root.ExperimentNames.ExperimentName.NAME, and if so

Callers 1

mainFunction · 0.85

Calls 3

isEnumDeclarationFunction · 0.85
setMethod · 0.65
parseMethod · 0.45

Tested by

no test coverage detected