* Contributors:
* Igor Malinin - initial contribution
*
- * $Id: OuterDocumentView.java,v 1.3 2004-09-25 22:42:52 jsurfer Exp $
+ * $Id: OuterDocumentView.java,v 1.5 2006-10-21 23:13:53 pombredanne Exp $
*/
package net.sourceforge.phpeclipse.ui.text.rules;
setTextStore(new TextStore());
setLineTracker(new DefaultLineTracker());
int length = getLength();
- if (length<0) {
- length = 0;
+ if (length < 0) {
+ length = 0;
}
getTracker().set(getStore().get(0, length));
-
+
completeInitialization();
}
-// public void addRange(Position range) {
-// DocumentEvent event = new DocumentEvent(this,
-// getLocalOffset(range.offset), range.length, "");
-// fireDocumentAboutToBeChanged(event);
-// ranges.add(-getIndex(range) - 1, range);
-// fireDocumentChanged(event);
-// }
-//
-// public void removeRange(Position range) {
-// String text;
-// try {
-// text = parent.get(range.offset, range.length);
-// } catch (BadLocationException e) {
-// return;
-// }
-// DocumentEvent event = new DocumentEvent(this,
-// getLocalOffset(range.offset), 0, text);
-// fireDocumentAboutToBeChanged(event);
-// deleteRange(range);
-// fireDocumentChanged(event);
-// }
-//
-// public void deleteRange(Position range) {
-// ranges.remove(getIndex(range));
-// }
-//
-// private int getIndex(Position range) {
-// return Collections.binarySearch(ranges, range, new Comparator() {
-// public int compare(Object o1, Object o2) {
-// int offset1 = ((Position) o1).offset;
-// int offset2 = ((Position) o2).offset;
-//
-// if (offset1 < offset2) return -1;
-// if (offset1 > offset2) return 1;
-// return 0;
-// }
-// });
-// }
+ // public void addRange(Position range) {
+ // DocumentEvent event = new DocumentEvent(this,
+ // getLocalOffset(range.offset), range.length, "");
+ // fireDocumentAboutToBeChanged(event);
+ // ranges.add(-getIndex(range) - 1, range);
+ // fireDocumentChanged(event);
+ // }
+ //
+ // public void removeRange(Position range) {
+ // String text;
+ // try {
+ // text = parent.get(range.offset, range.length);
+ // } catch (BadLocationException e) {
+ // return;
+ // }
+ // DocumentEvent event = new DocumentEvent(this,
+ // getLocalOffset(range.offset), 0, text);
+ // fireDocumentAboutToBeChanged(event);
+ // deleteRange(range);
+ // fireDocumentChanged(event);
+ // }
+ //
+ // public void deleteRange(Position range) {
+ // ranges.remove(getIndex(range));
+ // }
+ //
+ // private int getIndex(Position range) {
+ // return Collections.binarySearch(ranges, range, new Comparator() {
+ // public int compare(Object o1, Object o2) {
+ // int offset1 = ((Position) o1).offset;
+ // int offset2 = ((Position) o2).offset;
+ //
+ // if (offset1 < offset2) return -1;
+ // if (offset1 > offset2) return 1;
+ // return 0;
+ // }
+ // });
+ // }
/*
* @see org.eclipse.jface.text.AbstractDocument#fireDocumentAboutToBeChanged(DocumentEvent)
getTracker().replace(event.getOffset(), event.getLength(),
event.getText());
} catch (IndexOutOfBoundsException x) {
-
+
} catch (BadLocationException x) {
}
* @see net.sf.wdte.text.rules.IDocumentView#getLocalOffset(int)
*/
public int getLocalOffset(int parentOffset) {
-// Assert.isTrue(parentOffset>=0);
+ // Assert.isTrue(parentOffset>=0);
int localOffset = parentOffset;
Iterator i = ranges.iterator();
localOffset -= range.length;
}
// TODO jsurfer change start - check this
-// if (localOffset<0) {
-// return 0;
-// }
- // jsurfer change end
+ if (localOffset < 0) {
+ return 0;
+ } else if (localOffset > getLength()) {
+ return getLength();
+ }
+ // jsurfer change end
return localOffset;
}
}