Browse Source
git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@221 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61shortcuts
33 changed files with 409 additions and 187 deletions
@ -0,0 +1,55 @@
@@ -0,0 +1,55 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Daniel Grunwald" email="daniel@danielgrunwald.de"/>
|
||||
// <version value="$version"/>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.Collections; |
||||
using System.Collections.Specialized; |
||||
using System.Windows.Forms; |
||||
|
||||
using ICSharpCode.Core; |
||||
using ICSharpCode.TextEditor.Document; |
||||
using ICSharpCode.TextEditor; |
||||
using ICSharpCode.SharpDevelop.Dom; |
||||
using ICSharpCode.TextEditor.Gui.CompletionWindow; |
||||
|
||||
namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor |
||||
{ |
||||
/// <summary>
|
||||
/// Provides code completion for attribute names.
|
||||
/// </summary>
|
||||
public class AttributesDataProvider : CtrlSpaceCompletionDataProvider |
||||
{ |
||||
public AttributesDataProvider() : base(ExpressionContext.Attribute) |
||||
{ |
||||
this.ForceNewExpression = true; |
||||
} |
||||
|
||||
bool removeAttributeSuffix = true; |
||||
|
||||
public bool RemoveAttributeSuffix { |
||||
get { |
||||
return removeAttributeSuffix; |
||||
} |
||||
set { |
||||
removeAttributeSuffix = value; |
||||
} |
||||
} |
||||
|
||||
public override ICompletionData[] GenerateCompletionData(string fileName, TextArea textArea, char charTyped) |
||||
{ |
||||
ICompletionData[] data = base.GenerateCompletionData(fileName, textArea, charTyped); |
||||
if (removeAttributeSuffix) { |
||||
foreach (ICompletionData d in data) { |
||||
if (d.Text.EndsWith("Attribute")) { |
||||
d.Text = d.Text.Substring(0, d.Text.Length - 9); |
||||
} |
||||
} |
||||
} |
||||
return data; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,88 @@
@@ -0,0 +1,88 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Daniel Grunwald" email="daniel@danielgrunwald.de"/>
|
||||
// <version value="$version"/>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.Diagnostics; |
||||
|
||||
using ICSharpCode.Core; |
||||
using ICSharpCode.SharpDevelop.Dom; |
||||
using ICSharpCode.TextEditor; |
||||
using ICSharpCode.TextEditor.Document; |
||||
using ICSharpCode.TextEditor.Gui.CompletionWindow; |
||||
|
||||
namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor |
||||
{ |
||||
public class CtrlSpaceCompletionDataProvider : CodeCompletionDataProvider |
||||
{ |
||||
public CtrlSpaceCompletionDataProvider() |
||||
{ |
||||
} |
||||
|
||||
public CtrlSpaceCompletionDataProvider(ExpressionContext overrideContext) |
||||
{ |
||||
this.overrideContext = overrideContext; |
||||
} |
||||
|
||||
bool forceNewExpression; |
||||
|
||||
/// <summary>
|
||||
/// Gets/Sets whether the CtrlSpaceCompletionDataProvider creates a new completion
|
||||
/// dropdown instead of completing an old expression.
|
||||
/// Default value is false.
|
||||
/// </summary>
|
||||
public bool ForceNewExpression { |
||||
get { |
||||
return forceNewExpression; |
||||
} |
||||
set { |
||||
forceNewExpression = value; |
||||
} |
||||
} |
||||
|
||||
protected override void GenerateCompletionData(TextArea textArea, char charTyped) |
||||
{ |
||||
if (forceNewExpression) { |
||||
preSelection = ""; |
||||
if (charTyped != '\0') { |
||||
preSelection = null; |
||||
} |
||||
ExpressionContext context = overrideContext; |
||||
if (context == null) context = ExpressionContext.Default; |
||||
AddResolveResults(ParserService.CtrlSpace(caretLineNumber, caretColumn, fileName, textArea.Document.TextContent), context); |
||||
return; |
||||
} |
||||
|
||||
ExpressionResult expressionResult = GetExpression(textArea); |
||||
string expression = expressionResult.Expression; |
||||
preSelection = null; |
||||
if (expression == null || expression.Length == 0) { |
||||
preSelection = ""; |
||||
if (charTyped != '\0') { |
||||
preSelection = null; |
||||
} |
||||
AddResolveResults(ParserService.CtrlSpace(caretLineNumber, caretColumn, fileName, textArea.Document.TextContent), expressionResult.Context); |
||||
return; |
||||
} |
||||
|
||||
int idx = expression.LastIndexOf('.'); |
||||
if (idx > 0) { |
||||
preSelection = expression.Substring(idx + 1); |
||||
expression = expression.Substring(0, idx); |
||||
if (charTyped != '\0') { |
||||
preSelection = null; |
||||
} |
||||
GenerateCompletionData(textArea, expressionResult); |
||||
} else { |
||||
preSelection = expression; |
||||
if (charTyped != '\0') { |
||||
preSelection = null; |
||||
} |
||||
AddResolveResults(ParserService.CtrlSpace(caretLineNumber, caretColumn, fileName, textArea.Document.TextContent), expressionResult.Context); |
||||
} |
||||
} |
||||
} |
||||
} |
Loading…
Reference in new issue