test_class.file: php-frontend/src/test/java/org/sonar/php/tree/TreeUtilsTest.java
test_class.identifier: TreeUtilsTest
test_case.body: @Test
    public void test_findAncestorWithKind() {
      Tree tree = PHPParserBuilder.createParser().parse("<?= function foo() {for(;;) {} } ?>");
      FunctionDeclarationTree func = (FunctionDeclarationTree) ((CompilationUnitTreeImpl) tree).script().statements().get(0);
      StatementTree statementTree = func.body().statements().get(0);
      assertThat(findAncestorWithKind(statementTree, EnumSet.of(Tree.Kind.FUNCTION_DECLARATION))).isEqualTo(func);
      assertThat(findAncestorWithKind(statementTree, EnumSet.of(Tree.Kind.SCRIPT, Tree.Kind.FUNCTION_DECLARATION))).isEqualTo(func);
      assertThat(findAncestorWithKind(statementTree, singletonList(Tree.Kind.WHILE_STATEMENT))).isNull();
  
      assertThat(findAncestorWithKind(func, singletonList(Tree.Kind.FUNCTION_DECLARATION))).isEqualTo(func);
    }
test_case.class_method_signature: TreeUtilsTest.test_findAncestorWithKind()
test_case.full_signature: @Test public void test_findAncestorWithKind()
test_case.identifier: test_findAncestorWithKind
test_case.invocations: parse createParser get statements script get statements body isEqualTo assertThat findAncestorWithKind of isEqualTo assertThat findAncestorWithKind of isNull assertThat findAncestorWithKind singletonList isEqualTo assertThat findAncestorWithKind singletonList
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void test_findAncestorWithKind()
focal_class.file: php-frontend/src/main/java/org/sonar/php/tree/TreeUtils.java
focal_class.identifier: TreeUtils
focal_class.class_method_signature: TreeUtils.TreeUtils()
focal_class.full_signature: private  TreeUtils()
focal_class.identifier: TreeUtils
focal_class.modifiers: private
focal_class.parameters: ()
focal_class.signature:  TreeUtils()
focal_class.class_method_signature: TreeUtils.isDescendant(Tree tree, Tree potentialParent)
focal_class.full_signature: public static boolean isDescendant(Tree tree, Tree potentialParent)
focal_class.identifier: isDescendant
focal_class.modifiers: public static
focal_class.parameters: (Tree tree, Tree potentialParent)
focal_class.return: boolean
focal_class.signature: boolean isDescendant(Tree tree, Tree potentialParent)
focal_class.class_method_signature: TreeUtils.findAncestorWithKind(Tree tree, Collection<Tree.Kind> kinds)
focal_class.full_signature: @CheckForNull public static Tree findAncestorWithKind(Tree tree, Collection<Tree.Kind> kinds)
focal_class.identifier: findAncestorWithKind
focal_class.modifiers: @CheckForNull public static
focal_class.parameters: (Tree tree, Collection<Tree.Kind> kinds)
focal_class.return: Tree
focal_class.signature: Tree findAncestorWithKind(Tree tree, Collection<Tree.Kind> kinds)
focal_class.class_method_signature: TreeUtils.descendants(@Nullable Tree root)
focal_class.full_signature: public static Stream<Tree> descendants(@Nullable Tree root)
focal_class.identifier: descendants
focal_class.modifiers: public static
focal_class.parameters: (@Nullable Tree root)
focal_class.return: Stream<Tree>
focal_class.signature: Stream<Tree> descendants(@Nullable Tree root)
focal_class.class_method_signature: TreeUtils.descendants(@Nullable Tree root, Class<T> clazz)
focal_class.full_signature: public static Stream<T> descendants(@Nullable Tree root, Class<T> clazz)
focal_class.identifier: descendants
focal_class.modifiers: public static
focal_class.parameters: (@Nullable Tree root, Class<T> clazz)
focal_class.return: Stream<T>
focal_class.signature: Stream<T> descendants(@Nullable Tree root, Class<T> clazz)
focal_class.class_method_signature: TreeUtils.firstDescendant(@Nullable Tree root, Predicate<Tree> predicate)
focal_class.full_signature: public static Optional<Tree> firstDescendant(@Nullable Tree root, Predicate<Tree> predicate)
focal_class.identifier: firstDescendant
focal_class.modifiers: public static
focal_class.parameters: (@Nullable Tree root, Predicate<Tree> predicate)
focal_class.return: Optional<Tree>
focal_class.signature: Optional<Tree> firstDescendant(@Nullable Tree root, Predicate<Tree> predicate)
focal_class.class_method_signature: TreeUtils.firstDescendant(Tree root, Class<T> clazz)
focal_class.full_signature: public static Optional<T> firstDescendant(Tree root, Class<T> clazz)
focal_class.identifier: firstDescendant
focal_class.modifiers: public static
focal_class.parameters: (Tree root, Class<T> clazz)
focal_class.return: Optional<T>
focal_class.signature: Optional<T> firstDescendant(Tree root, Class<T> clazz)
focal_method.body: @CheckForNull
    public static Tree findAncestorWithKind(Tree tree, Collection<Tree.Kind> kinds) {
      Tree parent = tree;
      while (parent != null && !kinds.contains(parent.getKind())) {
        parent = parent.getParent();
      }
      return parent;
    }
focal_method.class_method_signature: TreeUtils.findAncestorWithKind(Tree tree, Collection<Tree.Kind> kinds)
focal_method.full_signature: @CheckForNull public static Tree findAncestorWithKind(Tree tree, Collection<Tree.Kind> kinds)
focal_method.identifier: findAncestorWithKind
focal_method.invocations: contains getKind getParent
focal_method.modifiers: @CheckForNull public static
focal_method.parameters: (Tree tree, Collection<Tree.Kind> kinds)
focal_method.return: Tree
focal_method.signature: Tree findAncestorWithKind(Tree tree, Collection<Tree.Kind> kinds)