Browse Source

Merge be047ccd7e into 1443fe0fe5

pull/728/merge
mykolav 10 years ago
parent
commit
1a5d6f85d3
  1. 5
      src/AddIns/BackendBindings/AspNet.Mvc/Project/Src/Completion/RazorCSharpCompletionBinding.cs
  2. 79
      src/AddIns/BackendBindings/CSharpBinding/Project/Src/Completion/CSharpCompletionBinding.cs
  3. 5
      src/AddIns/BackendBindings/XamlBinding/XamlBinding/XamlCodeCompletionBinding.cs
  4. 22
      src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CodeEditor.cs
  5. 6
      src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CustomCommands.cs
  6. 5
      src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlCodeCompletionBinding.cs
  7. 14
      src/Main/Base/Project/Editor/CodeCompletion/CodeCompletionBinding.cs

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

@ -48,6 +48,11 @@ namespace ICSharpCode.AspNet.Mvc.Completion @@ -48,6 +48,11 @@ namespace ICSharpCode.AspNet.Mvc.Completion
return false;
}
public bool CtrlShiftSpace(ITextEditor editor)
{
return false;
}
public CodeCompletionKeyPressResult HandleKeyPress(ITextEditor editor, char ch)
{
// We use HandleKeyPressed instead.

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

@ -71,24 +71,47 @@ namespace CSharpBinding.Completion @@ -71,24 +71,47 @@ namespace CSharpBinding.Completion
return ShowCompletion(editor, '\0', true);
}
bool ShowCompletion(ITextEditor editor, char completionChar, bool ctrlSpace)
public bool CtrlShiftSpace(ITextEditor editor)
{
CSharpCompletionContext completionContext;
if (fileContent == null) {
completionContext = CSharpCompletionContext.Get(editor);
} else {
completionContext = CSharpCompletionContext.Get(editor, context, currentLocation, fileContent);
return ShowInsight(editor);
}
if (completionContext == null)
return false;
private int GetCaretOffset(ITextEditor editor, CSharpCompletionContext completionContext)
{
int caretOffset;
if (fileContent == null) {
if (fileContent == null)
{
caretOffset = editor.Caret.Offset;
currentLocation = editor.Caret.Location;
} else {
}
else
{
caretOffset = completionContext.Document.GetOffset(currentLocation);
}
return caretOffset;
}
CSharpCompletionContext GetCompletionContext(ITextEditor editor)
{
CSharpCompletionContext completionContext;
if (fileContent == null)
{
completionContext = CSharpCompletionContext.Get(editor);
}
else
{
completionContext = CSharpCompletionContext.Get(editor, context, currentLocation, fileContent);
}
return completionContext;
}
bool ShowCompletion(ITextEditor editor, char completionChar, bool ctrlSpace)
{
var completionContext = GetCompletionContext(editor);
if (completionContext == null)
return false;
var caretOffset = GetCaretOffset(editor, completionContext);
var completionFactory = new CSharpCompletionDataFactory(completionContext, new CSharpResolver(completionContext.TypeResolveContextAtCaret));
@ -139,7 +162,37 @@ namespace CSharpBinding.Completion @@ -139,7 +162,37 @@ namespace CSharpBinding.Completion
return true;
}
if (CodeCompletionOptions.InsightEnabled && !ctrlSpace) {
if (!ctrlSpace) {
// Method Insight
// Method Insight
return ShowInsight(caretOffset, completionContext, completionFactory, completionChar);
}
return false;
}
bool ShowInsight(ITextEditor editor)
{
var completionContext = GetCompletionContext(editor);
if (completionContext == null)
return false;
var caretOffset = GetCaretOffset(editor, completionContext);
var completionFactory = new CSharpCompletionDataFactory(
completionContext,
new CSharpResolver(completionContext.TypeResolveContextAtCaret));
return ShowInsight(caretOffset, completionContext, completionFactory, '(');
}
bool ShowInsight(
int caretOffset,
CSharpCompletionContext completionContext,
CSharpCompletionDataFactory completionFactory,
char completionChar)
{
if (CodeCompletionOptions.InsightEnabled)
{
// Method Insight
var pce = new CSharpParameterCompletionEngine(
completionContext.Document,
@ -149,12 +202,14 @@ namespace CSharpBinding.Completion @@ -149,12 +202,14 @@ namespace CSharpBinding.Completion
completionContext.TypeResolveContextAtCaret
);
var newInsight = pce.GetParameterDataProvider(caretOffset, completionChar) as CSharpMethodInsight;
if (newInsight != null && newInsight.items.Count > 0) {
if (newInsight != null && newInsight.items.Count > 0)
{
newInsight.UpdateHighlightedParameter(pce);
newInsight.Show();
return true;
}
}
return false;
}

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

@ -244,6 +244,11 @@ namespace ICSharpCode.XamlBinding @@ -244,6 +244,11 @@ namespace ICSharpCode.XamlBinding
return false;
}
public bool CtrlShiftSpace(ITextEditor editor)
{
return false;
}
void DoTriggerCompletion(XamlCompletionContext context, XamlCompletionItemList completionList)
{
bool isExplicit;

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

@ -229,6 +229,8 @@ namespace ICSharpCode.AvalonEdit.AddIn @@ -229,6 +229,8 @@ namespace ICSharpCode.AvalonEdit.AddIn
codeEditorView.TextArea.SelectionChanged += TextAreaSelectionChanged;
codeEditorView.TextArea.DefaultInputHandler.CommandBindings.Add(
new CommandBinding(CustomCommands.CtrlSpaceCompletion, OnCodeCompletion));
codeEditorView.TextArea.DefaultInputHandler.CommandBindings.Add(
new CommandBinding(CustomCommands.CtrlShiftSpaceInsight, OnCodeInsight));
SearchPanel.Install(codeEditorView.TextArea);
textView.BackgroundRenderers.Add(textMarkerService);
@ -619,6 +621,26 @@ namespace ICSharpCode.AvalonEdit.AddIn @@ -619,6 +621,26 @@ namespace ICSharpCode.AvalonEdit.AddIn
}
}
void OnCodeInsight(object sender, ExecutedRoutedEventArgs e)
{
if (InsightWindow != null)
InsightWindow.Close();
// disable all code insight bindings when Insight is disabled
if (!CodeCompletionOptions.InsightEnabled)
return;
CodeEditorView textEditor = GetTextEditorFromSender(sender);
foreach (ICodeCompletionBinding cc in CodeCompletionBindings)
{
if (cc.CtrlShiftSpace(textEditor.Adapter))
{
e.Handled = true;
break;
}
}
}
void FetchParseInformation()
{
ParseInformation parseInfo = SD.ParserService.GetCachedParseInformation(this.FileName);

6
src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CustomCommands.cs

@ -31,5 +31,11 @@ namespace ICSharpCode.AvalonEdit.AddIn @@ -31,5 +31,11 @@ namespace ICSharpCode.AvalonEdit.AddIn
new InputGestureCollection {
new KeyGesture(Key.Space, ModifierKeys.Control)
});
public static readonly RoutedCommand CtrlShiftSpaceInsight = new RoutedCommand(
"CtrlShiftSpaceInsight", typeof(CodeEditor),
new InputGestureCollection {
new KeyGesture(Key.Space, ModifierKeys.Control | ModifierKeys.Shift)
});
}
}

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

