Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc5a6460

Browse files
committed
Enable basic script debugging
1 parent0676493 commitc5a6460

File tree

5 files changed

+147
-91
lines changed

5 files changed

+147
-91
lines changed

‎vsintegration/src/vs/FsPkgs/FSharp.LanguageService/FSharp.LanguageService.Base/ViewFilter.cs‎

Lines changed: 58 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,16 +64,21 @@ public class ViewFilter : IVsTextViewFilter, IVsTextViewEvents, IOleCommandTarge
6464
privateIntPtrpvaChar;
6565
privateboolgotEnterKey;
6666
privateboolsnippetBound;
67-
privateVsCommandsgotoCmd;
67+
privateVsCommandsgotoCmd;
68+
privatereadonlyGuidguidInteractive=newGuid("8B9BF77B-AF94-4588-8847-2EB2BFFD29EB");
69+
privatereadonlyuintcmdIDDebugSelection=0x01;
70+
privatereadonlyuintcmdIDDebugLine=0x02;
6871

6972
/// <include file='doc\ViewFilter.uex' path='docs/doc[@for="ViewFilter.SnippetBound"]/*' />
7073
protectedboolSnippetBound{
7174
get{returnsnippetBound;}
7275
set{snippetBound=value;}
7376
}
77+
7478
privateNativeMethods.ConnectionPointCookieexpansionEvents;
75-
#ifFX_ATLEAST_45
79+
7680
privateMicrosoft.VisualStudio.Shell.PackageprojectSystemPackage=null;
81+
7782
privateMicrosoft.VisualStudio.Shell.PackageGetProjectSystemPackage()
7883
{
7984
// Ideally the FsiToolWindow would be a part of the language service, but right now its code lives in the
@@ -89,7 +94,20 @@ private Microsoft.VisualStudio.Shell.Package GetProjectSystemPackage()
8994
}
9095
returnthis.projectSystemPackage;
9196
}
92-
#endif
97+
98+
privateboolDebuggerIsRunning()
99+
{
100+
vardebugger=this.service.GetIVsDebugger();
101+
returndebugger!=null&&this.mgr.LanguageService.IsDebugging;
102+
}
103+
104+
privateboolEditorSelectionIsEmpty()
105+
{
106+
stringselection;
107+
this.textView.GetSelectedText(outselection);
108+
returnselection=="";
109+
}
110+
93111
/// <include file='doc\ViewFilter.uex' path='docs/doc[@for="ViewFilter.ViewFilter"]/*' />
94112
internalViewFilter(CodeWindowManagermgr,IVsTextViewview){
95113
this.pvaChar=IntPtr.Zero;
@@ -416,15 +434,36 @@ protected virtual int QueryCommandStatus(ref Guid guidCmdGroup, uint nCmdId) {
416434
return(int)OleConstants.OLECMDERR_E_NOTSUPPORTED;
417435
}
418436
}
419-
#ifFX_ATLEAST_45
420437
elseif(guidCmdGroup==Microsoft.VisualStudio.VSConstants.VsStd11)
421438
{
422439
if(nCmdId==(uint)Microsoft.VisualStudio.VSConstants.VSStd11CmdID.ExecuteSelectionInInteractive)
423440
{
424441
return(int)OLECMDF.OLECMDF_SUPPORTED|(int)OLECMDF.OLECMDF_ENABLED;
425442
}
426443
}
427-
#endif
444+
elseif(guidCmdGroup==guidInteractive)
445+
{
446+
if(nCmdId==cmdIDDebugSelection)
447+
{
448+
if(DebuggerIsRunning())
449+
return(int)OLECMDF.OLECMDF_INVISIBLE;
450+
else
451+
{
452+
if(EditorSelectionIsEmpty())
453+
return(int)OLECMDF.OLECMDF_SUPPORTED;
454+
else
455+
return(int)OLECMDF.OLECMDF_SUPPORTED|(int)OLECMDF.OLECMDF_ENABLED;
456+
}
457+
}
458+
elseif(nCmdId==cmdIDDebugLine)
459+
{
460+
if(DebuggerIsRunning())
461+
return(int)OLECMDF.OLECMDF_INVISIBLE;
462+
else
463+
return(int)OLECMDF.OLECMDF_SUPPORTED|(int)OLECMDF.OLECMDF_ENABLED;
464+
}
465+
}
466+
428467
return(int)NativeMethods.E_FAIL;// delegate to next command target.
429468
}
430469

