Mercurial > projects > dwt-addons
comparison dwtx/jface/text/rules/RuleBasedPartitioner.d @ 134:51e6e63f930e
Regex fix for casts
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Sun, 24 Aug 2008 01:46:20 +0200 |
parents | 7d818bd32d63 |
children | b6bad70d540a |
comparison
equal
deleted
inserted
replaced
133:7d818bd32d63 | 134:51e6e63f930e |
---|---|
331 | 331 |
332 lastScannedPosition= start + length - 1; | 332 lastScannedPosition= start + length - 1; |
333 | 333 |
334 // remove all affected positions | 334 // remove all affected positions |
335 while (first < category.length) { | 335 while (first < category.length) { |
336 TypedPosition p= (TypedPosition) category[first]; | 336 TypedPosition p= cast(TypedPosition) category[first]; |
337 if (lastScannedPosition >= p.offset + p.length || | 337 if (lastScannedPosition >= p.offset + p.length || |
338 (p.overlapsWith(start, length) && | 338 (p.overlapsWith(start, length) && |
339 (!d.containsPosition(fPositionCategory, start, length) || | 339 (!d.containsPosition(fPositionCategory, start, length) || |
340 !contentType.equals(p.getType())))) { | 340 !contentType.equals(p.getType())))) { |
341 | 341 |
370 } | 370 } |
371 first= d.computeIndexInCategory(fPositionCategory, lastScannedPosition); | 371 first= d.computeIndexInCategory(fPositionCategory, lastScannedPosition); |
372 | 372 |
373 TypedPosition p; | 373 TypedPosition p; |
374 while (first < category.length) { | 374 while (first < category.length) { |
375 p= (TypedPosition) category[first++]; | 375 p= cast(TypedPosition) category[first++]; |
376 d.removePosition(fPositionCategory, p); | 376 d.removePosition(fPositionCategory, p); |
377 rememberRegion(p.offset, p.length); | 377 rememberRegion(p.offset, p.length); |
378 } | 378 } |
379 | 379 |
380 } catch (BadPositionCategoryException x) { | 380 } catch (BadPositionCategoryException x) { |
406 if (category.length is 0) | 406 if (category.length is 0) |
407 return null; | 407 return null; |
408 | 408 |
409 if (index < category.length) { | 409 if (index < category.length) { |
410 if (offset is category[index].offset) | 410 if (offset is category[index].offset) |
411 return (TypedPosition) category[index]; | 411 return cast(TypedPosition) category[index]; |
412 } | 412 } |
413 | 413 |
414 if (index > 0) | 414 if (index > 0) |
415 index--; | 415 index--; |
416 | 416 |
417 return (TypedPosition) category[index]; | 417 return cast(TypedPosition) category[index]; |
418 | 418 |
419 } catch (BadPositionCategoryException x) { | 419 } catch (BadPositionCategoryException x) { |
420 } catch (BadLocationException x) { | 420 } catch (BadLocationException x) { |
421 } | 421 } |
422 | 422 |
450 | 450 |
451 int index= fDocument.computeIndexInCategory(fPositionCategory, offset); | 451 int index= fDocument.computeIndexInCategory(fPositionCategory, offset); |
452 | 452 |
453 if (index < category.length) { | 453 if (index < category.length) { |
454 | 454 |
455 TypedPosition next= (TypedPosition) category[index]; | 455 TypedPosition next= cast(TypedPosition) category[index]; |
456 | 456 |
457 if (offset is next.offset) | 457 if (offset is next.offset) |
458 return new TypedRegion(next.getOffset(), next.getLength(), next.getType()); | 458 return new TypedRegion(next.getOffset(), next.getLength(), next.getType()); |
459 | 459 |
460 if (index is 0) | 460 if (index is 0) |
461 return new TypedRegion(0, next.offset, IDocument.DEFAULT_CONTENT_TYPE); | 461 return new TypedRegion(0, next.offset, IDocument.DEFAULT_CONTENT_TYPE); |
462 | 462 |
463 TypedPosition previous= (TypedPosition) category[index - 1]; | 463 TypedPosition previous= cast(TypedPosition) category[index - 1]; |
464 if (previous.includes(offset)) | 464 if (previous.includes(offset)) |
465 return new TypedRegion(previous.getOffset(), previous.getLength(), previous.getType()); | 465 return new TypedRegion(previous.getOffset(), previous.getLength(), previous.getType()); |
466 | 466 |
467 int endOffset= previous.getOffset() + previous.getLength(); | 467 int endOffset= previous.getOffset() + previous.getLength(); |
468 return new TypedRegion(endOffset, next.getOffset() - endOffset, IDocument.DEFAULT_CONTENT_TYPE); | 468 return new TypedRegion(endOffset, next.getOffset() - endOffset, IDocument.DEFAULT_CONTENT_TYPE); |
469 } | 469 } |
470 | 470 |
471 TypedPosition previous= (TypedPosition) category[category.length - 1]; | 471 TypedPosition previous= cast(TypedPosition) category[category.length - 1]; |
472 if (previous.includes(offset)) | 472 if (previous.includes(offset)) |
473 return new TypedRegion(previous.getOffset(), previous.getLength(), previous.getType()); | 473 return new TypedRegion(previous.getOffset(), previous.getLength(), previous.getType()); |
474 | 474 |
475 int endOffset= previous.getOffset() + previous.getLength(); | 475 int endOffset= previous.getOffset() + previous.getLength(); |
476 return new TypedRegion(endOffset, fDocument.getLength() - endOffset, IDocument.DEFAULT_CONTENT_TYPE); | 476 return new TypedRegion(endOffset, fDocument.getLength() - endOffset, IDocument.DEFAULT_CONTENT_TYPE); |
522 * @return the token's content type | 522 * @return the token's content type |
523 */ | 523 */ |
524 protected String getTokenContentType(IToken token) { | 524 protected String getTokenContentType(IToken token) { |
525 Object data= token.getData(); | 525 Object data= token.getData(); |
526 if (data instanceof String) | 526 if (data instanceof String) |
527 return (String) data; | 527 return cast(String) data; |
528 return null; | 528 return null; |
529 } | 529 } |
530 | 530 |
531 /* zero-length partition support */ | 531 /* zero-length partition support */ |
532 | 532 |
574 int start, end, gapOffset; | 574 int start, end, gapOffset; |
575 Position gap= null; | 575 Position gap= null; |
576 | 576 |
577 for (int i= 0; i < category.length; i++) { | 577 for (int i= 0; i < category.length; i++) { |
578 | 578 |
579 current= (TypedPosition) category[i]; | 579 current= cast(TypedPosition) category[i]; |
580 | 580 |
581 gapOffset= (previous !is null) ? previous.getOffset() + previous.getLength() : 0; | 581 gapOffset= (previous !is null) ? previous.getOffset() + previous.getLength() : 0; |
582 gap= new Position(gapOffset, current.getOffset() - gapOffset); | 582 gap= new Position(gapOffset, current.getOffset() - gapOffset); |
583 if ((includeZeroLengthPartitions || gap.getLength() > 0) && gap.overlapsWith(offset, length)) { | 583 if ((includeZeroLengthPartitions || gap.getLength() > 0) && gap.overlapsWith(offset, length)) { |
584 start= Math.max(offset, gapOffset); | 584 start= Math.max(offset, gapOffset); |