提交 39f92769 编写于 作者: A Artur Spychaj

Enable interactive commands

Enable execute in interactive command.
Enable reset interactive from project command.
上级 37e59ee5
......@@ -231,19 +231,8 @@
-->
<!-- Text editor commands -->
<Button guid="guidInteractiveWindowCmdSet" id="cmdidExecuteInInteractiveWindow" priority="0x101" type="Button">
<Parent guid="guidInteractiveWindowCmdSet" id="TextEditorGroup" />
<CommandFlag>DynamicVisibility</CommandFlag>
<CommandFlag>DefaultInvisible</CommandFlag>
<Strings>
<ButtonText>Execute in Interactive</ButtonText>
<CanonicalName>.InteractiveConsole.ExecuteInInteractive</CanonicalName>
<LocCanonicalName>.InteractiveConsole.ExecuteInInteractive</LocCanonicalName>
</Strings>
</Button>
<Button guid="guidInteractiveWindowCmdSet" id="cmdidCopyToInteractiveWindow" priority="0x102" type="Button">
<Parent guid="guidInteractiveWindowCmdSet" id="TextEditorGroup" />
<CommandFlag>DynamicVisibility</CommandFlag>
<CommandFlag>DefaultInvisible</CommandFlag>
<Strings>
......@@ -296,10 +285,8 @@
<KeyBinding guid="guidInteractiveWindowCmdSet" id="cmdidSearchHistoryPrevious" key1="VK_UP" mod1="Control Alt" editor="guidInteractiveWindow" />
<KeyBinding guid="guidInteractiveWindowCmdSet" id="cmdidCopyCode" key1="C" mod1="Control Shift" editor="guidInteractiveWindow" />
<KeyBinding guid="guidInteractiveWindowCmdSet" id="cmdidExecuteInInteractiveWindow" editor="GUID_TextEditorFactory" mod1="Control" key1="E" mod2="Control" key2="VK_RETURN" />
<KeyBinding guid="guidVSStd11" id="cmdidExecuteSelectionInInteractive" editor="guidCSharpEditorFactory" mod1="Control" key1="E" mod2="Control" key2="E" />
<KeyBinding guid="guidInteractiveWindowCmdSet" id="cmdidCopyToInteractiveWindow" editor="GUID_TextEditorFactory" mod1="Control" key1="K" mod2="Control" key2="VK_RETURN" />
<KeyBinding guid="guidInteractiveWindowCmdSet" id="cmdidExecuteInInteractiveWindow" editor="GUID_TextEditorFactory" mod1="Control" key1="VK_RETURN" />
<KeyBinding guid="guidInteractiveWindowCmdSet" id="cmdidCopyToInteractiveWindow" editor="GUID_TextEditorFactory" mod1="Control Shift" key1="VK_RETURN" />
</KeyBindings>
<UsedCommands>
......@@ -314,6 +301,9 @@
<GuidSymbol name="guidInteractiveWindowPkg" value="{F5199A4E-6A60-4F79-82E9-FC92A41C4610}" />
<GuidSymbol name="guidInteractiveWindow" value="{2D0A56AA-9527-4B78-B6E6-EBE6E05DA749}" />
<!-- This is the guid to refer to CSharp text editor scope for keybindings. -->
<GuidSymbol name="guidCSharpEditorFactory" value="{a6c744a8-0e4a-4fc6-886a-064283054674}" />
<!-- This is the guid used to group the menu commands together -->
<GuidSymbol name="guidInteractiveWindowCmdSet" value="{00B8868B-F9F5-4970-A048-410B05508506}">
<!-- Command -->
......
......@@ -10,7 +10,7 @@
namespace Microsoft.VisualStudio.LanguageServices.CSharp.Interactive
{
[ExportCommandHandler("Interactive Command Handler")]
[ExportCommandHandler("Interactive Command Handler", ContentTypeNames.CSharpContentType)]
internal sealed class CSharpInteractiveCommandHandler : InteractiveCommandHandler
{
private readonly CSharpVsInteractiveWindowProvider _interactiveWindowProvider;
......
......@@ -24,7 +24,6 @@
</Strings>
</Button>
<!-- https://github.com/dotnet/roslyn/issues/4688
<Button guid="guidCSharpInteractiveCommandSet" id="cmdidResetInteractiveFromProject" priority="0x0100" type="Button">
<Parent guid="guidCSharpInteractiveCommandSet" id="IDG_INTERACTIVE_PROJECT"/>
<CommandFlag>DynamicVisibility</CommandFlag>
......@@ -35,12 +34,12 @@
<LocCanonicalName>ResetC#InteractiveFromProject</LocCanonicalName>
</Strings>
</Button>
-->
</Buttons>
</Commands>
<VisibilityConstraints>
<VisibilityItem context="guidCSProjectContext" guid="guidCSharpInteractiveCommandSet" id="cmdidResetInteractiveFromProject" />
<VisibilityItem context="guidVBProjectContext" guid="guidCSharpInteractiveCommandSet" id="cmdidResetInteractiveFromProject" />
</VisibilityConstraints>
<!-- https://github.com/dotnet/roslyn/issues/3941
......@@ -61,6 +60,7 @@
</GuidSymbol>
<GuidSymbol name="guidCSProjectContext" value="{FAE04EC1-301F-11D3-BF4B-00C04F79EFBC}" />
<GuidSymbol name="guidVBProjectContext" value="{164B10B9-B200-11D0-8C61-00A0C91E29D5}" />
<!-- TODO (https://github.com/dotnet/roslyn/issues/6078): delete this -->
<GuidSymbol name="RoslynImageCatalogGuid" value="{ae27a6b0-e345-4288-96df-5eaf394ee369}">
......
......@@ -9,11 +9,6 @@
using Microsoft.VisualStudio.Text;
using Microsoft.VisualStudio.Utilities;
#if INTERACTIVE
using InteractiveCommandIds = Microsoft.VisualStudio.LanguageServices.InteractiveWindow.CommandIds;
using InteractiveGuids = Microsoft.VisualStudio.LanguageServices.InteractiveWindow.Guids;
#endif
namespace Microsoft.VisualStudio.LanguageServices.Implementation
{
internal abstract partial class AbstractOleCommandTarget
......@@ -52,12 +47,10 @@ public virtual int Exec(ref Guid pguidCmdGroup, uint commandId, uint executeInfo
{
return ExecuteVisualStudio97(ref pguidCmdGroup, commandId, executeInformation, pvaIn, pvaOut, subjectBuffer, contentType);
}
#if INTERACTIVE
else if (pguidCmdGroup == InteractiveGuids.InteractiveCommandSetId)
{
return ExecuteInteractiveCommands(ref pguidCmdGroup, commandId, executeInformation, pvaIn, pvaOut, subjectBuffer, contentType);
}
#endif
else if (pguidCmdGroup == VSConstants.VsStd11)
{
return ExecuteVisualStudio11(ref pguidCmdGroup, commandId, executeInformation, pvaIn, pvaOut, subjectBuffer, contentType);
}
else if (pguidCmdGroup == VSConstants.VsStd14)
{
return ExecuteVisualStudio2014(ref pguidCmdGroup, commandId, executeInformation, pvaIn, pvaOut, subjectBuffer, contentType);
......@@ -577,8 +570,7 @@ private void ExecuteGoToPreviousMethod(ITextBuffer subjectBuffer, IContentType c
lastHandler: executeNextCommandTarget);
}
#if INTERACTIVE
private int ExecuteInteractiveCommands(ref Guid pguidCmdGroup, uint commandId, uint executeInformation, IntPtr pvaIn, IntPtr pvaOut, ITextBuffer subjectBuffer, IContentType contentType)
private int ExecuteVisualStudio11(ref Guid pguidCmdGroup, uint commandId, uint executeInformation, IntPtr pvaIn, IntPtr pvaOut, ITextBuffer subjectBuffer, IContentType contentType)
{
int result = VSConstants.S_OK;
var guidCmdGroup = pguidCmdGroup;
......@@ -587,23 +579,18 @@ private int ExecuteInteractiveCommands(ref Guid pguidCmdGroup, uint commandId, u
result = NextCommandTarget.Exec(ref guidCmdGroup, commandId, executeInformation, pvaIn, pvaOut);
};
switch ((InteractiveCommandIds)commandId)
switch ((VSConstants.VSStd11CmdID)commandId)
{
case InteractiveCommandIds.ExecuteInInteractiveWindow:
case VSConstants.VSStd11CmdID.ExecuteSelectionInInteractive:
ExecuteExecuteInInteractiveWindow(subjectBuffer, contentType, executeNextCommandTarget);
break;
case InteractiveCommandIds.CopyToInteractiveWindow:
ExecuteCopyToToInteractiveWindow(subjectBuffer, contentType, executeNextCommandTarget);
break;
default:
return NextCommandTarget.Exec(ref pguidCmdGroup, commandId, executeInformation, pvaIn, pvaOut);
}
return result;
}
#endif
private void ExecuteMoveSelectedLinesUp(ITextBuffer subjectBuffer, IContentType contentType, Action executeNextCommandTarget)
{
......@@ -984,13 +971,6 @@ private void ExecuteExecuteInInteractiveWindow(ITextBuffer subjectBuffer, IConte
lastHandler: executeNextCommandTarget);
}
private void ExecuteCopyToToInteractiveWindow(ITextBuffer subjectBuffer, IContentType contentType, Action executeNextCommandTarget)
{
CurrentHandlers.Execute(contentType,
args: new CopyToInteractiveCommandArgs(ConvertTextView(), subjectBuffer),
lastHandler: executeNextCommandTarget);
}
private void ExecuteBrowserBackward(ITextBuffer subjectBuffer, IContentType contentType, Action executeNextCommandTarget)
{
ExecuteBrowserNavigationCommand(navigateBackward: true, executeNextCommandTarget: executeNextCommandTarget);
......
......@@ -12,11 +12,6 @@
using Microsoft.VisualStudio.Text.Editor;
using Roslyn.Utilities;
#if INTERACTIVE
using InteractiveCommandIds = Microsoft.VisualStudio.LanguageServices.InteractiveWindow.CommandIds;
using InteractiveGuids = Microsoft.VisualStudio.LanguageServices.InteractiveWindow.Guids;
#endif
namespace Microsoft.VisualStudio.LanguageServices.Implementation
{
internal abstract partial class AbstractOleCommandTarget
......@@ -42,12 +37,10 @@ public int QueryStatus(ref Guid pguidCmdGroup, uint commandCount, OLECMD[] prgCm
{
return QueryVisualStudio97Status(ref pguidCmdGroup, commandCount, prgCmds, commandText);
}
#if INTERACTIVE
else if (pguidCmdGroup == InteractiveGuids.InteractiveCommandSetId)
else if (pguidCmdGroup == VSConstants.VsStd11)
{
return QueryInteractiveCommandStatus(ref pguidCmdGroup, commandCount, prgCmds, commandText);
return QueryVisualStudio11Status(ref pguidCmdGroup, commandCount, prgCmds, commandText);
}
#endif
else if (pguidCmdGroup == VSConstants.VsStd14)
{
return QueryVisualStudio2014Status(ref pguidCmdGroup, commandCount, prgCmds, commandText);
......@@ -231,22 +224,17 @@ private int QueryVisualStudio2000Status(ref Guid pguidCmdGroup, uint commandCoun
}
}
#if INTERACTIVE
private int QueryInteractiveCommandStatus(ref Guid pguidCmdGroup, uint commandCount, OLECMD[] prgCmds, IntPtr commandText)
private int QueryVisualStudio11Status(ref Guid pguidCmdGroup, uint commandCount, OLECMD[] prgCmds, IntPtr commandText)
{
switch ((InteractiveCommandIds)prgCmds[0].cmdID)
switch ((VSConstants.VSStd11CmdID)prgCmds[0].cmdID)
{
case InteractiveCommandIds.ExecuteInInteractiveWindow:
return QueryExecuteInInteractiveWindowStatus(ref pguidCmdGroup, commandCount, prgCmds, commandText);
case InteractiveCommandIds.CopyToInteractiveWindow:
return QueryCopyToInteractiveWindowStatus(ref pguidCmdGroup, commandCount, prgCmds, commandText);
case VSConstants.VSStd11CmdID.ExecuteSelectionInInteractive:
return QueryExecuteInInteractiveWindowStatus(ref pguidCmdGroup, commandCount, prgCmds, commandText); ;
default:
return NextCommandTarget.QueryStatus(ref pguidCmdGroup, commandCount, prgCmds, commandText);
}
}
#endif
private int GetCommandState<T>(
Func<ITextView, ITextBuffer, T> createArgs,
......@@ -491,13 +479,6 @@ private int QueryExecuteInInteractiveWindowStatus(ref Guid pguidCmdGroup, uint c
ref pguidCmdGroup, commandCount, prgCmds, commandText);
}
private int QueryCopyToInteractiveWindowStatus(ref Guid pguidCmdGroup, uint commandCount, OLECMD[] prgCmds, IntPtr commandText)
{
return GetCommandState(
(v, b) => new CopyToInteractiveCommandArgs(v, b),
ref pguidCmdGroup, commandCount, prgCmds, commandText);
}
private int QueryEncapsulateFieldStatus(ref Guid pguidCmdGroup, uint commandCount, OLECMD[] prgCmds, IntPtr commandText)
{
return GetCommandState(
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册