Lines 675-680
Link Here
|
675 |
assertProposalDoesNotExist(proposals, FixMessages.LambdaExpressionsFix_convert_to_lambda_expression); |
675 |
assertProposalDoesNotExist(proposals, FixMessages.LambdaExpressionsFix_convert_to_lambda_expression); |
676 |
} |
676 |
} |
677 |
|
677 |
|
|
|
678 |
public void testConvertToLambda14() throws Exception { |
679 |
IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); |
680 |
StringBuffer buf= new StringBuffer(); |
681 |
buf.append("package test1;\n"); |
682 |
buf.append("import java.util.List;\n"); |
683 |
buf.append("\n"); |
684 |
buf.append("interface I<T> {\n"); |
685 |
buf.append(" void goo(List<T> i);\n"); |
686 |
buf.append("}\n"); |
687 |
buf.append("\n"); |
688 |
buf.append("public class X {\n"); |
689 |
buf.append(" public static void main(String[] args) {\n"); |
690 |
buf.append(" I i = new I<String>() {\n"); |
691 |
buf.append(" @Override\n"); |
692 |
buf.append(" public void goo(List<String> ls) {\n"); |
693 |
buf.append(" String s = ls.get(0);\n"); |
694 |
buf.append(" }\n"); |
695 |
buf.append(" };\n"); |
696 |
buf.append(" }\n"); |
697 |
buf.append("}\n"); |
698 |
ICompilationUnit cu= pack1.createCompilationUnit("X.java", buf.toString(), false, null); |
699 |
|
700 |
int offset= buf.toString().indexOf("I<String>()"); |
701 |
AssistContext context= getCorrectionContext(cu, offset, 0); |
702 |
assertNoErrors(context); |
703 |
List proposals= collectAssists(context, false); |
704 |
|
705 |
assertNumberOfProposals(proposals, 2); |
706 |
assertCorrectLabels(proposals); |
707 |
|
708 |
buf= new StringBuffer(); |
709 |
buf.append("package test1;\n"); |
710 |
buf.append("import java.util.List;\n"); |
711 |
buf.append("\n"); |
712 |
buf.append("interface I<T> {\n"); |
713 |
buf.append(" void goo(List<T> i);\n"); |
714 |
buf.append("}\n"); |
715 |
buf.append("\n"); |
716 |
buf.append("public class X {\n"); |
717 |
buf.append(" public static void main(String[] args) {\n"); |
718 |
buf.append(" I i = (I<String>) ls -> {\n"); |
719 |
buf.append(" String s = ls.get(0);\n"); |
720 |
buf.append(" };\n"); |
721 |
buf.append(" }\n"); |
722 |
buf.append("}\n"); |
723 |
String expected1= buf.toString(); |
724 |
|
725 |
assertExpectedExistInProposals(proposals, new String[] { expected1 }); |
726 |
} |
727 |
|
678 |
public void testConvertToAnonymousClassCreation1() throws Exception { |
728 |
public void testConvertToAnonymousClassCreation1() throws Exception { |
679 |
IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); |
729 |
IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); |
680 |
StringBuffer buf= new StringBuffer(); |
730 |
StringBuffer buf= new StringBuffer(); |