import { LineResults } from "../LineResults" ; import { CommandNames } from "../Names/CommandNames" ; import { KeywordNames } from "../Names/KeywordNames" ; import { Command } from "./Command" ; import { CommandResult } from "./CommandResult" ; import { CommandMetadata } from "./Metadata/CommandMetadata" ; import { KeywordParameter } from "./Metadata/Parameters/KeywordParameter" ; import { RepeatingParameters } from "./Metadata/Parameters/RepeatingParameters" ; import { SingleParameter } from "./Metadata/Parameters/SingleParameter" ; import { addLineEnder } from "./Utilities" ; /**
 * Starts an interface declaration.
 */ export class InterfaceStartCommand extends Command { /**
     * Metadata on the command.
     */ private static metadata : CommandMetadata = new CommandMetadata ( CommandNames . InterfaceStart ) . withDescription ( "Starts an interface declaration" ) . withIndentation ( [ 1 ] ) . withParameters ( [ new KeywordParameter ( [ KeywordNames . Export ] , "Keyword to export this interface publicly." , false ) , new SingleParameter ( "InterfaceName" , "The interface name." , true ) , new RepeatingParameters ( "Parent interfaces" , [ new SingleParameter ( "parentInterfaceName" , "Names of parent interfaces." , true ) ] ) , ] ) ; returns public getMetadata ( ) { return InterfaceStartCommand . metadata ; } param parameters returns public render ( parameters ) { if ( ! this . language . syntax . interfaces . supported ) { return LineResults . newSingleLine ( "" ) ; } const remainingParameters = parameters . slice ( 1 ) ; let line = "" ; line += this . getForExport ( remainingParameters ) ; line += this . language . syntax . interfaces . declareStartLeft ; line += remainingParameters [ 0 ] ; if ( remainingParameters . length > 1 ) { line += this . language . syntax . interfaces . declareExtendsLeft ; for ( let i = 1 ; i < remainingParameters . length ; i += 1 ) { line += remainingParameters [ i ] ; if ( i !== remainingParameters . length - 1 ) { line += this . language . syntax . interfaces . declareExtendsRight ; } } } const output = [ new CommandResult ( line , 0 ) ] ; addLineEnder ( output , this . language . syntax . interfaces . declareStartRight , 1 ) ; return new LineResults ( output ) ; } param remainingParameters returns private getForExport ( remainingParameters ) { if ( remainingParameters [ 0 ] !== KeywordNames . Export ) { return this . language . syntax . exports . internal ; } remainingParameters . shift ( ) ; let exported = this . language . syntax . exports . exportedLeft ; if ( this . language . syntax . exports . exportedIncludesName ) { exported += remainingParameters [ 0 ] ; exported += this . language . syntax . exports . exportedMiddle ; } return exported ; } }