refactor(domain): share AST property name reader
This commit is contained in:
@@ -10,6 +10,9 @@ import type {
|
||||
JavaScriptStaticPathContext,
|
||||
JavaScriptStaticStorage,
|
||||
} from "./javascriptStaticAnalysisTypes.js";
|
||||
import { propertyName } from "./javascriptAstValues.js";
|
||||
|
||||
export { propertyName } from "./javascriptAstValues.js";
|
||||
|
||||
/** Explicit result for source text that Babel cannot parse. */
|
||||
export const failedJavaScriptStaticAnalysis = (): JavaScriptStaticAnalysis => ({
|
||||
@@ -299,14 +302,6 @@ const calleeNameAt = (node: t.Node): string => {
|
||||
return "";
|
||||
};
|
||||
|
||||
/** Read a literal property name without evaluating computed syntax. */
|
||||
export const propertyName = (node: t.Node): string => {
|
||||
if (t.isIdentifier(node)) return node.name;
|
||||
if (t.isStringLiteral(node) || t.isNumericLiteral(node))
|
||||
return String(node.value);
|
||||
return "";
|
||||
};
|
||||
|
||||
/** Return a string literal value without evaluating an expression. */
|
||||
export const stringValue = (
|
||||
node: t.Node | null | undefined,
|
||||
|
||||
Reference in New Issue
Block a user