Lines 10-15
Link Here
|
10 |
* (reports 71244 & 74746: New Quick Assist's [quick assist]) |
10 |
* (reports 71244 & 74746: New Quick Assist's [quick assist]) |
11 |
* Benjamin Muskalla (buskalla@innoopract.com) - 104021: [quick fix] Introduce |
11 |
* Benjamin Muskalla (buskalla@innoopract.com) - 104021: [quick fix] Introduce |
12 |
* new local with casted type applied more than once |
12 |
* new local with casted type applied more than once |
|
|
13 |
* Billy Huang (billyhuang31@gmail.com) - [quick assist] concatenate/merge |
14 |
* string literals - https://bugs.eclipse.org/bugs/show_bug.cgi?id=77632 |
13 |
*******************************************************************************/ |
15 |
*******************************************************************************/ |
14 |
package org.eclipse.jdt.ui.tests.quickfix; |
16 |
package org.eclipse.jdt.ui.tests.quickfix; |
15 |
|
17 |
|
Lines 5502-5505
Link Here
|
5502 |
assertProposalDoesNotExist(proposals, "Pick out selected part of String"); |
5504 |
assertProposalDoesNotExist(proposals, "Pick out selected part of String"); |
5503 |
|
5505 |
|
5504 |
} |
5506 |
} |
|
|
5507 |
|
5508 |
public void testCombineStringsProposals1() throws Exception { |
5509 |
IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); |
5510 |
StringBuffer buf= new StringBuffer(); |
5511 |
buf.append("package test1;\n"); |
5512 |
buf.append("public class E {\n"); |
5513 |
buf.append(" public void foo() {\n"); |
5514 |
buf.append(" String string = \"Hello\" + \" World\";\n"); |
5515 |
buf.append(" }\n"); |
5516 |
buf.append("}\n"); |
5517 |
ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null); |
5518 |
|
5519 |
int offset= buf.toString().indexOf("\"Hello\""); |
5520 |
int length= "\"Hello\" + \"World\"".length(); |
5521 |
AssistContext context= getCorrectionContext(cu, offset, length); |
5522 |
List proposals= collectAssists(context, false); |
5523 |
|
5524 |
assertCorrectLabels(proposals); |
5525 |
|
5526 |
buf= new StringBuffer(); |
5527 |
buf.append("package test1;\n"); |
5528 |
buf.append("public class E {\n"); |
5529 |
buf.append(" public void foo() {\n"); |
5530 |
buf.append(" String string = \"Hello World\";\n"); |
5531 |
buf.append(" }\n"); |
5532 |
buf.append("}\n"); |
5533 |
String expected= buf.toString(); |
5534 |
|
5535 |
assertExpectedExistInProposals(proposals, new String[] { expected }); |
5536 |
|
5537 |
} |
5538 |
|
5539 |
public void testCombineStringsProposals2() throws Exception { |
5540 |
IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); |
5541 |
StringBuffer buf= new StringBuffer(); |
5542 |
buf.append("package test1;\n"); |
5543 |
buf.append("public class E {\n"); |
5544 |
buf.append(" public void foo() {\n"); |
5545 |
buf.append(" String string = \"Hello\" + \" \" + \"World\";\n"); |
5546 |
buf.append(" }\n"); |
5547 |
buf.append("}\n"); |
5548 |
ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null); |
5549 |
|
5550 |
int offset= buf.toString().indexOf("\"Hello\""); |
5551 |
int length= "\"Hello\" + \" \" + \"World\"".length(); |
5552 |
AssistContext context= getCorrectionContext(cu, offset, length); |
5553 |
List proposals= collectAssists(context, false); |
5554 |
|
5555 |
assertCorrectLabels(proposals); |
5556 |
|
5557 |
buf= new StringBuffer(); |
5558 |
buf.append("package test1;\n"); |
5559 |
buf.append("public class E {\n"); |
5560 |
buf.append(" public void foo() {\n"); |
5561 |
buf.append(" String string = \"Hello World\";\n"); |
5562 |
buf.append(" }\n"); |
5563 |
buf.append("}\n"); |
5564 |
String expected= buf.toString(); |
5565 |
|
5566 |
assertExpectedExistInProposals(proposals, new String[] { expected }); |
5567 |
|
5568 |
} |
5569 |
|
5570 |
public void testCombineStringsProposals3() throws Exception { |
5571 |
IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); |
5572 |
StringBuffer buf= new StringBuffer(); |
5573 |
buf.append("package test1;\n"); |
5574 |
buf.append("public class E {\n"); |
5575 |
buf.append(" public void foo() {\n"); |
5576 |
buf.append(" String string = \"Hello World\";\n"); |
5577 |
buf.append(" }\n"); |
5578 |
buf.append("}\n"); |
5579 |
ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null); |
5580 |
|
5581 |
int offset= buf.toString().indexOf("\"Hello World\""); |
5582 |
AssistContext context= getCorrectionContext(cu, offset, 0); |
5583 |
List proposals= collectAssists(context, false); |
5584 |
|
5585 |
assertProposalDoesNotExist(proposals, "Combine selected strings"); |
5586 |
|
5587 |
} |
5588 |
|
5589 |
public void testCombineStringsProposals4() throws Exception { |
5590 |
IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); |
5591 |
StringBuffer buf= new StringBuffer(); |
5592 |
buf.append("package test1;\n"); |
5593 |
buf.append("public class E {\n"); |
5594 |
buf.append(" public void foo() {\n"); |
5595 |
buf.append(" System.out.println(\"Hello\" + \" \" + \"World\");\n"); |
5596 |
buf.append(" }\n"); |
5597 |
buf.append("}\n"); |
5598 |
ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null); |
5599 |
|
5600 |
int offset= buf.toString().indexOf("\"Hello\""); |
5601 |
int length= "\"Hello\" + \" \" + \"World\"".length(); |
5602 |
AssistContext context= getCorrectionContext(cu, offset, length); |
5603 |
List proposals= collectAssists(context, false); |
5604 |
|
5605 |
assertCorrectLabels(proposals); |
5606 |
|
5607 |
buf= new StringBuffer(); |
5608 |
buf.append("package test1;\n"); |
5609 |
buf.append("public class E {\n"); |
5610 |
buf.append(" public void foo() {\n"); |
5611 |
buf.append(" System.out.println(\"Hello World\");\n"); |
5612 |
buf.append(" }\n"); |
5613 |
buf.append("}\n"); |
5614 |
String expected= buf.toString(); |
5615 |
|
5616 |
assertExpectedExistInProposals(proposals, new String[] { expected }); |
5617 |
|
5618 |
} |
5619 |
|
5620 |
public void testCombineStringsProposals5() throws Exception { |
5621 |
IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); |
5622 |
StringBuffer buf= new StringBuffer(); |
5623 |
buf.append("package test1;\n"); |
5624 |
buf.append("public class E {\n"); |
5625 |
buf.append(" public void foo() {\n"); |
5626 |
buf.append(" String string = \"Hello\" + \"World\" + 2;\n"); |
5627 |
buf.append(" }\n"); |
5628 |
buf.append("}\n"); |
5629 |
ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null); |
5630 |
|
5631 |
int offset= buf.toString().indexOf("\"Hello\" + \"World\""); |
5632 |
int length= "\"Hello\" + \"World\"".length(); |
5633 |
AssistContext context= getCorrectionContext(cu, offset, length); |
5634 |
List proposals= collectAssists(context, false); |
5635 |
|
5636 |
assertProposalDoesNotExist(proposals, "Combine selected strings"); |
5637 |
|
5638 |
} |
5505 |
} |
5639 |
} |