1 19 20 package org.netbeans.modules.html.editor.folding; 21 22 import org.netbeans.api.editor.fold.Fold; 23 import org.netbeans.api.editor.fold.FoldHierarchy; 24 import org.netbeans.spi.editor.fold.FoldOperation; 25 import org.netbeans.editor.ext.html.parser.SyntaxElement; 26 27 32 public class HTMLFoldUtils { 33 34 35 public static void printFolds(FoldOperation fo) { 36 FoldHierarchy fh = fo.getHierarchy(); 37 fh.lock(); 38 try { 39 Fold rootFold = fh.getRootFold(); 40 printChildren(rootFold, 0); 41 } finally { 42 fh.unlock(); 43 } 44 } 45 46 private static void printChildren(Fold f, int level) { 47 int foldCount = f.getFoldCount(); 48 for( int i = 0; i < level; i ++) System.out.print(" "); System.out.println(f.getDescription() + " [" + f.getStartOffset() + " - " + f.getEndOffset() + "]"); for (int i = 0; i < foldCount; i++) { 54 Fold childFold = f.getFold(i); 55 printChildren(childFold, level + 4); 56 } 57 58 } 59 60 public static String getContextName(int typeId) { 61 switch(typeId) { 62 case SyntaxElement.TYPE_TAG: 63 return "tag"; case SyntaxElement.TYPE_COMMENT: 65 return "comment"; default: 67 return "?"; } 69 } 70 71 } 72 | Popular Tags |