Skip to content
This repository was archived by the owner on Jun 11, 2026. It is now read-only.

Commit ca0ee35

Browse files
author
Priyan Vaithilingam
committed
Merge branch 'dev/priyan/talkpoints' of https://github.com/Microsoft/CodeTalk into dev/priyan/talkpoints
2 parents 2443d09 + 412c2f2 commit ca0ee35

2 files changed

Lines changed: 88 additions & 95 deletions

File tree

src/VisualStudio/CodeTalk/Commands/Commands.cs

Lines changed: 69 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@ namespace Microsoft.CodeTalk.Commands
2222
{
2323
public class GetFunctionsCommand : CommandBase
2424
{
25-
ResourceManager rm;
25+
ResourceManager rm;
2626

2727
public GetFunctionsCommand(CommandKeyConfig keys) : base(keys) { }
28-
28+
2929
public override void Execute()
3030
{
31-
rm = new ResourceManager(typeof(Resources));
32-
System.Diagnostics.Debug.WriteLine("Get Functions");
31+
rm = new ResourceManager(typeof(Resources));
32+
System.Diagnostics.Debug.WriteLine("Get Functions");
3333

3434
IEnumerable<ISyntaxEntity> functions = new List<ISyntaxEntity>();
3535
CodeFile codeFile;
@@ -47,8 +47,8 @@ public override void Execute()
4747
}
4848
catch (CodeTalkLanguageServiceException)
4949
{
50-
MessageBox.Show(rm.GetString("CompilationErrorMessage", CultureInfo.CurrentCulture), rm.GetString("CodeTalkString", CultureInfo.CurrentCulture), MessageBoxButtons.OK, MessageBoxIcon.Error);
51-
return;
50+
MessageBox.Show(rm.GetString("CompilationErrorMessage", CultureInfo.CurrentCulture), rm.GetString("CodeTalkString", CultureInfo.CurrentCulture), MessageBoxButtons.OK, MessageBoxIcon.Error);
51+
return;
5252
}
5353

5454
//Creating a function collector for getting all the functions
@@ -60,8 +60,8 @@ public override void Execute()
6060

6161
if (0 == functions.Count())
6262
{
63-
MessageBox.Show(rm.GetString("NoFunctionsString", CultureInfo.CurrentCulture), rm.GetString("CodeTalkString", CultureInfo.CurrentCulture), MessageBoxButtons.OK);
64-
return;
63+
MessageBox.Show(rm.GetString("NoFunctionsString", CultureInfo.CurrentCulture), rm.GetString("CodeTalkString", CultureInfo.CurrentCulture), MessageBoxButtons.OK);
64+
return;
6565
}
6666

6767
ToolWindowPane listFunctionsWindow = TalkCodePackage.currentPackage.FindToolWindow(typeof(AccessibilityToolWindow), 0, true);
@@ -72,31 +72,31 @@ public override void Execute()
7272
}
7373

7474
IVsWindowFrame windowFrame = (IVsWindowFrame)listFunctionsWindow.Frame;
75-
windowFrame.SetProperty((int)__VSFPROPID.VSFPROPID_Caption, rm.GetString("FunctionsListTitle", CultureInfo.CurrentCulture));
75+
windowFrame.SetProperty((int)__VSFPROPID.VSFPROPID_Caption, rm.GetString("FunctionsListTitle", CultureInfo.CurrentCulture));
7676

77-
Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(windowFrame.Show());
77+
Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(windowFrame.Show());
7878

79-
(listFunctionsWindow as AccessibilityToolWindow).windowControl.SetListView(functions, rm.GetString("FunctionsListTitle", CultureInfo.CurrentCulture));
80-
}
79+
(listFunctionsWindow as AccessibilityToolWindow).windowControl.SetListView(functions, rm.GetString("FunctionsListTitle", CultureInfo.CurrentCulture));
80+
}
8181

8282
public override bool PassControl() => false;
8383
}
8484