@@ -541,7 +580,6 @@ public virtual bool HandlePreExec(ref Guid guidCmdGroup, uint nCmdId, uint nCmde
541580

542581
}
543582
}
544-
#ifFX_ATLEAST_45
545583
elseif(guidCmdGroup==Microsoft.VisualStudio.VSConstants.VsStd11)
546584
{
547585
if(nCmdId==(uint)Microsoft.VisualStudio.VSConstants.VSStd11CmdID.ExecuteSelectionInInteractive)
@@ -550,7 +588,20 @@ public virtual bool HandlePreExec(ref Guid guidCmdGroup, uint nCmdId, uint nCmde
550588
returntrue;
551589
}
552590
}
553-
#endif
591+
elseif(guidCmdGroup==guidInteractive)
592+
{
593+
if(nCmdId==cmdIDDebugSelection)
594+
{
595+
Interactive.Hooks.OnMLSend(GetProjectSystemPackage(),false,true,null,null);
596+
returntrue;
597+
}
598+
elseif(nCmdId==cmdIDDebugLine)
599+
{
600+
Interactive.Hooks.OnMLSend(GetProjectSystemPackage(),true,true,null,null);
601+
returntrue;
602+
}
603+
}
604+
554605
returnfalse;
555606
}
556607

‎vsintegration/src/vs/FsPkgs/FSharp.VS.FSI/fsiBasis.fs‎

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -42,30 +42,21 @@ module internal Guids =
4242
#endif
4343

4444
// FSI Session command set
45-
letcmdIDFsiConsoleContextMenu=0x2100
46-
letguidFsiConsoleCmdSet= Guid("0E455B35-F2EB-431b-A0BE-B268D8A7D17F")
47-
#if FX_ATLEAST_45
4845
letguidInteractiveCommands= Microsoft.VisualStudio.VSConstants.VsStd11
4946
letcmdIDSessionInterrupt= int Microsoft.VisualStudio.VSConstants.VSStd11CmdID.InteractiveSessionInterrupt
5047
letcmdIDSessionRestart= int Microsoft.VisualStudio.VSConstants.VSStd11CmdID.InteractiveSessionRestart
51-
#else
52-
letguidInteractiveCommands= guidFsiConsoleCmdSet
53-
letcmdIDSessionInterrupt=0x102
54-
letcmdIDSessionRestart=0x103
55-
#endif
48+
49+
letguidFsiConsoleCmdSet= Guid("0E455B35-F2EB-431b-A0BE-B268D8A7D17F")
50+
letcmdIDAttachDebugger=0x104
51+
letcmdIDFsiConsoleContextMenu=0x2100
5652

5753
// Command set for SendToInteractive
58-
#if FX_ATLEAST_45
59-
// commands moved to VS Shell
60-
letguidInteractive= Microsoft.VisualStudio.VSConstants.VsStd11
54+
// some commands moved to VS Shell
55+
letguidInteractiveShell= Microsoft.VisualStudio.VSConstants.VsStd11
6156
letcmdIDSendSelection= int Microsoft.VisualStudio.VSConstants.VSStd11CmdID.ExecuteSelectionInInteractive
62-
letguidInteractive2= Microsoft.VisualStudio.VSConstants.VsStd11
63-
#else
64-
// hybrid still uses own commands
57+
// some commands not in VS Shell
6558
letguidInteractive= Guid("8B9BF77B-AF94-4588-8847-2EB2BFFD29EB")
66-
letcmdIDSendSelection=0x01
67-
letguidInteractive2= Guid("B607E86C-A761-4685-8D98-71A3BB73233A")
68-
#endif
59+
letcmdIDDebugSelection=0x01
6960

7061
letguidFsiPackage="eeeeeeee-9342-42f1-8ea9-42f0e8a6be55"// FSI-LINKAGE-POINT: when packaged here
7162
letguidFSharpProjectPkgString="91A04A73-4F2C-4E7C-AD38-C1A68E7DA05C"// FSI-LINKAGE-POINT: when packaged in project system

‎vsintegration/src/vs/FsPkgs/FSharp.VS.FSI/fsiCommands.vsct‎

Lines changed: 30 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -92,43 +92,28 @@
9292
</Strings>
9393
</Button>
9494

