コード例 #1
0
 protected int getViewIndexAtPosition(int pos) {
   Element elem = getElement();
   if (elem.isLeaf()) {
     return 0;
   }
   return super.getViewIndexAtPosition(pos);
 }
コード例 #2
0
 protected void loadChildren(ViewFactory f) {
   Element elem = getElement();
   if (elem.isLeaf()) {
     View v = new LabelView(elem);
     append(v);
   } else {
     super.loadChildren(f);
   }
 }
コード例 #3
0
 private void parse(Element node) {
   if (!showThumbs) {
     // do not show any thumbnails
     return;
   }
   int count = node.getElementCount();
   for (int i = 0; i < count; i++) {
     Element elm = node.getElement(i);
     Debug.log(8, elm.toString());
     if (elm.isLeaf()) {
       int start = elm.getStartOffset(), end = elm.getEndOffset();
       parseRange(start, end);
     } else {
       parse(elm);
     }
   }
 }
コード例 #4
0
 private int getFunctionStartOffset(String func, Element node) throws BadLocationException {
   Document doc = getDocument();
   int count = node.getElementCount();
   Pattern patDef = Pattern.compile("def\\s+" + func + "\\s*\\(");
   for (int i = 0; i < count; i++) {
     Element elm = node.getElement(i);
     if (elm.isLeaf()) {
       int start = elm.getStartOffset(), end = elm.getEndOffset();
       String line = doc.getText(start, end - start);
       Matcher matcher = patDef.matcher(line);
       if (matcher.find()) {
         return start;
       }
     } else {
       int p = getFunctionStartOffset(func, elm);
       if (p >= 0) {
         return p;
       }
     }
   }
   return -1;
 }