Skip to content

Commit

Permalink
Modifications done inside the bodyDeclaration and the issue has fixed.
Browse files Browse the repository at this point in the history
  • Loading branch information
subyssurendran666 committed Oct 13, 2024
1 parent 4e9610d commit 16aa3b9
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1408,14 +1408,15 @@ public void testRecord_029() throws Exception {
}
IPackageFragment pack1= this.sourceFolder.createPackageFragment("test1", false, null);

StringBuilder buf= new StringBuilder();
buf.append("package test1;\n");
buf.append("record Test(String name) {\n");
buf.append(" public static Builder builder() {}\n");
buf.append(" public static final class Builder {}\n");
buf.append("}\n");
String code = """
package test1;
public record Test(String name) {
public static Builder builder() {}
public static final class Builder {}
}
""";

ICompilationUnit cu= pack1.createCompilationUnit("Test.java", buf.toString(), false, null);
ICompilationUnit cu= pack1.createCompilationUnit("Test.java", code, false, null);

CompilationUnit astRoot= createAST(cu);
ASTRewrite rewrite= ASTRewrite.create(astRoot.getAST());
Expand All @@ -1429,14 +1430,14 @@ public void testRecord_029() throws Exception {

String preview= evaluateRewrite(cu, rewrite);

buf = new StringBuilder();
buf.append("package test1;\n");
buf.append("record Test(String name) {\n");
buf.append(" \n");
buf.append(" public static final class Builder {}\n");
buf.append("}\n");
String reWriteCode = """
package test1;
public record Test(String name) {
public static final class Builder {}
}
""";

assertEqualString(preview, buf.toString());
assertEqualString(preview, reWriteCode);
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,7 @@ protected void buildBodyDeclarations(

} else {
methodsIndex++;
continue;
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ final void addEditGroup(TextEditGroup editGroup, TextEdit edit) {
}

final TextEdit doTextRemove(int offset, int len, TextEditGroup editGroup) {
if (len <= 0) {
if (len == 0) {
return null;
}
TextEdit edit= new DeleteEdit(offset, len);
Expand Down

0 comments on commit 16aa3b9

Please sign in to comment.