Loading sharding-core/sharding-core-parse/sharding-core-parse-common/src/main/java/org/apache/shardingsphere/core/parse/antlr/extractor/util/ExtractorUtils.java +21 −0 Original line number Diff line number Diff line Loading @@ -93,6 +93,27 @@ public final class ExtractorUtils { return Optional.absent(); } /** * Find node only from first descendant which only has one child. * * @param node start node * @param ruleName rule name * @return matched node */ public static Optional<ParserRuleContext> findNodeOnlyFromFirstDescendant(final ParserRuleContext node, final RuleName ruleName) { ParserRuleContext nextNode = node; do { if (isMatchedNode(nextNode, ruleName)) { return Optional.of(nextNode); } if (1 != nextNode.getChildCount() || !(nextNode.getChild(0) instanceof ParserRuleContext)) { return Optional.absent(); } nextNode = (ParserRuleContext) nextNode.getChild(0); } while (null != nextNode); return Optional.absent(); } /** * Get all descendant nodes. * Loading Loading
sharding-core/sharding-core-parse/sharding-core-parse-common/src/main/java/org/apache/shardingsphere/core/parse/antlr/extractor/util/ExtractorUtils.java +21 −0 Original line number Diff line number Diff line Loading @@ -93,6 +93,27 @@ public final class ExtractorUtils { return Optional.absent(); } /** * Find node only from first descendant which only has one child. * * @param node start node * @param ruleName rule name * @return matched node */ public static Optional<ParserRuleContext> findNodeOnlyFromFirstDescendant(final ParserRuleContext node, final RuleName ruleName) { ParserRuleContext nextNode = node; do { if (isMatchedNode(nextNode, ruleName)) { return Optional.of(nextNode); } if (1 != nextNode.getChildCount() || !(nextNode.getChild(0) instanceof ParserRuleContext)) { return Optional.absent(); } nextNode = (ParserRuleContext) nextNode.getChild(0); } while (null != nextNode); return Optional.absent(); } /** * Get all descendant nodes. * Loading