Skip to content

Commit

Permalink
Bug 574376 - [dogfooding][cleanup] Use new StringBuffer -> StringBuilder
Browse files Browse the repository at this point in the history
cleanup for test code

Runs the new StringBuffer-> StringBuilder

This help to determine that it works correctly for clients we should run
it also on our own code base. This help to ensure that the cleanup works
fine and helps us to cleanup our own code base.

From the commit message of the cleanup:

- create a cleanup to replace usage of StringBuffer with
  StringBuilder.  The two are equivalent, but StringBuffer is
  thread-safe and synchronized which makes it slower than
  StringBuilder which was introduced in Java 1.5.


This uses the local variable change only.

Change-Id: I6e4de0112ab8183243d80c4a34c5281529d9f170
Signed-off-by: Lars Vogel <[email protected]>
Reviewed-on: https://git.eclipse.org/r/c/jdt/eclipse.jdt.ui/+/182328
Tested-by: JDT Bot <[email protected]>
Reviewed-by: Jeff Johnston <[email protected]>
  • Loading branch information
vogella authored and jjohnstn committed Jun 29, 2021
1 parent 0546fc5 commit cc3dd07
Show file tree
Hide file tree
Showing 63 changed files with 4,345 additions and 4,345 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,14 @@ public void tearDown() throws Exception {
public void testPackageRename1() throws Exception {
IPackageFragment fragment= getRoot().createPackageFragment("org.test", true, null);

StringBuffer buf= new StringBuffer();
StringBuilder buf= new StringBuilder();
buf.append("package org.test;\n");
buf.append("class A {\n");
buf.append("}\n");
ICompilationUnit cu1= fragment.createCompilationUnit("A.java", buf.toString(), true, null);
setReadOnly(cu1);

buf= new StringBuffer();
buf= new StringBuilder();
buf.append("package org.test;\n");
buf.append("class B {\n");
buf.append("}\n");
Expand All @@ -110,14 +110,14 @@ public void testPackageRename2() throws Exception {

IPackageFragment fragment= getRoot().createPackageFragment("org.test", true, null);

StringBuffer buf= new StringBuffer();
StringBuilder buf= new StringBuilder();
buf.append("package org.test;\n");
buf.append("public class A {\n");
buf.append("}\n");
ICompilationUnit cu1= fragment.createCompilationUnit("A.java", buf.toString(), true, null);
setReadOnly(cu1);

buf= new StringBuffer();
buf= new StringBuilder();
buf.append("package org.test;\n");
buf.append("public class B {\n");
buf.append("}\n");
Expand All @@ -126,7 +126,7 @@ public void testPackageRename2() throws Exception {

IPackageFragment fragment2= getRoot().createPackageFragment("org.other", true, null);

buf= new StringBuffer();
buf= new StringBuilder();
buf.append("package org.other;\n");
buf.append("public class C extends org.test.A {\n");
buf.append("}\n");
Expand Down Expand Up @@ -219,14 +219,14 @@ public void testCURename() throws Exception {

IPackageFragment fragment= getRoot().createPackageFragment("org.test", true, null);

StringBuffer buf= new StringBuffer();
StringBuilder buf= new StringBuilder();
buf.append("package org.test;\n");
buf.append("public class MyClass {\n");
buf.append("}\n");
ICompilationUnit cu1= fragment.createCompilationUnit("MyClass.java", buf.toString(), true, null);
setReadOnly(cu1);

buf= new StringBuffer();
buf= new StringBuilder();
buf.append("package org.test;\n");
buf.append("public class C extends MyClass {\n");
buf.append("}\n");
Expand All @@ -252,14 +252,14 @@ public void testTypeRename() throws Exception {

IPackageFragment fragment= getRoot().createPackageFragment("org.test", true, null);

StringBuffer buf= new StringBuffer();
StringBuilder buf= new StringBuilder();
buf.append("package org.test;\n");
buf.append("public class MyClass {\n");
buf.append("}\n");
ICompilationUnit cu1= fragment.createCompilationUnit("MyClass.java", buf.toString(), true, null);
setReadOnly(cu1);

buf= new StringBuffer();
buf= new StringBuilder();
buf.append("package org.test;\n");
buf.append("public class C extends MyClass {\n");
buf.append("}\n");
Expand Down Expand Up @@ -287,7 +287,7 @@ public void testMoveCU2() throws Exception {
IPackageFragment fragment= getRoot().createPackageFragment("org.test", true, null);
IPackageFragment otherFragment= getRoot().createPackageFragment("org.test1", true, null);

StringBuffer buf= new StringBuffer();
StringBuilder buf= new StringBuilder();
buf.append("package org.test;\n");
buf.append("public class MyClass {\n");
buf.append("}\n");
Expand All @@ -299,7 +299,7 @@ public void testMoveCU2() throws Exception {
file.create(getStream(content), true, null);
setReadOnly(file);

buf= new StringBuffer();
buf= new StringBuilder();
buf.append("package org.test;\n");
buf.append("public class C extends MyClass {\n");
buf.append("}\n");
Expand Down Expand Up @@ -361,15 +361,15 @@ public void testMoveCuWithReplace() throws Exception {
IPackageFragment fragment= getRoot().createPackageFragment("org.test", true, null);
IPackageFragment otherFragment= getRoot().createPackageFragment("org.test1", true, null);

StringBuffer buf= new StringBuffer();
StringBuilder buf= new StringBuilder();
buf.append("package org.test;\n");
buf.append("public class MyClass {\n");
buf.append("}\n");
ICompilationUnit cu1= fragment.createCompilationUnit("MyClass.java", buf.toString(), true, null);
setReadOnly(cu1);


buf= new StringBuffer();
buf= new StringBuilder();
buf.append("package org.test1;\n");
buf.append("public class MyClass {\n");
buf.append("}\n");
Expand Down Expand Up @@ -400,14 +400,14 @@ public void testCopyCuWithReplace() throws Exception {
IPackageFragment fragment= getRoot().createPackageFragment("org.test", true, null);
IPackageFragment otherFragment= getRoot().createPackageFragment("org.test1", true, null);

StringBuffer buf= new StringBuffer();
StringBuilder buf= new StringBuilder();
buf.append("package org.test;\n");
buf.append("public class MyClass {\n");
buf.append("}\n");
ICompilationUnit cu1= fragment.createCompilationUnit("MyClass.java", buf.toString(), true, null);
setReadOnly(cu1);

buf= new StringBuffer();
buf= new StringBuilder();
buf.append("package org.test1;\n");
buf.append("public class MyClass {\n");
buf.append("}\n");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -972,7 +972,7 @@ public void testDestination_yes_cuToOtherPackage() throws Exception {
public void testDestination_yes_cuToOtherPackageBug549674() throws Exception {
ParticipantTesting.reset();

StringBuffer buf= new StringBuffer();
StringBuilder buf= new StringBuilder();
buf.append("package p;\n");
buf.append("\n");
buf.append("import q.Class1;\n");
Expand All @@ -986,13 +986,13 @@ public void testDestination_yes_cuToOtherPackageBug549674() throws Exception {
buf.append("}\n");
ICompilationUnit toMove= getPackageP().createCompilationUnit("Class2.java", buf.toString(), false, new NullProgressMonitor());

buf= new StringBuffer();
buf= new StringBuilder();
buf.append("package q;\n");
buf.append("public class Class1 {\n");
buf.append("}\n");
getPackageQ().createCompilationUnit("Class1.java", buf.toString(), false, new NullProgressMonitor());

buf= new StringBuffer();
buf= new StringBuilder();
buf.append("package q;\n");
buf.append("public class Class3 {\n");
buf.append(" public interface InnerClass3 {\n");
Expand All @@ -1012,7 +1012,7 @@ public void testDestination_yes_cuToOtherPackageBug549674() throws Exception {
ICompilationUnit newCu= getPackageQ().getCompilationUnit(toMove.getElementName());
assertTrue("new file does not exist after moving", newCu.exists());

buf= new StringBuffer();
buf= new StringBuilder();
buf.append("package q;\n");
buf.append("\n");
buf.append("import q.Class3.InnerClass3;\n");
Expand All @@ -1036,7 +1036,7 @@ public void testDestination_yes_cuToOtherPackageBug549674() throws Exception {
public void testDestination_yes_cuToOtherPackageBug21008() throws Exception {
ParticipantTesting.reset();

StringBuffer buf= new StringBuffer();
StringBuilder buf= new StringBuilder();
buf.append("package p;\n");
buf.append("\n");
buf.append("import q.*;\n");
Expand All @@ -1048,13 +1048,13 @@ public void testDestination_yes_cuToOtherPackageBug21008() throws Exception {
buf.append("}\n");
ICompilationUnit toMove= getPackageP().createCompilationUnit("Class2.java", buf.toString(), false, new NullProgressMonitor());

buf= new StringBuffer();
buf= new StringBuilder();
buf.append("package q;\n");
buf.append("public class Class1 {\n");
buf.append("}\n");
getPackageQ().createCompilationUnit("Class1.java", buf.toString(), false, new NullProgressMonitor());

buf= new StringBuffer();
buf= new StringBuilder();
buf.append("package q;\n");
buf.append("public class Class3 {\n");
buf.append(" public interface InnerClass3 {\n");
Expand All @@ -1074,7 +1074,7 @@ public void testDestination_yes_cuToOtherPackageBug21008() throws Exception {
ICompilationUnit newCu= getPackageQ().getCompilationUnit(toMove.getElementName());
assertTrue("new file does not exist after moving", newCu.exists());

buf= new StringBuffer();
buf= new StringBuilder();
buf.append("package q;\n");
buf.append("\n");
buf.append("public class Class2 {\n");
Expand Down Expand Up @@ -1135,7 +1135,7 @@ public void testDestination_yes_cuToOtherPackageWithMultiRoot() throws Exception
public void testDestination_yes_cuToOtherPackageWithMultiRootBug109145() throws Exception {
ParticipantTesting.reset();

StringBuffer buf= new StringBuffer();
StringBuilder buf= new StringBuilder();
buf.append("package p;\n");
buf.append("public class Class2 {\n");
buf.append(" Class1 c;\n");
Expand All @@ -1144,7 +1144,7 @@ public void testDestination_yes_cuToOtherPackageWithMultiRootBug109145() throws

IPackageFragmentRoot testSrc= JavaProjectHelper.addSourceContainer(rts.getProject(), "testSrc");
IPackageFragment testP= testSrc.createPackageFragment("p", true, new NullProgressMonitor());
buf= new StringBuffer();
buf= new StringBuilder();
buf.append("package p;\n");
buf.append("public class Class1 {\n");
buf.append("}\n");
Expand All @@ -1163,7 +1163,7 @@ public void testDestination_yes_cuToOtherPackageWithMultiRootBug109145() throws
ICompilationUnit newCu= destination.getCompilationUnit(toMove.getElementName());
assertTrue("new file does not exist after moving", newCu.exists());

buf= new StringBuffer();
buf= new StringBuilder();
buf.append("package p2;\n");
buf.append("\n");
buf.append("import p.Class1;\n");
Expand All @@ -1173,7 +1173,7 @@ public void testDestination_yes_cuToOtherPackageWithMultiRootBug109145() throws
buf.append("}\n");
assertEqualLines(buf.toString(), newCu.getSource());

buf= new StringBuffer();
buf= new StringBuilder();
buf.append("package p;\n");
buf.append("public class Class1 {\n");
buf.append("}\n");
Expand Down
Loading

0 comments on commit cc3dd07

Please sign in to comment.