Lines 582-587
Link Here
|
582 |
} |
582 |
} |
583 |
|
583 |
|
584 |
/** |
584 |
/** |
|
|
585 |
* @bug 281655: [formatter] "Never join lines" does not work for annotations. |
586 |
* @test Verify that "Never join lines" now works for annotations and also that |
587 |
* element-value pairs are well wrapped using the new formatter option |
588 |
* @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=281655" |
589 |
*/ |
590 |
public void testBug281655() throws JavaModelException { |
591 |
this.formatterPrefs.join_wrapped_lines = false; |
592 |
String source = |
593 |
"@MessageDriven(mappedName = \"filiality/SchedulerMQService\", \n" + |
594 |
" activationConfig = { \n" + |
595 |
" @ActivationConfigProperty(propertyName = \"cronTrigger\",\n" + |
596 |
"propertyValue = \"0/10 * * * * ?\") \n" + |
597 |
" })\n" + |
598 |
"@RunAs(\"admin\")\n" + |
599 |
"@ResourceAdapter(\"quartz-ra.rar\")\n" + |
600 |
"@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)\n" + |
601 |
"public class X {\n" + |
602 |
"}\n"; |
603 |
formatSource(source, |
604 |
"@MessageDriven(mappedName = \"filiality/SchedulerMQService\",\n" + |
605 |
" activationConfig = {\n" + |
606 |
" @ActivationConfigProperty(propertyName = \"cronTrigger\",\n" + |
607 |
" propertyValue = \"0/10 * * * * ?\")\n" + |
608 |
" })\n" + |
609 |
"@RunAs(\"admin\")\n" + |
610 |
"@ResourceAdapter(\"quartz-ra.rar\")\n" + |
611 |
"@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)\n" + |
612 |
"public class X {\n" + |
613 |
"}\n" |
614 |
); |
615 |
} |
616 |
public void testBug281655a() throws JavaModelException { |
617 |
this.formatterPrefs.alignment_for_arguments_in_annotation = Alignment.M_NO_ALIGNMENT; |
618 |
String source = |
619 |
"@MessageDriven(mappedName = \"filiality/SchedulerMQService\", \n" + |
620 |
" activationConfig = { \n" + |
621 |
" @ActivationConfigProperty(propertyName = \"cronTrigger\",\n" + |
622 |
"propertyValue = \"0/10 * * * * ?\") \n" + |
623 |
" })\n" + |
624 |
"@RunAs(\"admin\")\n" + |
625 |
"@ResourceAdapter(\"quartz-ra.rar\")\n" + |
626 |
"@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)\n" + |
627 |
"public class X {\n" + |
628 |
"}\n"; |
629 |
formatSource(source, |
630 |
"@MessageDriven(mappedName = \"filiality/SchedulerMQService\", activationConfig = { @ActivationConfigProperty(propertyName = \"cronTrigger\", propertyValue = \"0/10 * * * * ?\") })\n" + |
631 |
"@RunAs(\"admin\")\n" + |
632 |
"@ResourceAdapter(\"quartz-ra.rar\")\n" + |
633 |
"@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)\n" + |
634 |
"public class X {\n" + |
635 |
"}\n" |
636 |
); |
637 |
} |
638 |
public void testBug281655b() throws JavaModelException { |
639 |
this.formatterPrefs.alignment_for_arguments_in_annotation = Alignment.M_COMPACT_SPLIT; |
640 |
String source = |
641 |
"@MessageDriven(mappedName = \"filiality/SchedulerMQService\", \n" + |
642 |
" activationConfig = { \n" + |
643 |
" @ActivationConfigProperty(propertyName = \"cronTrigger\",\n" + |
644 |
"propertyValue = \"0/10 * * * * ?\") \n" + |
645 |
" })\n" + |
646 |
"@RunAs(\"admin\")\n" + |
647 |
"@ResourceAdapter(\"quartz-ra.rar\")\n" + |
648 |
"@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)\n" + |
649 |
"public class X {\n" + |
650 |
"}\n"; |
651 |
formatSource(source, |
652 |
"@MessageDriven(\n" + |
653 |
" mappedName = \"filiality/SchedulerMQService\",\n" + |
654 |
" activationConfig = { @ActivationConfigProperty(\n" + |
655 |
" propertyName = \"cronTrigger\", propertyValue = \"0/10 * * * * ?\") })\n" + |
656 |
"@RunAs(\"admin\")\n" + |
657 |
"@ResourceAdapter(\"quartz-ra.rar\")\n" + |
658 |
"@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)\n" + |
659 |
"public class X {\n" + |
660 |
"}\n" |
661 |
); |
662 |
} |
663 |
public void testBug281655c() throws JavaModelException { |
664 |
this.formatterPrefs.alignment_for_arguments_in_annotation = Alignment.M_COMPACT_FIRST_BREAK_SPLIT; |
665 |
String source = |
666 |
"@MessageDriven(mappedName = \"filiality/SchedulerMQService\", \n" + |
667 |
" activationConfig = { \n" + |
668 |
" @ActivationConfigProperty(propertyName = \"cronTrigger\",\n" + |
669 |
"propertyValue = \"0/10 * * * * ?\") \n" + |
670 |
" })\n" + |
671 |
"@RunAs(\"admin\")\n" + |
672 |
"@ResourceAdapter(\"quartz-ra.rar\")\n" + |
673 |
"@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)\n" + |
674 |
"public class X {\n" + |
675 |
"}\n"; |
676 |
formatSource(source, |
677 |
"@MessageDriven(\n" + |
678 |
" mappedName = \"filiality/SchedulerMQService\",\n" + |
679 |
" activationConfig = { @ActivationConfigProperty(\n" + |
680 |
" propertyName = \"cronTrigger\", propertyValue = \"0/10 * * * * ?\") })\n" + |
681 |
"@RunAs(\"admin\")\n" + |
682 |
"@ResourceAdapter(\"quartz-ra.rar\")\n" + |
683 |
"@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)\n" + |
684 |
"public class X {\n" + |
685 |
"}\n" |
686 |
); |
687 |
} |
688 |
public void testBug281655d() throws JavaModelException { |
689 |
this.formatterPrefs.alignment_for_arguments_in_annotation = Alignment.M_ONE_PER_LINE_SPLIT; |
690 |
String source = |
691 |
"@MessageDriven(mappedName = \"filiality/SchedulerMQService\", \n" + |
692 |
" activationConfig = { \n" + |
693 |
" @ActivationConfigProperty(propertyName = \"cronTrigger\",\n" + |
694 |
"propertyValue = \"0/10 * * * * ?\") \n" + |
695 |
" })\n" + |
696 |
"@RunAs(\"admin\")\n" + |
697 |
"@ResourceAdapter(\"quartz-ra.rar\")\n" + |
698 |
"@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)\n" + |
699 |
"public class X {\n" + |
700 |
"}\n"; |
701 |
formatSource(source, |
702 |
"@MessageDriven(\n" + |
703 |
" mappedName = \"filiality/SchedulerMQService\",\n" + |
704 |
" activationConfig = { @ActivationConfigProperty(\n" + |
705 |
" propertyName = \"cronTrigger\",\n" + |
706 |
" propertyValue = \"0/10 * * * * ?\") })\n" + |
707 |
"@RunAs(\"admin\")\n" + |
708 |
"@ResourceAdapter(\"quartz-ra.rar\")\n" + |
709 |
"@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)\n" + |
710 |
"public class X {\n" + |
711 |
"}\n" |
712 |
); |
713 |
} |
714 |
public void testBug281655e() throws JavaModelException { |
715 |
this.formatterPrefs.alignment_for_arguments_in_annotation = Alignment.M_NEXT_SHIFTED_SPLIT; |
716 |
String source = |
717 |
"@MessageDriven(mappedName = \"filiality/SchedulerMQService\", \n" + |
718 |
" activationConfig = { \n" + |
719 |
" @ActivationConfigProperty(propertyName = \"cronTrigger\",\n" + |
720 |
"propertyValue = \"0/10 * * * * ?\") \n" + |
721 |
" })\n" + |
722 |
"@RunAs(\"admin\")\n" + |
723 |
"@ResourceAdapter(\"quartz-ra.rar\")\n" + |
724 |
"@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)\n" + |
725 |
"public class X {\n" + |
726 |
"}\n"; |
727 |
formatSource(source, |
728 |
"@MessageDriven(\n" + |
729 |
" mappedName = \"filiality/SchedulerMQService\",\n" + |
730 |
" activationConfig = { @ActivationConfigProperty(\n" + |
731 |
" propertyName = \"cronTrigger\",\n" + |
732 |
" propertyValue = \"0/10 * * * * ?\") })\n" + |
733 |
"@RunAs(\"admin\")\n" + |
734 |
"@ResourceAdapter(\"quartz-ra.rar\")\n" + |
735 |
"@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)\n" + |
736 |
"public class X {\n" + |
737 |
"}\n" |
738 |
); |
739 |
} |
740 |
public void testBug281655f() throws JavaModelException { |
741 |
this.formatterPrefs.alignment_for_arguments_in_annotation = Alignment.M_NEXT_PER_LINE_SPLIT; |
742 |
String source = |
743 |
"@MessageDriven(mappedName = \"filiality/SchedulerMQService\", \n" + |
744 |
" activationConfig = { \n" + |
745 |
" @ActivationConfigProperty(propertyName = \"cronTrigger\",\n" + |
746 |
"propertyValue = \"0/10 * * * * ?\") \n" + |
747 |
" })\n" + |
748 |
"@RunAs(\"admin\")\n" + |
749 |
"@ResourceAdapter(\"quartz-ra.rar\")\n" + |
750 |
"@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)\n" + |
751 |
"public class X {\n" + |
752 |
"}\n"; |
753 |
formatSource(source, |
754 |
"@MessageDriven(mappedName = \"filiality/SchedulerMQService\",\n" + |
755 |
" activationConfig = { @ActivationConfigProperty(propertyName = \"cronTrigger\",\n" + |
756 |
" propertyValue = \"0/10 * * * * ?\") })\n" + |
757 |
"@RunAs(\"admin\")\n" + |
758 |
"@ResourceAdapter(\"quartz-ra.rar\")\n" + |
759 |
"@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)\n" + |
760 |
"public class X {\n" + |
761 |
"}\n" |
762 |
); |
763 |
} |
764 |
|
765 |
/** |
766 |
* @bug 282030: [formatter] Java annotation formatting |
767 |
* @test Verify that element-value pairs are well wrapped using the new formatter option |
768 |
* @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=282030" |
769 |
*/ |
770 |
public void testBug282030() throws JavaModelException { |
771 |
String source = |
772 |
"@DeclareParents(value =\n" + |
773 |
"\"com.apress.springrecipes.calculator.ArithmeticCalculatorImpl\", defaultImpl =\n" + |
774 |
"MaxCalculatorImpl.class) \n" + |
775 |
"public class X {\n" + |
776 |
"}\n"; |
777 |
formatSource(source, |
778 |
"@DeclareParents(\n" + |
779 |
" value = \"com.apress.springrecipes.calculator.ArithmeticCalculatorImpl\",\n" + |
780 |
" defaultImpl = MaxCalculatorImpl.class)\n" + |
781 |
"public class X {\n" + |
782 |
"}\n" |
783 |
); |
784 |
} |
785 |
public void testBug282030a() throws JavaModelException { |
786 |
this.formatterPrefs.alignment_for_arguments_in_annotation = Alignment.M_NO_ALIGNMENT; |
787 |
String source = |
788 |
"@MyAnnot(value1 = \"this is an example\", value2 = \"of an annotation\", value3 = \"with several arguments\", value4 = \"which may need to be wrapped\")\n" + |
789 |
"public class Test {\n" + |
790 |
"}\n"; |
791 |
formatSource(source, |
792 |
"@MyAnnot(value1 = \"this is an example\", value2 = \"of an annotation\", value3 = \"with several arguments\", value4 = \"which may need to be wrapped\")\n" + |
793 |
"public class Test {\n" + |
794 |
"}\n" |
795 |
); |
796 |
} |
797 |
public void testBug282030b() throws JavaModelException { |
798 |
this.formatterPrefs.alignment_for_arguments_in_annotation = Alignment.M_COMPACT_SPLIT; |
799 |
String source = |
800 |
"@MyAnnot(value1 = \"this is an example\", value2 = \"of an annotation\", value3 = \"with several arguments\", value4 = \"which may need to be wrapped\")\n" + |
801 |
"public class Test {\n" + |
802 |
"}\n"; |
803 |
formatSource(source, |
804 |
"@MyAnnot(value1 = \"this is an example\", value2 = \"of an annotation\",\n" + |
805 |
" value3 = \"with several arguments\",\n" + |
806 |
" value4 = \"which may need to be wrapped\")\n" + |
807 |
"public class Test {\n" + |
808 |
"}\n" |
809 |
); |
810 |
} |
811 |
public void testBug282030c() throws JavaModelException { |
812 |
this.formatterPrefs.alignment_for_arguments_in_annotation = Alignment.M_COMPACT_FIRST_BREAK_SPLIT; |
813 |
String source = |
814 |
"@MyAnnot(value1 = \"this is an example\", value2 = \"of an annotation\", value3 = \"with several arguments\", value4 = \"which may need to be wrapped\")\n" + |
815 |
"public class Test {\n" + |
816 |
"}\n"; |
817 |
formatSource(source, |
818 |
"@MyAnnot(\n" + |
819 |
" value1 = \"this is an example\", value2 = \"of an annotation\",\n" + |
820 |
" value3 = \"with several arguments\",\n" + |
821 |
" value4 = \"which may need to be wrapped\")\n" + |
822 |
"public class Test {\n" + |
823 |
"}\n" |
824 |
); |
825 |
} |
826 |
public void testBug282030d() throws JavaModelException { |
827 |
this.formatterPrefs.alignment_for_arguments_in_annotation = Alignment.M_ONE_PER_LINE_SPLIT; |
828 |
String source = |
829 |
"@MyAnnot(value1 = \"this is an example\", value2 = \"of an annotation\", value3 = \"with several arguments\", value4 = \"which may need to be wrapped\")\n" + |
830 |
"public class Test {\n" + |
831 |
"}\n"; |
832 |
formatSource(source, |
833 |
"@MyAnnot(\n" + |
834 |
" value1 = \"this is an example\",\n" + |
835 |
" value2 = \"of an annotation\",\n" + |
836 |
" value3 = \"with several arguments\",\n" + |
837 |
" value4 = \"which may need to be wrapped\")\n" + |
838 |
"public class Test {\n" + |
839 |
"}\n" |
840 |
); |
841 |
} |
842 |
public void testBug282030e() throws JavaModelException { |
843 |
this.formatterPrefs.alignment_for_arguments_in_annotation = Alignment.M_NEXT_SHIFTED_SPLIT; |
844 |
String source = |
845 |
"@MyAnnot(value1 = \"this is an example\", value2 = \"of an annotation\", value3 = \"with several arguments\", value4 = \"which may need to be wrapped\")\n" + |
846 |
"public class Test {\n" + |
847 |
"}\n"; |
848 |
formatSource(source, |
849 |
"@MyAnnot(\n" + |
850 |
" value1 = \"this is an example\",\n" + |
851 |
" value2 = \"of an annotation\",\n" + |
852 |
" value3 = \"with several arguments\",\n" + |
853 |
" value4 = \"which may need to be wrapped\")\n" + |
854 |
"public class Test {\n" + |
855 |
"}\n" |
856 |
); |
857 |
} |
858 |
public void testBug282030f() throws JavaModelException { |
859 |
this.formatterPrefs.alignment_for_arguments_in_annotation = Alignment.M_NEXT_PER_LINE_SPLIT; |
860 |
String source = |
861 |
"@MyAnnot(value1 = \"this is an example\", value2 = \"of an annotation\", value3 = \"with several arguments\", value4 = \"which may need to be wrapped\")\n" + |
862 |
"public class Test {\n" + |
863 |
"}\n"; |
864 |
formatSource(source, |
865 |
"@MyAnnot(value1 = \"this is an example\",\n" + |
866 |
" value2 = \"of an annotation\",\n" + |
867 |
" value3 = \"with several arguments\",\n" + |
868 |
" value4 = \"which may need to be wrapped\")\n" + |
869 |
"public class Test {\n" + |
870 |
"}\n" |
871 |
); |
872 |
} |
873 |
public void testBug282030g1() throws JavaModelException { |
874 |
this.formatterPrefs.alignment_for_arguments_in_annotation = Alignment.M_ONE_PER_LINE_SPLIT; |
875 |
String source = |
876 |
"@MyAnnot1(member1 = \"sample1\", member2 = \"sample2\")\n" + |
877 |
"public class X {\n" + |
878 |
"}\n"; |
879 |
formatSource(source, |
880 |
"@MyAnnot1(member1 = \"sample1\", member2 = \"sample2\")\n" + |
881 |
"public class X {\n" + |
882 |
"}\n" |
883 |
); |
884 |
} |
885 |
public void testBug282030g2() throws JavaModelException { |
886 |
this.formatterPrefs.alignment_for_arguments_in_annotation = Alignment.M_ONE_PER_LINE_SPLIT | Alignment.M_FORCE; |
887 |
String source = |
888 |
"@MyAnnot1(member1 = \"sample1\", member2 = \"sample2\")\n" + |
889 |
"public class X {\n" + |
890 |
"}\n"; |
891 |
formatSource(source, |
892 |
"@MyAnnot1(\n" + |
893 |
" member1 = \"sample1\",\n" + |
894 |
" member2 = \"sample2\")\n" + |
895 |
"public class X {\n" + |
896 |
"}\n" |
897 |
); |
898 |
} |
899 |
public void testBug282030h1() throws JavaModelException { |
900 |
this.formatterPrefs.alignment_for_arguments_in_annotation = Alignment.M_ONE_PER_LINE_SPLIT; |
901 |
String source = |
902 |
"@MyAnnot1(name = \"sample1\", \n" + |
903 |
" value = { \n" + |
904 |
" @MyAnnot2(name = \"sample2\",\n" + |
905 |
"value = \"demo\") \n" + |
906 |
" })\n" + |
907 |
"public class X {\n" + |
908 |
"}\n"; |
909 |
formatSource(source, |
910 |
"@MyAnnot1(name = \"sample1\", value = { @MyAnnot2(\n" + |
911 |
" name = \"sample2\",\n" + |
912 |
" value = \"demo\") })\n" + |
913 |
"public class X {\n" + |
914 |
"}\n" |
915 |
); |
916 |
} |
917 |
public void testBug282030h2() throws JavaModelException { |
918 |
this.formatterPrefs.alignment_for_arguments_in_annotation = Alignment.M_ONE_PER_LINE_SPLIT | Alignment.M_FORCE; |
919 |
String source = |
920 |
"@MyAnnot1(name = \"sample1\", \n" + |
921 |
" value = { \n" + |
922 |
" @MyAnnot2(name = \"sample2\",\n" + |
923 |
"value = \"demo\") \n" + |
924 |
" })\n" + |
925 |
"public class X {\n" + |
926 |
"}\n"; |
927 |
formatSource(source, |
928 |
"@MyAnnot1(\n" + |
929 |
" name = \"sample1\",\n" + |
930 |
" value = { @MyAnnot2(\n" + |
931 |
" name = \"sample2\",\n" + |
932 |
" value = \"demo\") })\n" + |
933 |
"public class X {\n" + |
934 |
"}\n" |
935 |
); |
936 |
} |
937 |
|
938 |
/** |
585 |
* @bug 283467: [formatter] wrong indentation with 'Never join lines' selected |
939 |
* @bug 283467: [formatter] wrong indentation with 'Never join lines' selected |
586 |
* @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=283467" |
940 |
* @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=283467" |
587 |
*/ |
941 |
*/ |