MCPcopy
hub / github.com/sveltejs/svelte / reference

Method reference

packages/svelte/src/compiler/phases/scope.js:776–794  ·  view source on GitHub ↗

* @param {Identifier} node * @param {AST.SvelteNode[]} path

(node, path)

Source from the content-addressed store, hash-verified

774 * @param {AST.SvelteNode[]} path
775 */
776 reference(node, path) {
777 path = [...path]; // ensure that mutations to path afterwards don't affect this reference
778 let references = this.references.get(node.name);
779
780 if (!references) this.references.set(node.name, (references = []));
781
782 references.push({ node, path });
783
784 const binding = this.declarations.get(node.name);
785 if (binding) {
786 binding.references.push({ node, path });
787 } else if (this.parent) {
788 this.parent.reference(node, path);
789 } else {
790 // no binding was found, and this is the top level scope,
791 // which means this is a global
792 this.root.conflicts.add(node.name);
793 }
794 }
795
796 /**
797 * Does partial evaluation to find an exact value or at least the rough type of the expression.

Callers 4

create_scopesFunction · 0.95
SvelteDirectiveFunction · 0.80
LetDirectiveFunction · 0.80
StyleDirectiveFunction · 0.80

Calls 4

pushMethod · 0.80
setMethod · 0.65
getMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected