* Contributors:
* Igor Malinin - initial contribution
*
- * $Id: MultiViewPartitioner.java,v 1.6 2004-11-12 20:15:58 axelcl Exp $
+ * $Id: MultiViewPartitioner.java,v 1.7 2004-11-13 12:36:32 axelcl Exp $
*/
package net.sourceforge.phpeclipse.ui.text.rules;
*/
public ITypedRegion[] computePartitioning(int offset, int length) {
List list = new ArrayList();
-
+// if (DEBUG) {
+// System.out.print("MultiViewPartitioner::computePartitioning - Offset: ");
+// System.out.print(offset);
+// System.out.print(", Length: ");
+// System.out.print(length);
+// System.out.println("");
+// }
int end = offset + length;
int index = computeFlatNodeIndex(offset);
++index;
}
-
+// if (DEBUG) {
+// showList(list);
+// }
+
return (TypedRegion[]) list.toArray(new TypedRegion[list.size()]);
}
+ private void showList(List list) {
+ try {
+ throw new NullPointerException();
+ } catch (Exception e){
+ e.printStackTrace();
+ }
+ System.out.println(">>>>>List start");
+ TypedRegion temp;
+ for (int i = 0; i < list.size(); i++) {
+ temp = (TypedRegion)list.get(i);
+ System.out.print("Offset: ");
+ System.out.print(temp.getOffset());
+ System.out.print(", Length: ");
+ System.out.print(temp.getLength());
+ System.out.print(", Type: ");
+ System.out.print(temp.getType());
+ System.out.println("");
+ }
+ System.out.println("<<<<<List end");
+ }
private void addOuterPartitions(List list, int offset, int length, FlatNode prev, FlatNode next) {
// limit region
int start = offset;
}
if (outerDocument == null) {
+// if (DEBUG) {
+// if (end - start<0) {
+// throw new IndexOutOfBoundsException();
+// }
+// }
list.add(new TypedRegion(start, end - start, getContentType(null, IDocument.DEFAULT_CONTENT_TYPE)));
return;
}
end = offset;
}
}
-
+// if (DEBUG) {
+// if (end - start<0) {
+// showList(list);
+// System.out.print("MultiViewPartitioner::addOuterPartitions - Offset: ");
+// System.out.print(offset);
+// System.out.print(", Start: ");
+// System.out.print(start);
+// System.out.print(", End: ");
+// System.out.print(end);
+// System.out.print(", Type: ");
+// System.out.print(region.getType());
+// System.out.println("");
+// throw new IndexOutOfBoundsException();
+// }
+// }
list.add(new TypedRegion(start, end - start, getContentType(null, region.getType())));
}
}
private void addInnerPartitions(List list, int offset, int length, FlatNode position) {
InnerDocumentView innerDocument = null;
if (position instanceof ViewNode) {
- // TODO: revisit condition
+ // TODO: revisit condition
innerDocument = ((ViewNode) position).view;
}
if (innerDocument == null) {
// simple partition
+// if (DEBUG) {
+// if (position.length<0) {
+// throw new IndexOutOfBoundsException();
+// }
+// }
list.add(new TypedRegion(position.offset, position.length, getContentType(position.type, null)));
return;
}
// convert back to parent offsets
offset = innerDocument.getParentOffset(region.getOffset());
length = region.getLength();
-
+// if (DEBUG) {
+// if (length<0) {
+// throw new IndexOutOfBoundsException();
+// }
+// }
list.add(new TypedRegion(offset, length, getContentType(position.type, region.getType())));
}
} catch (BadLocationException x) {