@@ -95,10 +95,6 @@ export class Targets {
9595 return ignoredObjects ;
9696 }
9797
98- getSearchGlob ( ) : string {
99- return Targets . LanguageProvider . getGlob ( ) ;
100- }
101-
10298 public getCwd ( ) {
10399 return this . cwd ;
104100 }
@@ -139,12 +135,12 @@ export class Targets {
139135 this . resolvedObjects [ localPath ] = ileObject ;
140136 }
141137
142- public async loadProject ( withRef ?: string ) {
143- if ( withRef ) {
144- await this . handleRefsFile ( path . join ( this . cwd , withRef ) ) ;
138+ public async loadProject ( options : { withRef ?: string , additionalExtensions ?: string [ ] } = { } ) {
139+ if ( options . withRef ) {
140+ await this . handleRefsFile ( path . join ( this . cwd , options . withRef ) ) ;
145141 }
146142
147- const initialFiles = await this . fs . getFiles ( this . cwd , this . getSearchGlob ( ) ) ;
143+ const initialFiles = await this . fs . getFiles ( this . cwd , Targets . LanguageProvider . getGlob ( options . additionalExtensions ) ) ;
148144 await this . loadObjectsFromPaths ( initialFiles ) ;
149145 await Promise . allSettled ( initialFiles . map ( f => this . parseFile ( f ) ) ) ;
150146 }
@@ -153,7 +149,7 @@ export class Targets {
153149 return [ `MODULE` , `PGM` ] . includes ( Targets . LanguageProvider . getObjectType ( ext ) ) ;
154150 }
155151
156- public async resolvePathToObject ( localPath : string , newText ?: string ) {
152+ public async resolvePathToObject ( localPath : string , newText ?: string ) : Promise < ILEObject | undefined > {
157153 if ( this . resolvedObjects [ localPath ] ) {
158154 if ( newText ) this . resolvedObjects [ localPath ] . text = newText ;
159155 return this . resolvedObjects [ localPath ] ;
@@ -168,6 +164,15 @@ export class Targets {
168164 const name = getSystemNameFromPath ( hasProgramAttribute ? detail . name . substring ( 0 , detail . name . length - 4 ) : detail . name ) ;
169165 const type : ObjectType = ( isProgram ? "PGM" : this . getObjectType ( relativePath , extension ) ) ;
170166
167+ if ( ! type ) {
168+ this . logger . fileLog ( relativePath , {
169+ type : `warning` ,
170+ message : `Unknown object type for ${ relativePath } with extension ${ extension } .`
171+ } ) ;
172+
173+ return ;
174+ }
175+
171176 const theObject : ILEObject = {
172177 systemName : name ,
173178 type : type ,
@@ -371,19 +376,8 @@ export class Targets {
371376 }
372377
373378 // TODO: move this to language provider
374- getObjectType ( relativePath : string , ext : string ) : ObjectType {
375- const objType = Targets . LanguageProvider . getObjectType ( ext ) ;
376-
377- if ( ! objType ) {
378- this . logger . fileLog ( relativePath , {
379- type : `warning` ,
380- message : `'${ ext } ' not found a matching object type. Defaulting to '${ ext } '`
381- } ) ;
382-
383- return ( ext . toUpperCase ( ) as ObjectType ) ;
384- }
385-
386- return objType ;
379+ getObjectType ( relativePath : string , ext : string ) : ObjectType | undefined {
380+ return Targets . LanguageProvider . getObjectType ( ext ) ;
387381 }
388382
389383 public loadObjectsFromPaths ( paths : string [ ] ) {
@@ -408,9 +402,6 @@ export class Targets {
408402 try {
409403 const content = await this . fs . readFile ( filePath ) ;
410404
411- // Really only applied to rpg
412- const isFree = ( content . length >= 6 ? content . substring ( 0 , 6 ) . toLowerCase ( ) === `**free` : false ) ;
413-
414405 let textMatch ;
415406 try {
416407 [ textMatch ] = content . match ( TextRegex ) ;
@@ -422,11 +413,14 @@ export class Targets {
422413 } catch ( e ) { }
423414
424415 const options : FileOptions = {
425- isFree,
426416 text : textMatch
427417 } ;
428418
429- await Targets . LanguageProvider . handleLanguage ( this , filePath , content , options ) ;
419+ const ileObject = await this . resolvePathToObject ( filePath , options . text ) ;
420+ if ( ileObject ) {
421+ await Targets . LanguageProvider . handleLanguage ( this , filePath , content , ileObject ) ;
422+ }
423+
430424 } catch ( e ) {
431425 this . logger . fileLog ( relative , {
432426 message : `Failed to parse file.` ,
0 commit comments