mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
Minor code clean-up changes (#5737)
This commit is contained in:
@@ -4257,7 +4257,7 @@ namespace System.Management.Automation
|
||||
{
|
||||
var sessionStateInternal = executionContext.EngineSessionState;
|
||||
completionText = sessionStateInternal.NormalizeRelativePath(path, sessionStateInternal.CurrentLocation.ProviderPath);
|
||||
string parentDirectory = ".." + Path.DirectorySeparatorChar;
|
||||
string parentDirectory = ".." + StringLiterals.DefaultPathSeparator;
|
||||
if (!completionText.StartsWith(parentDirectory, StringComparison.Ordinal))
|
||||
completionText = Path.Combine(".", completionText);
|
||||
}
|
||||
@@ -4472,13 +4472,9 @@ namespace System.Management.Automation
|
||||
var wordToComplete = context.WordToComplete;
|
||||
var colon = wordToComplete.IndexOf(':');
|
||||
|
||||
var prefix = "$";
|
||||
var lastAst = context.RelatedAsts.Last();
|
||||
var variableAst = lastAst as VariableExpressionAst;
|
||||
if (variableAst != null && variableAst.Splatted)
|
||||
{
|
||||
prefix = "@";
|
||||
}
|
||||
var prefix = variableAst != null && variableAst.Splatted ? "@" : "$";
|
||||
|
||||
// Look for variables in the input (e.g. parameters, etc.) before checking session state - these
|
||||
// variables might not exist in session state yet.
|
||||
@@ -5923,7 +5919,7 @@ namespace System.Management.Automation
|
||||
internal static List<CompletionResult> CompleteHelpTopics(CompletionContext context)
|
||||
{
|
||||
var results = new List<CompletionResult>();
|
||||
var dirPath = Utils.GetApplicationBase(Utils.DefaultPowerShellShellID) + Path.DirectorySeparatorChar + CultureInfo.CurrentCulture.Name;
|
||||
var dirPath = Utils.GetApplicationBase(Utils.DefaultPowerShellShellID) + StringLiterals.DefaultPathSeparator + CultureInfo.CurrentCulture.Name;
|
||||
var wordToComplete = context.WordToComplete + "*";
|
||||
var topicPattern = WildcardPattern.Get("about_*.help.txt", WildcardOptions.IgnoreCase);
|
||||
List<string> files = new List<string>();
|
||||
|
||||
@@ -423,7 +423,7 @@ namespace System.Management.Automation
|
||||
{
|
||||
private readonly TypeInferenceContext _context;
|
||||
|
||||
private static readonly PSTypeName StringPSTypeName = new PSTypeName(typeof(string));
|
||||
private static readonly PSTypeName StringPSTypeName = new PSTypeName(typeof(string));
|
||||
|
||||
public TypeInferenceVisitor(TypeInferenceContext context)
|
||||
{
|
||||
|
||||
@@ -353,7 +353,7 @@ namespace System.Management.Automation
|
||||
// The title is automatically generated
|
||||
XmlElement title = _doc.CreateElement("maml:title", mamlURI);
|
||||
string titleStr = string.Format(CultureInfo.InvariantCulture,
|
||||
" -------------------------- {0} {1} --------------------------",
|
||||
"\t\t\t\t-------------------------- {0} {1} --------------------------",
|
||||
HelpDisplayStrings.ExampleUpperCase, count++);
|
||||
XmlText title_text = _doc.CreateTextNode(titleStr);
|
||||
example_node.AppendChild(title).AppendChild(title_text);
|
||||
|
||||
@@ -4981,13 +4981,13 @@ namespace Microsoft.PowerShell.Commands
|
||||
try
|
||||
{
|
||||
string originalPathComparison = path;
|
||||
if (!originalPathComparison.EndsWith("" + StringLiterals.DefaultPathSeparator, StringComparison.OrdinalIgnoreCase))
|
||||
if (!originalPathComparison.EndsWith(StringLiterals.DefaultPathSeparatorString, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
originalPathComparison += StringLiterals.DefaultPathSeparator;
|
||||
}
|
||||
|
||||
string basePathComparison = basePath;
|
||||
if (!basePathComparison.EndsWith("" + StringLiterals.DefaultPathSeparator, StringComparison.OrdinalIgnoreCase))
|
||||
if (!basePathComparison.EndsWith(StringLiterals.DefaultPathSeparatorString, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
basePathComparison += StringLiterals.DefaultPathSeparator;
|
||||
}
|
||||
@@ -5190,7 +5190,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
// See if the base and the path are already the same. We resolve this to
|
||||
// ..\Leaf, since resolving "." to "." doesn't offer much information.
|
||||
if (String.Equals(path, basePath, StringComparison.OrdinalIgnoreCase) &&
|
||||
(!originalPath.EndsWith("" + StringLiterals.DefaultPathSeparator, StringComparison.OrdinalIgnoreCase)))
|
||||
(!originalPath.EndsWith(StringLiterals.DefaultPathSeparatorString, StringComparison.OrdinalIgnoreCase)))
|
||||
{
|
||||
string childName = GetChildName(path);
|
||||
result = MakePath("..", childName);
|
||||
@@ -5237,7 +5237,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
if (!String.IsNullOrEmpty(commonBase))
|
||||
{
|
||||
if (String.Equals(path, commonBase, StringComparison.OrdinalIgnoreCase) &&
|
||||
(!path.EndsWith("" + StringLiterals.DefaultPathSeparator, StringComparison.OrdinalIgnoreCase)))
|
||||
(!path.EndsWith(StringLiterals.DefaultPathSeparatorString, StringComparison.OrdinalIgnoreCase)))
|
||||
{
|
||||
string childName = GetChildName(path);
|
||||
result = MakePath("..", result);
|
||||
|
||||
@@ -663,7 +663,7 @@ namespace System.Management.Automation.Provider
|
||||
// See if the base and the path are already the same. We resolve this to
|
||||
// ..\Leaf, since resolving "." to "." doesn't offer much information.
|
||||
if (String.Equals(normalizedPath, normalizedBasePath, StringComparison.OrdinalIgnoreCase) &&
|
||||
(!originalPath.EndsWith("" + StringLiterals.DefaultPathSeparator, StringComparison.OrdinalIgnoreCase)))
|
||||
(!originalPath.EndsWith(StringLiterals.DefaultPathSeparatorString, StringComparison.OrdinalIgnoreCase)))
|
||||
{
|
||||
string childName = GetChildName(path);
|
||||
result = MakePath("..", childName);
|
||||
@@ -703,7 +703,7 @@ namespace System.Management.Automation.Provider
|
||||
if (!String.IsNullOrEmpty(commonBase))
|
||||
{
|
||||
if (String.Equals(normalizedPath, commonBase, StringComparison.OrdinalIgnoreCase) &&
|
||||
(!normalizedPath.EndsWith("" + StringLiterals.DefaultPathSeparator, StringComparison.OrdinalIgnoreCase)))
|
||||
(!normalizedPath.EndsWith(StringLiterals.DefaultPathSeparatorString, StringComparison.OrdinalIgnoreCase)))
|
||||
{
|
||||
string childName = GetChildName(path);
|
||||
result = MakePath("..", result);
|
||||
|
||||
Reference in New Issue
Block a user