public static CommandCompletion CompleteInput(string input, int cursorIndex, Hashtable options, PowerShell powershell) { if (input == null) { return(EmptyCommandCompletion); } if (cursorIndex > input.Length) { throw PSTraceSource.NewArgumentException("cursorIndex"); } if (powershell == null) { throw PSTraceSource.NewArgumentNullException("powershell"); } int num; int num2; if (!powershell.IsChild) { RemoteRunspace remoteRunspace = powershell.Runspace as RemoteRunspace; if (remoteRunspace != null) { CheckScriptCallOnRemoteRunspace(remoteRunspace); if (remoteRunspace.GetCapabilities().Equals(RunspaceCapability.Default)) { powershell.Commands.Clear(); return(new CommandCompletion(new Collection <CompletionResult>(InvokeLegacyTabExpansion(powershell, input, cursorIndex, true, out num, out num2) ?? EmptyCompletionResult), -1, num, num2)); } } } return(new CommandCompletion(new Collection <CompletionResult>(InvokeLegacyTabExpansion(powershell, input, cursorIndex, true, out num, out num2) ?? EmptyCompletionResult), -1, num, num2)); //TODO: Trying with legacy //return CallScriptWithStringParameterSet(input, cursorIndex, options, powershell); }
public static CommandCompletion CompleteInput(Ast ast, Token[] tokens, IScriptPosition cursorPosition, Hashtable options, PowerShell powershell) { if (ast == null) { throw PSTraceSource.NewArgumentNullException("ast"); } if (tokens == null) { throw PSTraceSource.NewArgumentNullException("tokens"); } if (cursorPosition == null) { throw PSTraceSource.NewArgumentNullException("cursorPosition"); } if (powershell == null) { throw PSTraceSource.NewArgumentNullException("powershell"); } if (!powershell.IsChild) { RemoteRunspace remoteRunspace = powershell.Runspace as RemoteRunspace; if (remoteRunspace != null) { CheckScriptCallOnRemoteRunspace(remoteRunspace); if (remoteRunspace.GetCapabilities().Equals(RunspaceCapability.Default)) { int num; int num2; powershell.Commands.Clear(); Tuple <string, int, int> inputAndCursorFromAst = GetInputAndCursorFromAst(cursorPosition); return(new CommandCompletion(new Collection <CompletionResult>(InvokeLegacyTabExpansion(powershell, inputAndCursorFromAst.Item1, inputAndCursorFromAst.Item2, true, out num, out num2) ?? EmptyCompletionResult), -1, num + inputAndCursorFromAst.Item3, num2)); } string text = ast.Extent.Text; int offset = ((InternalScriptPosition)cursorPosition).Offset; return(CallScriptWithStringParameterSet(text, offset, options, powershell)); } } return(CallScriptWithAstParameterSet(ast, tokens, cursorPosition, options, powershell)); }
internal Pipeline CreatePipeline(RemoteRunspace remoteRunspace) { PowerShell shell = remoteRunspace.GetCapabilities().Equals(RunspaceCapability.Default) ? this.GetPowerShellForPSv2() : this.GetPowerShellForPSv3(); Pipeline pipeline = remoteRunspace.CreatePipeline(shell.Commands.Commands[0].CommandText, true); pipeline.Commands.Clear(); foreach (Command command in shell.Commands.Commands) { pipeline.Commands.Add(command); } pipeline.RedirectShellErrorOutputPipe = true; return pipeline; }