Skip to content

Commit d5463f7

Browse files
committed
some xml-doc
1 parent bcba323 commit d5463f7

File tree

4 files changed

+39
-8
lines changed

4 files changed

+39
-8
lines changed

Rubberduck.Core/AutoComplete/AutoCompleteHandlerBase.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55

66
namespace Rubberduck.AutoComplete
77
{
8+
/// <summary>
9+
/// A base class/interface for AC services / "handlers".
10+
/// </summary>
811
public abstract class AutoCompleteHandlerBase
912
{
1013
protected AutoCompleteHandlerBase(ICodePaneHandler pane)
@@ -14,6 +17,13 @@ protected AutoCompleteHandlerBase(ICodePaneHandler pane)
1417

1518
protected ICodePaneHandler CodePaneHandler { get; }
1619

20+
/// <summary>
21+
/// A method that returns <c>false</c> if the input isn't handled, <c>true</c> if it is.
22+
/// </summary>
23+
/// <param name="e">The autocompletion event info</param>
24+
/// <param name="settings">The current AC settings</param>
25+
/// <param name="result">If handled, the resulting <c>CodeString</c></param>
26+
/// <returns></returns>
1727
public abstract bool Handle(AutoCompleteEventArgs e, AutoCompleteSettings settings, out CodeString result);
1828
}
1929
}

Rubberduck.Core/AutoComplete/AutoCompleteService.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77

88
namespace Rubberduck.AutoComplete
99
{
10+
/// <summary>
11+
/// A service responsible for dispatching CodePane work to more specialized autocompletion services.
12+
/// Handles changes in configuration settings.
13+
/// </summary>
1014
public class AutoCompleteService : IDisposable
1115
{
1216
private static readonly ILogger Logger = LogManager.GetCurrentClassLogger();
@@ -151,6 +155,7 @@ private bool TryHandle(AutoCompleteEventArgs e, AutoCompleteHandlerBase handler)
151155
return false;
152156
}
153157

158+
Logger.Debug($"Keypress was handled by {handler.GetType().Name}.");
154159
e.Handled = true;
155160
return true;
156161

@@ -169,7 +174,8 @@ public void Dispose()
169174
}
170175

171176
private bool _isDisposed;
172-
protected virtual void Dispose(bool disposing)
177+
178+
private void Dispose(bool disposing)
173179
{
174180
if (_isDisposed || !disposing)
175181
{

Rubberduck.Core/AutoComplete/SelfClosingPairs/SelfClosingPairHandler.cs

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77

88
namespace Rubberduck.AutoComplete.SelfClosingPairs
99
{
10+
/// <summary>
11+
/// An AC handler that automatically closes certain specific "pairs" of characters, e.g. double quotes, or parentheses.
12+
/// </summary>
1013
public class SelfClosingPairHandler : AutoCompleteHandlerBase
1114
{
1215
private const int MaximumLines = 25;
@@ -38,6 +41,7 @@ public override bool Handle(AutoCompleteEventArgs e, AutoCompleteSettings settin
3841
result = null;
3942
if (!_scpInputLookup.TryGetValue(e.Character, out var pair) && e.Character != '\b')
4043
{
44+
// not an interesting keypress.
4145
return false;
4246
}
4347

@@ -49,15 +53,25 @@ public override bool Handle(AutoCompleteEventArgs e, AutoCompleteSettings settin
4953
return false;
5054
}
5155

56+
if (!original.CaretPosition.IsSingleCharacter)
57+
{
58+
// here would be an opportunity to "wrap selection" with a SCP.
59+
// todo: WrapSelectionWith(pair)?
60+
result = null;
61+
return false;
62+
}
63+
5264
if (pair != null)
5365
{
66+
// found a SCP for the input key; see if we should handle it:
5467
if (!HandleInternal(e, original, pair, out result))
5568
{
5669
return false;
5770
}
5871
}
5972
else if (e.Character == '\b')
6073
{
74+
// backspace - see if SCP logic needs to intervene:
6175
foreach (var scp in _selfClosingPairs)
6276
{
6377
if (HandleInternal(e, original, scp, out result))
@@ -69,9 +83,11 @@ public override bool Handle(AutoCompleteEventArgs e, AutoCompleteSettings settin
6983

7084
if (result == null)
7185
{
86+
// no meaningful output; let the input be handled by another handler, maybe.
7287
return false;
7388
}
7489

90+
// 1-based selection span in the code pane starts at column 1 but really encompasses the entire line.
7591
var snippetPosition = new Selection(result.SnippetPosition.StartLine, 1, result.SnippetPosition.EndLine, 1);
7692
result = new CodeString(result.Code, result.CaretPosition, snippetPosition);
7793

@@ -81,13 +97,6 @@ public override bool Handle(AutoCompleteEventArgs e, AutoCompleteSettings settin
8197

8298
private bool HandleInternal(AutoCompleteEventArgs e, CodeString original, SelfClosingPair pair, out CodeString result)
8399
{
84-
if (!original.CaretPosition.IsSingleCharacter)
85-
{
86-
// todo: WrapSelectionWith(pair)?
87-
result = null;
88-
return false;
89-
}
90-
91100
// if executing the SCP against the original code yields no result, we need to bail out.
92101
if (!_scpService.Execute(pair, original, e.Character, out result))
93102
{

Rubberduck.VBEEditor/SourceCodeHandling/ISourceCodeHandler.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
namespace Rubberduck.VBEditor.SourceCodeHandling
44
{
5+
/// <summary>
6+
/// An object that can rewrite a module's contents.
7+
/// </summary>
58
public interface ISourceCodeHandler : ISourceCodeProvider
69
{
710
/// <summary>
@@ -10,6 +13,9 @@ public interface ISourceCodeHandler : ISourceCodeProvider
1013
void SubstituteCode(QualifiedModuleName module, string newCode);
1114
}
1215

16+
/// <summary>
17+
/// An object that can manipulate the code in a CodePane.
18+
/// </summary>
1319
public interface ICodePaneHandler : ISourceCodeHandler
1420
{
1521
/// <summary>

0 commit comments

Comments
 (0)