private AstVisitor[] getNodeVisitors(AstNode ast) { AstVisitor[] nodeVisitors = visitorsByNodeType.get(ast.getType()); if (nodeVisitors == null) { nodeVisitors = new AstVisitor[0]; } return nodeVisitors; }
private AstVisitor[] getNodeVisitors(AstNode ast) { AstVisitor[] nodeVisitors = visitorsByNodeType.get(ast.getType()); if (nodeVisitors == null) { nodeVisitors = new AstVisitor[0]; } return nodeVisitors; }
private AstVisitor[] getNodeVisitors(AstNode ast) { AstVisitor[] nodeVisitors = visitorsByNodeType.get(ast.getType()); if (nodeVisitors == null) { nodeVisitors = new AstVisitor[0]; } return nodeVisitors; }
public static boolean isPostfixExpression(AstNode astNodeType) { return POSTFIX_EXPRESSION.contains(astNodeType.getType()); }
public AstSelect filter(AstNodeType type) { List<AstNode> result = Lists.newArrayList(); for (AstNode node : list) { if (node.getType() == type) { result.add(node); } } return AstSelectFactory.create(result); }
public static AstNode skipParenthesis(AstNode node) { if (node.getType() == PlSqlGrammar.BRACKED_EXPRESSION) { return node.getChildren().get(1); } return node; }
@Override public AstSelect filter(AstNodeType type) { List<AstNode> result = new ArrayList<>(); for (AstNode node : list) { if (node.getType() == type) { result.add(node); } } return AstSelectFactory.create(result); }
private static AstNode normalize(AstNode node) { if (node.getType() == PlSqlGrammar.METHOD_CALL || node.getType() == PlSqlGrammar.CALL_STATEMENT) { AstNode child = normalize(node.getFirstChild()); if (child.getFirstChild().getType() == PlSqlGrammar.HOST_AND_INDICATOR_VARIABLE) { child = child.getFirstChild(); } return child; } return node; }
private boolean hasVisibility(AstNode astNode) { for (AstNode modifier : astNode.getChildren(PHPGrammar.MEMBER_MODIFIER)) { if (VISIBILITIES.contains(modifier.getFirstChild().getType())) { return true; } } return false; }
public ModifierKeywordTreeImpl modifierKeyword(AstNode astNode) { JavaKeyword keyword = (JavaKeyword) astNode.getType(); return new ModifierKeywordTreeImpl(kindMaps.getModifier(keyword), astNode); }
@Override public void visitNode(AstNode ast) { if (ast.getType().equals(ErlangGrammarImpl.functionDeclaration)) { actualArity = getArity(ast.getFirstChild(ErlangGrammarImpl.functionClause)); } if (ast.getType().equals(ErlangGrammarImpl.callExpression) && getArityFromCall(ast).equals(actualArity)) { getContext().peekSourceCode().add(ErlangMetric.BRANCHES_OF_RECURSION, 1); } }
public ExpressionTree newPrefixedExpression(AstNode operatorTokenAstNode, ExpressionTree expression) { InternalSyntaxToken operatorToken = InternalSyntaxToken.create(operatorTokenAstNode); return new InternalPrefixUnaryExpression(kindMaps.getPrefixOperator((JavaPunctuator) operatorTokenAstNode.getType()), operatorToken, expression); }
@Override public AstSelect firstAncestor(AstNodeType type) { AstNode result = node.getParent(); while (result != null && result.getType() != type) { result = result.getParent(); } return AstSelectFactory.select(result); }
public AstSelect firstAncestor(AstNodeType type) { AstNode result = node.getParent(); while (result != null && result.getType() != type) { result = result.getParent(); } return AstSelectFactory.select(result); }
@Override public AstSelect firstAncestor(AstNodeType type) { AstNode result = node.getParent(); while (result != null && result.getType() != type) { result = result.getParent(); } return AstSelectFactory.select(result); }
public static InternalSyntaxToken create(AstNode astNode) { Preconditions.checkArgument(astNode.hasToken(), "has no token"); Preconditions.checkArgument(astNode.getToken() == astNode.getLastToken(), "has several tokens"); return new InternalSyntaxToken(astNode.getType(), astNode.getToken(), astNode.getFromIndex(), astNode.getToIndex()); }
public static InternalSyntaxToken create(AstNode astNode) { Preconditions.checkArgument(astNode.hasToken(), "has no token"); Preconditions.checkArgument(astNode.getToken() == astNode.getLastToken(), "has several tokens"); return new InternalSyntaxToken(astNode.getType(), astNode.getToken(), astNode.getFromIndex(), astNode.getToIndex()); }
@Override public void visitNode(AstNode ast) { AstNode args = ast.getFirstChild(ErlangGrammarImpl.funcDecl).getFirstChild( ErlangGrammarImpl.arguments); int numOfArgs = 0; for (AstNode arg : args.getChildren()) { if (!nonArg.contains(arg.getType())) { numOfArgs++; } } getContext().peekSourceCode().add(ErlangMetric.NUM_OF_FUNC_ARGS, numOfArgs); }
public ExpressionTree newPostfixExpression(ExpressionTree expression, Optional<AstNode> postfixOperatorAstNode) { ExpressionTree result = expression; if (postfixOperatorAstNode.isPresent()) { InternalSyntaxToken postfixOperatorToken = InternalSyntaxToken.create(postfixOperatorAstNode.get()); result = new InternalPostfixUnaryExpression(kindMaps.getPostfixOperator((JavaPunctuator) postfixOperatorAstNode.get().getType()), result, postfixOperatorToken); } return result; }