1 19 package org.netbeans.modules.xml.text.api; 20 21 import java.lang.reflect.Field ; 22 import java.lang.reflect.Modifier ; 23 import org.netbeans.editor.TokenContext; 24 import org.netbeans.editor.TokenContextPath; 25 import org.netbeans.editor.TokenID; 26 import org.netbeans.modules.xml.text.syntax.*; 27 28 37 38 public class XMLDefaultTokenContext extends TokenContext implements XMLTokenIDs { 39 40 41 public static final XMLDefaultTokenContext context = new XMLDefaultTokenContext(); 44 public static final TokenContextPath contextPath = context.getContextPath(); 45 46 47 private XMLDefaultTokenContext() { 48 super("xml-"); 49 50 try { 51 Field [] fields = XMLTokenIDs.class.getDeclaredFields(); 53 for (int i = 0; i < fields.length; i++) { 54 int flags = Modifier.STATIC | Modifier.FINAL; 55 if ((fields[i].getModifiers() & flags) == flags 56 && TokenID.class.isAssignableFrom(fields[i].getType()) 57 ) { 58 addTokenID((TokenID)fields[i].get(null)); 59 } 60 } 61 } catch (Exception e) { 62 if (Boolean.getBoolean("netbeans.debug.exceptions")) { e.printStackTrace(); 64 } 65 } 66 } 67 68 } 69 | Popular Tags |