Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » How is BadLocationException possible?
How is BadLocationException possible? [message #1271469] Sat, 15 March 2014 07:47 Go to next message
valentin Mising name is currently offline valentin Mising nameFriend
Messages: 38
Registered: December 2011
Member
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
__navigation_2108906030
How is this possible? What am I doing wrong?

[Updated on: Sat, 15 March 2014 07:53]

Report message to a moderator

Re: How is BadLocationException possible? [message #1273868 is a reply to message #1271469] Thu, 20 March 2014 17:10 Go to previous message
valentin Mising name is currently offline valentin Mising nameFriend
Messages: 38
Registered: December 2011
Member
I was responded on IRC that I should avoid looking into extrusions partitions, those which have categories that I had not declared in my partitioner.
Previous Topic:[CNF] excludes takes precedence over includes
Next Topic:Adding RunAs action into a plugin product
Goto Forum:
  


Current Time: Thu Apr 25 08:33:42 GMT 2024

Powered by FUDForum. Page generated in 0.04827 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top