/** * extracts the method name (function name for C) from the node * * <p>this assumes the node is a `Func` node. * * @param node a `Func` node. * @return the method name e.g. "main" */ public String getMethodName(FSTNode node) { String methodName = node.getName(); StringTokenizer st = new StringTokenizer(methodName, "("); if (st.hasMoreTokens()) { methodName = st.nextToken(); } st = new StringTokenizer(methodName, " "); while (st.hasMoreTokens()) { methodName = st.nextToken(); } return methodName; }
/** * extracts the feature name * * @param node `Feature` node or descendant of a `Feature` node. * @return name of the feature this node is a descendant of, e.g. "Base". */ public String getFeatureName(FSTNode node) { if (node.getType().equals("Feature")) return node.getName(); else return getFeatureName(node.getParent()); }
private static String getFeatureName(FSTNode node) { if (node.getType().equals("Feature")) return node.getName().toLowerCase() + (FSTGenComposerExtension.key ? "" : "()"); else return getFeatureName(node.getParent()); }