コード例 #1
0
        public override void DoCommand(object sender, EventArgs args)
        {
            var window     = ExecuteInReplCommand.EnsureReplWindow();
            var eval       = window.Evaluator as RemotePythonEvaluator;
            var activeView = IronPythonToolsPackage.GetActiveTextView();

            string path = activeView.GetFilePath();

            if (path != null)
            {
                var scope = eval.Engine.GetScope(path);
                if (scope != null)
                {
                    // we're now in the correct module, execute the code
                    string scopeName = eval.SetScope(scope);
                    window.Cancel();
                    if (scopeName != String.Empty)
                    {
                        window.WriteLine(eval.Prompt + " %module " + scopeName);
                        window.WriteLine(String.Format("Current scope changed to {0}", scopeName));
                    }
                    else
                    {
                        window.WriteLine(eval.Prompt + " %module (unknown name)");
                        window.WriteLine("Current scope changed to (unknown name)");
                    }

                    base.DoCommand(sender, args);
                }
                else
                {
                    window.WriteLine(String.Format("Could not find module: {0}", path));
                }
            }
            else
            {
                window.WriteLine("Could not find module");
            }
        }
コード例 #2
0
        /// <summary>
        /// Opens the find symbols dialog with a list of results.  This is done by requesting
        /// that VS does a search against our library GUID.  Our library then responds to
        /// that request by extracting the prvoided symbol list out and using that for the
        /// search results.
        /// </summary>
        private static void ShowFindSymbolsDialog(ExpressionAnalysis provider, params SymbolList[] symbols)
        {
            // ensure our library is loaded so find all references will go to our library
            Package.GetGlobalService(typeof(IPythonLibraryManager));

            if (provider.Expression != "")
            {
                var findSym = (IVsFindSymbol)IronPythonToolsPackage.GetGlobalService(typeof(SVsObjectSearch));
                VSOBSEARCHCRITERIA2 searchCriteria = new VSOBSEARCHCRITERIA2();
                searchCriteria.eSrchType   = VSOBSEARCHTYPE.SO_ENTIREWORD;
                searchCriteria.pIVsNavInfo = symbols.Length == 1 ? (IVsNavInfo)symbols[0] : (IVsNavInfo) new LocationCategory("Test", symbols);
                searchCriteria.grfOptions  = (uint)_VSOBSEARCHOPTIONS2.VSOBSO_LISTREFERENCES;
                searchCriteria.szName      = provider.Expression;

                Guid guid = Guid.Empty;
                //  new Guid("{a5a527ea-cf0a-4abf-b501-eafe6b3ba5c6}")
                ErrorHandler.ThrowOnFailure(findSym.DoSearch(new Guid(CommonConstants.LibraryGuid), new VSOBSEARCHCRITERIA2[] { searchCriteria }));
            }
            else
            {
                var statusBar = (IVsStatusbar)CommonPackage.GetGlobalService(typeof(SVsStatusbar));
                statusBar.SetText("The caret must be on valid expression to find all references.");
            }
        }
コード例 #3
0
 public PythonLibraryManager(IronPythonToolsPackage/*!*/ package)
     : base(package)
 {
     _package = package;
 }
コード例 #4
0
 public PythonLibraryManager(IronPythonToolsPackage /*!*/ package)
     : base(package)
 {
     _package = package;
 }