View | Details | Raw Unified | Return to bug 66216 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/jdt/core/tests/model/SortCompilationUnitElementsTests.java (-14 / +172 lines)
Lines 10-17 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.jdt.core.tests.model;
11
package org.eclipse.jdt.core.tests.model;
12
12
13
import java.lang.reflect.Method;
14
15
import junit.framework.Test;
13
import junit.framework.Test;
16
import junit.framework.TestSuite;
14
import junit.framework.TestSuite;
17
15
Lines 72-90 Link Here
72
}
70
}
73
71
74
public static Test suite() {
72
public static Test suite() {
75
	TestSuite suite = new Suite(SortCompilationUnitElementsTests.class.getName());
76
77
	if (true) {
73
	if (true) {
78
		Class c = SortCompilationUnitElementsTests.class;
74
		return new Suite(SortCompilationUnitElementsTests.class);
79
		Method[] methods = c.getMethods();
75
	}
80
		for (int i = 0, max = methods.length; i < max; i++) {
76
	TestSuite suite = new Suite(SortCompilationUnitElementsTests.class.getName());
81
			if (methods[i].getName().startsWith("test")) { //$NON-NLS-1$
77
	suite.addTest(new SortCompilationUnitElementsTests("test016")); //$NON-NLS-1$
82
				suite.addTest(new SortCompilationUnitElementsTests(methods[i].getName()));
83
			}
84
		}
85
	} else {
86
		suite.addTest(new SortCompilationUnitElementsTests("test014")); //$NON-NLS-1$
87
	}	
88
	return suite;
78
	return suite;
89
}
79
}
90
public void tearDownSuite() throws Exception {
80
public void tearDownSuite() throws Exception {
Lines 988-993 Link Here
988
			"  \n" +
978
			"  \n" +
989
			"  static int i; // end of static field declaration\n" + 
979
			"  static int i; // end of static field declaration\n" + 
990
			"  int j;\n" + 
980
			"  int j;\n" + 
981
			"}";
982
		sortUnit(this.getCompilationUnit("/P/src/X.java"), expectedResult);
983
	} finally {
984
		this.deleteFile("/P/src/X.java");
985
	}
986
}
987
/**
988
 * https://bugs.eclipse.org/bugs/show_bug.cgi?id=66216
989
 */
990
public void test016() throws CoreException {
991
	try {
992
		this.createFile(
993
			"/P/src/X.java",
994
			"public class X {\n" + 
995
			"   \n" + 
996
			"   public void c() {\n" + 
997
			"      \n" + 
998
			"   }\n" + 
999
			"   \n" + 
1000
			"   public void b() {\n" + 
1001
			"      \n" + 
1002
			"   }\n" + 
1003
			"   \n" + 
1004
			"   public void a() {\n" + 
1005
			"      class E {\n" + 
1006
			"         // this is the line that breaks the Sort Members.\n" + 
1007
			"         // comment this fix the problem.\n" + 
1008
			"         int x, y;\n" + 
1009
			"      }\n" + 
1010
			"      \n" + 
1011
			"      \n" + 
1012
			"      new Object() {\n" + 
1013
			"         // it breaks in an anonymous class also.\n" + 
1014
			"         // comment this fix the problem.\n" + 
1015
			"         int x, y;\n" + 
1016
			"      }; \n" + 
1017
			"      \n" + 
1018
			"      \n" + 
1019
			"      class D {\n" + 
1020
			"         // this appears to break also.\n" + 
1021
			"      }\n" + 
1022
			"   } \n" + 
1023
			"   \n" + 
1024
			"   private class F {\n" + 
1025
			"      // but this works fine\n" + 
1026
			"      int x, y;\n" + 
1027
			"   }\n" + 
1028
			"}"
1029
		);
1030
		String expectedResult = 
1031
			"public class X {\n" + 
1032
			"   \n" + 
1033
			"   private class F {\n" + 
1034
			"      // but this works fine\n" + 
1035
			"      int x, y;\n" + 
1036
			"   }\n" + 
1037
			"   \n" + 
1038
			"   public void a() {\n" + 
1039
			"      class E {\n" + 
1040
			"         // this is the line that breaks the Sort Members.\n" + 
1041
			"         // comment this fix the problem.\n" + 
1042
			"         int x, y;\n" + 
1043
			"      }\n" + 
1044
			"      \n" + 
1045
			"      \n" + 
1046
			"      new Object() {\n" + 
1047
			"         // it breaks in an anonymous class also.\n" + 
1048
			"         // comment this fix the problem.\n" + 
1049
			"         int x, y;\n" + 
1050
			"      }; \n" + 
1051
			"      \n" + 
1052
			"      \n" + 
1053
			"      class D {\n" + 
1054
			"         // this appears to break also.\n" + 
1055
			"      }\n" + 
1056
			"   } \n" + 
1057
			"   \n" + 
1058
			"   public void b() {\n" + 
1059
			"      \n" + 
1060
			"   }\n" + 
1061
			"   \n" + 
1062
			"   public void c() {\n" + 
1063
			"      \n" + 
1064
			"   }\n" + 
1065
			"}";
1066
		sortUnit(this.getCompilationUnit("/P/src/X.java"), expectedResult);
1067
	} finally {
1068
		this.deleteFile("/P/src/X.java");
1069
	}
1070
}
1071
/**
1072
 * https://bugs.eclipse.org/bugs/show_bug.cgi?id=66216
1073
 */
