@@ -88,17 +88,18 @@ export class ProjectIndexer {
88
88
const startTimestamp = Date . now ( )
89
89
const sourceFiles = this . program . getSourceFiles ( )
90
90
91
- const filesToIndex : ts . SourceFile [ ] = [ ]
91
+ const filesToIndexMap : Map < string , ts . SourceFile > = new Map ( )
92
92
// Visit every sourceFile in the program
93
93
for ( const sourceFile of sourceFiles ) {
94
94
const includes = this . config . fileNames . includes ( sourceFile . fileName )
95
95
if ( ! includes ) {
96
96
continue
97
97
}
98
- filesToIndex . push ( sourceFile )
98
+ const projectRelativePath = path . normalize ( path . relative ( this . options . cwd , sourceFile . fileName ) )
99
+ filesToIndexMap . set ( projectRelativePath , sourceFile )
99
100
}
100
101
101
- if ( filesToIndex . length === 0 ) {
102
+ if ( filesToIndexMap . size === 0 ) {
102
103
throw new Error (
103
104
`no indexable files in project '${ this . options . projectDisplayName } '`
104
105
)
@@ -108,7 +109,7 @@ export class ProjectIndexer {
108
109
? new ProgressBar (
109
110
` ${ this . options . projectDisplayName } [:bar] :current/:total :title` ,
110
111
{
111
- total : filesToIndex . length ,
112
+ total : filesToIndexMap . size ,
112
113
renderThrottle : 100 ,
113
114
incomplete : '_' ,
114
115
complete : '#' ,
@@ -119,9 +120,10 @@ export class ProjectIndexer {
119
120
)
120
121
: undefined
121
122
let lastWrite = startTimestamp
122
- for ( const [ index , sourceFile ] of filesToIndex . entries ( ) ) {
123
- const title = path . relative ( this . options . cwd , sourceFile . fileName )
124
- jobs ?. tick ( { title } )
123
+ let index = - 1
124
+ for ( const [ projectRelativePath , sourceFile ] of filesToIndexMap . entries ( ) ) {
125
+ index += 1
126
+ jobs ?. tick ( { title : projectRelativePath } )
125
127
if ( ! this . options . progressBar ) {
126
128
const now = Date . now ( )
127
129
const elapsed = now - lastWrite
@@ -131,7 +133,7 @@ export class ProjectIndexer {
131
133
}
132
134
}
133
135
const document = new scip . scip . Document ( {
134
- relative_path : path . relative ( this . options . cwd , sourceFile . fileName ) ,
136
+ relative_path : projectRelativePath ,
135
137
occurrences : [ ] ,
136
138
} )
137
139
const input = new Input ( sourceFile . fileName , sourceFile . getText ( ) )
0 commit comments