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

Enable interactive commands

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