1074
public void test017() throws CoreException {
1075
	try {
1076
		this.createFile(
1077
			"/P/src/X.java",
1078
			"public class X {\n" + 
1079
			"   \n" + 
1080
			"   public void c() {\n" + 
1081
			"      \n" + 
1082
			"   }\n" + 
1083
			"   \n" + 
1084
			"   public void b() {\n" + 
1085
			"      \n" + 
1086
			"   }\n" + 
1087
			"   \n" + 
1088
			"   public void a() {\n" + 
1089
			"      class E {\n" + 
1090
			"         // this is the line that breaks the Sort Members.\n" + 
1091
			"         // comment this fix the problem.\n" + 
1092
			"         int x, y; // my comment\n" + 
1093
			"      }\n" + 
1094
			"      \n" + 
1095
			"      \n" + 
1096
			"      new Object() {\n" + 
1097
			"         // it breaks in an anonymous class also.\n" + 
1098
			"         // comment this fix the problem.\n" + 
1099
			"         int x, y; // my comment\n" + 
1100
			"      }; \n" + 
1101
			"      \n" + 
1102
			"      \n" + 
1103
			"      class D {\n" + 
1104
			"         // this appears to break also.\n" + 
1105
			"      }\n" + 
1106
			"   } \n" + 
1107
			"   \n" + 
1108
			"   private class F {\n" + 
1109
			"      // but this works fine\n" + 
1110
			"      int x, y;\n" + 
1111
			"   }\n" + 
1112
			"}"
1113
		);
1114
		String expectedResult = 
1115
			"public class X {\n" + 
1116
			"   \n" + 
1117
			"   private class F {\n" + 
1118
			"      // but this works fine\n" + 
1119
			"      int x, y;\n" + 
1120
			"   }\n" + 
1121
			"   \n" + 
1122
			"   public void a() {\n" + 
1123
			"      class E {\n" + 
1124
			"         // this is the line that breaks the Sort Members.\n" + 
1125
			"         // comment this fix the problem.\n" + 
1126
			"         int x, y; // my comment\n" + 
1127
			"      }\n" + 
1128
			"      \n" + 
1129
			"      \n" + 
1130
			"      new Object() {\n" + 
1131
			"         // it breaks in an anonymous class also.\n" + 
1132
			"         // comment this fix the problem.\n" + 
1133
			"         int x, y; // my comment\n" + 
1134
			"      }; \n" + 
1135
			"      \n" + 
1136
			"      \n" + 
1137
			"      class D {\n" + 
1138
			"         // this appears to break also.\n" + 
1139
			"      }\n" + 
1140
			"   } \n" + 
1141
			"   \n" + 
1142
			"   public void b() {\n" + 
1143
			"      \n" + 
1144
			"   }\n" + 
1145
			"   \n" + 
1146
			"   public void c() {\n" + 
1147
			"      \n" + 
1148
			"   }\n" + 
991
			"}";
1149
			"}";
992
		sortUnit(this.getCompilationUnit("/P/src/X.java"), expectedResult);
1150
		sortUnit(this.getCompilationUnit("/P/src/X.java"), expectedResult);
993
	} finally {
1151
	} finally {

Return to bug 66216