Exemplo n.º 1
0
        private IEnumerable <ISymbol> GetLocationSymbols()
        {
            if (codeLines.Length == 0)
            {
                throw new ArgumentException("No lines were specified.");
            }
            else
            {
                var root = startingDocument.GetSyntaxRootAsync().Result.DescendantNodes();

                IEnumerable <MemberDeclarationSyntax> declarations = root
                                                                     .OfType <MethodDeclarationSyntax>().Cast <MemberDeclarationSyntax>()
                                                                     .Union(root.OfType <PropertyDeclarationSyntax>())
                                                                     .Union(root.OfType <ConstructorDeclarationSyntax>());

                return(codeLines.Select(line =>
                                        declarations
                                        .Where(n => {
                    var lineSpan = n.GetLocation().GetLineSpan();
                    return lineSpan.StartLinePosition.Line <= line && lineSpan.EndLinePosition.Line >= line;
                })
                                        .Select(x => solution.GetMemberDeclarationSymbol(startingDocument, x))
                                        .First()
                                        ));
            }
        }