8585
public class GetContextCommand : CommandBase
8686
{
87-
ResourceManager rm;
87+
ResourceManager rm;
8888

89-
public GetContextCommand(CommandKeyConfig keys) : base(keys) { }
89+
public GetContextCommand(CommandKeyConfig keys) : base(keys) { }
9090

9191
public override bool PassControl()
9292
{
9393
return false;
9494
}
9595
public override void Execute()
9696
{
97-
rm = new ResourceManager(typeof(Resources));
97+
rm = new ResourceManager(typeof(Resources));
9898

99-
CodeFile codeFile;
99+
CodeFile codeFile;
100100
IList<ISyntaxEntity> contextHierarchy;
101101

102102
//Getting the code text from the active document
@@ -112,8 +112,8 @@ public override void Execute()
112112
}
113113
catch (CodeTalkLanguageServiceException)
114114
{
115-
MessageBox.Show(rm.GetString("CompilationErrorMessage", CultureInfo.CurrentCulture), rm.GetString("CodeTalkString", CultureInfo.CurrentCulture), MessageBoxButtons.OK, MessageBoxIcon.Error);
116-
return;
115+
MessageBox.Show(rm.GetString("CompilationErrorMessage", CultureInfo.CurrentCulture), rm.GetString("CodeTalkString", CultureInfo.CurrentCulture), MessageBoxButtons.OK, MessageBoxIcon.Error);
116+
return;
117117
}
118118
try
119119
{
@@ -124,8 +124,8 @@ public override void Execute()
124124

125125
if (0 == contextHierarchy.Count)
126126
{
127-
MessageBox.Show(rm.GetString("NoContextString", CultureInfo.CurrentCulture) + " " + currentLineNumber.ToString(), rm.GetString("CodeTalkString", CultureInfo.CurrentCulture), MessageBoxButtons.OK);
128-
return;
127+
MessageBox.Show(rm.GetString("NoContextString", CultureInfo.CurrentCulture) + " " + currentLineNumber.ToString(), rm.GetString("CodeTalkString", CultureInfo.CurrentCulture), MessageBoxButtons.OK);
128+
return;
129129
}
130130

131131
var entities = contextHierarchy.Reverse().ToList().ConvertAll(x => (ISyntaxEntity)x);
@@ -134,16 +134,16 @@ public override void Execute()
134134

135135
if ((null == listFunctionsWindow) || (null == listFunctionsWindow.Frame))
136136
{
137-
MessageBox.Show("Cannote create tool window", "Cannot create tool window", MessageBoxButtons.OK);
137+
MessageBox.Show("Cannote create tool window", "Cannot create tool window", MessageBoxButtons.OK);
138138
}
139139

140140
IVsWindowFrame windowFrame = (IVsWindowFrame)listFunctionsWindow.Frame;
141-
windowFrame.SetProperty((int)__VSFPROPID.VSFPROPID_Caption, rm.GetString("GetContextTitle", CultureInfo.CurrentCulture));
141+
windowFrame.SetProperty((int)__VSFPROPID.VSFPROPID_Caption, rm.GetString("GetContextTitle", CultureInfo.CurrentCulture));
142142

143-
Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(windowFrame.Show());
143+
Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(windowFrame.Show());
144144

145-
(listFunctionsWindow as AccessibilityToolWindow).windowControl.SetListView(entities, rm.GetString("GetContextTitle", CultureInfo.CurrentCulture), false);
146-
}
145+
(listFunctionsWindow as AccessibilityToolWindow).windowControl.SetListView(entities, rm.GetString("GetContextTitle", CultureInfo.CurrentCulture), false);
146+
}
147147
catch (IndexOutOfRangeException)
148148
{
149149
MessageBox.Show("The cursor does not seem to be in code. please move the cursor and try again.", "CodeTalk", MessageBoxButtons.OK, MessageBoxIcon.Error);
@@ -165,14 +165,14 @@ public override void Execute()
165165

166166
public class GetErrorsCommand : CommandBase
167167
{
168-
ResourceManager rm;
168+
ResourceManager rm;
169169

170-
public GetErrorsCommand(CommandKeyConfig keys) : base(keys) { }
170+
public GetErrorsCommand(CommandKeyConfig keys) : base(keys) { }
171171

172172
public override void Execute()
173173
{
174-
rm = new ResourceManager(typeof(Resources));
175-
System.Diagnostics.Debug.WriteLine("Get Errors");
174+
rm = new ResourceManager(typeof(Resources));
175+
System.Diagnostics.Debug.WriteLine("Get Errors");
176176

177177
var errors = new List<ISyntaxEntity>();
178178

@@ -190,26 +190,26 @@ public override void Execute()
190190
{
191191
System.Threading.Tasks.Task.Run(() =>
192192
{
193-
MessageBox.Show(rm.GetString("NoErrorsString", CultureInfo.CurrentCulture), rm.GetString("CodeTalkString", CultureInfo.CurrentCulture), MessageBoxButtons.OK);
194-
});
193+
MessageBox.Show(rm.GetString("NoErrorsString", CultureInfo.CurrentCulture), rm.GetString("CodeTalkString", CultureInfo.CurrentCulture), MessageBoxButtons.OK);
194+
});
195195
return;
196196
}
197197

198198
ToolWindowPane listFunctionsWindow = TalkCodePackage.currentPackage.FindToolWindow(typeof(AccessibilityToolWindow), 0, true);
199199

200200
if ((null == listFunctionsWindow) || (null == listFunctionsWindow.Frame))
201201
{
202-
MessageBox.Show("Cannote create tool window", "Cannot create tool window", MessageBoxButtons.OK);
203-
}
204-
else
205-
{
206-
IVsWindowFrame windowFrame = (IVsWindowFrame)listFunctionsWindow.Frame;
207-
windowFrame.SetProperty((int)__VSFPROPID.VSFPROPID_Caption, rm.GetString("ErrorListTitle", CultureInfo.CurrentCulture));
202+
MessageBox.Show("Cannote create tool window", "Cannot create tool window", MessageBoxButtons.OK);
203+
}
204+
else
205+
{
206+
IVsWindowFrame windowFrame = (IVsWindowFrame)listFunctionsWindow.Frame;
207+
windowFrame.SetProperty((int)__VSFPROPID.VSFPROPID_Caption, rm.GetString("ErrorListTitle", CultureInfo.CurrentCulture));
208208

209-
Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(windowFrame.Show());
209+
Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(windowFrame.Show());
210210

211-
(listFunctionsWindow as AccessibilityToolWindow).windowControl.SetListView(errors, rm.GetString("ErrorListTitle", CultureInfo.CurrentCulture));
212-
}
211+
(listFunctionsWindow as AccessibilityToolWindow).windowControl.SetListView(errors, rm.GetString("ErrorListTitle", CultureInfo.CurrentCulture));
212+
}
213213

