Lines 221-226
public class DefaultJavaFoldingStructureProvider implements IJavaFoldingStructur
Link Here
|
221 |
public boolean collapseMembers() { |
221 |
public boolean collapseMembers() { |
222 |
return fAllowCollapsing && fCollapseMembers; |
222 |
return fAllowCollapsing && fCollapseMembers; |
223 |
} |
223 |
} |
|
|
224 |
|
225 |
/** |
226 |
* Returns <code>true</code> if try/catch/finally's should be collapsed. |
227 |
* |
228 |
* @return <code>true</code> if try/catch/finally's should be collapsed |
229 |
*/ |
230 |
public boolean collapseTrys() { |
231 |
return fAllowCollapsing && fCollapseTrys; |
232 |
} |
233 |
|
234 |
/** |
235 |
* Returns <code>true</code> if for/while/do-while's should be collapsed. |
236 |
* |
237 |
* @return <code>true</code> if for/while/do-while's should be collapsed |
238 |
*/ |
239 |
public boolean collapseLoops() { |
240 |
return fAllowCollapsing && fCollapseLoops; |
241 |
} |
242 |
|
243 |
/** |
244 |
* Returns <code>true</code> if conditionals should be collapsed. |
245 |
* |
246 |
* @return <code>true</code> if conditionals should be collapsed |
247 |
*/ |
248 |
public boolean collapseConditionals() { |
249 |
return fAllowCollapsing && fCollapseConditionals; |
250 |
} |
251 |
|
252 |
/** |
253 |
* Returns <code>true</code> if switches should be collapsed. |
254 |
* |
255 |
* @return <code>true</code> if switches should be collapsed |
256 |
*/ |
257 |
public boolean collapseSwitches() { |
258 |
return fAllowCollapsing && fCollapseSwitches; |
259 |
} |
260 |
|
261 |
/** |
262 |
* Returns <code>true</code> if synchronizeds should be collapsed. |
263 |
* |
264 |
* @return <code>true</code> if synchronizeds should be collapsed |
265 |
*/ |
266 |
public boolean collapseSynchronizeds() { |
267 |
return fAllowCollapsing && fCollapseSynchronizeds; |
268 |
} |
269 |
|
270 |
/** |
271 |
* Returns <code>true</code> if unnameds should be collapsed. |
272 |
* |
273 |
* @return <code>true</code> if unnameds should be collapsed |
274 |
*/ |
275 |
public boolean collapseUnnameds() { |
276 |
return fAllowCollapsing && fCollapseUnnameds; |
277 |
} |
224 |
} |
278 |
} |
225 |
|
279 |
|
226 |
/** |
280 |
/** |
Lines 701-706
public class DefaultJavaFoldingStructureProvider implements IJavaFoldingStructur
Link Here
|
701 |
private boolean fCollapseInnerTypes= true; |
755 |
private boolean fCollapseInnerTypes= true; |
702 |
private boolean fCollapseMembers= false; |
756 |
private boolean fCollapseMembers= false; |
703 |
private boolean fCollapseHeaderComments= true; |
757 |
private boolean fCollapseHeaderComments= true; |
|
|
758 |
private boolean fCollapseConditionals= false; |
759 |
private boolean fCollapseLoops= false; |
760 |
private boolean fCollapseSynchronizeds= false; |
761 |
private boolean fCollapseSwitches= false; |
762 |
private boolean fCollapseUnnameds= false; |
763 |
private boolean fCollapseTrys= false; |
704 |
|
764 |
|
705 |
/* filters */ |
765 |
/* filters */ |
706 |
/** Member filter, matches nested members (but not top-level types). */ |
766 |
/** Member filter, matches nested members (but not top-level types). */ |
Lines 871-876
public class DefaultJavaFoldingStructureProvider implements IJavaFoldingStructur
Link Here
|
871 |
fCollapseJavadoc= store.getBoolean(PreferenceConstants.EDITOR_FOLDING_JAVADOC); |
931 |
fCollapseJavadoc= store.getBoolean(PreferenceConstants.EDITOR_FOLDING_JAVADOC); |
872 |
fCollapseMembers= store.getBoolean(PreferenceConstants.EDITOR_FOLDING_METHODS); |
932 |
fCollapseMembers= store.getBoolean(PreferenceConstants.EDITOR_FOLDING_METHODS); |
873 |
fCollapseHeaderComments= store.getBoolean(PreferenceConstants.EDITOR_FOLDING_HEADERS); |
933 |
fCollapseHeaderComments= store.getBoolean(PreferenceConstants.EDITOR_FOLDING_HEADERS); |
|
|
934 |
fCollapseConditionals= store.getBoolean(PreferenceConstants.EDITOR_FOLDING_CONDITIONALS); |
935 |
fCollapseSwitches= store.getBoolean(PreferenceConstants.EDITOR_FOLDING_SWITCHES); |
936 |
fCollapseLoops= store.getBoolean(PreferenceConstants.EDITOR_FOLDING_LOOPS); |
937 |
fCollapseTrys= store.getBoolean(PreferenceConstants.EDITOR_FOLDING_TRYS); |
938 |
fCollapseSynchronizeds= store.getBoolean(PreferenceConstants.EDITOR_FOLDING_SYNCHRONIZEDS); |
939 |
fCollapseUnnameds= store.getBoolean(PreferenceConstants.EDITOR_FOLDING_UNNAMEDS); |
874 |
} |
940 |
} |
875 |
|
941 |
|
876 |
private void update(FoldingStructureComputationContext ctx) { |
942 |
private void update(FoldingStructureComputationContext ctx) { |
Lines 1026-1031
public class DefaultJavaFoldingStructureProvider implements IJavaFoldingStructur
Link Here
|
1026 |
IRegion[] regions= computeProjectionRanges((ISourceReference) element, ctx); |
1092 |
IRegion[] regions= computeProjectionRanges((ISourceReference) element, ctx); |
1027 |
if (regions.length > 0) { |
1093 |
if (regions.length > 0) { |
1028 |
// comments |
1094 |
// comments |
|
|
1095 |
int commentsLength= 0; |
1029 |
for (int i= 0; i < regions.length - 1; i++) { |
1096 |
for (int i= 0; i < regions.length - 1; i++) { |
1030 |
IRegion normalized= alignRegion(regions[i], ctx); |
1097 |
IRegion normalized= alignRegion(regions[i], ctx); |
1031 |
if (normalized != null) { |
1098 |
if (normalized != null) { |
Lines 1040-1055
public class DefaultJavaFoldingStructureProvider implements IJavaFoldingStructur
Link Here
|
1040 |
ctx.addProjectionRange(new JavaProjectionAnnotation(commentCollapse, element, true), position); |
1107 |
ctx.addProjectionRange(new JavaProjectionAnnotation(commentCollapse, element, true), position); |
1041 |
} |
1108 |
} |
1042 |
} |
1109 |
} |
|
|
1110 |
if (normalized != null) |
1111 |
commentsLength+= normalized.getLength(); |
1043 |
} |
1112 |
} |
1044 |
// code |
1113 |
// code |
1045 |
if (collapseCode) { |
1114 |
if (collapseCode) { |
1046 |
IRegion normalized= alignRegion(regions[regions.length - 1], ctx); |
1115 |
IRegion normalized= alignRegion(regions[regions.length - 1], ctx); |
1047 |
if (normalized != null) { |
1116 |
if (normalized != null) { |
1048 |
Position position= element instanceof IMember ? createMemberPosition(normalized, (IMember) element) : createCommentPosition(normalized); |
1117 |
Position position= element instanceof IMember ? createMemberPosition(normalized, (IMember) element) : createCommentPosition(normalized); |
1049 |
if (position != null) |
1118 |
if (position != null) { |
1050 |
ctx.addProjectionRange(new JavaProjectionAnnotation(collapse, element, false), position); |
1119 |
ctx.addProjectionRange(new JavaProjectionAnnotation(collapse, element, false), position); |
|
|
1120 |
computeCodeBlockFoldingStructure(element, ctx, normalized, commentsLength); |
1121 |
} |
1122 |
} |
1123 |
} |
1124 |
} |
1125 |
} |
1126 |
|
1127 |
private void computeCodeBlockFoldingStructure(IJavaElement element, FoldingStructureComputationContext ctx, IRegion region, int commentsLength) { |
1128 |
try { |
1129 |
ISourceReference srcRef= (ISourceReference) element; |
1130 |
String contents= null; |
1131 |
try { |
1132 |
contents= srcRef.getSource(); |
1133 |
} catch (JavaModelException e) { |
1134 |
} |
1135 |
|
1136 |
int pos= 0; |
1137 |
boolean inSingleLineComment= false; |
1138 |
boolean inBlockComment= false; |
1139 |
boolean inCharLiteral= false; |
1140 |
boolean inString= false; |
1141 |
String lastBlockToken= ""; //$NON-NLS-1$ |
1142 |
while (pos < contents.length()) { |
1143 |
if (contents.charAt(pos) == '/') { |
1144 |
if (contents.charAt(pos + 1) == '/') { // Java comment |
1145 |
if (!inBlockComment && !inString && !inCharLiteral) |
1146 |
inSingleLineComment= true; |
1147 |
} |
1148 |
else if (contents.charAt(pos + 1) == '*') { // Java block comment |
1149 |
if (!inBlockComment && !inString && !inSingleLineComment && !inCharLiteral) { |
1150 |
inBlockComment= true; |
1151 |
int subpos= ++pos; |
1152 |
while (true) { |
1153 |
if (contents.charAt(subpos) == '*') { |
1154 |
if (contents.charAt(subpos + 1) == '/') { |
1155 |
subpos++; |
1156 |
break; |
1157 |
} |
1158 |
} |
1159 |
subpos++; |
1160 |
} |
1161 |
subpos++; |
1162 |
IRegion normalized= alignRegion(new Region(region.getOffset() + pos - commentsLength, subpos - pos), ctx); |
1163 |
if (normalized != null) { |
1164 |
Position position= createCommentPosition(normalized); |
1165 |
ctx.addProjectionRange(new JavaProjectionAnnotation(ctx.collapseJavadoc(), element, true), position); |
1166 |
} |
1167 |
} |
1168 |
} |
1169 |
} |
1170 |
else if (contents.charAt(pos) == '*') { |
1171 |
if (contents.charAt(pos + 1) == '/') { // End of java block comment |
1172 |
inBlockComment= false; |
1173 |
} |
1174 |
} |
1175 |
else if (contents.charAt(pos) == '\'') { // Character literal |
1176 |
if (!inString && !inSingleLineComment && !inBlockComment) |
1177 |
inCharLiteral= !inCharLiteral; |
1178 |
} |
1179 |
else if (contents.charAt(pos) == '"') { // String |
1180 |
if (!inCharLiteral && !inSingleLineComment && !inBlockComment) |
1181 |
inString= !inString; |
1182 |
} |
1183 |
else if (contents.charAt(pos) == '\n' || contents.charAt(pos) == '\r') { // New line or carriage return |
1184 |
inSingleLineComment= false; |
1185 |
} |
1186 |
else if (!inSingleLineComment && !inBlockComment && !inString && !inCharLiteral) { |
1187 |
if (contents.charAt(pos) == '{') { |
1188 |
/* |
1189 |
if (lastBlockToken == "") { //$NON-NLS-1$ |
1190 |
int level= 0; |
1191 |
int subpos= pos; |
1192 |
subpos++; |
1193 |
pos= subpos; |
1194 |
while (level != -1) { |
1195 |
if (contents.charAt(subpos) == '{') { |
1196 |
level++; |
1197 |
} |
1198 |
else if (contents.charAt(subpos) == '}') { |
1199 |
level--; |
1200 |
} |
1201 |
subpos++; |
1202 |
} |
1203 |
IRegion normalized= alignRegion(new Region(region.getOffset() + pos - commentsLength, subpos - pos), ctx); |
1204 |
if (normalized != null) { |
1205 |
Position position= new Position(normalized.getOffset(), normalized.getLength()); |
1206 |
ctx.addProjectionRange(new JavaProjectionAnnotation(ctx.collapseUnnameds(), element, false), position); |
1207 |
} |
1208 |
} |
1209 |
*/ |
1210 |
} |
1211 |
else if (contents.charAt(pos) == 'c') { |
1212 |
if (contents.charAt(pos + 1) == 'a') { |
1213 |
if (contents.charAt(pos + 2) == 't') { |
1214 |
if (contents.charAt(pos + 3) == 'c') { |
1215 |
if (contents.charAt(pos + 4) == 'h') { // catch |
1216 |
lastBlockToken= "catch"; //$NON-NLS-1$ |
1217 |
pos += "catch".length() - 1; //$NON-NLS-1$ |
1218 |
int level= 0; |
1219 |
int subpos= pos; |
1220 |
while (contents.charAt(subpos) != '{') { |
1221 |
subpos++; |
1222 |
} |
1223 |
subpos++; |
1224 |
pos= subpos; |
1225 |
while (level != -1) { |
1226 |
if (contents.charAt(subpos) == '{') { |
1227 |
level++; |
1228 |
} |
1229 |
else if (contents.charAt(subpos) == '}') { |
1230 |
level--; |
1231 |
} |
1232 |
subpos++; |
1233 |
} |
1234 |
IRegion normalized= alignRegion(new Region(region.getOffset() + pos - commentsLength, subpos - pos), ctx); |
1235 |
if (normalized != null) { |
1236 |
Position position= new Position(normalized.getOffset(), normalized.getLength()); |
1237 |
ctx.addProjectionRange(new JavaProjectionAnnotation(ctx.collapseTrys(), element, false), position); |
1238 |
} |
1239 |
} |
1240 |
} |
1241 |
} |
1242 |
} |
1243 |
} |
1244 |
else if (contents.charAt(pos) == 'd') { |
1245 |
if (contents.charAt(pos + 1) == 'o') { // do |
1246 |
lastBlockToken= "do"; //$NON-NLS-1$ |
1247 |
pos += "do".length() - 1; //$NON-NLS-1$ |
1248 |
int level= 0; |
1249 |
int subpos= pos; |
1250 |
while (contents.charAt(subpos) != '{') { |
1251 |
subpos++; |
1252 |
} |
1253 |
subpos++; |
1254 |
pos= subpos; |
1255 |
while (level != -1) { |
1256 |
if (contents.charAt(subpos) == '{') { |
1257 |
level++; |
1258 |
} |
1259 |
else if (contents.charAt(subpos) == '}') { |
1260 |
level--; |
1261 |
} |
1262 |
subpos++; |
1263 |
} |
1264 |
IRegion normalized= alignRegion(new Region(region.getOffset() + pos - commentsLength, subpos - pos), ctx); |
1265 |
if (normalized != null) { |
1266 |
Position position= new Position(normalized.getOffset(), normalized.getLength()); |
1267 |
ctx.addProjectionRange(new JavaProjectionAnnotation(ctx.collapseLoops(), element, false), position); |
1268 |
} |
1269 |
} |
1270 |
} |
1271 |
else if (contents.charAt(pos) == 'e') { |
1272 |
if (contents.charAt(pos + 1) == 'l') { |
1273 |
if (contents.charAt(pos + 2) == 's') { |
1274 |
if (contents.charAt(pos + 3) == 'e') { // else |
1275 |
lastBlockToken= "else"; //$NON-NLS-1$ |
1276 |
int subpos= pos; |
1277 |
while (contents.charAt(subpos) != '{' && contents.charAt(subpos) != ';') { |
1278 |
subpos++; |
1279 |
} |
1280 |
if (contents.charAt(subpos) == '{') { |
1281 |
lastBlockToken= ""; //$NON-NLS-1$ |
1282 |
int level= 0; |
1283 |
subpos++; |
1284 |
while (level != -1) { |
1285 |
if (contents.charAt(subpos) == '{') { |
1286 |
level++; |
1287 |
} |
1288 |
else if (contents.charAt(subpos) == '}') { |
1289 |
level--; |
1290 |
} |
1291 |
subpos++; |
1292 |
} |
1293 |
IRegion normalized= alignRegion(new Region(region.getOffset() + pos - commentsLength, subpos - pos), ctx); |
1294 |
if (normalized != null) { |
1295 |
Position position= new Position(normalized.getOffset(), normalized.getLength()); |
1296 |
ctx.addProjectionRange(new JavaProjectionAnnotation(ctx.collapseConditionals(), element, false), position); |
1297 |
} |
1298 |
} |
1299 |
} |
1300 |
} |
1301 |
} |
1302 |
} |
1303 |
else if (contents.charAt(pos) == 'f') { |
1304 |
if (contents.charAt(pos + 1) == 'i') { |
1305 |
if (contents.charAt(pos + 2) == 'n') { |
1306 |
if (contents.charAt(pos + 3) == 'a') { |
1307 |
if (contents.charAt(pos + 4) == 'l') { |
1308 |
if (contents.charAt(pos + 5) == 'l') { |
1309 |
if (contents.charAt(pos + 6) == 'y') { // finally |
1310 |
lastBlockToken= "finally"; //$NON-NLS-1$ |
1311 |
pos += "finally".length() - 1; //$NON-NLS-1$ |
1312 |
int level= 0; |
1313 |
int subpos= pos; |
1314 |
while (contents.charAt(subpos) != '{') { |
1315 |
subpos++; |
1316 |
} |
1317 |
subpos++; |
1318 |
pos= subpos; |
1319 |
while (level != -1) { |
1320 |
if (contents.charAt(subpos) == '{') { |
1321 |
lastBlockToken= ""; //$NON-NLS-1$ |
1322 |
level++; |
1323 |
} |
1324 |
else if (contents.charAt(subpos) == '}') { |
1325 |
level--; |
1326 |
} |
1327 |
subpos++; |
1328 |
} |
1329 |
IRegion normalized= alignRegion(new Region(region.getOffset() + pos - commentsLength, subpos - pos), ctx); |
1330 |
if (normalized != null) { |
1331 |
Position position= new Position(normalized.getOffset(), normalized.getLength()); |
1332 |
ctx.addProjectionRange(new JavaProjectionAnnotation(ctx.collapseTrys(), element, false), position); |
1333 |
} |
1334 |
} |
1335 |
} |
1336 |
} |
1337 |
} |
1338 |
} |
1339 |
} |
1340 |
else if (contents.charAt(pos + 1) == 'o') { |
1341 |
if (contents.charAt(pos + 2) == 'r') { // for |
1342 |
lastBlockToken= "for"; //$NON-NLS-1$ |
1343 |
int subpos= pos; |
1344 |
while (contents.charAt(subpos) != '(') { |
1345 |
subpos++; |
1346 |
} |
1347 |
int plevel= 0; |
1348 |
subpos++; |
1349 |
while (plevel != -1) { |
1350 |
if (contents.charAt(subpos) == '(') { |
1351 |
plevel++; |
1352 |
} |
1353 |
else if (contents.charAt(subpos) == ')') { |
1354 |
plevel--; |
1355 |
} |
1356 |
subpos++; |
1357 |
} |
1358 |
while (contents.charAt(subpos) != '{' && contents.charAt(subpos) != ';') { |
1359 |
subpos++; |
1360 |
} |
1361 |
if (contents.charAt(subpos) == '{') { |
1362 |
lastBlockToken= ""; //$NON-NLS-1$ |
1363 |
int level= 0; |
1364 |
subpos++; |
1365 |
while (level != -1) { |
1366 |
if (contents.charAt(subpos) == '{') { |
1367 |
level++; |
1368 |
} |
1369 |
else if (contents.charAt(subpos) == '}') { |
1370 |
level--; |
1371 |
} |
1372 |
subpos++; |
1373 |
} |
1374 |
IRegion normalized= alignRegion(new Region(region.getOffset() + pos - commentsLength, subpos - pos), ctx); |
1375 |
if (normalized != null) { |
1376 |
Position position= new Position(normalized.getOffset(), normalized.getLength()); |
1377 |
ctx.addProjectionRange(new JavaProjectionAnnotation(ctx.collapseLoops(), element, false), position); |
1378 |
} |
1379 |
} |
1380 |
} |
1381 |
} |
1382 |
} |
1383 |
else if (contents.charAt(pos) == 'i') { |
1384 |
if (contents.charAt(pos + 1) == 'f') { // if |
1385 |
lastBlockToken= "if"; //$NON-NLS-1$ |
1386 |
int subpos= pos; |
1387 |
while (contents.charAt(subpos) != '{' && contents.charAt(subpos) != ';') { |
1388 |
subpos++; |
1389 |
} |
1390 |
if (contents.charAt(subpos) == '{') { |
1391 |
lastBlockToken= ""; //$NON-NLS-1$ |
1392 |
int level= 0; |
1393 |
subpos++; |
1394 |
while (level != -1) { |
1395 |
if (contents.charAt(subpos) == '{') { |
1396 |
level++; |
1397 |
} |
1398 |
else if (contents.charAt(subpos) == '}') { |
1399 |
level--; |
1400 |
} |
1401 |
subpos++; |
1402 |
} |
1403 |
IRegion normalized= alignRegion(new Region(region.getOffset() + pos - commentsLength, subpos - pos), ctx); |
1404 |
if (normalized != null) { |
1405 |
Position position= new Position(normalized.getOffset(), normalized.getLength()); |
1406 |
ctx.addProjectionRange(new JavaProjectionAnnotation(ctx.collapseConditionals(), element, false), position); |
1407 |
} |
1408 |
} |
1409 |
} |
1410 |
} |
1411 |
else if (contents.charAt(pos) == 's') { |
1412 |
if (contents.charAt(pos + 1) == 'w') { |
1413 |
if (contents.charAt(pos + 2) == 'i') { |
1414 |
if (contents.charAt(pos + 3) == 't') { |
1415 |
if (contents.charAt(pos + 4) == 'c') { |
1416 |
if (contents.charAt(pos + 5) == 'h') { // switch |
1417 |
lastBlockToken= "switch"; //$NON-NLS-1$ |
1418 |
int subpos= pos; |
1419 |
while (contents.charAt(subpos) != '{') { |
1420 |
subpos++; |
1421 |
} |
1422 |
if (contents.charAt(subpos) == '{') { |
1423 |
lastBlockToken= ""; //$NON-NLS-1$ |
1424 |
int level= 0; |
1425 |
subpos++; |
1426 |
while (level != -1) { |
1427 |
if (contents.charAt(subpos) == '{') { |
1428 |
level++; |
1429 |
} |
1430 |
else if (contents.charAt(subpos) == '}') { |
1431 |
level--; |
1432 |
} |
1433 |
subpos++; |
1434 |
} |
1435 |
} |
1436 |
IRegion normalized= alignRegion(new Region(region.getOffset() + pos - commentsLength, subpos - pos), ctx); |
1437 |
if (normalized != null) { |
1438 |
Position position= new Position(normalized.getOffset(), normalized.getLength()); |
1439 |
ctx.addProjectionRange(new JavaProjectionAnnotation(ctx.collapseSwitches(), element, false), position); |
1440 |
} |
1441 |
} |
1442 |
} |
1443 |
} |
1444 |
} |
1445 |
} |
1446 |
else if (contents.charAt(pos + 1) == 'y') { |
1447 |
if (contents.charAt(pos + 2) == 'n') { |
1448 |
if (contents.charAt(pos + 3) == 'c') { |
1449 |
if (contents.charAt(pos + 4) == 'h') { |
1450 |
if (contents.charAt(pos + 5) == 'r') { |
1451 |
if (contents.charAt(pos + 6) == 'o') { |
1452 |
if (contents.charAt(pos + 7) == 'n') { |
1453 |
if (contents.charAt(pos + 8) == 'i') { |
1454 |
if (contents.charAt(pos + 9) == 'z') { |
1455 |
if (contents.charAt(pos + 10) == 'e') { |
1456 |
if (contents.charAt(pos + 11) == 'd') { // synchronized |
1457 |
lastBlockToken= "synchronized"; //$NON-NLS-1$ |
1458 |
int subpos= pos; |
1459 |
while (contents.charAt(subpos) != '{') { |
1460 |
subpos++; |
1461 |
} |
1462 |
if (contents.charAt(subpos) == '{') { |
1463 |
lastBlockToken= ""; //$NON-NLS-1$ |
1464 |
int level= 0; |
1465 |
subpos++; |
1466 |
while (level != -1) { |
1467 |
if (contents.charAt(subpos) == '{') { |
1468 |
level++; |
1469 |
} |
1470 |
else if (contents.charAt(subpos) == '}') { |
1471 |
level--; |
1472 |
} |
1473 |
subpos++; |
1474 |
} |
1475 |
} |
1476 |
IRegion normalized= alignRegion(new Region(region.getOffset() + pos - commentsLength, subpos - pos), ctx); |
1477 |
if (normalized != null) { |
1478 |
Position position= new Position(normalized.getOffset(), normalized.getLength()); |
1479 |
ctx.addProjectionRange(new JavaProjectionAnnotation(ctx.collapseSynchronizeds(), element, false), position); |
1480 |
} |
1481 |
} |
1482 |
} |
1483 |
} |
1484 |
} |
1485 |
} |
1486 |
} |
1487 |
} |
1488 |
} |
1489 |
} |
1490 |
} |
1491 |
} |
1492 |
} |
1493 |
else if (contents.charAt(pos) == 't') { |
1494 |
if (contents.charAt(pos + 1) == 'r') { |
1495 |
if (contents.charAt(pos + 2) == 'y') { // try |
1496 |
lastBlockToken= "try"; //$NON-NLS-1$ |
1497 |
pos += "try".length() - 1; //$NON-NLS-1$ |
1498 |
int level= 0; |
1499 |
int subpos= pos; |
1500 |
while (contents.charAt(subpos) != '{') { |
1501 |
subpos++; |
1502 |
} |
1503 |
lastBlockToken= ""; //$NON-NLS-1$ |
1504 |
subpos++; |
1505 |
pos= subpos; |
1506 |
while (level != -1) { |
1507 |
if (contents.charAt(subpos) == '{') { |
1508 |
level++; |
1509 |
} |
1510 |
else if (contents.charAt(subpos) == '}') { |
1511 |
level--; |
1512 |
} |
1513 |
subpos++; |
1514 |
} |
1515 |
IRegion normalized= alignRegion(new Region(region.getOffset() + pos - commentsLength, subpos - pos), ctx); |
1516 |
if (normalized != null) { |
1517 |
Position position= new Position(normalized.getOffset(), normalized.getLength()); |
1518 |
ctx.addProjectionRange(new JavaProjectionAnnotation(ctx.collapseTrys(), element, false), position); |
1519 |
} |
1520 |
} |
1521 |
} |
1522 |
} |
1523 |
else if (contents.charAt(pos) == 'w') { |
1524 |
if (contents.charAt(pos + 1) == 'h') { |
1525 |
if (contents.charAt(pos + 2) == 'i') { |
1526 |
if (contents.charAt(pos + 3) == 'l') { |
1527 |
if (contents.charAt(pos + 4) == 'e') { // while |
1528 |
lastBlockToken= "while"; //$NON-NLS-1$ |
1529 |
int subpos= pos; |
1530 |
while (contents.charAt(subpos) != '{' && contents.charAt(subpos) != ';') { |
1531 |
subpos++; |
1532 |
} |
1533 |
if (contents.charAt(subpos) == '{') { |
1534 |
lastBlockToken= ""; //$NON-NLS-1$ |
1535 |
int level= 0; |
1536 |
subpos++; |
1537 |
while (level != -1) { |
1538 |
if (contents.charAt(subpos) == '{') { |
1539 |
level++; |
1540 |
} |
1541 |
else if (contents.charAt(subpos) == '}') { |
1542 |
level--; |
1543 |
} |
1544 |
subpos++; |
1545 |
} |
1546 |
IRegion normalized= alignRegion(new Region(region.getOffset() + pos - commentsLength, subpos - pos), ctx); |
1547 |
if (normalized != null) { |
1548 |
Position position= new Position(normalized.getOffset(), normalized.getLength()); |
1549 |
ctx.addProjectionRange(new JavaProjectionAnnotation(ctx.collapseLoops(), element, false), position); |
1550 |
} |
1551 |
} |
1552 |
} |
1553 |
} |
1554 |
} |
1555 |
} |
1556 |
} |
1051 |
} |
1557 |
} |
|
|
1558 |
pos++; |
1052 |
} |
1559 |
} |
|
|
1560 |
} catch (StringIndexOutOfBoundsException exception) { |
1053 |
} |
1561 |
} |
1054 |
} |
1562 |
} |
1055 |
|
1563 |
|
1056 |
- |
|
|