95-
<!-- In Dev11, shell now has
95+
<!-- In Dev11+, shell now has
9696
<Button guid ="guidVSStd11" id ="cmdidInteractiveSessionInterrupt" priority ="0x100" type ="Button">
9797
<Button guid ="guidVSStd11" id ="cmdidInteractiveSessionRestart" priority ="0x105" type ="Button">
9898
-->
99-
<!-- In Dev10 hybrid, we need buttons below-->
100-
<ButtonCondition="!Defined(FX_ATLEAST_45)"guid="guidFsiConsoleCmdSet"id="cmdidSessionInterrupt"priority="0x0100"type="Button">
101-
<Parentguid="guidFsiConsoleCmdSet"id="IDG_VS_WNDO_OTRWNDWS1"/>
102-
<!-- Icon guid="guidImages" id="bmpPic2" /-->
103-
<Iconguid="guidCancelEvaluationBmp"id="bmpConsole" />
99+
<Buttonguid="guidFsiConsoleCmdSet"id="cmdidAttachDebugger"priority="0x0100"type="Button">
104100
<Strings>
105-
<CommandName>FSharp.Interactive.Interrupt</CommandName>
106-
<ButtonText>Cancel Evaluation</ButtonText><!-- This was called "Interrupt Session"-->
107-
</Strings>
108-
</Button>
109-
<ButtonCondition="!Defined(FX_ATLEAST_45)"guid="guidFsiConsoleCmdSet"id="cmdidSessionRestart"priority="0x0100"type="Button">
110-
<Parentguid="guidFsiConsoleCmdSet"id="IDG_VS_WNDO_OTRWNDWS1"/>
111-
<!-- Icon guid="guidImages" id="bmpPic2" /-->
112-
<Iconguid="guidResetSessionBmp"id="bmpConsole" />
113-
<Strings>
114-
<CommandName>FSharp.Interactive.Restart</CommandName>
115-
<ButtonText>Reset Session</ButtonText>
101+
<CommandName>FSharp.Interactive.AttachDebugger</CommandName>
102+
<ButtonText>Attach Debugger</ButtonText>
116103
</Strings>
117104
</Button>
118105

119106
<!-- The following places a button on the F# Editor Context Menu-->
120-
<!-- In Dev11, shell now has
107+
<!-- In Dev11+, shell now has
121108
<Button guid ="guidVSStd11" id ="cmdidExecuteSelectionInInteractive" priority ="0x100" type ="Button">
122109
-->
123-
<!-- In Dev10 hybrid, we need buttons below-->
124-
<ButtonCondition="!Defined(FX_ATLEAST_45)" guid ="guidInteractive" id ="cmdidSendSelection" priority ="0x100" type ="Button">
125-
<Parentguid="guidSHLMainMenu"id="IDG_VS_CODEWIN_LANGUAGE"/>
126-
<Iconguid="guidFsiConsoleBmp"id="bmpConsole"/>
110+
<Button guid ="guidInteractive" id ="cmdidDebugSelection" priority ="0x106" type ="Button">
111+
<Parentguid="guidSHLMainMenu"id="IDG_VS_CODEWIN_LANGUAGE"/>
127112
<Strings>
128-
<ButtonText>Send To Interactive</ButtonText>
129-
<CommandName>Interactive.Send.Selection.Context</CommandName>
113+
<ButtonText>Debug in F# Interactive</ButtonText>
114+
<CommandName>Interactive.Debug.Selection.Context</CommandName>
130115
</Strings>
131-
<CommandFlag>DynamicVisibility | DefaultInvisible</CommandFlag>
116+
<CommandFlag>DynamicVisibility | DefaultInvisible</CommandFlag>
132117
</Button>
133118

