Esempio n. 1
0
        /// <summary>
        /// Finds all symbols in a script
        /// </summary>
        /// <param name="scriptAst">The abstract syntax tree of the given script</param>
        /// <param name="powerShellVersion">The PowerShell version the Ast was generated from</param>
        /// <returns>A collection of SymbolReference objects</returns>
        static public IEnumerable <SymbolReference> FindSymbolsInDocument(Ast scriptAst, Version powerShellVersion)
        {
            IEnumerable <SymbolReference> symbolReferences = null;

            // TODO: Restore this when we figure out how to support multiple
            //       PS versions in the new PSES-as-a-module world (issue #276)
//            if (powerShellVersion >= new Version(5,0))
//            {
//#if PowerShellv5
//                FindSymbolsVisitor2 findSymbolsVisitor = new FindSymbolsVisitor2();
//                scriptAst.Visit(findSymbolsVisitor);
//                symbolReferences = findSymbolsVisitor.SymbolReferences;
//#endif
//            }
//            else
            {
                if (IsPowerShellDataFileAst(scriptAst))
                {
                    var findHashtableSymbolsVisitor = new FindHashtableSymbolsVisitor();
                    scriptAst.Visit(findHashtableSymbolsVisitor);
                    symbolReferences = findHashtableSymbolsVisitor.SymbolReferences;
                }
                else
                {
                    FindSymbolsVisitor findSymbolsVisitor = new FindSymbolsVisitor();
                    scriptAst.Visit(findSymbolsVisitor);
                    symbolReferences = findSymbolsVisitor.SymbolReferences;
                }
            }

            return(symbolReferences);
        }
        /// <summary>
        /// Finds all symbols in a script
        /// </summary>
        /// <param name="scriptAst">The abstract syntax tree of the given script</param>
        /// <returns>A collection of SymbolReference objects</returns>
        static public IEnumerable <SymbolReference> FindSymbolsInDocument(Ast scriptAst)
        {
            FindSymbolsVisitor findSymbolsVisitor = new FindSymbolsVisitor();

            scriptAst.Visit(findSymbolsVisitor);

            return(findSymbolsVisitor.SymbolReferences);
        }
Esempio n. 3
0
        /// <summary>
        /// Finds all symbols in a script
        /// </summary>
        /// <param name="scriptAst">The abstract syntax tree of the given script</param>
        /// <param name="powerShellVersion">The PowerShell version the Ast was generated from</param>
        /// <returns>A collection of SymbolReference objects</returns>
        static public IEnumerable <SymbolReference> FindSymbolsInDocument(Ast scriptAst, Version powerShellVersion)
        {
            IEnumerable <SymbolReference> symbolReferences = null;

            if (powerShellVersion >= new Version(5, 0))
            {
#if PowerShellv5
                FindSymbolsVisitor2 findSymbolsVisitor = new FindSymbolsVisitor2();
                scriptAst.Visit(findSymbolsVisitor);
                symbolReferences = findSymbolsVisitor.SymbolReferences;
#endif
            }
            else
            {
                FindSymbolsVisitor findSymbolsVisitor = new FindSymbolsVisitor();
                scriptAst.Visit(findSymbolsVisitor);
                symbolReferences = findSymbolsVisitor.SymbolReferences;
            }

            return(symbolReferences);
        }
 public FindSymbolsVisitor2()
 {
     this.findSymbolsVisitor = new FindSymbolsVisitor();
 }
Esempio n. 5
0
 public FindSymbolsVisitor2()
 {
     this.findSymbolsVisitor = new FindSymbolsVisitor();
 }
        /// <summary>
        /// Finds all symbols in a script
        /// </summary>
        /// <param name="scriptAst">The abstract syntax tree of the given script</param>
        /// <returns>A collection of SymbolReference objects</returns>
        public static IEnumerable<SymbolReference> FindSymbolsInDocument(Ast scriptAst)
        {
            FindSymbolsVisitor findSymbolsVisitor = new FindSymbolsVisitor();
            scriptAst.Visit(findSymbolsVisitor);

            return findSymbolsVisitor.SymbolReferences;
        }
        /// <summary>
        /// Finds all symbols in a script
        /// </summary>
        /// <param name="scriptAst">The abstract syntax tree of the given script</param>
        /// <param name="powerShellVersion">The PowerShell version the Ast was generated from</param>
        /// <returns>A collection of SymbolReference objects</returns>
        static public IEnumerable<SymbolReference> FindSymbolsInDocument(Ast scriptAst, Version powerShellVersion)
        {
            IEnumerable<SymbolReference> symbolReferences = null;

            if (powerShellVersion >= new Version(5,0))
            {
#if PowerShellv5
                FindSymbolsVisitor2 findSymbolsVisitor = new FindSymbolsVisitor2();
                scriptAst.Visit(findSymbolsVisitor);
                symbolReferences = findSymbolsVisitor.SymbolReferences;
#endif
            }
            else
            {
                FindSymbolsVisitor findSymbolsVisitor = new FindSymbolsVisitor();
                scriptAst.Visit(findSymbolsVisitor);
                symbolReferences = findSymbolsVisitor.SymbolReferences;
            }

            return symbolReferences;
        }