diff --git a/src/baseTranspiler.ts b/src/baseTranspiler.ts index 869123e..abfbe8e 100644 --- a/src/baseTranspiler.ts +++ b/src/baseTranspiler.ts @@ -1118,6 +1118,10 @@ class BaseTranspiler { return undefined; // stub } + printReplaceAllCall(node, identation, name = undefined, parsedArg = undefined, parsedArg2 = undefined) { + return undefined; // stub + } + printToStringCall(node, identation, name = undefined) { return undefined; // stub } @@ -1264,6 +1268,8 @@ class BaseTranspiler { return this.printSliceCall(node, identation, name, parsedArg, parsedArg2); case 'replace': return this.printReplaceCall(node, identation, name, parsedArg, parsedArg2); + case 'replaceAll': + return this.printReplaceAllCall(node, identation, name, parsedArg, parsedArg2); } } } diff --git a/src/csharpTranspiler.ts b/src/csharpTranspiler.ts index 93ad63b..f2b88af 100644 --- a/src/csharpTranspiler.ts +++ b/src/csharpTranspiler.ts @@ -957,6 +957,10 @@ export class CSharpTranspiler extends BaseTranspiler { return `((string)${name}).Replace((string)${parsedArg}, (string)${parsedArg2})`; } + printReplaceAllCall(node, identation, name = undefined, parsedArg = undefined, parsedArg2 = undefined) { + return `((string)${name}).Replace((string)${parsedArg}, (string)${parsedArg2})`; + } + printPadEndCall(node, identation, name, parsedArg, parsedArg2) { return `(${name} as String).PadRight(Convert.ToInt32(${parsedArg}), Convert.ToChar(${parsedArg2}))`; } diff --git a/src/goTranspiler.ts b/src/goTranspiler.ts index 5b6c39e..3d1c344 100644 --- a/src/goTranspiler.ts +++ b/src/goTranspiler.ts @@ -1260,6 +1260,10 @@ ${this.getIden(identation)}return ${rightPart}`; return `Replace(${name}, ${parsedArg}, ${parsedArg2})`; } + printReplaceAllCall(node, identation, name = undefined, parsedArg = undefined, parsedArg2 = undefined) { + return `Replace(${name}, ${parsedArg}, ${parsedArg2})`; + } + printPadEndCall(node, identation, name, parsedArg, parsedArg2) { return `PadEnd(${name}, ${parsedArg}, ${parsedArg2})`; } diff --git a/src/phpTranspiler.ts b/src/phpTranspiler.ts index e7c8fe9..a862870 100644 --- a/src/phpTranspiler.ts +++ b/src/phpTranspiler.ts @@ -220,6 +220,10 @@ export class PhpTranspiler extends BaseTranspiler { return `str_replace(${parsedArg}, ${parsedArg2}, ${name})`; } + printReplaceAllCall(node, identation, name = undefined, parsedArg = undefined, parsedArg2 = undefined) { + return `str_replace(${parsedArg}, ${parsedArg2}, ${name})`; + } + printIncludesCall(node, identation, name = undefined, parsedArg = undefined) { // "ol".includes("o") -> str_contains("ol", "o") or [12,3,4].includes(3) -> in_array(3, [12,3,4]) const leftSide = node.expression?.expression; diff --git a/src/pythonTranspiler.ts b/src/pythonTranspiler.ts index 17efc75..637ca59 100644 --- a/src/pythonTranspiler.ts +++ b/src/pythonTranspiler.ts @@ -215,6 +215,10 @@ export class PythonTranspiler extends BaseTranspiler { return `${name}.replace(${parsedArg}, ${parsedArg2})`; } + printReplaceAllCall(node: any, identation: any, name?: any, parsedArg?: any, parsedArg2?: any) { + return `${name}.replace(${parsedArg}, ${parsedArg2})`; + } + printElementAccessExpressionExceptionIfAny(node) { if (node.expression.kind === SyntaxKind.ThisKeyword) { return "getattr(self, " + this.printNode(node.argumentExpression, 0) + ")"; diff --git a/tests/integration/source/transpilable.ts b/tests/integration/source/transpilable.ts index 4afde66..d2407a8 100644 --- a/tests/integration/source/transpilable.ts +++ b/tests/integration/source/transpilable.ts @@ -71,6 +71,10 @@ class Test { const both = firstConcat.concat(secondConcat); console.log(both.length); // should print 4 console.log(both[2]); // should print "c" + + const baseString = "aabba"; + const replacedAllString = baseString.replaceAll("a", ""); + console.log(replacedAllString); // should print "bb" } }