Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using text blocks in org.eclipse.jdt.ui.tests.refactoring #964

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -88,60 +88,62 @@ public void before() throws Exception {

fImport.createCompilationUnit(
"Provider.java",
"package import_in;\n" +
"\n" +
"import import_use.List;\n" +
"import java.io.File;\n" +
"import java.util.ArrayList;\n" +
"import java.util.Map;\n" +
"import static java.lang.Math.PI;\n" +
"\n" +
"public class Provider {\n" +
" public File useAsReturn() {\n" +
" return null;\n" +
" }\n" +
" public void useInArgument(File file) {\n" +
" file= null;\n" +
" }\n" +
" public void useInDecl() {\n" +
" List list= null;\n" +
" }\n" +
" public int useInDecl2() {\n" +
" return new ArrayList().size();\n" +
" }\n" +
" public Object useInDecl3() {\n" +
" return new java.util.HashMap();\n" +
" }\n" +
" public void useInClassLiteral() {\n" +
" Class clazz= File.class;\n" +
" }\n" +
" public void useArray() {\n" +
" List[] lists= null;\n" +
" }\n" +
" public void useInLocalClass() {\n" +
" class Local extends File {\n" +
" private static final long serialVersionUID = 1L;\n" +
" public Local(String s) {\n" +
" super(s);\n" +
" }\n" +
" public void foo(Map map) {\n" +
" }\n" +
" public void bar(Byte b) {\n" +
" }\n" +
" }\n" +
" }\n" +
" public void useStaticImport() {\n" +
" double i= PI;\n" +
" }\n" +
"}\n",
"""
package import_in;

import import_use.List;
import java.io.File;
import java.util.ArrayList;
import java.util.Map;
import static java.lang.Math.PI;

public class Provider {
public File useAsReturn() {
return null;
}
public void useInArgument(File file) {
file= null;
}
public void useInDecl() {
List list= null;
}
public int useInDecl2() {
return new ArrayList().size();
}
public Object useInDecl3() {
return new java.util.HashMap();
}
public void useInClassLiteral() {
Class clazz= File.class;
}
public void useArray() {
List[] lists= null;
}
public void useInLocalClass() {
class Local extends File {
private static final long serialVersionUID = 1L;
public Local(String s) {
super(s);
}
public void foo(Map map) {
}
public void bar(Byte b) {
}
}
}
public void useStaticImport() {
double i= PI;
}
}
""",
true, null);

IPackageFragment importUse= root.createPackageFragment("import_use", true, null);
importUse.createCompilationUnit("List.java",
"package import_use;" +
"" +
"public class List {" +
"}",
"""
package import_use;\
public class List {\
}""",
true, null);

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -416,13 +416,14 @@ public void testRenameRecordCompactConstructorFailLocalVariableConflict() throws

@Test
public void testRenameRecordComponentFail01() throws Exception{
String errorMsg = "<ERROR\n" +
" \n" +
"ERROR: Method 'void g()' already exists in 'p.A', having same signature as the new accessor method.\n" +
"Context: A.java (not open) [in p [in src [in TestProject]]]\n" +
"code: none\n" +
"Data: null\n" +
">";
String errorMsg = """
<ERROR

ERROR: Method 'void g()' already exists in 'p.A', having same signature as the new accessor method.
Context: A.java (not open) [in p [in src [in TestProject]]]
code: none
Data: null
>""";
renameRecordComponentFail("A","f","g",errorMsg);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,20 @@
*/
public class TextDiffContentTest {
private static final String MODIFIED_SOURCE_CONTENTS =
"// my file\n"+
"\n"+
"CMyClass::CMyClass()\n"+
"\t{\n"+
"\tGoodCall();\n"+
"\tDumbCall();\n"+
"\t// [[[ begin\n"+
"\tMagicCall();\n"+
"\t// ]]] end\n"+
"\t}\n"+
"\n"+
"// other stuff\n";
"""
// my file

CMyClass::CMyClass()
{
GoodCall();
DumbCall();
// [[[ begin
MagicCall();
// ]]] end
}

// other stuff
""";

private DocumentChange fDocumentChange;

Expand Down Expand Up @@ -149,14 +151,18 @@ public void testEmptySourceRangeNoContext2() throws Exception {
public void testEmptySourceRangeContext() throws Exception {
String src = getSource(fEdit1.getRegion(), 2);
String preview = getPreview(fChange1, 2);
assertEquals("\tMagicCall();\n" +
"\t// ]]] end\n" +
"\t}\n",
assertEquals("""
MagicCall();
// ]]] end
}
""",
src);
assertEquals(" MagicCall();\n" +
" // ]]] end\n" +
" FinalCall();\n" +
" }\n",
assertEquals("""
MagicCall();
// ]]] end
FinalCall();
}
""",
preview);
}
@Test
Expand All @@ -182,14 +188,18 @@ public void testEmptyTargetRangeNoContext() throws Exception {
public void testEmptyTargetRangeContext() throws Exception {
String src = getSource(fEdit3.getRegion(), 2);
String preview = getPreview(fChange3, 2);
assertEquals("\t{\n"+"\tGoodCall();\n"+
"\tDumbCall();\n"+
"\t// [[[ begin\n"+
"\tMagicCall();",
assertEquals("""
{
GoodCall();
DumbCall();
// [[[ begin
MagicCall();""",
src);
assertEquals("\t{\n"+"\tGoodCall();\n"+
"\t// [[[ begin\n"+
"\tMagicCall();",
assertEquals("""
{
GoodCall();
// [[[ begin
MagicCall();""",
preview);

}
Expand Down
Loading