@ -99,6 +99,11 @@ namespace ICSharpCode.XmlEditor @@ -99,6 +99,11 @@ namespace ICSharpCode.XmlEditor
return false;
}
public bool CtrlShiftSpace(ITextEditor editor)
{
return false;
}
bool ElementStartsWith(string text, int elementStartIndex, ITextSource document)
{
int textLength = Math.Min(text.Length, document.TextLength - elementStartIndex);

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

@ -51,6 +51,12 @@ namespace ICSharpCode.SharpDevelop.Editor.CodeCompletion @@ -51,6 +51,12 @@ namespace ICSharpCode.SharpDevelop.Editor.CodeCompletion
/// </summary>
/// <returns>Returns whether the completion binding has shown code completion.</returns>
bool CtrlSpace(ITextEditor editor);
/// <summary>
/// Invokes ctrl-shift-space code insight.
/// </summary>
/// <returns>Returns whether the completion binding has shown code insight.</returns>
bool CtrlShiftSpace(ITextEditor editor);
}
/// <summary>
@ -165,5 +171,13 @@ namespace ICSharpCode.SharpDevelop.Editor.CodeCompletion @@ -165,5 +171,13 @@ namespace ICSharpCode.SharpDevelop.Editor.CodeCompletion
else
return false;
}
public bool CtrlShiftSpace(ITextEditor editor)
{
if (MatchesExtension(editor))
return binding.CtrlShiftSpace(editor);
else
return false;
}
}
}

Loading…
Cancel
Save