214214

215215
}
@@ -219,14 +219,14 @@ public override void Execute()
219219

220220
public class GetSummaryCommand : CommandBase
221221
{
222-
ResourceManager rm;
222+
ResourceManager rm;
223223

224-
public GetSummaryCommand(CommandKeyConfig keys) : base(keys) { }
224+
public GetSummaryCommand(CommandKeyConfig keys) : base(keys) { }
225225

226226
public override void Execute()
227227
{
228-
rm = new ResourceManager(typeof(Resources));
229-
System.Diagnostics.Debug.WriteLine("Get Summary");
228+
rm = new ResourceManager(typeof(Resources));
229+
System.Diagnostics.Debug.WriteLine("Get Summary");
230230

231231
//Getting the code text from the active document
232232
var path = TalkCodePackage.vsOperations.GetActiveDocumentPath();
@@ -244,22 +244,22 @@ public override void Execute()
244244

245245
if ((null == listFunctionsWindow) || (null == listFunctionsWindow.Frame))
246246
{
247-
MessageBox.Show("Cannote create tool window", "Cannot create tool window", MessageBoxButtons.OK);
248-
}
249-
else
250-
{
251-
IVsWindowFrame windowFrame = (IVsWindowFrame)listFunctionsWindow.Frame;
252-
windowFrame.SetProperty((int)__VSFPROPID.VSFPROPID_Caption, rm.GetString("FileSummaryTitle", CultureInfo.CurrentCulture));
253-
Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(windowFrame.Show());
254-
255-
(listFunctionsWindow as GetSummaryToolWindow).windowControl.SetTreeView(codeFile, rm.GetString("FileSSummaryTitle", CultureInfo.CurrentCulture));
256-
}
247+
MessageBox.Show("Cannote create tool window", "Cannot create tool window", MessageBoxButtons.OK);
248+
}
249+
else
250+
{
251+
IVsWindowFrame windowFrame = (IVsWindowFrame)listFunctionsWindow.Frame;
252+
windowFrame.SetProperty((int)__VSFPROPID.VSFPROPID_Caption, rm.GetString("FileSummaryTitle", CultureInfo.CurrentCulture));
253+
Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(windowFrame.Show());
254+
255+
(listFunctionsWindow as GetSummaryToolWindow).windowControl.SetTreeView(codeFile, rm.GetString("FileSSummaryTitle", CultureInfo.CurrentCulture));
256+
}
257257

258258
}
259259
catch (CodeTalkLanguageServiceException)
260260
{
261-
MessageBox.Show(rm.GetString("FileProcessError", CultureInfo.CurrentCulture));
262-
}
261+
MessageBox.Show(rm.GetString("FileProcessError", CultureInfo.CurrentCulture));
262+
}
263263
}
264264

