INNER CODE UNIT · TypeScript
getMethodSignature
maciejtreder/ng-toolkit · schematics/_utils/index.ts:163
export function getMethodSignature(tree: Tree, filePath: string, name: string): string | null {
let fileContent = getFileContent(tree, filePath);
let results: any = fileContent.match(new RegExp("(?:public|private|).*" + name + ".*?\\(([\\s\\S]*?\\))"));
if (results) {
fileContent = fileContent.substr(results.index);
let lines = fileContent.split('\n');
let endCut = 0;
let openingBraces = 0;
for (let line of lines) {
endCut += line.length + 1
openingBraces += (line.match(/{/g) || []).length;
if (openingBraces > 0) {
break;
}
}
return fileContent.substr(0, endCut);