@@ -14,27 +14,23 @@ import {
1414 typeParameterDescriptor ,
1515} from './Descriptor'
1616import { Input } from './Input'
17- import * as lsif from './lsif'
18- import { LsifSymbol } from './LsifSymbol'
19- import { lsiftyped } from './main'
2017import { Packages } from './Packages'
2118import { Range } from './Range'
19+ import * as scip from './scip'
20+ import { ScipSymbol } from './ScipSymbol'
2221import * as ts_inline from './TypeScriptInternal'
2322
24- type Descriptor = lsif . lib . codeintel . lsiftyped . Descriptor
25- type Relationship = lsif . lib . codeintel . lsiftyped . Relationship
26-
2723export class FileIndexer {
2824 private localCounter = new Counter ( )
2925 private propertyCounters : Map < string , Counter > = new Map ( )
30- private localSymbolTable : Map < ts . Node , LsifSymbol > = new Map ( )
26+ private localSymbolTable : Map < ts . Node , ScipSymbol > = new Map ( )
3127 private workingDirectoryRegExp : RegExp
3228 constructor (
3329 public readonly checker : ts . TypeChecker ,
3430 public readonly options : ProjectOptions ,
3531 public readonly input : Input ,
36- public readonly document : lsif . lib . codeintel . lsiftyped . Document ,
37- public readonly globalSymbolTable : Map < ts . Node , LsifSymbol > ,
32+ public readonly document : scip . scip . Document ,
33+ public readonly globalSymbolTable : Map < ts . Node , ScipSymbol > ,
3834 public readonly packages : Packages ,
3935 public readonly sourceFile : ts . SourceFile
4036 ) {
@@ -45,21 +41,21 @@ export class FileIndexer {
4541 this . visit ( this . sourceFile )
4642 }
4743 private emitSourceFileOccurrence ( ) : void {
48- const symbol = this . lsifSymbol ( this . sourceFile )
44+ const symbol = this . scipSymbol ( this . sourceFile )
4945 if ( symbol . isEmpty ( ) ) {
5046 return
5147 }
5248 this . document . occurrences . push (
53- new lsif . lib . codeintel . lsiftyped . Occurrence ( {
49+ new scip . scip . Occurrence ( {
5450 range : [ 0 , 0 , 0 ] ,
5551 symbol : symbol . value ,
56- symbol_roles : lsiftyped . SymbolRole . Definition ,
52+ symbol_roles : scip . scip . SymbolRole . Definition ,
5753 } )
5854 )
5955 const moduleName =
6056 this . sourceFile . moduleName || path . basename ( this . sourceFile . fileName )
6157 this . document . symbols . push (
62- new lsiftyped . SymbolInformation ( {
58+ new scip . scip . SymbolInformation ( {
6359 symbol : symbol . value ,
6460 documentation : [ '```ts\nmodule "' + moduleName + '"\n```' ] ,
6561 } )
@@ -106,24 +102,24 @@ export class FileIndexer {
106102 let role = 0
107103 const isDefinition = this . declarationName ( node . parent ) === node
108104 if ( isDefinition ) {
109- role |= lsiftyped . SymbolRole . Definition
105+ role |= scip . scip . SymbolRole . Definition
110106 }
111107 for ( const declaration of sym ?. declarations || [ ] ) {
112- const lsifSymbol = this . lsifSymbol ( declaration )
108+ const scipSymbol = this . scipSymbol ( declaration )
113109
114- if ( lsifSymbol . isEmpty ( ) ) {
110+ if ( scipSymbol . isEmpty ( ) ) {
115111 // Skip empty symbols
116112 continue
117113 }
118114 this . document . occurrences . push (
119- new lsif . lib . codeintel . lsiftyped . Occurrence ( {
115+ new scip . scip . Occurrence ( {
120116 range,
121- symbol : lsifSymbol . value ,
117+ symbol : scipSymbol . value ,
122118 symbol_roles : role ,
123119 } )
124120 )
125121 if ( isDefinition ) {
126- this . addSymbolInformation ( node , sym , declaration , lsifSymbol )
122+ this . addSymbolInformation ( node , sym , declaration , scipSymbol )
127123 this . handleShorthandPropertyDefinition ( declaration , range )
128124 this . handleObjectBindingPattern ( node , range )
129125 // Only emit one symbol for definitions sites, see https://github.com/sourcegraph/lsif-typescript/issues/45
@@ -153,14 +149,14 @@ export class FileIndexer {
153149 const tpe = this . checker . getTypeAtLocation ( node . parent . parent )
154150 const property = tpe . getProperty ( node . getText ( ) )
155151 for ( const declaration of property ?. declarations || [ ] ) {
156- const lsifSymbol = this . lsifSymbol ( declaration )
157- if ( lsifSymbol . isEmpty ( ) ) {
152+ const scipSymbol = this . scipSymbol ( declaration )
153+ if ( scipSymbol . isEmpty ( ) ) {
158154 continue
159155 }
160156 this . document . occurrences . push (
161- new lsif . lib . codeintel . lsiftyped . Occurrence ( {
157+ new scip . scip . Occurrence ( {
162158 range,
163- symbol : lsifSymbol . value ,
159+ symbol : scipSymbol . value ,
164160 } )
165161 )
166162 }
@@ -190,14 +186,14 @@ export class FileIndexer {
190186 return
191187 }
192188 for ( const symbol of valueSymbol ?. declarations || [ ] ) {
193- const lsifSymbol = this . lsifSymbol ( symbol )
194- if ( lsifSymbol . isEmpty ( ) ) {
189+ const scipSymbol = this . scipSymbol ( symbol )
190+ if ( scipSymbol . isEmpty ( ) ) {
195191 continue
196192 }
197193 this . document . occurrences . push (
198- new lsif . lib . codeintel . lsiftyped . Occurrence ( {
194+ new scip . scip . Occurrence ( {
199195 range,
200- symbol : lsifSymbol . value ,
196+ symbol : scipSymbol . value ,
201197 } )
202198 )
203199 }
@@ -210,7 +206,7 @@ export class FileIndexer {
210206 node : ts . Node ,
211207 sym : ts . Symbol ,
212208 declaration : ts . Node ,
213- symbol : LsifSymbol
209+ symbol : ScipSymbol
214210 ) : void {
215211 const documentation = [
216212 '```ts\n' +
@@ -223,7 +219,7 @@ export class FileIndexer {
223219 }
224220
225221 this . document . symbols . push (
226- new lsiftyped . SymbolInformation ( {
222+ new scip . scip . SymbolInformation ( {
227223 symbol : symbol . value ,
228224 documentation,
229225 relationships : this . relationships ( declaration , symbol ) ,
@@ -233,15 +229,15 @@ export class FileIndexer {
233229
234230 private relationships (
235231 declaration : ts . Node ,
236- declarationSymbol : LsifSymbol
237- ) : Relationship [ ] {
238- const relationships : Relationship [ ] = [ ]
232+ declarationSymbol : ScipSymbol
233+ ) : scip . scip . Relationship [ ] {
234+ const relationships : scip . scip . Relationship [ ] = [ ]
239235 const isAddedSymbol = new Set < string > ( )
240236 const pushImplementation = (
241237 node : ts . NamedDeclaration ,
242238 isReferences : boolean
243239 ) : void => {
244- const symbol = this . lsifSymbol ( node )
240+ const symbol = this . scipSymbol ( node )
245241 if ( symbol . isEmpty ( ) ) {
246242 return
247243 }
@@ -255,7 +251,7 @@ export class FileIndexer {
255251 }
256252 isAddedSymbol . add ( symbol . value )
257253 relationships . push (
258- new lsiftyped . Relationship ( {
254+ new scip . scip . Relationship ( {
259255 symbol : symbol . value ,
260256 is_implementation : true ,
261257 is_reference : isReferences ,
@@ -309,19 +305,19 @@ export class FileIndexer {
309305 return undefined
310306 }
311307
312- private lsifSymbol ( node : ts . Node ) : LsifSymbol {
313- const fromCache : LsifSymbol | undefined =
308+ private scipSymbol ( node : ts . Node ) : ScipSymbol {
309+ const fromCache : ScipSymbol | undefined =
314310 this . globalSymbolTable . get ( node ) || this . localSymbolTable . get ( node )
315311 if ( fromCache ) {
316312 return fromCache
317313 }
318314 if ( ts . isBlock ( node ) ) {
319- return LsifSymbol . empty ( )
315+ return ScipSymbol . empty ( )
320316 }
321317 if ( ts . isSourceFile ( node ) ) {
322318 const package_ = this . packages . symbol ( node . fileName )
323319 if ( ! package_ ) {
324- return this . cached ( node , LsifSymbol . empty ( ) )
320+ return this . cached ( node , ScipSymbol . empty ( ) )
325321 }
326322 return this . cached ( node , package_ )
327323 }
@@ -337,8 +333,8 @@ export class FileIndexer {
337333 }
338334 return this . cached (
339335 node ,
340- LsifSymbol . global (
341- this . lsifSymbol ( node . getSourceFile ( ) ) ,
336+ ScipSymbol . global (
337+ this . scipSymbol ( node . getSourceFile ( ) ) ,
342338 metaDescriptor ( `${ node . name . getText ( ) } ${ counter . next ( ) } ` )
343339 )
344340 )
@@ -362,7 +358,7 @@ export class FileIndexer {
362358 const tpe = this . checker . getTypeOfSymbolAtLocation ( props , node )
363359 const property = tpe . getProperty ( node . name . text )
364360 for ( const decl of property ?. declarations || [ ] ) {
365- return this . lsifSymbol ( decl )
361+ return this . scipSymbol ( decl )
366362 }
367363 } catch {
368364 // TODO: https://github.com/sourcegraph/lsif-typescript/issues/34
@@ -373,25 +369,25 @@ export class FileIndexer {
373369 }
374370 }
375371
376- const owner = this . lsifSymbol ( node . parent )
372+ const owner = this . scipSymbol ( node . parent )
377373 if ( owner . isEmpty ( ) || owner . isLocal ( ) ) {
378374 return this . newLocalSymbol ( node )
379375 }
380376
381377 if ( isAnonymousContainerOfSymbols ( node ) ) {
382- return this . cached ( node , this . lsifSymbol ( node . parent ) )
378+ return this . cached ( node , this . scipSymbol ( node . parent ) )
383379 }
384380
385381 if ( ts . isImportSpecifier ( node ) || ts . isImportClause ( node ) ) {
386382 const tpe = this . checker . getTypeAtLocation ( node )
387383 for ( const declaration of tpe . symbol ?. declarations || [ ] ) {
388- return this . lsifSymbol ( declaration )
384+ return this . scipSymbol ( declaration )
389385 }
390386 }
391387
392388 const desc = this . descriptor ( node )
393389 if ( desc ) {
394- return this . cached ( node , LsifSymbol . global ( owner , desc ) )
390+ return this . cached ( node , ScipSymbol . global ( owner , desc ) )
395391 }
396392
397393 // Fallback case: generate a local symbol. It's not a bug when this case
@@ -401,16 +397,16 @@ export class FileIndexer {
401397 return this . newLocalSymbol ( node )
402398 }
403399
404- private newLocalSymbol ( node : ts . Node ) : LsifSymbol {
405- const symbol = LsifSymbol . local ( this . localCounter . next ( ) )
400+ private newLocalSymbol ( node : ts . Node ) : ScipSymbol {
401+ const symbol = ScipSymbol . local ( this . localCounter . next ( ) )
406402 this . localSymbolTable . set ( node , symbol )
407403 return symbol
408404 }
409- private cached ( node : ts . Node , symbol : LsifSymbol ) : LsifSymbol {
405+ private cached ( node : ts . Node , symbol : ScipSymbol ) : ScipSymbol {
410406 this . globalSymbolTable . set ( node , symbol )
411407 return symbol
412408 }
413- private descriptor ( node : ts . Node ) : Descriptor | undefined {
409+ private descriptor ( node : ts . Node ) : scip . scip . Descriptor | undefined {
414410 if (
415411 ts . isInterfaceDeclaration ( node ) ||
416412 ts . isEnumDeclaration ( node ) ||
0 commit comments