public void testRangeContaining1() { RangeSet<Integer> rangeSet = TreeRangeSet.create(); rangeSet.add(Range.closed(3, 10)); assertEquals(Range.closed(3, 10), rangeSet.rangeContaining(5)); assertTrue(rangeSet.contains(5)); assertNull(rangeSet.rangeContaining(1)); assertFalse(rangeSet.contains(1)); }
public void testRangeContaining2() { RangeSet<Integer> rangeSet = TreeRangeSet.create(); rangeSet.add(Range.closed(3, 10)); rangeSet.remove(Range.open(5, 7)); assertEquals(Range.closed(3, 5), rangeSet.rangeContaining(5)); assertTrue(rangeSet.contains(5)); assertEquals(Range.closed(7, 10), rangeSet.rangeContaining(8)); assertTrue(rangeSet.contains(8)); assertNull(rangeSet.rangeContaining(6)); assertFalse(rangeSet.contains(6)); }
/** * Expand a token range to start and end on acceptable boundaries for re-formatting. * * @param iRange the {@link Range} of tokens * @return the expanded token range */ private Range<Integer> expandToBreakableRegions(Range<Integer> iRange) { // The original line range. int loTok = iRange.lowerEndpoint(); int hiTok = iRange.upperEndpoint() - 1; // Expand the token indices to formattable boundaries (e.g. edges of statements). if (!partialFormatRanges.contains(loTok) || !partialFormatRanges.contains(hiTok)) { return EMPTY_RANGE; } loTok = partialFormatRanges.rangeContaining(loTok).lowerEndpoint(); hiTok = partialFormatRanges.rangeContaining(hiTok).upperEndpoint(); return Range.closedOpen(loTok, hiTok + 1); }
/** * Checks given position is part of deleted-range and returns next position of upper-end as all the messages are * deleted up to that point. * * @param position * @return next available position */ public PositionImpl getNextAvailablePosition(PositionImpl position) { Range<PositionImpl> range = individualDeletedMessages.rangeContaining(position); if (range != null) { PositionImpl nextPosition = range.upperEndpoint().getNext(); return (nextPosition != null && nextPosition.compareTo(position) > 0) ? nextPosition : position.getNext(); } return position.getNext(); }
private Optional<Description> generateFix(String replacement) { int startPosition = getStartPosition(getCurrentPath().getLeaf(), state); if (emittedFixes.contains(startPosition)) { // We already emitted a fix surrounding this location. return Optional.empty(); } Range<Integer> containingPre = preTags.rangeContaining(startPosition); if (containingPre == null) { return reportAll ? Optional.of(replacementFix(replacement)) : Optional.empty(); } if (emittedFixes.intersects(containingPre)) { return Optional.empty(); } emittedFixes.add(containingPre); SuggestedFix fix = wrapInCodeTag(containingPre); return Optional.of( buildDescription(diagnosticPosition(getCurrentPath(), state)) .setMessage( "This HTML entity is invalid. Enclosing the code in this <pre>/<code> tag with" + " a {@code } block will force Javadoc to interpret HTML literally.") .addFix(fix) .build()); }
continue; Range<Integer> containingPre = preTags.rangeContaining(range.lowerEndpoint()); if (containingPre == null) { containingPre = range;
if (individualDeletedMessages.contains(positionAfterNewMarkDelete)) { Range<PositionImpl> rangeToBeMarkDeleted = individualDeletedMessages .rangeContaining(positionAfterNewMarkDelete); newMarkDeletePosition = rangeToBeMarkDeleted.upperEndpoint();
void testViewAgainstExpected(RangeSet<Integer> expected, RangeSet<Integer> view) { assertEquals(expected, view); assertEquals(expected.asRanges(), view.asRanges()); assertEquals(expected.isEmpty(), view.isEmpty()); if (!expected.isEmpty()) { assertEquals(expected.span(), view.span()); } for (int i = MIN_BOUND - 1; i <= MAX_BOUND + 1; i++) { assertEquals(expected.contains(i), view.contains(i)); assertEquals(expected.rangeContaining(i), view.rangeContaining(i)); } testEnclosing(view); if (view instanceof TreeRangeSet) { testRangesByLowerBounds((TreeRangeSet<Integer>) view, expected.asRanges()); } }
/** * Return the unique range for {@code key} that contains {@code value} * or {@code null} if it does not exist. * * @param key * @param value * @return the range containing {@code value} for {@code key} */ public Range<Value> get(Text key, Value value) { RangeSet<Value> set = ranges.get(key); if(set != null) { return set.rangeContaining(value); } else { return null; } }
/** * Expand a token range to start and end on acceptable boundaries for re-formatting. * * @param iRange the {@link Range} of tokens * @return the expanded token range */ private Range<Integer> expandToBreakableRegions(Range<Integer> iRange) { // The original line range. int loTok = iRange.lowerEndpoint(); int hiTok = iRange.upperEndpoint() - 1; // Expand the token indices to formattable boundaries (e.g. edges of statements). if (!partialFormatRanges.contains(loTok) || !partialFormatRanges.contains(hiTok)) { return EMPTY_RANGE; } loTok = partialFormatRanges.rangeContaining(loTok).lowerEndpoint(); hiTok = partialFormatRanges.rangeContaining(hiTok).upperEndpoint(); return Range.closedOpen(loTok, hiTok + 1); }
/** * Checks given position is part of deleted-range and returns next position of upper-end as all the messages are * deleted up to that point. * * @param position * @return next available position */ public PositionImpl getNextAvailablePosition(PositionImpl position) { Range<PositionImpl> range = individualDeletedMessages.rangeContaining(position); if (range != null) { PositionImpl nextPosition = range.upperEndpoint().getNext(); return (nextPosition != null && nextPosition.compareTo(position) > 0) ? nextPosition : position.getNext(); } return position.getNext(); }
/** * Checks given position is part of deleted-range and returns next position of upper-end as all the messages are * deleted up to that point * * @param position * @return next available position */ public PositionImpl getNextAvailablePosition(PositionImpl position) { Range<PositionImpl> range = individualDeletedMessages.rangeContaining(position); if (range != null) { PositionImpl nextPosition = range.upperEndpoint().getNext(); return (nextPosition != null && nextPosition.compareTo(position) > 0) ? nextPosition : position.getNext(); } return position.getNext(); }
public void testRangeContaining1() { RangeSet<Integer> rangeSet = TreeRangeSet.create(); rangeSet.add(Range.closed(3, 10)); assertEquals(Range.closed(3, 10), rangeSet.rangeContaining(5)); assertTrue(rangeSet.contains(5)); assertNull(rangeSet.rangeContaining(1)); assertFalse(rangeSet.contains(1)); }
public void testRangeContaining2() { RangeSet<Integer> rangeSet = TreeRangeSet.create(); rangeSet.add(Range.closed(3, 10)); rangeSet.remove(Range.open(5, 7)); assertEquals(Range.closed(3, 5), rangeSet.rangeContaining(5)); assertTrue(rangeSet.contains(5)); assertEquals(Range.closed(7, 10), rangeSet.rangeContaining(8)); assertTrue(rangeSet.contains(8)); assertNull(rangeSet.rangeContaining(6)); assertFalse(rangeSet.contains(6)); }
if (individualDeletedMessages.contains(positionAfterNewMarkDelete)) { Range<PositionImpl> rangeToBeMarkDeleted = individualDeletedMessages .rangeContaining(positionAfterNewMarkDelete); newMarkDeletePosition = rangeToBeMarkDeleted.upperEndpoint();
if (individualDeletedMessages.contains(positionAfterNewMarkDelete)) { Range<PositionImpl> rangeToBeMarkDeleted = individualDeletedMessages .rangeContaining(positionAfterNewMarkDelete); newMarkDeletePosition = rangeToBeMarkDeleted.upperEndpoint();
void testViewAgainstExpected(RangeSet<Integer> expected, RangeSet<Integer> view) { assertEquals(expected, view); assertEquals(expected.asRanges(), view.asRanges()); assertEquals(expected.isEmpty(), view.isEmpty()); if (!expected.isEmpty()) { assertEquals(expected.span(), view.span()); } for (int i = MIN_BOUND - 1; i <= MAX_BOUND + 1; i++) { assertEquals(expected.contains(i), view.contains(i)); assertEquals(expected.rangeContaining(i), view.rangeContaining(i)); } testEnclosing(view); if (view instanceof TreeRangeSet) { testRangesByLowerBounds((TreeRangeSet<Integer>) view, expected.asRanges()); } }