Home / Function/ extract_all_identifiers_from_expression() — svelte Function Reference

extract_all_identifiers_from_expression() — svelte Function Reference

Architecture documentation for the extract_all_identifiers_from_expression() function in ast.js from the svelte codebase.

Entity Profile

Dependency Diagram

graph TD
  f37fcfdb_9d8e_8c81_7fc8_e49a289d52bc["extract_all_identifiers_from_expression()"]
  0c5c28a7_226d_4e7c_e75e_0853c0a9fc2c["ast.js"]
  f37fcfdb_9d8e_8c81_7fc8_e49a289d52bc -->|defined in| 0c5c28a7_226d_4e7c_e75e_0853c0a9fc2c
  8f93b8d1_a873_5c72_eae3_de296245116a["instance_script.VariableDeclaration()"]
  8f93b8d1_a873_5c72_eae3_de296245116a -->|calls| f37fcfdb_9d8e_8c81_7fc8_e49a289d52bc
  5d553a43_30d1_f81d_668e_5d7134967ec9["instance_script.LabeledStatement()"]
  5d553a43_30d1_f81d_668e_5d7134967ec9 -->|calls| f37fcfdb_9d8e_8c81_7fc8_e49a289d52bc
  4931635c_2415_3c69_a7a7_e98ad2cfd475["BindDirective()"]
  4931635c_2415_3c69_a7a7_e98ad2cfd475 -->|calls| f37fcfdb_9d8e_8c81_7fc8_e49a289d52bc
  style f37fcfdb_9d8e_8c81_7fc8_e49a289d52bc fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/svelte/src/compiler/utils/ast.js lines 146–185

export function extract_all_identifiers_from_expression(expr) {
	/** @type {ESTree.Identifier[]} */
	let nodes = [];
	/** @type {string[]} */
	let keypath = [];

	walk(
		expr,
		{},
		{
			Identifier(node, { path }) {
				const parent = path.at(-1);
				if (parent?.type !== 'MemberExpression' || parent.property !== node || parent.computed) {
					nodes.push(node);
				}

				if (parent?.type === 'MemberExpression' && parent.computed && parent.property === node) {
					keypath.push(`[${node.name}]`);
				} else {
					keypath.push(node.name);
				}
			},
			Literal(node, { path }) {
				const value = typeof node.value === 'string' ? `"${node.value}"` : String(node.value);
				const parent = path.at(-1);
				if (parent?.type === 'MemberExpression' && parent.computed && parent.property === node) {
					keypath.push(`[${value}]`);
				} else {
					keypath.push(value);
				}
			},
			ThisExpression(_, { next }) {
				keypath.push('this');
				next();
			}
		}
	);

	return [keypath.join('.'), nodes];
}

Domain

Subdomains

Frequently Asked Questions

What does extract_all_identifiers_from_expression() do?
extract_all_identifiers_from_expression() is a function in the svelte codebase, defined in packages/svelte/src/compiler/utils/ast.js.
Where is extract_all_identifiers_from_expression() defined?
extract_all_identifiers_from_expression() is defined in packages/svelte/src/compiler/utils/ast.js at line 146.
What calls extract_all_identifiers_from_expression()?
extract_all_identifiers_from_expression() is called by 3 function(s): BindDirective, instance_script.LabeledStatement, instance_script.VariableDeclaration.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free