public override AstVisitAction VisitPipeline(PipelineAst pipelineAst)
        {
            if (this.lineNumber == pipelineAst.Extent.StartLineNumber)
            {
                // Which command is the cursor in?
                foreach (var commandAst in pipelineAst.PipelineElements.OfType <CommandAst>())
                {
                    int    trueEndColumnNumber = commandAst.Extent.EndColumnNumber;
                    string currentLine         = commandAst.Extent.StartScriptPosition.Line;

                    if (currentLine.Length >= trueEndColumnNumber)
                    {
                        // Get the text left in the line after the command's extent
                        string remainingLine =
                            currentLine.Substring(
                                commandAst.Extent.EndColumnNumber);

                        // Calculate the "true" end column number by finding out how many
                        // whitespace characters are between this command and the next (or
                        // the end of the line).
                        // NOTE: +1 is added to trueEndColumnNumber to account for the position
                        // just after the last character in the command string or script line.
                        int preTrimLength  = remainingLine.Length;
                        int postTrimLength = remainingLine.TrimStart().Length;
                        trueEndColumnNumber =
                            commandAst.Extent.EndColumnNumber +
                            (preTrimLength - postTrimLength) + 1;
                    }

                    if (commandAst.Extent.StartColumnNumber <= columnNumber &&
                        trueEndColumnNumber >= columnNumber)
                    {
                        this.FoundCommandReference =
                            new SymbolReference(
                                SymbolType.Function,
                                commandAst.CommandElements[0].Extent);

                        return(AstVisitAction.StopVisit);
                    }
                }
            }

            return(base.VisitPipeline(pipelineAst));
        }
        /// <summary>
        /// Check if the left hand side of an assignmentStatementAst is a VariableExpressionAst
        /// with the same name as that of symbolRef.
        /// </summary>
        /// <param name="assignmentStatementAst">An AssignmentStatementAst</param>
        /// <returns>A decision to stop searching if the right VariableExpressionAst was found,
        /// or a decision to continue if it wasn't found</returns>
        public override AstVisitAction VisitAssignmentStatement(AssignmentStatementAst assignmentStatementAst)
        {
            if (variableName == null)
            {
                return(AstVisitAction.Continue);
            }

            // We want to check VariableExpressionAsts from within this AssignmentStatementAst so we visit it.
            FindDeclarationVariableExpressionVisitor visitor = new FindDeclarationVariableExpressionVisitor(symbolRef);

            assignmentStatementAst.Left.Visit(visitor);

            if (visitor.FoundDeclaration != null)
            {
                FoundDeclaration = visitor.FoundDeclaration;
                return(AstVisitAction.StopVisit);
            }
            return(AstVisitAction.Continue);
        }
        /// <summary>
        /// Constructor used when searching for aliases is needed
        /// </summary>
        /// <param name="symbolReference">The found symbolReference that other symbols are being compared to</param>
        /// <param name="CmdletToAliasDictionary">Dictionary maping cmdlets to aliases for finding alias references</param>
        /// <param name="AliasToCmdletDictionary">Dictionary maping aliases to cmdlets for finding alias references</param>
        public FindReferencesVisitor(
            SymbolReference symbolReference,
            Dictionary <String, List <String> > CmdletToAliasDictionary,
            Dictionary <String, String> AliasToCmdletDictionary)
        {
            this.symbolRef               = symbolReference;
            this.FoundReferences         = new List <SymbolReference>();
            this.needsAliases            = true;
            this.CmdletToAliasDictionary = CmdletToAliasDictionary;
            this.AliasToCmdletDictionary = AliasToCmdletDictionary;

            // Try to get the symbolReference's command name of an alias,
            // if a command name does not exists (if the symbol isn't an alias to a command)
            // set symbolRefCommandName to and empty string value
            AliasToCmdletDictionary.TryGetValue(symbolReference.ScriptRegion.Text, out symbolRefCommandName);
            if (symbolRefCommandName == null)
            {
                symbolRefCommandName = string.Empty;
            }
        }
        /// <summary>
        /// Constructs an instance of a ParameterSetSignatures object
        /// </summary>
        /// <param name="commandInfoSet">Collection of parameter set info</param>
        /// <param name="foundSymbol"> The SymbolReference of the command</param>
        public ParameterSetSignatures(IEnumerable <CommandParameterSetInfo> commandInfoSet, SymbolReference foundSymbol)
        {
            List <ParameterSetSignature> paramSetSignatures = new();

            foreach (CommandParameterSetInfo setInfo in commandInfoSet)
            {
                paramSetSignatures.Add(new ParameterSetSignature(setInfo));
            }
            Signatures   = paramSetSignatures.ToArray();
            CommandName  = foundSymbol.ScriptRegion.Text;
            ScriptRegion = foundSymbol.ScriptRegion;
        }
 /// <summary>
 /// Constructor used when searching for aliases is not needed
 /// </summary>
 /// <param name="foundSymbol">The found symbolReference that other symbols are being compared to</param>
 public FindReferencesVisitor(SymbolReference foundSymbol)
 {
     this.symbolRef       = foundSymbol;
     this.FoundReferences = new List <SymbolReference>();
     this.needsAliases    = false;
 }