Exemplo n.º 1
0
        public override void DoCommand(object sender, EventArgs args)
        {
            var activeView = PythonToolsPackage.GetActiveTextView(_serviceProvider);
            var pyProj     = activeView.TextBuffer.GetProject(_serviceProvider);
            var analyzer   = activeView.GetAnalyzerAtCaret(_serviceProvider);
            var window     = ExecuteInReplCommand.EnsureReplWindow(_serviceProvider, analyzer, pyProj);
            var eval       = window.InteractiveWindow.Evaluator as PythonReplEvaluator;

            string path = activeView.GetFilePath();
            string scope;

            if (path != null && (scope = eval.GetScopeByFilename(path)) != null)
            {
                // we're now in the correct module, execute the code
                window.InteractiveWindow.Operations.Cancel();
                // TODO: get correct prompt
                window.InteractiveWindow.WriteLine(">>>" + " $module " + scope);
                eval.SetScope(scope);

                base.DoCommand(sender, args);
            }
            else
            {
                window.InteractiveWindow.WriteLine("Could not find defining module.");
            }
        }
Exemplo n.º 2
0
        public override void DoCommand(object sender, EventArgs args)
        {
            var activeView = PythonToolsPackage.GetActiveTextView();
            var analyzer   = activeView.GetAnalyzer();
            var window     = ExecuteInReplCommand.EnsureReplWindow(analyzer);
            var eval       = window.Evaluator as PythonReplEvaluator;

            string path = activeView.GetFilePath();
            string scope;

            if (path != null && (scope = eval.GetScopeByFilename(path)) != null)
            {
                // we're now in the correct module, execute the code
                eval.SetScope(scope);
                window.Cancel();
                window.WriteLine(window.GetOptionValue(ReplOptions.PrimaryPrompt) + " $module " + scope);
                window.WriteLine(String.Format("Current scope changed to {0}", scope));

                base.DoCommand(sender, args);
            }
            else
            {
                window.WriteLine("Could not find defining module.");
            }
        }