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

Function buildMap

test/fixtures/snapshot/typescript.js:146873–146895  ·  view source on GitHub ↗
(rules)

Source from the content-addressed store, hash-verified

146871 };
146872 }
146873 function buildMap(rules) {
146874 // Map from bucket index to array of rules
146875 var map = new Array(mapRowLength * mapRowLength);
146876 // This array is used only during construction of the rulesbucket in the map
146877 var rulesBucketConstructionStateList = new Array(map.length);
146878 for (var _i = 0, rules_2 = rules; _i < rules_2.length; _i++) {
146879 var rule = rules_2[_i];
146880 var specificRule = rule.leftTokenRange.isSpecific && rule.rightTokenRange.isSpecific;
146881 for (var _a = 0, _b = rule.leftTokenRange.tokens; _a < _b.length; _a++) {
146882 var left = _b[_a];
146883 for (var _c = 0, _d = rule.rightTokenRange.tokens; _c < _d.length; _c++) {
146884 var right = _d[_c];
146885 var index = getRuleBucketIndex(left, right);
146886 var rulesBucket = map[index];
146887 if (rulesBucket === undefined) {
146888 rulesBucket = map[index] = [];
146889 }
146890 addRule(rulesBucket, rule.rule, specificRule, rulesBucketConstructionStateList, index);
146891 }
146892 }
146893 }
146894 return map;
146895 }
146896 function getRuleBucketIndex(row, column) {
146897 ts.Debug.assert(row <= 160 /* SyntaxKind.LastKeyword */ && column <= 160 /* SyntaxKind.LastKeyword */, "Must compute formatting context from tokens");
146898 return (row * mapRowLength) + column;

Callers 1

createRulesMapFunction · 0.85

Calls 2

getRuleBucketIndexFunction · 0.85
addRuleFunction · 0.85

Tested by

no test coverage detected