import { ImportsPrinter } from "./Imports/ImportsPrinter" ; import { ImportsStore } from "./Imports/ImportsStore" ; import { FileSyntax } from "./Languages/Properties/Syntax/FileSyntax" ; import { LineResults } from "./LineResults" ; /**
 * Generates line results from raw Budgie.
 */ export class LineResultsGenerator { /**
     * Metadata on a language's file content syntax.
     */ private fileSyntax : FileSyntax ; /**
     * Renders imports to output line results.
     */ private importsPrinter : ImportsPrinter ; param fileSyntax param importsPrinter public constructor ( fileSyntax , importsPrinter ) { this . fileSyntax = fileSyntax ; this . importsPrinter = importsPrinter ; } param allLineResults param importsStore param asFullFile return remarks public generateLineResults ( allLineResults , importsStore , asFullFile ) { if ( importsStore . hasAnyImports ( ) ) { let importInsertionIndex ; if ( asFullFile && this . fileSyntax . importsAfterStartLines ) { importInsertionIndex = 1 ; } else { importInsertionIndex = 0 ; } const allImportStores = importsStore . getAllImportStores ( ) ; for ( let i = allImportStores . length - 1 ; i >= 0 ; i -= 1 ) { allLineResults . splice ( importInsertionIndex , 0 , this . importsPrinter . render ( allImportStores [ i ] ) ) ; } const blankLineInsertionIndex = importInsertionIndex + allImportStores . length ; if ( allLineResults . length > blankLineInsertionIndex && allLineResults [ blankLineInsertionIndex ] . commandResults . length !== 0 && allLineResults [ blankLineInsertionIndex ] . commandResults [ 0 ] . text !== "" ) { allLineResults . splice ( blankLineInsertionIndex , 0 , LineResults . newSingleLine ( "" ) ) ; } } return allLineResults ; } }