1 19 20 package org.netbeans.modules.web.core.syntax.folding; 21 22 import java.io.PrintStream ; 23 import org.netbeans.api.editor.fold.Fold; 24 import org.netbeans.api.editor.fold.FoldHierarchy; 25 import org.netbeans.modules.web.core.syntax.JspSyntaxSupport; 26 import org.netbeans.spi.editor.fold.FoldOperation; 27 28 33 34 public class JspFoldUtils { 35 36 37 public static void printFolds(FoldOperation foldOperation) { 38 printFolds(foldOperation.getHierarchy(), System.out); 39 } 40 41 42 public static void printFolds(FoldHierarchy foldHierarchy, PrintStream out) { 43 foldHierarchy.lock(); 44 try { 45 Fold rootFold = foldHierarchy.getRootFold(); 46 printChildren(rootFold, 0, out); 47 } finally { 48 foldHierarchy.unlock(); 49 } 50 } 51 52 private static void printChildren(Fold fold, int level, PrintStream out) { 53 int foldCount = fold.getFoldCount(); 54 for( int i = 0; i < level; i ++) System.out.print(" "); 56 out.println(fold.getDescription() + "[" + fold.getType().toString() + "; " + fold.getStartOffset() + " - " + fold.getEndOffset() + "]"); 58 System.out.println(fold.getDescription() + "[" + fold.getType().toString() + "; " + fold.getStartOffset() + " - " + fold.getEndOffset() + "]"); 59 for (int i = 0; i < foldCount; i++) { 61 Fold childFold = fold.getFold(i); 62 printChildren(childFold, level + 4, out); 63 } 64 } 65 66 public static String getContextName(int typeId) { 67 switch(typeId) { 68 case JspSyntaxSupport.COMMENT_COMPLETION_CONTEXT: 69 return "comment"; 70 case JspSyntaxSupport.CONTENTL_COMPLETION_CONTEXT: 71 return "content language"; 72 case JspSyntaxSupport.DIRECTIVE_COMPLETION_CONTEXT: 73 return "directive"; 74 case JspSyntaxSupport.ENDTAG_COMPLETION_CONTEXT: 75 return "end tag"; 76 case JspSyntaxSupport.SCRIPTINGL_COMPLETION_CONTEXT: 77 return "scripting"; 78 case JspSyntaxSupport.TAG_COMPLETION_CONTEXT: 79 return "tag"; 80 case JspSyntaxSupport.TEXT_COMPLETION_CONTEXT: 81 return "text"; 82 default: 83 return "?"; 84 } 85 } 86 87 } 88 | Popular Tags |