@@ -21,7 +21,7 @@ export function createVueLanguageServiceProxy<T>(
2121case 'getCodeFixesAtPosition' :
2222return getCodeFixesAtPosition ( target [ p ] ) ;
2323case 'getDefinitionAndBoundSpan' :
24- return getDefinitionAndBoundSpan ( ts , language , asScriptId , languageService , vueOptions , target [ p ] ) ;
24+ return getDefinitionAndBoundSpan ( language , asScriptId , target [ p ] ) ;
2525}
2626} ;
2727
@@ -190,11 +190,8 @@ function getCodeFixesAtPosition(
190190}
191191
192192function getDefinitionAndBoundSpan < T > (
193- ts : typeof import ( 'typescript' ) ,
194193language : Language < T > ,
195194asScriptId : ( fileName : string ) => T ,
196- languageService : ts . LanguageService ,
197- vueOptions : VueCompilerOptions ,
198195getDefinitionAndBoundSpan : ts . LanguageService [ 'getDefinitionAndBoundSpan' ] ,
199196) : ts . LanguageService [ 'getDefinitionAndBoundSpan' ] {
200197return ( fileName , position ) => {
@@ -203,7 +200,6 @@ function getDefinitionAndBoundSpan<T>(
203200return result ;
204201}
205202
206- const program = languageService . getProgram ( ) ! ;
207203const sourceScript = language . scripts . get ( asScriptId ( fileName ) ) ;
208204if ( ! sourceScript ?. generated ) {
209205return result ;
@@ -237,19 +233,6 @@ function getDefinitionAndBoundSpan<T>(
237233}
238234}
239235
240- for ( const definition of result . definitions ) {
241- if ( vueOptions . extensions . some ( ext => definition . fileName . endsWith ( ext ) ) ) {
242- continue ;
243- }
244-
245- const sourceFile = program . getSourceFile ( definition . fileName ) ;
246- if ( ! sourceFile ) {
247- continue ;
248- }
249-
250- visit ( sourceFile , definition , sourceFile ) ;
251- }
252-
253236for ( const definition of skippedDefinitions ) {
254237definitions . delete ( definition ) ;
255238}
@@ -258,49 +241,5 @@ function getDefinitionAndBoundSpan<T>(
258241definitions : [ ...definitions ] ,
259242textSpan : result . textSpan ,
260243} ;
261-
262- function visit (
263- node : ts . Node ,
264- definition : ts . DefinitionInfo ,
265- sourceFile : ts . SourceFile ,
266- ) {
267- if ( ts . isPropertySignature ( node ) && node . type ) {
268- proxy ( node . name , node . type , definition , sourceFile ) ;
269- }
270- else if ( ts . isVariableDeclaration ( node ) && ts . isIdentifier ( node . name ) && node . type && ! node . initializer ) {
271- proxy ( node . name , node . type , definition , sourceFile ) ;
272- }
273- else {
274- ts . forEachChild ( node , child => visit ( child , definition , sourceFile ) ) ;
275- }
276- }
277-
278- function proxy (
279- name : ts . PropertyName ,
280- type : ts . TypeNode ,
281- definition : ts . DefinitionInfo ,
282- sourceFile : ts . SourceFile ,
283- ) {
284- const { textSpan, fileName } = definition ;
285- const start = name . getStart ( sourceFile ) ;
286- const end = name . getEnd ( ) ;
287-
288- if ( start !== textSpan . start || end - start !== textSpan . length ) {
289- return ;
290- }
291-
292- if ( ! ts . isIndexedAccessTypeNode ( type ) ) {
293- return ;
294- }
295-
296- const pos = type . indexType . getStart ( sourceFile ) ;
297- const res = getDefinitionAndBoundSpan ( fileName , pos ) ;
298- if ( res ?. definitions ?. length ) {
299- for ( const definition of res . definitions ) {
300- definitions . add ( definition ) ;
301- }
302- skippedDefinitions . push ( definition ) ;
303- }
304- }
305244} ;
306245}
0 commit comments