import { BodyBasedExpression } from '../Expression' ; import { OclExecutionContext } from '../../OclExecutionContext' ; oclExpression oclExample export class SubstringExpression extends BodyBasedExpression { evaluate ( visitor , localVariables ? ) { const source = this . getSource ( ) . evaluate ( visitor , localVariables ) ; if ( ! this . getBody ( ) ) { return source ; } let start ; let end ; if ( Array . isArray ( this . getBody ( ) ) ) { start = this . getBody ( ) [ 0 ] ; end = this . getBody ( ) [ 1 ] ; } else { start = this . getBody ( ) ; } const startIndex = start . evaluate ( visitor , localVariables ) ; const endIndex = end ? end . evaluate ( visitor , localVariables ) : source . length ; return source . substring ( startIndex , endIndex ) ; } }