//
        // -----------------------------------------------------
        // Borrowed from ParsedDocument and overridden
        // -----------------------------------------------------
        //

        public override IEnumerable <FoldingRegion> GenerateFolds()
        {
            foreach (FoldingRegion fold in AdditionalFolds)
            {
                yield return(fold);
            }

            foreach (FoldingRegion fold in ConditionalRegions.ToFolds())
            {
                yield return(fold);
            }

            IEnumerable <FoldingRegion> commentFolds = Comments.ToPythonFolds();

            if (CompilationUnit != null && CompilationUnit.Types != null && CompilationUnit.Types.Count > 0)
            {
                commentFolds = commentFolds.FlagIfInsideMembers(CompilationUnit.Types, delegate(FoldingRegion f) {
                    f.Type = FoldType.CommentInsideMember;
                });
            }
            foreach (FoldingRegion fold in commentFolds)
            {
                yield return(fold);
            }

            if (CompilationUnit == null)
            {
                yield break;
            }

            FoldingRegion usingFold = CompilationUnit.Usings.ToFold();

            if (usingFold != null)
            {
                yield return(usingFold);
            }

            foreach (FoldingRegion fold in CompilationUnit.Types.ToFolds())
            {
                yield return(fold);
            }

            PythonCompilationUnit pyUnit = CompilationUnit as PythonCompilationUnit;

            foreach (IMember m in pyUnit.Members)
            {
                var fold = new FoldingRegion(m.Name, m.BodyRegion, FoldType.Member);
                yield return(fold);
            }
        }
Пример #2
0
        public virtual IEnumerable <FoldingRegion> GenerateFolds()
        {
            foreach (FoldingRegion fold in AdditionalFolds)
            {
                yield return(fold);
            }

            foreach (FoldingRegion fold in ConditionalRegions.ToFolds())
            {
                yield return(fold);
            }

            IEnumerable <FoldingRegion> commentFolds = comments.ToFolds();

            if (CompilationUnit != null && CompilationUnit.Types != null && CompilationUnit.Types.Count > 0)
            {
                commentFolds = commentFolds.FlagIfInsideMembers(CompilationUnit.Types, delegate(FoldingRegion f) {
                    f.Type = FoldType.CommentInsideMember;
                });
            }
            foreach (FoldingRegion fold in commentFolds)
            {
                yield return(fold);
            }

            if (CompilationUnit == null)
            {
                yield break;
            }

            FoldingRegion usingFold = CompilationUnit.Usings.ToFold();

            if (usingFold != null)
            {
                yield return(usingFold);
            }

            foreach (FoldingRegion fold in CompilationUnit.Types.ToFolds())
            {
                yield return(fold);
            }
        }