MCPcopy Create free account
hub / github.com/codemix/graph / rewriteOrderAliases

Function rewriteOrderAliases

packages/graph/src/astToSteps.ts:3155–3350  ·  view source on GitHub ↗
(
  value: ConditionValue,
  aliasMap: Map<string, AliasInfo>,
)

Source from the content-addressed store, hash-verified

3153}
3154
3155function rewriteOrderAliases(
3156 value: ConditionValue,
3157 aliasMap: Map<string, AliasInfo>,
3158): ConditionValue {
3159 if (value === null || value === undefined) {
3160 return value;
3161 }
3162
3163 if (typeof value !== "object") {
3164 return value;
3165 }
3166
3167 switch (value.type) {
3168 case "variableRef": {
3169 const aliasInfo = aliasMap.get(value.variable);
3170 if (!aliasInfo) {
3171 return value;
3172 }
3173 if (aliasInfo.property) {
3174 return {
3175 type: "propertyRef",
3176 variable: aliasInfo.variable,
3177 property: aliasInfo.property,
3178 };
3179 }
3180 return {
3181 type: "variableRef",
3182 variable: aliasInfo.variable,
3183 };
3184 }
3185 case "pathRef": {
3186 const aliasInfo = aliasMap.get(value.variable);
3187 if (!aliasInfo || aliasInfo.property) {
3188 return value;
3189 }
3190 return {
3191 type: "pathRef",
3192 variable: aliasInfo.variable,
3193 };
3194 }
3195 case "propertyRef":
3196 return value;
3197 case "parameterRef":
3198 case "null":
3199 return value;
3200 case "arithmeticExpression":
3201 return {
3202 ...value,
3203 left: rewriteOrderAliases(value.left, aliasMap),
3204 right: rewriteOrderAliases(value.right, aliasMap),
3205 };
3206 case "unaryExpression":
3207 return {
3208 ...value,
3209 operand: rewriteOrderAliases(value.operand, aliasMap),
3210 };
3211 case "booleanExpression":
3212 if (value.operator === "NOT") {

Callers 1

Calls 2

getMethod · 0.65
mapMethod · 0.45

Tested by

no test coverage detected