import { LineResults } from "../LineResults" ; import { CommandNames } from "../Names/CommandNames" ; import { Command } from "./Command" ; import { CommandMetadata } from "./Metadata/CommandMetadata" ; import { SingleParameter } from "./Metadata/Parameters/SingleParameter" ; /**
 * Declares a variable.
 */ export class VariableCommand extends Command { /**
     * Metadata on the command.
     */ private static metadata : CommandMetadata = new CommandMetadata ( CommandNames . Variable ) . withDescription ( "Declares a variable" ) . withParameters ( [ new SingleParameter ( "name" , "The name of the variable." , true ) , new SingleParameter ( "type" , "The type of the variable." , true ) , new SingleParameter ( "value" , "The starting value of the variable." , false ) , ] ) ; returns public getMetadata ( ) { return VariableCommand . metadata ; } param parameters returns public render ( parameters ) { if ( parameters . length === 3 && ! this . language . syntax . variables . declarationRequired ) { return LineResults . newSingleLine ( "\0" ) ; } const starter = this . language . syntax . variables . declaration ; const newParameters = parameters . slice ( ) ; newParameters [ 0 ] = CommandNames . VariableInline ; const enderLine = this . context . convertParsed ( newParameters ) ; const line = starter + enderLine . commandResults [ 0 ] . text ; return LineResults . newSingleLine ( line ) . withAddSemicolon ( true ) . withImports ( enderLine . addedImports ) ; } }