Home / File/ CallExpression.js — svelte Source File

CallExpression.js — svelte Source File

Architecture documentation for CallExpression.js, a javascript file in the svelte codebase. 14 imports, 1 dependents.

File javascript Compiler Transformer 14 imports 1 dependents 5 functions

Entity Profile

Dependency Diagram

graph LR
  3f0209c9_7af2_542f_1c9c_3be0eb046971["CallExpression.js"]
  ee93d8a6_6fde_b1c1_e15b_3a4da5326305["scope.js"]
  3f0209c9_7af2_542f_1c9c_3be0eb046971 --> ee93d8a6_6fde_b1c1_e15b_3a4da5326305
  bed91719_d047_2256_e199_ee875d5f49b9["get_rune"]
  3f0209c9_7af2_542f_1c9c_3be0eb046971 --> bed91719_d047_2256_e199_ee875d5f49b9
  495501a4_a342_6a4d_ac11_e3e2fee8b218["errors.js"]
  3f0209c9_7af2_542f_1c9c_3be0eb046971 --> 495501a4_a342_6a4d_ac11_e3e2fee8b218
  a146f6ac_0088_8736_b6ce_318f9f115170["e"]
  3f0209c9_7af2_542f_1c9c_3be0eb046971 --> a146f6ac_0088_8736_b6ce_318f9f115170
  0c5c28a7_226d_4e7c_e75e_0853c0a9fc2c["ast.js"]
  3f0209c9_7af2_542f_1c9c_3be0eb046971 --> 0c5c28a7_226d_4e7c_e75e_0853c0a9fc2c
  68a38b3b_6f0f_ed43_404f_3d00302677a2["get_parent"]
  3f0209c9_7af2_542f_1c9c_3be0eb046971 --> 68a38b3b_6f0f_ed43_404f_3d00302677a2
  bf0d8f1b_17da_970d_bf44_fbcf099d5371["utils.js"]
  3f0209c9_7af2_542f_1c9c_3be0eb046971 --> bf0d8f1b_17da_970d_bf44_fbcf099d5371
  3aac8d0a_5cc9_78ed_97ef_1c2a43db9e18["is_pure"]
  3f0209c9_7af2_542f_1c9c_3be0eb046971 --> 3aac8d0a_5cc9_78ed_97ef_1c2a43db9e18
  e40e188e_6def_6359_11b9_9532abe99b8d["is_safe_identifier"]
  3f0209c9_7af2_542f_1c9c_3be0eb046971 --> e40e188e_6def_6359_11b9_9532abe99b8d
  62f818c8_e890_17ed_5ec1_92f953d4a7a6["state.js"]
  3f0209c9_7af2_542f_1c9c_3be0eb046971 --> 62f818c8_e890_17ed_5ec1_92f953d4a7a6
  bde97aff_493a_f552_a038_3e029fefca90["locate_node"]
  3f0209c9_7af2_542f_1c9c_3be0eb046971 --> bde97aff_493a_f552_a038_3e029fefca90
  bbca3d2a_42c8_b215_d3b5_5077ccaf0797["nodes.js"]
  3f0209c9_7af2_542f_1c9c_3be0eb046971 --> bbca3d2a_42c8_b215_d3b5_5077ccaf0797
  6e00a8f3_2371_ecf1_5a93_296f787aca83["ExpressionMetadata"]
  3f0209c9_7af2_542f_1c9c_3be0eb046971 --> 6e00a8f3_2371_ecf1_5a93_296f787aca83
  95c28355_f14c_c3cd_5a03_d5a53ca255bc["builders"]
  3f0209c9_7af2_542f_1c9c_3be0eb046971 --> 95c28355_f14c_c3cd_5a03_d5a53ca255bc
  style 3f0209c9_7af2_542f_1c9c_3be0eb046971 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

/** @import { ArrowFunctionExpression, CallExpression, Expression, FunctionDeclaration, FunctionExpression, Identifier, VariableDeclarator } from 'estree' */
/** @import { AST } from '#compiler' */
/** @import { Context } from '../types' */
import { get_rune } from '../../scope.js';
import * as e from '../../../errors.js';
import { get_parent } from '../../../utils/ast.js';
import { is_pure, is_safe_identifier } from './shared/utils.js';
import { dev, locate_node, source } from '../../../state.js';
import * as b from '#compiler/builders';
import { ExpressionMetadata } from '../../nodes.js';

/**
 * @param {CallExpression} node
 * @param {Context} context
 */
export function CallExpression(node, context) {
	const parent = /** @type {AST.SvelteNode} */ (get_parent(context.path, -1));

	const rune = get_rune(node, context.state.scope);

	if (rune && rune !== '$inspect') {
		for (const arg of node.arguments) {
			if (arg.type === 'SpreadElement') {
				e.rune_invalid_spread(node, rune);
			}
		}
	}

	switch (rune) {
		case null:
			if (!is_safe_identifier(node.callee, context.state.scope)) {
				context.state.analysis.needs_context = true;
			}

			break;

		case '$bindable':
			if (node.arguments.length > 1) {
				e.rune_invalid_arguments_length(node, '$bindable', 'zero or one arguments');
			}

			if (
				parent.type !== 'AssignmentPattern' ||
				context.path.at(-3)?.type !== 'ObjectPattern' ||
				context.path.at(-4)?.type !== 'VariableDeclarator' ||
				get_rune(
					/** @type {VariableDeclarator} */ (context.path.at(-4)).init,
					context.state.scope
				) !== '$props'
			) {
				e.bindable_invalid_location(node);
			}

			// We need context in case the bound prop is stale
			context.state.analysis.needs_context = true;

			break;

		case '$host':
			if (node.arguments.length > 0) {
// ... (280 more lines)

Domain

Subdomains

Frequently Asked Questions

What does CallExpression.js do?
CallExpression.js is a source file in the svelte codebase, written in javascript. It belongs to the Compiler domain, Transformer subdomain.
What functions are defined in CallExpression.js?
CallExpression.js defines 5 function(s): CallExpression, get_function_label, is_class_property_assignment_at_constructor_root, is_class_property_definition, is_variable_declaration.
What does CallExpression.js depend on?
CallExpression.js imports 14 module(s): ExpressionMetadata, ast.js, builders, e, errors.js, get_parent, get_rune, is_pure, and 6 more.
What files import CallExpression.js?
CallExpression.js is imported by 1 file(s): index.js.
Where is CallExpression.js in the architecture?
CallExpression.js is located at packages/svelte/src/compiler/phases/2-analyze/visitors/CallExpression.js (domain: Compiler, subdomain: Transformer, directory: packages/svelte/src/compiler/phases/2-analyze/visitors).

Analyze Your Own Codebase

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

Try Supermodel Free