Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions deps/acorn/acorn-walk/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
## 8.3.5 (2026-02-19)

### Bug fixes

Emit a more informative error message when trying to walk a node type that has no walker function.

Specify callbacks in types to receive `AnyNode` type, so that they can be narrowed more easily.

Support import attributes.

## 8.3.4 (2024-09-09)

### Bug fixes
Expand Down
12 changes: 6 additions & 6 deletions deps/acorn/acorn-walk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ produce a meaningful state. (An example of a use of state is to track
scope at each point in the tree.)

```js
const acorn = require("acorn")
const walk = require("acorn-walk")
import * as acorn from "acorn"
import * as walk from "acorn-walk"

walk.simple(acorn.parse("let x = 10"), {
Literal(node) {
Expand All @@ -62,8 +62,8 @@ a tree, building up an array of ancestor nodes (including the current node)
and passing the array to the callbacks as a third parameter.

```js
const acorn = require("acorn")
const walk = require("acorn-walk")
import * as acorn from "acorn"
import * as walk from "acorn-walk"

walk.ancestor(acorn.parse("foo('hi')"), {
Literal(_node, _state, ancestors) {
Expand Down Expand Up @@ -97,8 +97,8 @@ current node) and passing the array to the callbacks as a third
parameter.

```js
const acorn = require("acorn")
const walk = require("acorn-walk")
import * as acorn from "acorn"
import * as walk from "acorn-walk"

walk.full(acorn.parse("1 + 1"), node => {
console.log(`There's a ${node.type} node at ${node.ch}`)
Expand Down
47 changes: 11 additions & 36 deletions deps/acorn/acorn-walk/dist/walk.d.mts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import * as acorn from "acorn"

export type FullWalkerCallback<TState> = (
node: acorn.Node,
node: acorn.AnyNode,
state: TState,
type: string
) => void

export type FullAncestorWalkerCallback<TState> = (
node: acorn.Node,
node: acorn.AnyNode,
state: TState,
ancestors: acorn.Node[],
ancestors: acorn.AnyNode[],
type: string
) => void

Expand All @@ -29,24 +29,24 @@ export type SimpleVisitors<TState> = {
}

export type AncestorVisitors<TState> = {
[type in acorn.AnyNode["type"]]?: ( node: Extract<acorn.AnyNode, { type: type }>, state: TState, ancestors: acorn.Node[]
[type in acorn.AnyNode["type"]]?: ( node: Extract<acorn.AnyNode, { type: type }>, state: TState, ancestors: acorn.AnyNode[]
) => void
} & {
[type in keyof AggregateType]?: (node: AggregateType[type], state: TState, ancestors: acorn.Node[]) => void
[type in keyof AggregateType]?: (node: AggregateType[type], state: TState, ancestors: acorn.AnyNode[]) => void
}

export type WalkerCallback<TState> = (node: acorn.Node, state: TState) => void
export type WalkerCallback<TState> = (node: acorn.AnyNode, state: TState) => void

export type RecursiveVisitors<TState> = {
[type in acorn.AnyNode["type"]]?: ( node: Extract<acorn.AnyNode, { type: type }>, state: TState, callback: WalkerCallback<TState>) => void
} & {
[type in keyof AggregateType]?: (node: AggregateType[type], state: TState, callback: WalkerCallback<TState>) => void
}

export type FindPredicate = (type: string, node: acorn.Node) => boolean
export type FindPredicate = (type: string, node: acorn.AnyNode) => boolean

export interface Found<TState> {
node: acorn.Node,
node: acorn.AnyNode,
state: TState
}

Expand All @@ -66,10 +66,6 @@ export function simple<TState>(

/**
* does a 'simple' walk over a tree, building up an array of ancestor nodes (including the current node) and passing the array to the callbacks as a third parameter.
* @param node
* @param visitors
* @param base
* @param state
*/
export function ancestor<TState>(
node: acorn.Node,
Expand All @@ -94,10 +90,6 @@ export function recursive<TState>(

/**
* does a 'full' walk over a tree, calling the {@link callback} with the arguments (node, state, type) for each node
* @param node
* @param callback
* @param base
* @param state
*/
export function full<TState>(
node: acorn.Node,
Expand All @@ -108,10 +100,6 @@ export function full<TState>(

/**
* does a 'full' walk over a tree, building up an array of ancestor nodes (including the current node) and passing the array to the callbacks as a third parameter.
* @param node
* @param callback
* @param base
* @param state
*/
export function fullAncestor<TState>(
node: acorn.Node,
Expand All @@ -122,8 +110,6 @@ export function fullAncestor<TState>(

/**
* builds a new walker object by using the walker functions in {@link functions} and filling in the missing ones by taking defaults from {@link base}.
* @param functions
* @param base
*/
export function make<TState>(
functions: RecursiveVisitors<TState>,
Expand All @@ -132,33 +118,22 @@ export function make<TState>(

/**
* tries to locate a node in a tree at the given start and/or end offsets, which satisfies the predicate test. {@link start} and {@link end} can be either `null` (as wildcard) or a `number`. {@link test} may be a string (indicating a node type) or a function that takes (nodeType, node) arguments and returns a boolean indicating whether this node is interesting. {@link base} and {@link state} are optional, and can be used to specify a custom walker. Nodes are tested from inner to outer, so if two nodes match the boundaries, the inner one will be preferred.
* @param node
* @param start
* @param end
* @param type
* @param base
* @param state
*/
export function findNodeAt<TState>(
node: acorn.Node,
start: number | undefined,
end?: number | undefined,
start: number | undefined | null,
end?: number | undefined | null,
type?: FindPredicate | string,
base?: RecursiveVisitors<TState>,
state?: TState
): Found<TState> | undefined

/**
* like {@link findNodeAt}, but will match any node that exists 'around' (spanning) the given position.
* @param node
* @param start
* @param type
* @param base
* @param state
*/
export function findNodeAround<TState>(
node: acorn.Node,
start: number | undefined,
start: number | undefined | null,
type?: FindPredicate | string,
base?: RecursiveVisitors<TState>,
state?: TState
Expand Down
47 changes: 11 additions & 36 deletions deps/acorn/acorn-walk/dist/walk.d.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import * as acorn from "acorn"

export type FullWalkerCallback<TState> = (
node: acorn.Node,
node: acorn.AnyNode,
state: TState,
type: string
) => void

export type FullAncestorWalkerCallback<TState> = (
node: acorn.Node,
node: acorn.AnyNode,
state: TState,
ancestors: acorn.Node[],
ancestors: acorn.AnyNode[],
type: string
) => void

Expand All @@ -29,24 +29,24 @@ export type SimpleVisitors<TState> = {
}

export type AncestorVisitors<TState> = {
[type in acorn.AnyNode["type"]]?: ( node: Extract<acorn.AnyNode, { type: type }>, state: TState, ancestors: acorn.Node[]
[type in acorn.AnyNode["type"]]?: ( node: Extract<acorn.AnyNode, { type: type }>, state: TState, ancestors: acorn.AnyNode[]
) => void
} & {
[type in keyof AggregateType]?: (node: AggregateType[type], state: TState, ancestors: acorn.Node[]) => void
[type in keyof AggregateType]?: (node: AggregateType[type], state: TState, ancestors: acorn.AnyNode[]) => void
}

export type WalkerCallback<TState> = (node: acorn.Node, state: TState) => void
export type WalkerCallback<TState> = (node: acorn.AnyNode, state: TState) => void

export type RecursiveVisitors<TState> = {
[type in acorn.AnyNode["type"]]?: ( node: Extract<acorn.AnyNode, { type: type }>, state: TState, callback: WalkerCallback<TState>) => void
} & {
[type in keyof AggregateType]?: (node: AggregateType[type], state: TState, callback: WalkerCallback<TState>) => void
}

export type FindPredicate = (type: string, node: acorn.Node) => boolean
export type FindPredicate = (type: string, node: acorn.AnyNode) => boolean

export interface Found<TState> {
node: acorn.Node,
node: acorn.AnyNode,
state: TState
}

Expand All @@ -66,10 +66,6 @@ export function simple<TState>(

/**
* does a 'simple' walk over a tree, building up an array of ancestor nodes (including the current node) and passing the array to the callbacks as a third parameter.
* @param node
* @param visitors
* @param base
* @param state
*/
export function ancestor<TState>(
node: acorn.Node,
Expand All @@ -94,10 +90,6 @@ export function recursive<TState>(

/**
* does a 'full' walk over a tree, calling the {@link callback} with the arguments (node, state, type) for each node
* @param node
* @param callback
* @param base
* @param state
*/
export function full<TState>(
node: acorn.Node,
Expand All @@ -108,10 +100,6 @@ export function full<TState>(

/**
* does a 'full' walk over a tree, building up an array of ancestor nodes (including the current node) and passing the array to the callbacks as a third parameter.
* @param node
* @param callback
* @param base
* @param state
*/
export function fullAncestor<TState>(
node: acorn.Node,
Expand All @@ -122,8 +110,6 @@ export function fullAncestor<TState>(

/**
* builds a new walker object by using the walker functions in {@link functions} and filling in the missing ones by taking defaults from {@link base}.
* @param functions
* @param base
*/
export function make<TState>(
functions: RecursiveVisitors<TState>,
Expand All @@ -132,33 +118,22 @@ export function make<TState>(

/**
* tries to locate a node in a tree at the given start and/or end offsets, which satisfies the predicate test. {@link start} and {@link end} can be either `null` (as wildcard) or a `number`. {@link test} may be a string (indicating a node type) or a function that takes (nodeType, node) arguments and returns a boolean indicating whether this node is interesting. {@link base} and {@link state} are optional, and can be used to specify a custom walker. Nodes are tested from inner to outer, so if two nodes match the boundaries, the inner one will be preferred.
* @param node
* @param start
* @param end
* @param type
* @param base
* @param state
*/
export function findNodeAt<TState>(
node: acorn.Node,
start: number | undefined,
end?: number | undefined,
start: number | undefined | null,
end?: number | undefined | null,
type?: FindPredicate | string,
base?: RecursiveVisitors<TState>,
state?: TState
): Found<TState> | undefined

/**
* like {@link findNodeAt}, but will match any node that exists 'around' (spanning) the given position.
* @param node
* @param start
* @param type
* @param base
* @param state
*/
export function findNodeAround<TState>(
node: acorn.Node,
start: number | undefined,
start: number | undefined | null,
type?: FindPredicate | string,
base?: RecursiveVisitors<TState>,
state?: TState
Expand Down
Loading
Loading