diff --git a/ballerina-shell/modules/shell-cli/src/main/java/io/ballerina/shell/cli/handlers/HelpCommand.java b/ballerina-shell/modules/shell-cli/src/main/java/io/ballerina/shell/cli/handlers/HelpCommand.java index 848f40cb2316..90ca1dd8c15b 100644 --- a/ballerina-shell/modules/shell-cli/src/main/java/io/ballerina/shell/cli/handlers/HelpCommand.java +++ b/ballerina-shell/modules/shell-cli/src/main/java/io/ballerina/shell/cli/handlers/HelpCommand.java @@ -73,8 +73,8 @@ public void run(String... args) { } else { try { ballerinaShell.outputInfo(NEW_LINE + bbeHelpProvider.getDescription(topic) - .replaceAll(TAGS, EMPTY_STRING)); - ballerinaShell.outputInfo(URL_PREFIX + URL + topic.replaceAll(" ", "-")); + .replace(TAGS, EMPTY_STRING)); + ballerinaShell.outputInfo(URL_PREFIX + URL + topic.replace(" ", "-")); } catch (HelpProviderException e) { ballerinaShell.outputError(NEW_LINE + "Can not find the topic : " + topic + NEW_LINE + NEW_LINE + diff --git a/ballerina-shell/modules/shell-cli/src/main/java/io/ballerina/shell/cli/handlers/help/BbeTopicsProvider.java b/ballerina-shell/modules/shell-cli/src/main/java/io/ballerina/shell/cli/handlers/help/BbeTopicsProvider.java index 5518d4752e1e..90af306ea714 100644 --- a/ballerina-shell/modules/shell-cli/src/main/java/io/ballerina/shell/cli/handlers/help/BbeTopicsProvider.java +++ b/ballerina-shell/modules/shell-cli/src/main/java/io/ballerina/shell/cli/handlers/help/BbeTopicsProvider.java @@ -66,7 +66,7 @@ private void populateTopicList() { Stream sampleList = Arrays.stream(samples); sampleList.forEach((bbeRecordElement) -> { if (bbeRecordElement != null) { - topicList.add(bbeRecordElement.getUrl().replaceAll("-", " ")); + topicList.add(bbeRecordElement.getUrl().replace("-", " ")); } }); } diff --git a/ballerina-shell/modules/shell-core/src/main/java/io/ballerina/shell/utils/StringUtils.java b/ballerina-shell/modules/shell-core/src/main/java/io/ballerina/shell/utils/StringUtils.java index 00bf4493a5c2..4ce5351c1abb 100644 --- a/ballerina-shell/modules/shell-core/src/main/java/io/ballerina/shell/utils/StringUtils.java +++ b/ballerina-shell/modules/shell-core/src/main/java/io/ballerina/shell/utils/StringUtils.java @@ -62,7 +62,7 @@ public static String quoted(String identifier) { */ public static String shortenedString(Object input) { String value = String.valueOf(input); - value = value.replaceAll("\n", ""); + value = value.replace("\n", ""); if (value.length() > MAX_VAR_STRING_LENGTH) { int subStrLength = MAX_VAR_STRING_LENGTH / 2; return value.substring(0, subStrLength) diff --git a/bvm/ballerina-profiler/src/main/java/io/ballerina/runtime/profiler/runtime/StackTraceMap.java b/bvm/ballerina-profiler/src/main/java/io/ballerina/runtime/profiler/runtime/StackTraceMap.java index 8f208758e739..e113cb20cf89 100644 --- a/bvm/ballerina-profiler/src/main/java/io/ballerina/runtime/profiler/runtime/StackTraceMap.java +++ b/bvm/ballerina-profiler/src/main/java/io/ballerina/runtime/profiler/runtime/StackTraceMap.java @@ -62,6 +62,6 @@ static String getCallStackString(String stackKey) { } private static String decodeStackElement(String stackElement) { - return Utils.decodeIdentifier(stackElement.replaceAll("\\$value\\$", "")); + return Utils.decodeIdentifier(stackElement.replace("$value$", "")); } } diff --git a/cli/ballerina-cli/src/main/java/io/ballerina/cli/cmd/CommandUtil.java b/cli/ballerina-cli/src/main/java/io/ballerina/cli/cmd/CommandUtil.java index 7eddeec8e46f..52df15957bd4 100644 --- a/cli/ballerina-cli/src/main/java/io/ballerina/cli/cmd/CommandUtil.java +++ b/cli/ballerina-cli/src/main/java/io/ballerina/cli/cmd/CommandUtil.java @@ -954,9 +954,9 @@ public static void initPackage(Path path, String packageName) throws IOException String defaultManifest = FileUtils.readFileAsString(NEW_CMD_DEFAULTS + "/" + "manifest-app.toml"); // replace manifest distribution with a guessed value defaultManifest = defaultManifest - .replaceAll(ORG_NAME, ProjectUtils.guessOrgName()) - .replaceAll(PKG_NAME, guessPkgName(packageName, "app")) - .replaceAll(DIST_VERSION, RepoUtils.getBallerinaShortVersion()); + .replace(ORG_NAME, ProjectUtils.guessOrgName()) + .replace(PKG_NAME, guessPkgName(packageName, "app")) + .replace(DIST_VERSION, RepoUtils.getBallerinaShortVersion()); Files.write(ballerinaToml, defaultManifest.getBytes(StandardCharsets.UTF_8)); } @@ -966,9 +966,9 @@ private static void initLibPackage(Path path, String packageName) throws IOExcep String defaultManifest = FileUtils.readFileAsString(NEW_CMD_DEFAULTS + "/" + "manifest-lib.toml"); // replace manifest org and name with a guessed value. - defaultManifest = defaultManifest.replaceAll(ORG_NAME, ProjectUtils.guessOrgName()) - .replaceAll(PKG_NAME, guessPkgName(packageName, "lib")) - .replaceAll(DIST_VERSION, RepoUtils.getBallerinaShortVersion()); + defaultManifest = defaultManifest.replace(ORG_NAME, ProjectUtils.guessOrgName()) + .replace(PKG_NAME, guessPkgName(packageName, "lib")) + .replace(DIST_VERSION, RepoUtils.getBallerinaShortVersion()); write(ballerinaToml, defaultManifest.getBytes(StandardCharsets.UTF_8)); @@ -990,16 +990,16 @@ private static void initToolPackage(Path path, String packageName) throws IOExce String defaultManifest = FileUtils.readFileAsString(NEW_CMD_DEFAULTS + "/" + "manifest-app.toml"); defaultManifest = defaultManifest - .replaceAll(ORG_NAME, ProjectUtils.guessOrgName()) - .replaceAll(PKG_NAME, guessPkgName(packageName, TOOL_DIR)) - .replaceAll(DIST_VERSION, RepoUtils.getBallerinaShortVersion()); + .replace(ORG_NAME, ProjectUtils.guessOrgName()) + .replace(PKG_NAME, guessPkgName(packageName, TOOL_DIR)) + .replace(DIST_VERSION, RepoUtils.getBallerinaShortVersion()); Files.write(ballerinaToml, defaultManifest.getBytes(StandardCharsets.UTF_8)); Path balToolToml = path.resolve(ProjectConstants.BAL_TOOL_TOML); Files.createFile(balToolToml); String balToolManifest = FileUtils.readFileAsString(NEW_CMD_DEFAULTS + "/" + "manifest-tool.toml"); - balToolManifest = balToolManifest.replaceAll(TOOL_ID, guessPkgName(packageName, TOOL_DIR)); + balToolManifest = balToolManifest.replace(TOOL_ID, guessPkgName(packageName, TOOL_DIR)); write(balToolToml, balToolManifest.getBytes(StandardCharsets.UTF_8)); } diff --git a/cli/ballerina-cli/src/main/java/io/ballerina/cli/cmd/PushCommand.java b/cli/ballerina-cli/src/main/java/io/ballerina/cli/cmd/PushCommand.java index 6cd22d3b0a9d..804b4246e9d4 100644 --- a/cli/ballerina-cli/src/main/java/io/ballerina/cli/cmd/PushCommand.java +++ b/cli/ballerina-cli/src/main/java/io/ballerina/cli/cmd/PushCommand.java @@ -515,7 +515,7 @@ private void pushBalaToRemote(Path balaPath, CentralAPIClient client) { errorMessage = errorMessage.substring(0, errorMessage.indexOf("\n\tat")); } - errorMessage = errorMessage.replaceAll("error: ", ""); + errorMessage = errorMessage.replace("error: ", ""); // when unauthorized access token for organization is given if (errorMessage.contains("subject claims missing in the user info repsonse")) { diff --git a/cli/ballerina-cli/src/main/java/io/ballerina/cli/utils/NativeUtils.java b/cli/ballerina-cli/src/main/java/io/ballerina/cli/utils/NativeUtils.java index 8d5f6e2f0bc2..addca020483d 100644 --- a/cli/ballerina-cli/src/main/java/io/ballerina/cli/utils/NativeUtils.java +++ b/cli/ballerina-cli/src/main/java/io/ballerina/cli/utils/NativeUtils.java @@ -303,7 +303,7 @@ private static void extractMockFunctionClassMapping(Map testS functionToMock = key.substring(key.indexOf(MOCK_LEGACY_DELIMITER) + 1); } } - functionToMock = functionToMock.replaceAll("\\\\", ""); + functionToMock = functionToMock.replace("\\", ""); mockFunctionClassMapping.computeIfAbsent(functionToMockClassName, k -> new ArrayList<>()).add("$ORIG_" + functionToMock); } @@ -444,7 +444,7 @@ private static void dumpJar(Map modifiedClassDefs, Map modifiedClassDef : modifiedClassDefs.entrySet()) { if (modifiedClassDef.getValue().length > 0) { String entry = modifiedClassDef.getKey(); - String path = entry.replaceAll("\\.", PATH_SEPARATOR) + CLASS_EXTENSION; + String path = entry.replace(".", PATH_SEPARATOR) + CLASS_EXTENSION; duplicatePaths.add(path); jarOutputStream.putNextEntry(new ZipEntry(path)); jarOutputStream.write(modifiedClassDefs.get(entry)); @@ -502,7 +502,7 @@ private static void populateClassNameVsFunctionToMockMap(Map new ArrayList<>()).add(functionToMock); } diff --git a/cli/ballerina-cli/src/main/java/io/ballerina/cli/utils/TestUtils.java b/cli/ballerina-cli/src/main/java/io/ballerina/cli/utils/TestUtils.java index 4fc9f8678033..facd0066b192 100644 --- a/cli/ballerina-cli/src/main/java/io/ballerina/cli/utils/TestUtils.java +++ b/cli/ballerina-cli/src/main/java/io/ballerina/cli/utils/TestUtils.java @@ -180,7 +180,7 @@ public static void generateTesterinaReports(Project project, TestReport testRepo testReport.finalizeTestResults(project.buildOptions().codeCoverage()); Gson gson = new Gson(); - String json = gson.toJson(testReport).replaceAll("\\\\\\(", "("); + String json = gson.toJson(testReport).replace("\\(", "("); File jsonFile = new File(reportDir.resolve(RESULTS_JSON_FILE).toString()); try (FileOutputStream fileOutputStream = new FileOutputStream(jsonFile)) { diff --git a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/util/ProjectUtils.java b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/util/ProjectUtils.java index 1012b6d88f37..898cedddf0e7 100644 --- a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/util/ProjectUtils.java +++ b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/util/ProjectUtils.java @@ -388,7 +388,7 @@ public static String guessPkgName(String packageName, String template) { // if package name has consecutive underscores, replace them with a single underscore if (packageName.contains("__")) { - packageName = packageName.replaceAll("__", "_"); + packageName = packageName.replace("__", "_"); } // if package name has trailing underscore remove it diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/ClosureGenerator.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/ClosureGenerator.java index 2d37d6e97c83..ea8a3885e78f 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/ClosureGenerator.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/ClosureGenerator.java @@ -759,7 +759,7 @@ private String generateName(String name, BLangNode parent) { case CLASS_DEFN: return generateName(((BLangClassDefinition) parent).name.getValue() + UNDERSCORE + name, parent.parent); case FUNCTION: - name = ((BLangFunction) parent).symbol.name.value.replaceAll("\\.", UNDERSCORE) + UNDERSCORE + name; + name = ((BLangFunction) parent).symbol.name.value.replace(".", UNDERSCORE) + UNDERSCORE + name; return generateName(name, parent.parent); case RESOURCE_FUNC: return generateName(((BLangResourceFunction) parent).name.value + UNDERSCORE + name, parent.parent); diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/tree/BLangMarkdownDocumentation.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/tree/BLangMarkdownDocumentation.java index 40ebf9b04ba2..73f8cfdcaab0 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/tree/BLangMarkdownDocumentation.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/tree/BLangMarkdownDocumentation.java @@ -107,7 +107,7 @@ public BLangMarkDownDeprecatedParametersDocumentation getDeprecatedParametersDoc public String getDocumentation() { return documentationLines.stream() .map(BLangMarkdownDocumentationLine::getText) - .collect(Collectors.joining("\n")).replaceAll("\r", ""); + .collect(Collectors.joining("\n")).replace("\r", ""); } @Override diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/tree/expressions/BLangMarkDownDeprecationDocumentation.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/tree/expressions/BLangMarkDownDeprecationDocumentation.java index bb286b4d67fc..89e26fe926e3 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/tree/expressions/BLangMarkDownDeprecationDocumentation.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/tree/expressions/BLangMarkDownDeprecationDocumentation.java @@ -60,7 +60,7 @@ public void addDeprecationLine(String text) { @Override public String getDocumentation() { - return String.join("\n", this.deprecationDocumentationLines).replaceAll("\r", ""); + return String.join("\n", this.deprecationDocumentationLines).replace("\r", ""); } @Override diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/tree/expressions/BLangMarkdownParameterDocumentation.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/tree/expressions/BLangMarkdownParameterDocumentation.java index 55bb8ed87235..54471a12f08f 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/tree/expressions/BLangMarkdownParameterDocumentation.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/tree/expressions/BLangMarkdownParameterDocumentation.java @@ -56,7 +56,7 @@ public void addParameterDocumentationLine(String text) { @Override public String getParameterDocumentation() { - return parameterDocumentationLines.stream().collect(Collectors.joining("\n")).replaceAll("\r", ""); + return parameterDocumentationLines.stream().collect(Collectors.joining("\n")).replace("\r", ""); } @Override diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/tree/expressions/BLangMarkdownReturnParameterDocumentation.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/tree/expressions/BLangMarkdownReturnParameterDocumentation.java index 4910ad0337e3..7e888af47d17 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/tree/expressions/BLangMarkdownReturnParameterDocumentation.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/tree/expressions/BLangMarkdownReturnParameterDocumentation.java @@ -59,7 +59,7 @@ public void addReturnParameterDocumentationLine(String text) { @Override public String getReturnParameterDocumentation() { - return returnParameterDocumentationLines.stream().collect(Collectors.joining("\n")).replaceAll("\r", ""); + return returnParameterDocumentationLines.stream().collect(Collectors.joining("\n")).replace("\r", ""); } @Override diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/common/utils/CommonUtil.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/common/utils/CommonUtil.java index ae00b91e605f..0e6c14ed9125 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/common/utils/CommonUtil.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/common/utils/CommonUtil.java @@ -269,7 +269,7 @@ public static boolean isLangLibOrLangTest(ModuleID moduleID) { * @return The identifier with escape characters escaped */ public static String escapeEscapeCharsInIdentifier(String identifier) { - return identifier.replaceAll("\\\\", "\\\\\\\\"); + return identifier.replace("\\", "\\\\"); } /** @@ -279,8 +279,8 @@ public static String escapeEscapeCharsInIdentifier(String identifier) { * @return Processed text */ public static String escapeSpecialCharsInInsertText(String text) { - return text.replaceAll("\\\\", "\\\\\\\\") - .replaceAll("\\$", Matcher.quoteReplacement("\\$")); + return text.replace("\\", "\\\\") + .replace("$", "\\$"); } /** diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/telemetry/LSTelemetryEvent.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/telemetry/LSTelemetryEvent.java index 0ab38e6cb4c1..99ad89e8175b 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/telemetry/LSTelemetryEvent.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/telemetry/LSTelemetryEvent.java @@ -46,7 +46,7 @@ protected static String getComponentName(LSOperation operation) { if (operation == null) { return LS_TELEMETRY_COMPONENT_NAME; } - return LS_TELEMETRY_COMPONENT_NAME + "." + operation.getName().replaceAll("/", "_"); + return LS_TELEMETRY_COMPONENT_NAME + "." + operation.getName().replace("/", "_"); } public String getComponent() { diff --git a/misc/ballerinalang-data-mapper/src/main/java/org/ballerinalang/datamapper/AIDataMapperCodeActionUtil.java b/misc/ballerinalang-data-mapper/src/main/java/org/ballerinalang/datamapper/AIDataMapperCodeActionUtil.java index 9653a1210378..3ba45bab1b48 100644 --- a/misc/ballerinalang-data-mapper/src/main/java/org/ballerinalang/datamapper/AIDataMapperCodeActionUtil.java +++ b/misc/ballerinalang-data-mapper/src/main/java/org/ballerinalang/datamapper/AIDataMapperCodeActionUtil.java @@ -789,9 +789,9 @@ private String generateMappingFunction(String mappingFromServer, String foundTyp rightType = rhsSignature; } - mappingFromServer = mappingFromServer.replaceAll("\"", ""); - mappingFromServer = mappingFromServer.replaceAll(",", ", "); - mappingFromServer = mappingFromServer.replaceAll(":", ": "); + mappingFromServer = mappingFromServer.replace("\"", ""); + mappingFromServer = mappingFromServer.replace(",", ", "); + mappingFromServer = mappingFromServer.replace(":", ": "); // change the generated mapping function to be compatible with spread fields. diff --git a/misc/ballerinalang-data-mapper/src/main/java/org/ballerinalang/datamapper/DataMapperNodeVisitor.java b/misc/ballerinalang-data-mapper/src/main/java/org/ballerinalang/datamapper/DataMapperNodeVisitor.java index 66e1b680a20f..f76c1a6587f9 100644 --- a/misc/ballerinalang-data-mapper/src/main/java/org/ballerinalang/datamapper/DataMapperNodeVisitor.java +++ b/misc/ballerinalang-data-mapper/src/main/java/org/ballerinalang/datamapper/DataMapperNodeVisitor.java @@ -95,7 +95,7 @@ public void visit(VariableDeclarationNode variableDeclarationNode) { SpecificFieldNode specificFieldNode = (SpecificFieldNode) field; if (specificFieldNode.fieldName().kind() == SyntaxKind.STRING_LITERAL) { String fieldName = ((BasicLiteralNode) specificFieldNode.fieldName()).literalToken().text(); - fieldName = fieldName.replaceAll("\"", ""); + fieldName = fieldName.replace("\"", ""); Optional symbol = this.model.symbol(variableDeclarationNode); if (symbol.isPresent()) { TypeSymbol typeSymbol = ((VariableSymbol) symbol.get()).typeDescriptor(); diff --git a/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/utils/PackageUtils.java b/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/utils/PackageUtils.java index 6df63e7f6a27..45244fec0e01 100644 --- a/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/utils/PackageUtils.java +++ b/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/utils/PackageUtils.java @@ -262,7 +262,7 @@ public static String[] getQModuleNameParts(String path) { String[] moduleParts; // Makes the path os-independent, as some of the incoming windows source paths can contain both of the // separator types(possibly due to a potential JDI bug). - path = path.replaceAll("\\\\", "/"); + path = path.replace("\\", "/"); if (path.contains("/")) { moduleParts = path.split("/"); } else { @@ -349,9 +349,9 @@ private static String getFullModuleName(Document document) { private static String replaceSeparators(String path) { if (path.contains("/")) { - return path.replaceAll("/", "."); + return path.replace("/", "."); } else if (path.contains("\\")) { - return path.replaceAll("\\\\", "."); + return path.replace("\\", "."); } return path; } diff --git a/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/variable/types/BTypeDesc.java b/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/variable/types/BTypeDesc.java index aee66f64fd36..ec4910070e35 100644 --- a/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/variable/types/BTypeDesc.java +++ b/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/variable/types/BTypeDesc.java @@ -40,7 +40,7 @@ public String computeValue() { try { String stringValue = getStringValue(context, jvmValue); if (stringValue.startsWith(TYPEDESC_VALUE_PREFIX)) { - stringValue = stringValue.replaceAll(TYPEDESC_VALUE_PREFIX, ""); + stringValue = stringValue.replace(TYPEDESC_VALUE_PREFIX, ""); } return stringValue; } catch (Exception e) { diff --git a/misc/debug-adapter/modules/debug-adapter-runtime/src/main/java/org/ballerinalang/debugadapter/runtime/DebuggerRuntime.java b/misc/debug-adapter/modules/debug-adapter-runtime/src/main/java/org/ballerinalang/debugadapter/runtime/DebuggerRuntime.java index d3d6a7265e5f..2c6f8122bc02 100644 --- a/misc/debug-adapter/modules/debug-adapter-runtime/src/main/java/org/ballerinalang/debugadapter/runtime/DebuggerRuntime.java +++ b/misc/debug-adapter/modules/debug-adapter-runtime/src/main/java/org/ballerinalang/debugadapter/runtime/DebuggerRuntime.java @@ -366,7 +366,7 @@ public static Object getXMLStepResult(BXml xmlVal, String xmlStepPattern) { private static BString[] processXMLNamePattern(String xmlNamePattern) { // removes LT and GT tokens if presents. - xmlNamePattern = xmlNamePattern.replaceAll("<", "").replaceAll(">", ""); + xmlNamePattern = xmlNamePattern.replace("<", "").replace(">", ""); if (xmlNamePattern.contains(XML_STEP_SEPARATOR)) { String[] stepParts = xmlNamePattern.split(XML_ALL_CHILDREN_STEP); diff --git a/misc/semver-checker/modules/semver-checker-core/src/main/java/io/ballerina/semver/checker/util/SyntaxTreeUtils.java b/misc/semver-checker/modules/semver-checker-core/src/main/java/io/ballerina/semver/checker/util/SyntaxTreeUtils.java index 509f54c4049e..1e74a4a4e33f 100644 --- a/misc/semver-checker/modules/semver-checker-core/src/main/java/io/ballerina/semver/checker/util/SyntaxTreeUtils.java +++ b/misc/semver-checker/modules/semver-checker-core/src/main/java/io/ballerina/semver/checker/util/SyntaxTreeUtils.java @@ -49,7 +49,7 @@ public class SyntaxTreeUtils { * @return node typename */ public static String getNodeKindName(SyntaxKind nodeKind) { - return nodeKind.name().toLowerCase(Locale.ROOT).toLowerCase(Locale.ENGLISH).replaceAll("_", " "); + return nodeKind.name().toLowerCase(Locale.ROOT).toLowerCase(Locale.ENGLISH).replace("_", " "); } /** diff --git a/misc/testerina/modules/testerina-compiler-plugin/src/main/java/org/ballerinalang/testerina/compiler/TestExecutionGenerationTask.java b/misc/testerina/modules/testerina-compiler-plugin/src/main/java/org/ballerinalang/testerina/compiler/TestExecutionGenerationTask.java index 60e2253f1049..690283f7161d 100644 --- a/misc/testerina/modules/testerina-compiler-plugin/src/main/java/org/ballerinalang/testerina/compiler/TestExecutionGenerationTask.java +++ b/misc/testerina/modules/testerina-compiler-plugin/src/main/java/org/ballerinalang/testerina/compiler/TestExecutionGenerationTask.java @@ -248,7 +248,7 @@ private static void gatherMockedFunctions(List mockedFunctionList, Expre if ("test".equals(modulePrefix) && "call".equals(methodName) && "when".equals(identifier)) { String mockedFunction = methodCallExpressionNode.arguments() - .get(0).toString().replaceAll("\"", ""); + .get(0).toString().replace("\"", ""); mockedFunctionList.add(mockedFunction); } } diff --git a/misc/testerina/modules/testerina-core/src/main/java/org/ballerinalang/testerina/core/AssertionDiffEvaluator.java b/misc/testerina/modules/testerina-core/src/main/java/org/ballerinalang/testerina/core/AssertionDiffEvaluator.java index cf883346ffd6..77532cb0bd24 100644 --- a/misc/testerina/modules/testerina-core/src/main/java/org/ballerinalang/testerina/core/AssertionDiffEvaluator.java +++ b/misc/testerina/modules/testerina-core/src/main/java/org/ballerinalang/testerina/core/AssertionDiffEvaluator.java @@ -99,7 +99,7 @@ public static BString getStringDiff(BString actual, BString expected) { } } } - output = output.replaceAll("\n\n", " \n \n "); + output = output.replace("\n\n", " \n \n "); return StringUtils.fromString(output); } diff --git a/misc/testerina/modules/testerina-core/src/main/java/org/ballerinalang/testerina/core/MockAnnotationProcessor.java b/misc/testerina/modules/testerina-core/src/main/java/org/ballerinalang/testerina/core/MockAnnotationProcessor.java index 1a60b64447c9..d7bcf39d2813 100644 --- a/misc/testerina/modules/testerina-core/src/main/java/org/ballerinalang/testerina/core/MockAnnotationProcessor.java +++ b/misc/testerina/modules/testerina-core/src/main/java/org/ballerinalang/testerina/core/MockAnnotationProcessor.java @@ -265,7 +265,7 @@ public void process(FunctionNode functionNode, List an // Adding ` # --> ` to registry String className = getQualifiedClassName(bLangTestablePackage, functionToMockID.toString(), vals[1]); - vals[1] = vals[1].replaceAll("\\\\", ""); + vals[1] = vals[1].replace("\\", ""); registry.addMockFunctionsSourceMap(bLangTestablePackage.packageID.getName().toString() + MODULE_DELIMITER + className + MOCK_LEGACY_DELIMITER + vals[1], functionName); } else { diff --git a/misc/testerina/modules/testerina-core/src/main/java/org/ballerinalang/testerina/core/TestProcessor.java b/misc/testerina/modules/testerina-core/src/main/java/org/ballerinalang/testerina/core/TestProcessor.java index b2ad8e9653d5..d820b59d34ba 100644 --- a/misc/testerina/modules/testerina-core/src/main/java/org/ballerinalang/testerina/core/TestProcessor.java +++ b/misc/testerina/modules/testerina-core/src/main/java/org/ballerinalang/testerina/core/TestProcessor.java @@ -405,7 +405,7 @@ private boolean isGroupAvailable(List inputGroups, List function * @return String */ private String getStringValue(Node valueExpr) { - return valueExpr.toString().replaceAll("\\\"", "").trim(); + return valueExpr.toString().replace("\"", "").trim(); } /** diff --git a/misc/testerina/modules/testerina-core/src/main/java/org/ballerinalang/testerina/natives/io/StringUtils.java b/misc/testerina/modules/testerina-core/src/main/java/org/ballerinalang/testerina/natives/io/StringUtils.java index 3e69a1d54699..79988c655d17 100644 --- a/misc/testerina/modules/testerina-core/src/main/java/org/ballerinalang/testerina/natives/io/StringUtils.java +++ b/misc/testerina/modules/testerina-core/src/main/java/org/ballerinalang/testerina/natives/io/StringUtils.java @@ -163,7 +163,7 @@ public static Object decode(BString str, BString charset) { try { String javaStr = str.getValue(); javaStr = javaStr.replaceAll("%(?![0-9a-fA-F]{2})", "%25"); - javaStr = javaStr.replaceAll("\\+", "%2B"); + javaStr = javaStr.replace("+", "%2B"); return io.ballerina.runtime.api.utils.StringUtils.fromString( URLDecoder.decode(javaStr, charset.getValue())); } catch (UnsupportedEncodingException | IllegalArgumentException e) { diff --git a/misc/testerina/modules/testerina-core/src/main/java/org/ballerinalang/testerina/natives/mock/FunctionMock.java b/misc/testerina/modules/testerina-core/src/main/java/org/ballerinalang/testerina/natives/mock/FunctionMock.java index 7761394262dc..cd5bb9167a5a 100644 --- a/misc/testerina/modules/testerina-core/src/main/java/org/ballerinalang/testerina/natives/mock/FunctionMock.java +++ b/misc/testerina/modules/testerina-core/src/main/java/org/ballerinalang/testerina/natives/mock/FunctionMock.java @@ -112,7 +112,7 @@ private static Object callMockFunction(String originalFunction, String originalC if (Thread.currentThread().getStackTrace().length >= 5) { String classname = Thread.currentThread().getStackTrace()[4].getClassName(); if (classname.contains("/")) { - classname = classname.replaceAll("/", "."); + classname = classname.replace("/", "."); } String[] projectInfo = classname.split(Pattern.quote(".")); // Set project info diff --git a/misc/testerina/modules/testerina-runtime/src/main/java/org/ballerinalang/test/runtime/BTestMain.java b/misc/testerina/modules/testerina-runtime/src/main/java/org/ballerinalang/test/runtime/BTestMain.java index 247874b2966b..d4902ec5ee91 100644 --- a/misc/testerina/modules/testerina-runtime/src/main/java/org/ballerinalang/test/runtime/BTestMain.java +++ b/misc/testerina/modules/testerina-runtime/src/main/java/org/ballerinalang/test/runtime/BTestMain.java @@ -329,7 +329,7 @@ private static byte[] replaceMethodBody(Method method, Method mockMethod, String try { InputStream ins; if (coverage) { - String instrumentedClassPath = instrumentDir + "/" + clazz.getName().replaceAll("\\.", "/") + ".class"; + String instrumentedClassPath = instrumentDir + "/" + clazz.getName().replace(".", "/") + ".class"; ins = new FileInputStream(instrumentedClassPath); } else { ins = clazz.getResourceAsStream(clazz.getSimpleName() + ".class"); diff --git a/misc/testerina/modules/testerina-runtime/src/main/java/org/ballerinalang/test/runtime/util/JacocoInstrumentUtils.java b/misc/testerina/modules/testerina-runtime/src/main/java/org/ballerinalang/test/runtime/util/JacocoInstrumentUtils.java index 73628ad38308..09e3afb893bc 100644 --- a/misc/testerina/modules/testerina-runtime/src/main/java/org/ballerinalang/test/runtime/util/JacocoInstrumentUtils.java +++ b/misc/testerina/modules/testerina-runtime/src/main/java/org/ballerinalang/test/runtime/util/JacocoInstrumentUtils.java @@ -45,7 +45,7 @@ public static void instrumentOffline(List projectModuleJarList, Path destDi URLClassLoader classLoader = new URLClassLoader(projectModuleJarList.toArray(new URL[0])); for (String className : mockClassNames) { Class clazz = classLoader.loadClass(className); - File file = new File(destDir.toString(), className.replaceAll("\\.", "/") + ".class"); + File file = new File(destDir.toString(), className.replace(".", "/") + ".class"); file.getParentFile().mkdirs(); try (InputStream input = clazz.getResourceAsStream(clazz.getSimpleName() + ".class"); OutputStream output = new FileOutputStream(file)) { diff --git a/misc/testerina/modules/testerina-runtime/src/main/java/org/ballerinalang/test/runtime/util/TesterinaUtils.java b/misc/testerina/modules/testerina-runtime/src/main/java/org/ballerinalang/test/runtime/util/TesterinaUtils.java index 18c0540ee677..2cca02100101 100644 --- a/misc/testerina/modules/testerina-runtime/src/main/java/org/ballerinalang/test/runtime/util/TesterinaUtils.java +++ b/misc/testerina/modules/testerina-runtime/src/main/java/org/ballerinalang/test/runtime/util/TesterinaUtils.java @@ -168,7 +168,7 @@ private static int getTestExecutionState(Class initClazz) { */ public static String formatError(String errorMsg) { StringBuilder newErrMsg = new StringBuilder(); - errorMsg = errorMsg.replaceAll("\n", "\n\t"); + errorMsg = errorMsg.replace("\n", "\n\t"); List msgParts = Arrays.asList(errorMsg.split("\n")); boolean stackTraceStartFlag = true;