Ejemplo n.º 1
0
        /// <summary>
        /// Retrieves list of packages available to the current file.
        /// Consists of packages in the base library and packages
        /// added via 'library' statements.
        /// </summary>
        public static IEnumerable <string> GetFilePackageNames(this AstRoot ast)
        {
            // TODO: results can be cached until AST actually changes
            AstLibrarySearch search = new AstLibrarySearch();

            ast.Accept(search, null);

            return(search.PackageNames);
        }
Ejemplo n.º 2
0
        public static IReadOnlyCollection <IAstNode> FindElements(this AstRoot tree, Func <IAstNode, bool> filter)
        {
            MultipleElementFinder finder = new MultipleElementFinder(filter);

            tree.Accept(finder, null);

            if (finder.Result.Count == 0)
            {
                return(new IAstNode[0]);
            }

            return(new ReadOnlyCollection <IAstNode>(finder.Result));
        }