INNER CODE UNIT · TypeScript

match

maciejtreder/ng-toolkit · schematics/_utils/index.ts:279

        let match = sourceText.match(/(?:export|) class.*?{[\s\S]*?((?:constructor|public|private|)[\w\s]*?\()/);
        if (match) {
            changePos = (match['index'] || 0) + match[0].length - match[1].length;
        } else {
            changePos = sourceText.lastIndexOf("}") - 1;
        }
    } else {
        changePos = sourceText.lastIndexOf("}") - 1;
    }
    changeRecorder.insertLeft(changePos, `\n${body}\n`);
    tree.commitUpdate(changeRecorder);
}

export function addParamterToMethod(tree: Tree, filePath: string, name: string, parameterDeclaration: string): void {
    let method = getMethod(tree, filePath, name);
    const fileContent = getFileContent(tree, filePath);
    if (method) {
        let results: any = method.match(new RegExp("(?:public|private|\\s).*" + name + "[\\s\\S]*?(\([\\s\\S]*?\)[\\s\\S]*?{)"));

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…