/** * @return true if this node has an ancestor of the specified type * @since 1.17 */ public boolean hasAncestor(AstNodeType nodeType) { return getFirstAncestor(nodeType) != null; }
/** * @return true if this node has an ancestor of one of specified types * @since 1.19.2 */ public boolean hasAncestor(AstNodeType... nodeTypes) { return getFirstAncestor(nodeTypes) != null; }
/** * @return true if this node has an ancestor of the specified type * @since 1.17 */ public boolean hasAncestor(AstNodeType nodeType) { return getFirstAncestor(nodeType) != null; }
/** * @return true if this node has an ancestor of the specified type * @since 1.17 */ public boolean hasAncestor(AstNodeType nodeType) { return getFirstAncestor(nodeType) != null; }
/** * @return true if this node has an ancestor of one of specified types * @since 1.19.2 */ public boolean hasAncestor(AstNodeType... nodeTypes) { return getFirstAncestor(nodeTypes) != null; }
/** * @return true if this node has an ancestor of one of specified types * @since 1.19.2 */ public boolean hasAncestor(AstNodeType... nodeTypes) { return getFirstAncestor(nodeTypes) != null; }
/** * @deprecated in 1.17, use {@link #getFirstAncestor(AstNodeType)} instead */ @Deprecated public AstNode findFirstParent(AstNodeType nodeType) { return getFirstAncestor(nodeType); }
/** * @deprecated in 1.17, use {@link #getFirstAncestor(AstNodeType)} instead */ @Deprecated public AstNode findFirstParent(AstNodeType nodeType) { return getFirstAncestor(nodeType); }
/** * @deprecated in 1.17, use {@link #getFirstAncestor(AstNodeType)} instead */ @Deprecated public AstNode findFirstParent(AstNodeType nodeType) { return getFirstAncestor(nodeType); }
public static boolean insideFunction(AstNode astNode, AstNode funcDef) { return astNode.getFirstAncestor(PythonGrammar.FUNCDEF).equals(funcDef); }
/** * @return first ancestor of the specified type, or null if not found * @since 1.17 */ public AstNode getFirstAncestor(AstNodeType nodeType) { if (parent == null) { return null; } else if (parent.is(nodeType)) { return parent; } else { return parent.getFirstAncestor(nodeType); } }
/** * Loads the classDeclaration node. * * @param astNode The node of the method of which the class declaration is * obtained. * @return the classDeclaration value. */ private AstNode getClassDeclaration(AstNode astNode) { return astNode.getFirstAncestor(ApexGrammarRuleKey.TYPE_DECLARATION) .getFirstChild(ApexGrammarRuleKey.CLASS_OR_INTERFACE_DECLARATION); } }
private boolean isInsideSubExpression(AstNode node) { AstNode subExpression = node.getFirstAncestor(CSharpGrammar.EXPRESSION); AstNode expression = subExpression.getFirstAncestor(CSharpGrammar.EXPRESSION); return expression != null && !isLambdaExpression(expression) && !isDelegateExpression(expression); }
/** * @return first ancestor of the specified type, or null if not found * @since 1.17 */ public AstNode getFirstAncestor(AstNodeType nodeType) { if (parent == null) { return null; } else if (parent.is(nodeType)) { return parent; } else { return parent.getFirstAncestor(nodeType); } }
private boolean isMultilineComment(AstNode node) { String str = node.getTokenValue(); AstNode expressionStatement = node.getFirstAncestor(PythonGrammar.EXPRESSION_STMT); return (str.endsWith("'''") || str.endsWith("\"\"\"")) && expressionStatement != null && expressionStatement.getNumberOfChildren() == 1; }
private static boolean isMultilineComment(AstNode node) { String str = node.getTokenValue(); AstNode expressionStatement = node.getFirstAncestor(PythonGrammar.EXPRESSION_STMT); return (str.endsWith("'''") || str.endsWith("\"\"\"")) && expressionStatement != null && expressionStatement.getNumberOfChildren() == 1; }
private static boolean isMultilineComment(AstNode node) { String str = node.getTokenValue(); AstNode expressionStatement = node.getFirstAncestor(PythonGrammar.EXPRESSION_STMT); return (str.endsWith("'''") || str.endsWith("\"\"\"")) && expressionStatement != null && expressionStatement.getNumberOfChildren() == 1; }
@Override public void visitNode(AstNode node) { AstNode suite = node.getFirstAncestor(PythonGrammar.SUITE); List<AstNode> statements = suite.getChildren(PythonGrammar.STATEMENT); if (statements.size() > 1) { if (!docstringException(statements)) { raiseIssue(node); } } else { visitOneOrZeroStatement(node, suite, statements.size()); } }
@Override public void visitNode(AstNode node) { AstNode suite = node.getFirstAncestor(PythonGrammar.SUITE); if (suite != null) { List<AstNode> statements = suite.getChildren(PythonGrammar.STATEMENT); if (statements.size() > 1) { if (!docstringException(statements)) { addIssue(node, MESSAGE); } } else { visitOneOrZeroStatement(node, suite, statements.size()); } } }
@Override public void visitNode(AstNode astNode) { if (astNode.getFirstAncestor(ErlangGrammarImpl.functionDeclaration) != null) { getContext().peekSourceCode().add(ErlangMetric.STATEMENTS, 1); } } }