Skip to content
This repository was archived by the owner on Oct 16, 2020. It is now read-only.

Commit eb3bb41

Browse files
committed
Do not change the code completion binding API.
Prevent the CtrlShiftSpace support from breaking existing addins that use ICodeCompletionBinding by adding another optional interface IInsightCodeCompletionBinding that includes the new method.
1 parent 6ce54b8 commit eb3bb41

File tree

6 files changed

+13
-23
lines changed

6 files changed

+13
-23
lines changed

src/AddIns/BackendBindings/AspNet.Mvc/Project/Src/Completion/RazorCSharpCompletionBinding.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,6 @@ public bool CtrlSpace(ITextEditor editor)
4848
return false;
4949
}
5050

51-
public bool CtrlShiftSpace(ITextEditor editor)
52-
{
53-
return false;
54-
}
55-
5651
public CodeCompletionKeyPressResult HandleKeyPress(ITextEditor editor, char ch)
5752
{
5853
// We use HandleKeyPressed instead.

src/AddIns/BackendBindings/CSharpBinding/Project/Src/Completion/CSharpCompletionBinding.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535

3636
namespace CSharpBinding.Completion
3737
{
38-
public class CSharpCompletionBinding : ICodeCompletionBinding
38+
public class CSharpCompletionBinding : ICodeCompletionBinding, IInsightCodeCompletionBinding
3939
{
4040
ICodeContext context;
4141
TextLocation currentLocation;

src/AddIns/BackendBindings/XamlBinding/XamlBinding/XamlCodeCompletionBinding.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -244,11 +244,6 @@ bool CtrlSpace(ITextEditor editor, XamlCompletionContext context)
244244
return false;
245245
}
246246

247-
public bool CtrlShiftSpace(ITextEditor editor)
248-
{
249-
return false;
250-
}
251-
252247
void DoTriggerCompletion(XamlCompletionContext context, XamlCompletionItemList completionList)
253248
{
254249
bool isExplicit;

src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CodeEditor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -631,7 +631,7 @@ void OnCodeInsight(object sender, ExecutedRoutedEventArgs e)
631631
return;
632632

633633
CodeEditorView textEditor = GetTextEditorFromSender(sender);
634-
foreach (ICodeCompletionBinding cc in CodeCompletionBindings) {
634+
foreach (IInsightCodeCompletionBinding cc in CodeCompletionBindings.OfType<IInsightCodeCompletionBinding>()) {
635635
if (cc.CtrlShiftSpace(textEditor.Adapter)) {
636636
e.Handled = true;
637637
break;

src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlCodeCompletionBinding.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,6 @@ public bool CtrlSpace(ITextEditor editor)
9898
}
9999
return false;
100100
}
101-
102-
public bool CtrlShiftSpace(ITextEditor editor)
103-
{
104-
return false;
105-
}
106101

107102
bool ElementStartsWith(string text, int elementStartIndex, ITextSource document)
108103
{

src/Main/Base/Project/Editor/CodeCompletion/CodeCompletionBinding.cs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,10 @@ public interface ICodeCompletionBinding
5151
/// </summary>
5252
/// <returns>Returns whether the completion binding has shown code completion.</returns>
5353
bool CtrlSpace(ITextEditor editor);
54-
54+
}
55+
56+
public interface IInsightCodeCompletionBinding
57+
{
5558
/// <summary>
5659
/// Invokes ctrl-shift-space code insight.
5760
/// </summary>
@@ -120,7 +123,7 @@ public object BuildItem(BuildItemArgs args)
120123
}
121124
}
122125

123-
public sealed class LazyCodeCompletionBinding : ICodeCompletionBinding
126+
public sealed class LazyCodeCompletionBinding : ICodeCompletionBinding, IInsightCodeCompletionBinding
124127
{
125128
Codon codon;
126129
string[] extensions;
@@ -174,10 +177,12 @@ public bool CtrlSpace(ITextEditor editor)
174177

175178
public bool CtrlShiftSpace(ITextEditor editor)
176179
{
177-
if (MatchesExtension(editor))
178-
return binding.CtrlShiftSpace(editor);
179-
else
180-
return false;
180+
if (MatchesExtension(editor)) {
181+
var insightBinding = binding as IInsightCodeCompletionBinding;
182+
if (insightBinding != null)
183+
return insightBinding.CtrlShiftSpace(editor);
184+
}
185+
return false;
181186
}
182187
}
183188
}

0 commit comments

Comments
 (0)