134119
</Buttons>
@@ -177,20 +162,18 @@
177162
<CommandPlacementguid="guidVSStd97"id="cmdidClearPane"priority="0x0200">
178163
<Parentguid="guidFsiConsoleCmdSet"id="FsiConsoleClearGrp"/>
179164
</CommandPlacement>
180-
<!-- Context menu, session group: Hybrid-->
181-
<CommandPlacementCondition="!Defined(FX_ATLEAST_45)"guid="guidFsiConsoleCmdSet"id="cmdidSessionInterrupt"priority="0x0100">
182-
<Parentguid="guidFsiConsoleCmdSet"id="FsiConsoleSessionsGrp"/>
183-
</CommandPlacement>
184-
<CommandPlacementCondition="!Defined(FX_ATLEAST_45)"guid="guidFsiConsoleCmdSet"id="cmdidSessionRestart"priority="0x0300">
165+
166+
<!-- Context menu, session group-->
167+
<CommandPlacementguid="guidVSStd11"id="cmdidInteractiveSessionInterrupt"priority="0x0100">
185168
<Parentguid="guidFsiConsoleCmdSet"id="FsiConsoleSessionsGrp"/>
186169
</CommandPlacement>
187-
<!-- Context menu, session group: Dev11-->
188-
<CommandPlacementCondition="Defined(FX_ATLEAST_45)"guid="guidVSStd11"id="cmdidInteractiveSessionInterrupt"priority="0x0100">
170+
<CommandPlacementguid="guidVSStd11"id="cmdidInteractiveSessionRestart"priority="0x0300">
189171
<Parentguid="guidFsiConsoleCmdSet"id="FsiConsoleSessionsGrp"/>
190172
</CommandPlacement>
191-
<CommandPlacementCondition="Defined(FX_ATLEAST_45)"guid="guidVSStd11"id="cmdidInteractiveSessionRestart"priority="0x0300">
173+
<CommandPlacementguid="guidFsiConsoleCmdSet"id="cmdidAttachDebugger"priority="0x0700">
192174
<Parentguid="guidFsiConsoleCmdSet"id="FsiConsoleSessionsGrp"/>
193175
</CommandPlacement>
176+
194177
<!-- Adds MLSend to the context menu:
195178
<CommandPlacement guid="guidFsiConsoleCmdSet" id="cmdidMLSendSelection" priority="0x0500">
196179
<Parent guid="guidFsiConsoleCmdSet" id="FsiConsoleSessionsGrp"/>
@@ -226,24 +209,24 @@
226209
ALT-ENTER is globally bound to Diagram.Property.
227210
Here we bind it in the Editor context of the standard TextEditor.
228211
Ideally, we would bind it for F# only editor.
229-
Both Hybrid and Dev11 are used here, to build both ways.
230212
-->
231-
<KeyBindingCondition="!Defined(FX_ATLEAST_45)"guid="guidInteractive"id="cmdidSendSelection"editor="GUID_TextEditorFactory"key1="VK_RETURN"mod1="Alt" />
232-
<KeyBindingCondition="Defined(FX_ATLEAST_45)"guid ="guidVSStd11" id ="cmdidExecuteSelectionInInteractive"editor="GUID_TextEditorFactory"key1="VK_RETURN"mod1="Alt" />
213+
<KeyBinding guid="guidInteractive" id ="cmdidDebugSelection"editor="GUID_TextEditorFactory"key1="D"mod1="Control"key2="VK_RETURN"mod2="Alt" />
214+
<KeyBinding guid ="guidVSStd11" id ="cmdidExecuteSelectionInInteractive"editor="GUID_TextEditorFactory"key1="VK_RETURN"mod1="Alt" />
233215

234216
<!-- CRTL-ALT-F for FSI window - following similar bindings for "other windows"-->
235217
<KeyBindingguid="guidFsiPackageCmdSet"id="cmdidFsiToolWindow"editor="guidVSStd97"key1="F"mod1="Control Alt" />
236218

237-
<!-- CRTL-Break when in FSI ToolWindow is Interrupt-->
238-
<KeyBindingCondition="!Defined(FX_ATLEAST_45)"guid="guidFsiConsoleCmdSet"id="cmdidSessionInterrupt"editor="guidFsiToolWindow"key1="VK_CANCEL"mod1="Control" />
239-
<KeyBindingCondition="Defined(FX_ATLEAST_45)"guid="guidVSStd11"id="cmdidInteractiveSessionInterrupt"editor="guidFsiToolWindow"key1="VK_CANCEL"mod1="Control" />
219+
<!-- CRTL-Break when in FSI ToolWindow is Interrupt-->
220+
<KeyBindingguid="guidVSStd11"id="cmdidInteractiveSessionInterrupt"editor="guidFsiToolWindow"key1="VK_CANCEL"mod1="Control" />
240221

241-
<!-- CRTL-Alt-R when in FSI ToolWindow is Reset-->
242-
<KeyBindingCondition="!Defined(FX_ATLEAST_45)"guid="guidFsiConsoleCmdSet"id="cmdidSessionRestart"editor="guidFsiToolWindow"key1="R"mod1="Control Alt" />
243-
<KeyBindingCondition="Defined(FX_ATLEAST_45)"guid="guidVSStd11"id="cmdidInteractiveSessionRestart"editor="guidFsiToolWindow"key1="R"mod1="Control Alt" />
222+
<!-- CRTL-Alt-R when in FSI ToolWindow is Reset-->
223+
<KeyBindingguid="guidVSStd11"id="cmdidInteractiveSessionRestart"editor="guidFsiToolWindow"key1="R"mod1="Control Alt" />
244224

