77 LiquidTagDecrement ,
88 LiquidTagFor ,
99 LiquidTagIncrement ,
10+ LiquidTagSnippet ,
1011 LiquidTagTablerow ,
1112 LiquidVariableLookup ,
1213 NamedTags ,
@@ -16,7 +17,7 @@ import {
1617import { LiquidCheckDefinition , Severity , SourceCodeType , ThemeDocset } from '../../types' ;
1718import { isError , last } from '../../utils' ;
1819import { hasLiquidDoc } from '../../liquid-doc/liquidDoc' ;
19- import { isWithinRawTagThatDoesNotParseItsContents } from '../utils' ;
20+ import { isWithinRawTagThatDoesNotParseItsContents , findInlineSnippetAncestor } from '../utils' ;
2021
2122type Scope = { start ?: number ; end ?: number } ;
2223
@@ -66,9 +67,16 @@ export const UndefinedObject: LiquidCheckDefinition = {
6667 }
6768
6869 return {
69- async LiquidDocParamNode ( node : LiquidDocParamNode ) {
70+ async LiquidDocParamNode ( node : LiquidDocParamNode , ancestors : LiquidHtmlNode [ ] ) {
7071 const paramName = node . paramName ?. value ;
71- if ( paramName ) {
72+ if ( ! paramName ) return ;
73+ const snippetAncestor = findInlineSnippetAncestor ( ancestors ) ;
74+ if ( snippetAncestor ) {
75+ indexVariableScope ( paramName , {
76+ start : snippetAncestor . blockStartPosition . end ,
77+ end : snippetAncestor . blockEndPosition ?. start ,
78+ } ) ;
79+ } else {
7280 fileScopedVariables . add ( paramName ) ;
7381 }
7482 } ,
@@ -142,9 +150,9 @@ export const UndefinedObject: LiquidCheckDefinition = {
142150 const parent = last ( ancestors ) ;
143151 if ( isLiquidTag ( parent ) && isLiquidTagCapture ( parent ) ) return ;
144152
145- if ( parent ?. type === NodeTypes . RenderMarkup && parent . snippet === node ) return ;
153+ if ( isLiquidTag ( parent ) && isLiquidTagSnippet ( parent ) && parent . markup === node ) return ;
146154
147- if ( isLiquidTag ( parent ) && parent . name === 'snippet' && parent . markup === node ) return ;
155+ if ( parent ?. type === NodeTypes . RenderMarkup && parent . snippet === node ) return ;
148156
149157 variables . push ( node ) ;
150158 } ,
@@ -272,6 +280,10 @@ function isLiquidTagCapture(node: LiquidTag): node is LiquidTagCapture {
272280 return node . name === NamedTags . capture ;
273281}
274282
283+ function isLiquidTagSnippet ( node : LiquidTag ) : node is LiquidTagSnippet {
284+ return node . name === NamedTags . snippet ;
285+ }
286+
275287function isLiquidTagAssign ( node : LiquidTag ) : node is LiquidTagAssign {
276288 return node . name === NamedTags . assign && typeof node . markup !== 'string' ;
277289}
0 commit comments