public void TerminateTraversalPrematurely()
        {
            string source = "class A { class B { class C { }; }; class D { }; class E { }; };";

            var spellings = new List <string>();
            var visitor   = new DelegatingCursorVisitor((cursor, parent) =>
            {
                if (cursor.Kind != CursorKind.ClassDecl)
                {
                    return(ChildVisitResult.Recurse);
                }

                string spelling = cursor.GetSpelling();
                spellings.Add(spelling);

                if (spelling == "B")
                {
                    return(ChildVisitResult.Continue);
                }
                else if (spelling == "D")
                {
                    return(ChildVisitResult.Break);
                }
                else
                {
                    return(ChildVisitResult.Recurse);
                }
            });

            using (var empty = disposables.WriteToEmpty(source))
            {
                Assert.AreEqual(true, visitor.VisitChildren(empty.GetCursor()));
                CollectionAssert.AreEqual(new[] { "A", "B", "D" }, spellings);
            }
        }
        public void VisitFunctionDeclaration()
        {
            string source = "void foo();";

            string spelling = null;
            var    visitor  = new DelegatingCursorVisitor((cursor, parent) =>
            {
                if (cursor.Kind == CursorKind.FunctionDecl)
                {
                    spelling = cursor.GetSpelling();
                }

                return(ChildVisitResult.Recurse);
            });

            using (var empty = disposables.WriteToEmpty(source))
            {
                Assert.AreEqual(false, visitor.VisitChildren(empty.GetCursor()));
                Assert.AreEqual("foo", spelling);
            }
        }