import { Parser } from './Parser'; export class VtlParser implements Parser { variables: Set = new Set(); getVariables(fileContent: string): string[] { const variables: string[] = []; const stringsSlittedByBraces = fileContent.split('${'); const stringsDefaultByDollarSignOnly = fileContent.split('"$'); for (let i = 1; i < stringsSlittedByBraces.length; i++) { const element = stringsSlittedByBraces[i]; if (element) { const firstElement = element.split('}')[0]; if (!variables.includes(firstElement)) { variables.push(firstElement); } else { console.log(firstElement); } } } for (let i = 1; i < stringsDefaultByDollarSignOnly.length; i++) { const element = stringsDefaultByDollarSignOnly[i]; if (element && !element.includes('$')) { const firstElement = element.split('"')[0] .replace('{', '') .replace('}', '').trim(); if (!variables.includes(firstElement)) { variables.push(firstElement); } } } this.variables = new Set(variables); return [...variables]; } } /* $vdns_int_private_ip_0 $vdns_onap_private_ip_0 aaaa false dddd */