/** * Returns a token list for the specified segment of text representing the specified line number. * This method is basically a wrapper for <code>tokenMaker.getTokenList</code> that takes into * account the last token on the previous line to assure token accuracy. * * @param line The line number of <code>text</code> in the document, >= 0. * @return A token list representing the specified line. */ public final Token getTokenListForLine(int line) { Element map = getDefaultRootElement(); Element elem = map.getElement(line); int startOffset = elem.getStartOffset(); // int endOffset = (line==map.getElementCount()-1 ? elem.getEndOffset() - 1: // elem.getEndOffset() - 1); int endOffset = elem.getEndOffset() - 1; // Why always "-1"? try { getText(startOffset, endOffset - startOffset, s); } catch (BadLocationException ble) { ble.printStackTrace(); return null; } int initialTokenType = line == 0 ? Token.NULL : getLastTokenTypeOnLine(line - 1); return tokenMaker.getTokenList(s, initialTokenType, startOffset); }