I occasionally receive BadLocationException when monitor the partitions, after documentChanged2 is applied,
protected IDocument createDocument(Object element) throws CoreException {
final IDocument document = super.createDocument(element);
if (document != null) {
IDocumentPartitioner partitioner =new FastPartitioner() {
public IRegion documentChanged2(DocumentEvent e) {
IRegion result = super.documentChanged2(e);
for (String cat : document.getPositionCategories()) {
System.out.println(" " + cat); // __navigation_2108906030
for (Position p: document.getPositions(cat)) {
System.out.print(" " + p); // offset: 5, length: 0
int line = document.getLineOfOffset(p.getOffset()); // BadLocationException
int col = p.getOffset() - document.getLineOffset(line);
System.out.println(", (line:"+(line+1) + ", col:"+col +")");
return result;
}}
I receive BadLocationException at document.getLineOfOffset(p.getOffset())
because my document is only 2 characters long whereas p.offset = 5 for category How is this possible? What am I doing wrong?
[Updated on: Sat, 15 March 2014 07:53]
Report message to a moderator