265265
public override bool PassControl() => false;
@@ -268,31 +268,30 @@ public override void Execute()
268268

269269
public class CreateBreakpointCommand : CommandBase
270270
{
271-
ResourceManager rm;
271+
ResourceManager rm;
272272

273-
public CreateBreakpointCommand(CommandKeyConfig keys) : base(keys) { }
273+
public CreateBreakpointCommand(CommandKeyConfig keys) : base(keys) { }
274274

275275
public override void Execute()
276276
{
277-
rm = new ResourceManager(typeof(Resources));
278-
Debug.WriteLine("Create Breakpoint");
277+
rm = new ResourceManager(typeof(Resources));
279278

280279
if (TalkCodePackage.vsOperations.RemoveBreakpointIfExists()) { return; }
281280

282281
ToolWindowPane talkpointWindow = TalkCodePackage.currentPackage.FindToolWindow(typeof(TalkpointToolWindow), 0, true);
283282

284283
if ((null == talkpointWindow) || (null == talkpointWindow.Frame))
285284
{
286-
MessageBox.Show("Cannote create breakpoint window", "Cannot create tool window", MessageBoxButtons.OK);
287-
}
288-
else
289-
{
290-
IVsWindowFrame twindowFrame = (IVsWindowFrame)talkpointWindow.Frame;
291-
twindowFrame.SetProperty((int)__VSFPROPID.VSFPROPID_Caption, rm.GetString("TalkPointWindowTitle", CultureInfo.CurrentCulture));
292-
293-
Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(twindowFrame.Show());
294-
((talkpointWindow as TalkpointToolWindow).Content as TalkpointToolWindowControl).ClearAll();
295-
}
285+
MessageBox.Show("Cannote create breakpoint window", "Cannot create tool window", MessageBoxButtons.OK);
286+
}
287+
else
288+
{
289+
IVsWindowFrame twindowFrame = (IVsWindowFrame)talkpointWindow.Frame;
290+
twindowFrame.SetProperty((int)__VSFPROPID.VSFPROPID_Caption, rm.GetString("TalkPointWindowTitle", CultureInfo.CurrentCulture));
291+
292+
Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(twindowFrame.Show());
293+
((talkpointWindow as TalkpointToolWindow).Content as TalkpointToolWindowControl).ClearAll();
294+
}
296295
}
297296

298297
public override bool PassControl() => false;

src/VisualStudio/CodeTalk/VSOperations.cs

