public static IEnumerable<ITagSpan<IOutliningRegionTag>> GetTags(ParseResult parseResult, IOutliningRegionTagCreator tagCreator) {

            var transitionBlocks = parseResult.SyntaxTree.GetRoot().DescendantNodes().OfType<TransitionDefinitionBlockSyntax>();

            foreach (var transitionBlock in transitionBlocks) {
                var extent = transitionBlock.Extent;
                
                if (extent.IsEmptyOrMissing) {
                    continue;
                }

                var startLine = parseResult.Snapshot.GetLineNumberFromPosition(extent.Start);
                var endLine = parseResult.Snapshot.GetLineNumberFromPosition(extent.End);
                if (startLine == endLine) {
                    continue;
                }

                var collapsedForm = "Transitions";
                var rgnSpan  = new SnapshotSpan(new SnapshotPoint(parseResult.Snapshot, extent.Start), extent.Length);
                var hintSpan = new SnapshotSpan(new SnapshotPoint(parseResult.Snapshot, extent.Start), extent.Length);
                var rgnTag   = tagCreator.CreateTag(collapsedForm, hintSpan);

                yield return new TagSpan<IOutliningRegionTag>(rgnSpan, rgnTag);
            }
        }
        public static IEnumerable<ITagSpan<IOutliningRegionTag>> GetTags(ParseResult parseResult, IOutliningRegionTagCreator tagCreator) {

            foreach (var taskDef in parseResult.SyntaxTree.GetRoot().DescendantNodes<TaskDefinitionSyntax>()) {

                var extent = taskDef.Extent;

                var nameToken = taskDef.Identifier;
                if (nameToken.IsMissing) {
                    continue;
                }

                var rgnStartToken = nameToken.NextToken();
                if (rgnStartToken.IsMissing) {
                    continue;
                }

                var start  = Math.Min(nameToken.End + 1, rgnStartToken.Start);
                int length = extent.End - start;

                if (length <= 0) {
                    continue;
                }

                var regionSpan = new SnapshotSpan(new SnapshotPoint(parseResult.Snapshot, start), length);
                var hintSpan   = new SnapshotSpan(new SnapshotPoint(parseResult.Snapshot, extent.Start), extent.Length);
                var tag        = tagCreator.CreateTag("...", hintSpan);

                yield return new TagSpan<IOutliningRegionTag>(regionSpan, tag);
            }
        }
        public static IEnumerable< ITagSpan<IOutliningRegionTag>> GetTags(ParseResult parseResult, IOutliningRegionTagCreator tagCreator) {

            var usingDirectives = parseResult.SyntaxTree.GetRoot().DescendantNodes<CodeUsingDeclarationSyntax>().ToList();
            if (usingDirectives.Count<2) {
                yield break;
            }

            var firstUsing = usingDirectives[0];
            var lastUsing  = usingDirectives[usingDirectives.Count - 1];

            var usingKeyword = firstUsing.UsingKeyword;
            if (usingKeyword.IsMissing) {
                yield break;
            }

            var extendStart = firstUsing.Extent;
            var extendEnd   = lastUsing.Extent;

            var start         = usingKeyword.End + 1;
            int length        = extendEnd.End - start - 1; // Letzte ] noch mit anzeigen..

            if (length <= 0) {
                yield break;
            }

            var regionSpan = new SnapshotSpan(new SnapshotPoint(parseResult.Snapshot, start), length);
            var hintSpan   = new SnapshotSpan(new SnapshotPoint(parseResult.Snapshot, extendStart.Start), extendEnd.End- extendStart.Start);
            var tag        = tagCreator.CreateTag("...", hintSpan);

            yield return new TagSpan<IOutliningRegionTag>(regionSpan, tag);
        }
        public static IEnumerable<ITagSpan<IOutliningRegionTag>> GetTags(ParseResult parseResult, IOutliningRegionTagCreator tagCreator) {

            foreach(var mc in parseResult.SyntaxTree.Tokens.OfType(SyntaxTokenType.MultiLineComment)) {
                var extent = mc.Extent;

                if (extent.IsEmptyOrMissing) {
                    continue;
                }

                var startLine = parseResult.Snapshot.GetLineNumberFromPosition(extent.Start);
                var endLine   = parseResult.Snapshot.GetLineNumberFromPosition(extent.End);
                if (startLine == endLine) {
                    continue;
                }

                var collapsedForm = "/* ...";
                var rgnSpan  = new SnapshotSpan(new SnapshotPoint(parseResult.Snapshot, extent.Start), extent.Length);
                var hintSpan = new SnapshotSpan(new SnapshotPoint(parseResult.Snapshot, extent.Start), extent.Length);
                var rgnTag = tagCreator.CreateTag(collapsedForm, hintSpan);

                yield return new TagSpan<IOutliningRegionTag>(rgnSpan, rgnTag);
            }           
        }
        public static IEnumerable<ITagSpan<IOutliningRegionTag>> GetTags(ParseResult parseResult, IOutliningRegionTagCreator tagCreator) {
            
            var nsDecl = parseResult.SyntaxTree.GetRoot().DescendantNodes<CodeNamespaceDeclarationSyntax>().FirstOrDefault();
            if (nsDecl == null) {
                yield break;
            }

            var keywordToken = nsDecl.NamespaceprefixKeyword;
            if (keywordToken.IsMissing) {
                yield break;
            }

            var start  = keywordToken.End + 1;
            int length = parseResult.Snapshot.Length - start; // Bis zum Ende der Datei

            if (length <= 0) {
                yield break;
            }

            var span = new SnapshotSpan(new SnapshotPoint(parseResult.Snapshot, start), length);
            var tag  = tagCreator.CreateTag("...", span);

            yield return new TagSpan<IOutliningRegionTag>(span, tag);
        }
        public static IEnumerable<ITagSpan<IOutliningRegionTag>> GetTags(ParseResult parseResult, IOutliningRegionTagCreator tagCreator) {

            // Task Declarations
            foreach (var taskReferenceDefinition in parseResult.SyntaxTree.GetRoot().DescendantNodes().OfType<TaskDeclarationSyntax>()) {
                var extent = taskReferenceDefinition.Extent;
               
                if (extent.Length <= 0) {
                    continue;
                }

                var nameToken = taskReferenceDefinition.Identifier;

                if (nameToken.IsMissing) {
                    continue;
                }

                var rgnStartToken = nameToken.NextToken();
                if (rgnStartToken.IsMissing) {
                    continue;
                }

                int start  = Math.Min(nameToken.End+1, rgnStartToken.Start);
                int length = extent.End - start;

                if (length <= 0) {
                    continue;
                }

                var rgnSpan  = new SnapshotSpan(new SnapshotPoint(parseResult.Snapshot, start), length);
                var hintSpan = new SnapshotSpan(new SnapshotPoint(parseResult.Snapshot, extent.Start), extent.Length);
                var rgnTag   = tagCreator.CreateTag("...", hintSpan);

                yield return new TagSpan<IOutliningRegionTag>(rgnSpan, rgnTag);
            }


            // Zusammenhängende Blöcke von taskref "file" als Region zusammenfassen
            var allRelevant = parseResult.SyntaxTree.GetRoot().DescendantNodes<TaskDefinitionSyntax>().Concat<SyntaxNode>(
                parseResult.SyntaxTree.GetRoot().DescendantNodes <TaskDeclarationSyntax>())
                .Concat(
                    parseResult.SyntaxTree.GetRoot().DescendantNodes<IncludeDirectiveSyntax>())
                .OrderBy(s => s.Extent.Start);

            IncludeDirectiveSyntax firstInclude = null;
            IncludeDirectiveSyntax lastInclude  = null;
            foreach (var syntaxNode in allRelevant) {

                var include = syntaxNode as IncludeDirectiveSyntax;
                if (include != null) {
                    if (firstInclude == null) {
                        firstInclude = include;
                    }
                    lastInclude = include;
                } else {
                    if (firstInclude != null && firstInclude != lastInclude) {

                        var extendStart = firstInclude.Extent;
                        var extendEnd   = lastInclude.Extent;

                        var keywordToken = firstInclude.TaskrefKeyword;
                        
                        if (keywordToken.IsMissing) {
                            yield break;
                        }

                        int start = keywordToken.End + 1;

                        int length = extendEnd.End - start;

                        var regionSpan = new SnapshotSpan(new SnapshotPoint(parseResult.Snapshot, start), length);
                        var hintSpan   = new SnapshotSpan(new SnapshotPoint(parseResult.Snapshot, extendStart.Start), extendEnd.End - extendStart.Start);
                        var tag        = tagCreator.CreateTag("...", hintSpan);

                        yield return new TagSpan<IOutliningRegionTag>(regionSpan, tag);
                    }
                    firstInclude = lastInclude = null;
                }
            }
        }