示例#1
0
 public static String getName(Node node) {
   if (node == null) {
     return EMPTY_STRING;
   }
   if (node instanceof ClassNode) {
     return getName(((ClassNode) node).getCPath());
   }
   if (node instanceof ModuleNode) {
     return getName(((ModuleNode) node).getCPath());
   }
   if (node instanceof INameNode) {
     return ((INameNode) node).getName();
   }
   // tries reflection
   try {
     Method getNameMethod = node.getClass().getMethod("getName", new Class[] {}); // $NON-NLS-1$
     Object name = getNameMethod.invoke(node, new Object[0]);
     return (String) name;
   } catch (Exception e) {
     return EMPTY_STRING;
   }
 }