Lines changed: 19 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,9 @@ public void AddTonalTalkPointToCurrentLine(Tones tone, bool doesContinue)
144144
{
145145
var cursorPos = GetCurrentCursorPosition();
146146
var filePath = GetActiveDocumentPath();
147-
//Toggling Talkpoint
148-
RemoveIfTalkpointsExists(filePath, cursorPos);
149-
if (CheckIfBreakpointExists(filePath, cursorPos))
147+
//Toggling Talkpoint
148+
RemoveIfTalkpointsExists(filePath, cursorPos);
149+
if (CheckIfBreakpointExists(filePath, cursorPos))
150150
{
151151
RemoveBreakpoints(filePath, cursorPos);
152152
return;
@@ -166,14 +166,14 @@ public void AddTonalTalkPointToCurrentLine(CustomTone customTone, bool doesConti
166166
{
167167
var cursorPos = GetCurrentCursorPosition();
168168
var filePath = GetActiveDocumentPath();
169-
//Toggling Talkpoint
170-
RemoveIfTalkpointsExists(filePath, cursorPos);
171-
if (CheckIfBreakpointExists(filePath, cursorPos))
169+
//Toggling Talkpoint
170+
RemoveIfTalkpointsExists(filePath, cursorPos);
171+
if (CheckIfBreakpointExists(filePath, cursorPos))
172172
{
173173
RemoveBreakpoints(filePath, cursorPos);
174174
return;
175175
}
176-
Talkpoint talkpoint = new ToneTalkpoint(filePath, cursorPos, doesContinue, customTone);
176+
Talkpoint talkpoint = new ToneTalkpoint(filePath, cursorPos, doesContinue, customTone);
177177
AddTalkPoint(talkpoint);
178178
}
179179
catch (Exception exp) //We have to catch the exception here, or the IDE can crash
@@ -188,14 +188,14 @@ public void AddTextualTalkpointToCurrentLine(string statement, bool doesContinue
188188
{
189189
var cursorPos = GetCurrentCursorPosition();
190190
var filePath = GetActiveDocumentPath();
191-
//Toggling Talkpoint
192-
RemoveIfTalkpointsExists(filePath, cursorPos);
193-
if (CheckIfBreakpointExists(filePath, cursorPos))
191+
//Toggling Talkpoint
192+
RemoveIfTalkpointsExists(filePath, cursorPos);
193+
if (CheckIfBreakpointExists(filePath, cursorPos))
194194
{
195195
RemoveBreakpoints(filePath, cursorPos);
196196
return;
197197
}
198-
Talkpoint talkpoint = new TextTalkpoint(filePath, cursorPos, doesContinue, statement);
198+
Talkpoint talkpoint = new TextTalkpoint(filePath, cursorPos, doesContinue, statement);
199199
AddTalkPoint(talkpoint);
200200
}
201201
catch (Exception exp) //We have to catch the exception here, or the IDE can crash
@@ -210,9 +210,9 @@ public void AddExpressionTalkpointToCurrentLine(string expression, bool doesCont
210210
{
211211
var cursorPos = GetCurrentCursorPosition();
212212
var filePath = GetActiveDocumentPath();
213-
//Toggling Talkpoint
214-
RemoveIfTalkpointsExists(filePath, cursorPos);
215-
if (CheckIfBreakpointExists(filePath, cursorPos))
213+
//Toggling Talkpoint
214+
RemoveIfTalkpointsExists(filePath, cursorPos);
215+
if (CheckIfBreakpointExists(filePath, cursorPos))
216216
{
217217
RemoveBreakpoints(filePath, cursorPos);
218218
return;
@@ -265,18 +265,12 @@ public bool CheckIfBreakpointExists(string filePath, CursorPos position)
265265
return false;
266266
}
267267

268-
public void RemoveIfTalkpointsExists(string filePath, CursorPos position)
269-
{
270-
foreach (var talkpoint in mTalkPoints)
271-
{
272-
if(talkpoint.filePath.Equals(filePath) && talkpoint.position.lineNumber == position.lineNumber)
273-
{
274-
mTalkPoints.Remove(talkpoint);
275-
}
276-
}
277-
}
268+
public void RemoveIfTalkpointsExists(string filePath, CursorPos position)
269+
{
270+
mTalkPoints.RemoveAll(t => (t.filePath.Equals(filePath) && t.position.lineNumber == position.lineNumber));
271+
}
278272

279-
public void RemoveBreakpoints(string filePath, CursorPos position)
273+
public void RemoveBreakpoints(string filePath, CursorPos position)
280274
{
281275

282276
mTalkPoints.RemoveAll(b => (b.filePath.Equals(filePath) && b.position.lineNumber == position.lineNumber));

0 commit comments

Comments
 (0)