/// <summary> /// Initializes a new instance of the CompletionResult class. /// </summary> /// <param name="completionText">The text to be used as the auto completion result.</param> /// <param name="listItemText">The text to be displayed in a list.</param> /// <param name="resultType">The type of completion result.</param> /// <param name="toolTip">The text for the tooltip with details to be displayed about the object.</param> public CompletionResult(string completionText, string listItemText, CompletionResultType resultType, string toolTip) { if (String.IsNullOrEmpty(completionText)) { throw PSTraceSource.NewArgumentNullException("completionText"); } if (String.IsNullOrEmpty(listItemText)) { throw PSTraceSource.NewArgumentNullException("listItemText"); } if (resultType < CompletionResultType.Text || resultType > CompletionResultType.DynamicKeyword) { throw PSTraceSource.NewArgumentOutOfRangeException("resultType", resultType); } if (String.IsNullOrEmpty(toolTip)) { throw PSTraceSource.NewArgumentNullException("toolTip"); } _completionText = completionText; _listItemText = listItemText; _toolTip = toolTip; _resultType = resultType; }
/// <summary> /// Initializes a new instance of the CompletionResult class /// </summary> /// <param name="completionText">the text to be used as the auto completion result</param> /// <param name="listItemText">he text to be displayed in a list</param> /// <param name="resultType">the type of completion result</param> /// <param name="toolTip">the text for the tooltip with details to be displayed about the object</param> public CompletionResult(string completionText, string listItemText, CompletionResultType resultType, string toolTip, string detail) { if (String.IsNullOrEmpty(completionText)) { throw new Exception("CompletionText"); } if (String.IsNullOrEmpty(listItemText)) { throw new Exception("CompletionText"); } if (resultType < CompletionResultType.Text || resultType > CompletionResultType.DynamicKeyword) { throw new Exception("CompletionText"); } if (String.IsNullOrEmpty(toolTip)) { throw new Exception("CompletionText"); } _completionText = completionText; _listItemText = listItemText; _toolTip = toolTip; _resultType = resultType; _detail = detail; }
private static CompletionType ConvertCompletionResultType( CompletionResultType completionResultType) { switch (completionResultType) { case CompletionResultType.Command: return(CompletionType.Command); case CompletionResultType.Method: return(CompletionType.Method); case CompletionResultType.ParameterName: return(CompletionType.ParameterName); case CompletionResultType.ParameterValue: return(CompletionType.ParameterValue); case CompletionResultType.Property: return(CompletionType.Property); case CompletionResultType.Variable: return(CompletionType.Variable); case CompletionResultType.Namespace: return(CompletionType.Namespace); case CompletionResultType.Type: return(CompletionType.Type); #if !PowerShellv3 case CompletionResultType.Keyword: return(CompletionType.Keyword); #endif case CompletionResultType.ProviderContainer: return(CompletionType.Folder); case CompletionResultType.ProviderItem: return(CompletionType.File); default: // TODO: Trace the unsupported CompletionResultType return(CompletionType.Unknown); } }
internal static List <CompletionResult> PSv2GenerateMatchSetOfFiles(CompletionExecutionHelper helper, string lastWord, bool completingAtStartOfLine, string quote) { List <CompletionResult> list = new List <CompletionResult>(); lastWord = lastWord ?? string.Empty; bool flag = string.IsNullOrEmpty(lastWord); bool flag2 = !flag && lastWord.EndsWith("*", StringComparison.Ordinal); bool flag3 = WildcardPattern.ContainsWildcardCharacters(lastWord); string str = lastWord + "*"; bool shouldFullyQualifyPaths = PSv2ShouldFullyQualifyPathsPath(helper, lastWord); bool flag5 = lastWord.StartsWith(@"\\", StringComparison.Ordinal) || lastWord.StartsWith("//", StringComparison.Ordinal); List <PathItemAndConvertedPath> list2 = null; List <PathItemAndConvertedPath> list3 = null; if (flag3 && !flag) { list2 = PSv2FindMatches(helper, lastWord, shouldFullyQualifyPaths); } if (!flag2) { list3 = PSv2FindMatches(helper, str, shouldFullyQualifyPaths); } IEnumerable <PathItemAndConvertedPath> enumerable = CombineMatchSets(list2, list3); if (enumerable != null) { foreach (PathItemAndConvertedPath path in enumerable) { string str2 = WildcardPattern.Escape(path.Path); string str3 = WildcardPattern.Escape(path.ConvertedPath); string completionText = flag5 ? str3 : str2; completionText = AddQuoteIfNecessary(completionText, quote, completingAtStartOfLine); bool? nullable = SafeGetProperty <bool?>(path.Item, "PSIsContainer"); string listItemText = SafeGetProperty <string>(path.Item, "PSChildName"); string toolTip = CompletionExecutionHelper.SafeToString(path.ConvertedPath); if (nullable.HasValue && !string.IsNullOrEmpty(listItemText) && toolTip != null) { CompletionResultType resultType = nullable.Value ? CompletionResultType.ProviderContainer : CompletionResultType.ProviderItem; list.Add(new CompletionResult(completionText, listItemText, resultType, toolTip)); } } } return(list); }
public CompletionResult(string completionText, string listItemText, CompletionResultType resultType, string toolTip) { if (string.IsNullOrEmpty(completionText)) { throw PSTraceSource.NewArgumentNullException("completionText"); } if (string.IsNullOrEmpty(listItemText)) { throw PSTraceSource.NewArgumentNullException("listItemText"); } if ((resultType < CompletionResultType.Text) || (resultType > CompletionResultType.Type)) { throw PSTraceSource.NewArgumentOutOfRangeException("resultType", resultType); } if (string.IsNullOrEmpty(toolTip)) { throw PSTraceSource.NewArgumentNullException("toolTip"); } this.completionText = completionText; this.listItemText = listItemText; this.toolTip = toolTip; this.resultType = resultType; }
internal static void ReportTabCompletionTelemetry(long elapsedMilliseconds, int count, CompletionResultType completionResultType) { // We'll collect some general statistics. int idx = (int)completionResultType; if (idx >= 0 && idx <= (int)CompletionResultType.DynamicKeyword) { s_tabCompletionTimes[idx] += elapsedMilliseconds; s_tabCompletionCounts[idx]++; s_tabCompletionResultCounts[idx] += count; } // Also write an event for any slow tab completion (> 250ms). if (elapsedMilliseconds > 250) { TelemetryWrapper.TraceMessage("PSSlowTabCompletion", new { Time = elapsedMilliseconds, Count = count, Type = completionResultType, }); } }
private static CompletionType ConvertCompletionResultType( CompletionResultType completionResultType) { switch (completionResultType) { case CompletionResultType.Command: return CompletionType.Command; case CompletionResultType.Method: return CompletionType.Method; case CompletionResultType.ParameterName: return CompletionType.ParameterName; case CompletionResultType.ParameterValue: return CompletionType.ParameterValue; case CompletionResultType.Variable: return CompletionType.Variable; case CompletionResultType.Namespace: return CompletionType.Namespace; case CompletionResultType.Type: return CompletionType.Type; #if !PowerShellv3 case CompletionResultType.Keyword: return CompletionType.Keyword; #endif case CompletionResultType.ProviderContainer: case CompletionResultType.ProviderItem: return CompletionType.Path; default: // TODO: Trace the unsupported CompletionResultType return CompletionType.Unknown; } }
private static CompletionResult GetCompletionResult(string word, string wordLabel, CompletionResultType resultType) { // Only wrap in single quotes if they have a space. This makes it easier // to use on macOs return(new CompletionResult(word.Contains(" ") ? $"'{word}'" : word, wordLabel, resultType, wordLabel + ": " + word)); }
/// <summary> /// Initializes a new instance of the CompletionResult class /// </summary> /// <param name="completionText">the text to be used as the auto completion result</param> /// <param name="listItemText">he text to be displayed in a list</param> /// <param name="resultType">the type of completion result</param> /// <param name="toolTip">the text for the tooltip with details to be displayed about the object</param> public CompletionResult(string completionText, string listItemText, CompletionResultType resultType, string toolTip) { if (String.IsNullOrEmpty(completionText)) { throw PSTraceSource.NewArgumentNullException("completionText"); } if (String.IsNullOrEmpty(listItemText)) { throw PSTraceSource.NewArgumentNullException("listItemText"); } if (resultType < CompletionResultType.Text || resultType > CompletionResultType.DynamicKeyword) { throw PSTraceSource.NewArgumentOutOfRangeException("resultType", resultType); } if (String.IsNullOrEmpty(toolTip)) { throw PSTraceSource.NewArgumentNullException("toolTip"); } _completionText = completionText; _listItemText = listItemText; _toolTip = toolTip; _resultType = resultType; }