Java Code Examples for org.antlr.v4.runtime.tree.RuleNode#getChild()

The following examples show how to use org.antlr.v4.runtime.tree.RuleNode#getChild() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NodeUsesProvider.java    From sonar-tsql-plugin with GNU General Public License v3.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public Object visitChildren(final RuleNode node) {

	final int n = node.getChildCount();

	for (int i = 0; i < n; i++) {
		final ParseTree c = node.getChild(i);
		c.accept(this);

	}
	final String textToFind = node.getText();
	if (StringUtils.containsIgnoreCase(textToFind, tempText)
			|| StringUtils.containsIgnoreCase(tempText, textToFind)) {
		nodes.add(new ParsedNode(node));
	}
	return null;

}
 
Example 2
Source File: Visitor.java    From swift-js-transpiler with MIT License 5 votes vote down vote up
public String visitChildren(RuleNode node, List<Integer> withoutNodes) {
    if(node == null) return "";
    String result = this.defaultResult();
    int n = node.getChildCount();

    for(int i = 0; i < n && this.shouldVisitNextChild(node, result); ++i) {
        if(withoutNodes != null && withoutNodes.contains(i)) continue;
        ParseTree c = node.getChild(i);
        String childResult = c instanceof TerminalNode ? printTerminalNode((TerminalNode) c) : c.accept(this);
        result = this.aggregateResult(result, childResult);
    }

    return result;
}
 
Example 3
Source File: Visitor.java    From swift-js-transpiler with MIT License 5 votes vote down vote up
public String visitWithoutTerminals(RuleNode node) {
    String result = this.defaultResult();
    int n = node.getChildCount();

    for(int i = 0; i < n && this.shouldVisitNextChild(node, result); ++i) {
        ParseTree c = node.getChild(i);
        if(c instanceof TerminalNode) continue;
        String childResult = c.accept(this);
        result = this.aggregateResult(result, childResult);
    }

    return result;
}
 
Example 4
Source File: Visitor.java    From swift-js-transpiler with MIT License 5 votes vote down vote up
public String visitWithoutStrings(RuleNode node, String string) {
    String result = this.defaultResult();
    int n = node.getChildCount();

    for(int i = 0; i < n && this.shouldVisitNextChild(node, result); ++i) {
        ParseTree c = node.getChild(i);
        if(string.contains(c.getText())) continue;
        String childResult = c instanceof TerminalNode ? printTerminalNode((TerminalNode) c) : c.accept(this);
        result = this.aggregateResult(result, childResult);
    }

    return result;
}
 
Example 5
Source File: Visitor.java    From swift-js-transpiler with MIT License 5 votes vote down vote up
public String visitWithoutClasses(RuleNode node, Class nodeType) {
    String result = this.defaultResult();
    int n = node.getChildCount();

    for(int i = 0; i < n && this.shouldVisitNextChild(node, result); ++i) {
        ParseTree c = node.getChild(i);
        if(c.getClass() == nodeType) continue;
        String childResult = c instanceof TerminalNode ? printTerminalNode((TerminalNode) c) : c.accept(this);
        result = this.aggregateResult(result, childResult);
    }

    return result;
}