import { CaseStyle } from "../Languages/Casing/CaseStyle" ; import { LineResults } from "../LineResults" ; import { CommandNames } from "../Names/CommandNames" ; import { KeywordNames } from "../Names/KeywordNames" ; import { Command } from "./Command" ; import { CommandMetadata } from "./Metadata/CommandMetadata" ; import { KeywordParameter } from "./Metadata/Parameters/KeywordParameter" ; import { RepeatingParameters } from "./Metadata/Parameters/RepeatingParameters" ; import { SingleParameter } from "./Metadata/Parameters/SingleParameter" ; /**
 * Calls a static function.
 */ export class StaticFunctionCommand extends Command { /**
     * Metadata on the command.
     */ private static metadata : CommandMetadata = new CommandMetadata ( CommandNames . StaticFunction ) . withDescription ( "Calls a static function" ) . withParameters ( [ new KeywordParameter ( KeywordNames . Privacies , "The privacy of the function." , true ) , new SingleParameter ( "className" , "The name of the class the function is on." , true ) , new SingleParameter ( "functionName" , "The name of the function." , true ) , new RepeatingParameters ( "Function parameters" , [ new SingleParameter ( "parameterName" , "A named parameter for the function." , true ) , ] ) , ] ) ; returns public getMetadata ( ) { return StaticFunctionCommand . metadata ; } param parameters public render ( parameters ) { const publicity = parameters [ 1 ] ; const className = parameters [ 2 ] ; const functionName = parameters [ 3 ] ; let output = className + "." ; output += this . getPublicityPrefix ( publicity ) ; output += this . context . convertStringToCase ( functionName , this . getPublicityCase ( publicity ) ) ; output += "(" ; if ( parameters . length > 4 ) { output += parameters [ 4 ] ; for ( let i = 5 ; i < parameters . length ; i += 1 ) { output += ", " ; output += parameters [ i ] ; } } output += ")" ; return LineResults . newSingleLine ( output ) . withAddSemicolon ( true ) ; } param publicity returns private getPublicityCase ( publicity ) { if ( publicity === KeywordNames . Private ) { return this . language . syntax . classes . statics . functions . privateCase ; } if ( publicity === KeywordNames . Protected ) { return this . language . syntax . classes . statics . functions . protectedCase ; } return this . language . syntax . classes . statics . functions . publicCase ; } param publicity returns private getPublicityPrefix ( publicity ) { if ( publicity === KeywordNames . Private ) { return this . language . syntax . classes . statics . functions . privatePrefix ; } if ( publicity === KeywordNames . Protected ) { return this . language . syntax . classes . statics . functions . protectedPrefix ; } return this . language . syntax . classes . statics . functions . publicPrefix ; } }