public void ShouldNotHaveParamBlockIfScriptHasNoParametersDefined()
        {
            var           ast        = GenerateAst(scriptWithoutParameters);
            ParamBlockAst paramBlock = null;
            bool          result     = PowerShellParseUtilities.HasParamBlock(ast, out paramBlock);

            Assert.AreEqual <bool>(false, result);
        }
        private ParamBlockAst GenerateParamBlockAst(string script)
        {
            var           ast        = GenerateAst(script);
            ParamBlockAst paramBlock = null;

            if (PowerShellParseUtilities.HasParamBlock(ast, out paramBlock))
            {
                return(paramBlock);
            }
            return(null);
        }
        public static ParamBlockAst GetScriptParameters(IVsEditorAdaptersFactoryService adaptersFactory, IVsTextManager textManager)
        {
            IVsTextView   vsTextView;
            ParamBlockAst paramBlock = null;

            //Returns the active or previously active view.
            //
            // Parameters:
            //   fMustHaveFocus:
            //     [in] If true, then the current UI active view is returned. If false, then
            //     the last active view is returned, regardless of whether this view is currently
            //     UI active.
            //
            //   pBuffer:
            //     [in] Pass null for pBuffer to get the previously active code view, regardless
            //     of the text buffer that it was associated with. If you pass in a valid pointer
            //     to a buffer, then you are returned the last active view for that particular
            //     buffer.
            //
            //   ppView:
            //     [out] Pointer to the Microsoft.VisualStudio.TextManager.Interop.IVsTextView
            //     interface.
            textManager.GetActiveView(1, null, out vsTextView);
            if (vsTextView == null)
            {
                return(null);
            }

            IVsTextLines textLines;

            vsTextView.GetBuffer(out textLines);
            ITextBuffer textBuffer = adaptersFactory.GetDataBuffer(textLines as IVsTextBuffer);
            Ast         scriptAst;

            if (!textBuffer.Properties.TryGetProperty <Ast>(BufferProperties.Ast, out scriptAst))
            {
                return(null);
            }

            PowerShellParseUtilities.HasParamBlock(scriptAst, out paramBlock);
            return(paramBlock);
        }