@@ -4,17 +4,16 @@ import {
4
4
findRoot as findConfigFileRoot ,
5
5
isError ,
6
6
LiquidDocDefinition ,
7
- LiquidDocParameter ,
8
7
makeFileExists ,
9
8
makeGetDefaultSchemaTranslations ,
10
9
makeGetDefaultTranslations ,
11
10
makeGetMetafieldDefinitions ,
11
+ makeGetLiquidDocDefinitions ,
12
12
memoize ,
13
13
parseJSON ,
14
14
path ,
15
15
recursiveReadDirectory ,
16
16
SourceCodeType ,
17
- visit ,
18
17
} from '@shopify/theme-check-common' ;
19
18
import {
20
19
Connection ,
@@ -174,7 +173,6 @@ export function startServer(
174
173
return getDefaultSchemaTranslations ( ) ;
175
174
} ;
176
175
177
- // todo - put this stuff in theme check common
178
176
const getLiquidDocDefinitionsForURI = async (
179
177
uri : string ,
180
178
snippetName : string ,
@@ -183,34 +181,13 @@ export function startServer(
183
181
const snippetURI = path . join ( rootUri , 'snippets' , `${ snippetName } .liquid` ) ;
184
182
const snippet = documentManager . get ( snippetURI ) ;
185
183
186
- if ( ! snippet || isError ( snippet ) ) return { name : snippetName } ;
187
-
188
- if ( snippet . type !== SourceCodeType . LiquidHtml ) return { name : snippetName } ;
189
-
190
- const ast = snippet . ast ;
191
- if ( isError ( ast ) ) return { name : snippetName } ;
192
-
193
- const liquidDocAnnotations = visit < SourceCodeType . LiquidHtml , LiquidDocParameter > ( ast , {
194
- LiquidDocParamNode : ( node ) => {
195
- return {
196
- name : node . paramName . value ,
197
- description : node . paramDescription ?. value ,
198
- type : node . type ,
199
- } ;
200
- } ,
201
- } ) ;
184
+ if ( ! snippet || snippet . type !== SourceCodeType . LiquidHtml || isError ( snippet . ast ) ) {
185
+ return { name : snippetName } ;
186
+ }
202
187
203
- const parameters : LiquidDocParameter [ ] = [ ] ;
204
- liquidDocAnnotations . forEach ( ( annotation ) => {
205
- if ( annotation . type === 'LiquidDocParamNode' ) {
206
- parameters . push ( annotation ) ;
207
- }
208
- } ) ;
188
+ const getLiquidDocDefinitions = makeGetLiquidDocDefinitions ( snippet . ast , snippetName ) ;
209
189
210
- return {
211
- name : snippetName ,
212
- parameters : parameters ,
213
- } ;
190
+ return getLiquidDocDefinitions ( ) ;
214
191
} ;
215
192
216
193
const snippetFilter = ( [ uri ] : FileTuple ) => / \. l i q u i d $ / . test ( uri ) && / s n i p p e t s / . test ( uri ) ;
0 commit comments