private string[] GenerateMatchSetOfCmdlets(
     string lastWord,
     bool isPSSnapInSpecified,
     CultureInfo ci)
 {
     using (CommandCompletionBase.tracer.TraceMethod(lastWord, new object[0]))
     {
         string[] strArray = (string[])null;
         Collection <PSObject> collection = this.exec.ExecuteCommand(string.Format((IFormatProvider)CultureInfo.InvariantCulture, "& {{ trap {{ continue }} ; get-command '{0}' -type Cmdlet }}", (object)(lastWord + "*")));
         if (collection != null && collection.Count > 0)
         {
             PSSnapinQualifiedName[] snapinQualifiedNameArray = new PSSnapinQualifiedName[collection.Count];
             for (int index = 0; index < collection.Count; ++index)
             {
                 string fullName = CmdletInfo.GetFullName(collection[index]);
                 snapinQualifiedNameArray[index] = PSSnapinQualifiedName.GetInstance(fullName);
             }
             Array.Sort <PSSnapinQualifiedName>(snapinQualifiedNameArray, new Comparison <PSSnapinQualifiedName>(CommandCompletionBase.PSSnapinQualifiedNameComparison));
             if (isPSSnapInSpecified)
             {
                 strArray = new string[collection.Count];
                 for (int index = 0; index < snapinQualifiedNameArray.Length; ++index)
                 {
                     strArray[index] = snapinQualifiedNameArray[index].FullName;
                 }
             }
             else
             {
                 strArray = CommandCompletionBase.PrependPSSnapInNameForSameCmdletNames(snapinQualifiedNameArray);
             }
         }
         return(strArray);
     }
 }
        private string[] GenerateMatchSet(
            string input,
            string lastWord,
            CultureInfo ci,
            bool completingAtStartOfLine,
            ref bool addQuotes)
        {
            bool isPSSnapInSpecified = false;
            bool flag = CommandCompletionBase.IsCommandLikeCmdlet(lastWord, out isPSSnapInSpecified);

            string[] strArray1          = (string[])null;
            string[] matchSetFromCmdlet = this.GenerateMatchSetFromCmdlet(input, lastWord);
            if (matchSetFromCmdlet != null)
            {
                addQuotes = false;
                return(matchSetFromCmdlet);
            }
            if (flag)
            {
                strArray1 = this.GenerateMatchSetOfCmdlets(lastWord, isPSSnapInSpecified, ci);
            }
            string[] matchSetOfFiles = this.GenerateMatchSetOfFiles(lastWord, ci, completingAtStartOfLine);
            string[] strArray2;
            if (strArray1 == null)
            {
                strArray2 = matchSetOfFiles;
            }
            else if (matchSetOfFiles == null)
            {
                strArray2 = strArray1;
            }
            else
            {
                strArray2 = new string[strArray1.Length + matchSetOfFiles.Length];
                matchSetOfFiles.CopyTo((Array)strArray2, 0);
                strArray1.CopyTo((Array)strArray2, matchSetOfFiles.Length);
            }
            addQuotes = true;
            return(strArray2);
        }
        private string[] GenerateMatchSetOfFiles(
            string lastWord,
            CultureInfo ci,
            bool completingAtStartOfLine)
        {
            bool   matchFoundInCurrentLocation = false;
            bool   flag1 = (!lastWord.StartsWith("'", StringComparison.CurrentCulture) || !lastWord.EndsWith("'", StringComparison.CurrentCulture)) && (!lastWord.StartsWith("\"", StringComparison.CurrentCulture) || !lastWord.EndsWith("\"", StringComparison.CurrentCulture));
            bool   flag2 = string.IsNullOrEmpty(lastWord);
            bool   flag3 = lastWord.EndsWith("*", StringComparison.CurrentCulture);
            bool   flag4 = WildcardPattern.ContainsWildcardCharacters(lastWord);
            string path  = flag1 ? "'" + lastWord + "*'" : lastWord + "*";
            bool   shouldFullyQualifyPaths = this.ShouldFullyQualifyPathsPath(lastWord, path);
            bool   flag5 = false;

            if (lastWord.StartsWith("\\\\", StringComparison.CurrentCulture) || lastWord.StartsWith("//", StringComparison.CurrentCulture))
            {
                flag5 = true;
            }
            string[] s1 = (string[])null;
            string[] s2 = (string[])null;
            if (flag4 && !flag2)
            {
                s1 = this.FindMatches(flag1 ? "'" + lastWord + "'" : lastWord, shouldFullyQualifyPaths, ci, ref matchFoundInCurrentLocation);
            }
            if (!flag3)
            {
                s2 = this.FindMatches(path, shouldFullyQualifyPaths, ci, ref matchFoundInCurrentLocation);
            }
            string[] strArray = CommandCompletionBase.CombineMatchSets(s1, s2, ci);
            if (strArray != null)
            {
                for (int index = 0; index < strArray.Length; ++index)
                {
                    string s = CommandCompletionBase.EscapeSpecialCharacters(strArray[index]);
                    strArray[index] = completingAtStartOfLine && matchFoundInCurrentLocation || s == "~" ? ".\\" + s : (!flag5 ? s : this.RemoveProviderQualifier(s));
                }
            }
            return(strArray);
        }
        internal string GetNextCompletionMatch(string input, bool lookForward)
        {
            try
            {
                switch (input)
                {
                case "":
                case null:
                    return(input + "    ");

                default:
                    if (input.Trim().Length != 0)
                    {
                        if (this.exec.CancelTabCompletion || input.Length == 0 || input != this.lastCompletedInput)
                        {
                            this.exec.CancelTabCompletion = false;
                            this.matchSet          = this.GetFreshMatches(ref input, ref this.currentAddQuotes, out this.currentClosingQuote, ref this.currentReplacementIndex);
                            this.currentMatchIndex = -1;
                        }
                        string completionText = (string)null;
                        if (this.matchSet != null)
                        {
                            completionText = CommandCompletionBase.GetNextMatch(lookForward, this.matchSet, ref this.currentMatchIndex);
                        }
                        this.lastCompletedInput = CommandCompletionBase.ComposeCompletedInput(input, completionText, this.currentReplacementIndex, this.currentClosingQuote, this.currentAddQuotes);
                        return(this.lastCompletedInput);
                    }
                    goto case "";
                }
            }
            catch (Exception ex)
            {
                CommandCompletionBase.tracer.TraceException(ex);
                CommandProcessorBase.CheckForSevereException(ex);
                return(string.Empty);
            }
        }