/** * Throws an exception. * * @param offset the illegal character or line offset that caused the exception * @throws BadLocationException always */ private void fail(int offset) throws BadLocationException { throw new BadLocationException(); }
/** * Throws an exception. * * @param offset the illegal character or line offset that caused the exception * @throws BadLocationException always */ private void fail(int offset) throws BadLocationException { throw new BadLocationException(); }
@Override public final int getLineLength(int line) throws BadLocationException { int lines= fLines.size(); if (line < 0 || line > lines) throw new BadLocationException(); if (lines == 0 || lines == line) return 0; Line l= fLines.get(line); return l.length; }
@Override public final String getLineDelimiter(int line) throws BadLocationException { int lines= fLines.size(); if (line < 0 || line > lines) throw new BadLocationException(); if (lines == 0) return null; if (line == lines) return null; Line l= fLines.get(line); return l.delimiter; }
@Override public final String getLineDelimiter(int line) throws BadLocationException { int lines= fLines.size(); if (line < 0 || line > lines) throw new BadLocationException(); if (lines == 0) return null; if (line == lines) return null; Line l= fLines.get(line); return l.delimiter; }
@Override public final int getLineLength(int line) throws BadLocationException { int lines= fLines.size(); if (line < 0 || line > lines) throw new BadLocationException(); if (lines == 0 || lines == line) return 0; Line l= fLines.get(line); return l.length; }
/** * Enforces the invariant that all positions must be disjoint. * * @param position the position to check * @throws BadLocationException if the disjointness check fails */ private void enforceDisjoint(LinkedPosition position) throws BadLocationException { for (LinkedPosition p : fPositions) { if (p.overlapsWith(position)) throw new BadLocationException(); } }
@Override public final int getNumberOfLines(int position, int length) throws BadLocationException { if (position < 0 || position + length > fTextLength) throw new BadLocationException(); if (length == 0) // optimization return 1; return getNumberOfLines(getLineNumberOfOffset(position), position, length); }
@Override public int computeIndexInCategory(String category, int offset) throws BadLocationException, BadPositionCategoryException { if (0 > offset || offset > getLength()) throw new BadLocationException(); List<Position> c= fPositions.get(category); if (c == null) throw new BadPositionCategoryException(); return computeIndexInPositionList(c, offset); }
@Override public int computeIndexInCategory(String category, int offset) throws BadLocationException, BadPositionCategoryException { if (0 > offset || offset > getLength()) throw new BadLocationException(); List<Position> c= fPositions.get(category); if (c == null) throw new BadPositionCategoryException(); return computeIndexInPositionList(c, offset); }
@Override public char getChar(int pos) throws BadLocationException { if ((0 > pos) || (pos >= getLength())) throw new BadLocationException(); return getStore().get(pos); }
@Override public char getChar(int pos) throws BadLocationException { if ((0 > pos) || (pos >= getLength())) throw new BadLocationException(); return getStore().get(pos); }
@Override public String get(int pos, int length) throws BadLocationException { int myLength= getLength(); if ((0 > pos) || (0 > length) || (pos + length > myLength)) throw new BadLocationException(); return getStore().get(pos, length); }
private final void checkOriginRegion(IRegion originRegion) throws BadLocationException { int offset= originRegion.getOffset(); int endOffset= inclusiveEnd(originRegion); int max= fMasterDocument.getLength(); if (offset < 0 || offset > max || endOffset < 0 || endOffset > max) throw new BadLocationException(); }
protected final void checkBadLocation(int offset) throws BadLocationException { ITextRegion lastRegion = getLastToken(); if (offset < 0 || lastRegion.getEnd() < offset) { throw new BadLocationException("offset " + offset + " is out of [0, " + lastRegion.getEnd() + "]"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ } }
@Override public final IRegion getLineInformationOfOffset(int position) throws BadLocationException { if (position > fTextLength) throw new BadLocationException("Offset > length: " + position + " > " + fTextLength); //$NON-NLS-1$//$NON-NLS-2$ if (position == fTextLength) { int size= fLines.size(); if (size == 0) return new Region(0, 0); Line l= fLines.get(size - 1); return (l.delimiter != null ? new Line(fTextLength, 0) : new Line(fTextLength - l.length, l.length)); } return getLineInformation(findLine(position)); }
private final void checkOriginRegion(IRegion originRegion) throws BadLocationException { int offset= originRegion.getOffset(); int endOffset= inclusiveEnd(originRegion); int max= fMasterDocument.getLength(); if (offset < 0 || offset > max || endOffset < 0 || endOffset > max) throw new BadLocationException(); }
@Override public String get(int pos, int length) throws BadLocationException { int myLength= getLength(); if ((0 > pos) || (0 > length) || (pos + length > myLength)) throw new BadLocationException(); return getStore().get(pos, length); }
@Override public boolean isLineInformationRepairNeeded(int offset, int length, String text) throws BadLocationException { if ((0 > offset) || (0 > length) || (offset + length > getLength())) throw new BadLocationException(); return isLineInformationRepairNeeded(text) || isLineInformationRepairNeeded(get(offset, length)); }
@Override public boolean isLineInformationRepairNeeded(int offset, int length, String text) throws BadLocationException { if ((0 > offset) || (0 > length) || (offset + length > getLength())) throw new BadLocationException(); return isLineInformationRepairNeeded(text) || isLineInformationRepairNeeded(get(offset, length)); }