245225
<!-- CRTL-Alt-C when in FSI ToolWindow is Clear All-->
246226
<KeyBindingguid="guidVSStd97"id="cmdidClearPane"editor="guidFsiToolWindow"key1="C"mod1="Control Alt" />
227+
228+
<!-- CRTL-Alt-D when in FSI ToolWindow is attach debugger-->
229+
<KeyBindingguid="guidFsiConsoleCmdSet"id="cmdidAttachDebugger"editor="guidFsiToolWindow"key1="D"mod1="Control Alt" />
247230
</KeyBindings>
248231

249232
<Symbols>
@@ -279,9 +262,7 @@
279262
<IDSymbolname="FsiConsoleClearGrp"value="0x1040" />
280263
<IDSymbolname="FsiConsoleSessionsGrp"value="0x1050" />
281264
<IDSymbolname="cmdidFsiConsole"value="0x101" />
282-
<!-- below is only used by hybrid-->
283-
<IDSymbolCondition="!Defined(FX_ATLEAST_45)"name="cmdidSessionInterrupt"value="0x102" />
284-
<IDSymbolCondition="!Defined(FX_ATLEAST_45)"name="cmdidSessionRestart"value="0x103" />
265+
<IDSymbolname="cmdidAttachDebugger"value="0x104" />
285266
</GuidSymbol>
286267

287268
<GuidSymbolname="guidFsiConsoleBmp"value="{9074CE8B-8F1E-4c23-8EDC-82C25E0323A8}" >
@@ -301,12 +282,11 @@
301282
<IDSymbolname="cmdidInteractiveSessionInterrupt" value ="0x01A"/>
302283
<IDSymbolname="cmdidInteractiveSessionRestart" value ="0x01B"/>
303284
</GuidSymbol>
304-
305-
<!-- below is only used by hybrid-->
306-
<GuidSymbolCondition="!Defined(FX_ATLEAST_45)"name="guidInteractive"value="{8B9BF77B-AF94-4588-8847-2EB2BFFD29EB}" >
307-
<IDSymbolname="cmdidSendSelection" value ="0x01"/>
308-
</GuidSymbol>
309285

286+
<GuidSymbolname="guidInteractive"value="{8B9BF77B-AF94-4588-8847-2EB2BFFD29EB}" >
287+
<IDSymbolname="cmdidDebugSelection" value ="0x01"/>
288+
</GuidSymbol>
289+
310290
</Symbols>
311291

312292
</CommandTable>

‎vsintegration/src/vs/FsPkgs/FSharp.VS.FSI/fsiPackageHooks.fs‎

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,11 @@ module internal Hooks =
6969
with e2->
7070
(System.Windows.Forms.MessageBox.Show(VFSIstrings.SR.exceptionRaisedWhenRequestingToolWindow(e2.ToString()))|> ignore)
7171

72-
letOnMLSend(this:Package)(sender:obj)(e:EventArgs)=
73-
withFSIToolWindow this(fun window-> window.MLSend(sender, e))
72+
letOnMLSend(this:Package)(debug:bool)(sender:obj)(e:EventArgs)=
73+
withFSIToolWindow this(fun window->
74+
if debugthen window.MLSend(sender, e)
75+
else window.MLDebugSelection(sender, e)
76+
)
7477

7578
letAddReferencesToFSI(this:Package)references=
7679
withFSIToolWindow this(fun window-> window.AddReferences references)
@@ -124,16 +127,3 @@ module internal Hooks =
124127
letid=new CommandID(Guids.guidFsiPackageCmdSet,int32 Guids.cmdIDLaunchFsiToolWindow)
125128
letcmd=new MenuCommand(new EventHandler(ShowToolWindow this), id)
126129
commandService.AddCommand(cmd)
127-
128-
#if FX_ATLEAST_45
129-
// Dev11 handles FSI commands in LS ViewFilter
130-
#else
131-
// See VS SDK docs on "Command Routing Algorithm".
132-
// Add OLECommand to OleCommandTarget at the package level,
133-
// for when it is fired from other contexts, e.g. text editor.
134-
letid=new CommandID(Guids.guidInteractive,int32 Guids.cmdIDSendSelection)
135-
letcmd=new OleMenuCommand(new EventHandler(OnMLSend this), id)
136-
cmd.BeforeQueryStatus.AddHandler(new EventHandler(supportWhenFSharpDocument))
137-
commandService.AddCommand(cmd)
138-
139-
#endif

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp