import { LineResults } from "../LineResults" ; import { CommandNames } from "../Names/CommandNames" ; import { Command } from "./Command" ; import { CommandResult } from "./CommandResult" ; import { CommandMetadata } from "./Metadata/CommandMetadata" ; import { SingleParameter } from "./Metadata/Parameters/SingleParameter" ; import { addLineEnder } from "./Utilities" ; /**
 * Starts to initialize a new dictionary.
 */ export class DictionaryNewStartCommand extends Command { /**
     * Metadata on the command.
     */ private static metadata : CommandMetadata = new CommandMetadata ( CommandNames . DictionaryNewStart ) . withDescription ( "Starts to initialize a new dictionary" ) . withIndentation ( [ 1 ] ) . withParameters ( [ new SingleParameter ( "keyType" , "The type of the keys." , true ) , new SingleParameter ( "valueType" , "Tye type of the values" , true ) , ] ) ; returns public getMetadata ( ) { return DictionaryNewStartCommand . metadata ; } param parameters returns public render ( parameters ) { if ( ! this . language . syntax . dictionaries . initializeAsNew ) { return LineResults . newSingleLine ( "{" ) ; } const typeLine = this . context . convertParsed ( [ CommandNames . DictionaryType , parameters [ 1 ] , parameters [ 2 ] ] ) ; const output = "new " + typeLine . commandResults [ 0 ] . text ; const results = [ new CommandResult ( output , 0 ) ] ; addLineEnder ( results , this . language . syntax . dictionaries . initializeStart , 1 ) ; return new LineResults ( results ) . withImports ( this . language . syntax . dictionaries . requiredImports ) . withImports ( typeLine . addedImports ) ; } }