Browse Source
git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@4970 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61shortcuts
15 changed files with 294 additions and 350 deletions
@ -1,84 +0,0 @@ |
|||||||
// <file>
|
|
||||||
// <copyright see="prj:///doc/copyright.txt"/>
|
|
||||||
// <license see="prj:///doc/license.txt"/>
|
|
||||||
// <owner name="Christian Hornung" email=""/>
|
|
||||||
// <version>$Revision$</version>
|
|
||||||
// </file>
|
|
||||||
|
|
||||||
using System; |
|
||||||
using ICSharpCode.SharpDevelop; |
|
||||||
using ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor; |
|
||||||
using ICSharpCode.TextEditor; |
|
||||||
using ICSharpCode.TextEditor.Gui.CompletionWindow; |
|
||||||
|
|
||||||
namespace Hornung.ResourceToolkit.CodeCompletion |
|
||||||
{ |
|
||||||
/// <summary>
|
|
||||||
/// Provides code completion data for the ${res tag.
|
|
||||||
/// </summary>
|
|
||||||
public class ICSharpCodeCoreTagCompletionDataProvider : AbstractCompletionDataProvider |
|
||||||
{ |
|
||||||
int startOffset; |
|
||||||
TextArea textArea; |
|
||||||
bool nonMatchingCharTyped; |
|
||||||
|
|
||||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1303:DoNotPassLiteralsAsLocalizedParameters", MessageId = "ICSharpCode.TextEditor.Gui.CompletionWindow.DefaultCompletionData.#ctor(System.String,System.String,System.Int32)")] |
|
||||||
public override ICompletionData[] GenerateCompletionData(string fileName, TextArea textArea, char charTyped) |
|
||||||
{ |
|
||||||
this.textArea = textArea; |
|
||||||
this.startOffset = textArea.Caret.Offset; |
|
||||||
this.nonMatchingCharTyped = false; |
|
||||||
this.DefaultIndex = 0; |
|
||||||
return new ICompletionData[] { new DefaultCompletionData("{res", null, ClassBrowserIconService.GotoArrow.ImageIndex) }; |
|
||||||
} |
|
||||||
|
|
||||||
public override CompletionDataProviderKeyResult ProcessKey(char key) |
|
||||||
{ |
|
||||||
// Return NormalKey as long as:
|
|
||||||
// - the typed string matches the ${res tag
|
|
||||||
// - ':' is not pressed
|
|
||||||
// Return InsertionKey when:
|
|
||||||
// - ':' is pressed and the typed string matches the ${res tag
|
|
||||||
// - the typed string does not match the ${res tag and more than one
|
|
||||||
// character has already been typed (to close the completion window)
|
|
||||||
|
|
||||||
string typedTag = this.GetTypedText(); |
|
||||||
if (key != ':') { |
|
||||||
typedTag += key; |
|
||||||
} |
|
||||||
|
|
||||||
bool match = "${res:".StartsWith(typedTag, StringComparison.OrdinalIgnoreCase); |
|
||||||
|
|
||||||
if (key == ':') { |
|
||||||
if (match || this.nonMatchingCharTyped) { |
|
||||||
return CompletionDataProviderKeyResult.InsertionKey; |
|
||||||
} else { |
|
||||||
this.nonMatchingCharTyped = true; |
|
||||||
return CompletionDataProviderKeyResult.NormalKey; |
|
||||||
} |
|
||||||
} else { |
|
||||||
if (match) { |
|
||||||
this.nonMatchingCharTyped = false; |
|
||||||
return CompletionDataProviderKeyResult.NormalKey; |
|
||||||
} else { |
|
||||||
if (this.nonMatchingCharTyped) { |
|
||||||
return CompletionDataProviderKeyResult.InsertionKey; |
|
||||||
} else { |
|
||||||
this.nonMatchingCharTyped = true; |
|
||||||
return CompletionDataProviderKeyResult.NormalKey; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
string GetTypedText() |
|
||||||
{ |
|
||||||
if (this.textArea == null) { |
|
||||||
return String.Empty; |
|
||||||
} |
|
||||||
|
|
||||||
int offset = Math.Max(this.startOffset, 0); |
|
||||||
return this.textArea.Document.GetText(offset, Math.Min(Math.Max(this.textArea.Caret.Offset - offset, 0), this.textArea.Document.TextLength - offset)); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -0,0 +1,37 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt"/>
|
||||||
|
// <license see="prj:///doc/license.txt"/>
|
||||||
|
// <owner name="Christian Hornung" email=""/>
|
||||||
|
// <version>$Revision$</version>
|
||||||
|
// </file>
|
||||||
|
|
||||||
|
using System; |
||||||
|
using ICSharpCode.SharpDevelop; |
||||||
|
using ICSharpCode.SharpDevelop.Editor; |
||||||
|
using ICSharpCode.SharpDevelop.Editor.CodeCompletion; |
||||||
|
|
||||||
|
namespace Hornung.ResourceToolkit.CodeCompletion |
||||||
|
{ |
||||||
|
/// <summary>
|
||||||
|
/// Provides code completion data for the ${res tag.
|
||||||
|
/// </summary>
|
||||||
|
public sealed class ICSharpCodeCoreTagCompletionItemList : DefaultCompletionItemList |
||||||
|
{ |
||||||
|
public ICSharpCodeCoreTagCompletionItemList(ITextEditor editor) |
||||||
|
: base() |
||||||
|
{ |
||||||
|
var item = new DefaultCompletionItem("{res") { Image = ClassBrowserIconService.Keyword }; |
||||||
|
this.Items.Add(item); |
||||||
|
this.SuggestedItem = item; |
||||||
|
} |
||||||
|
|
||||||
|
public override CompletionItemListKeyResult ProcessInput(char key) |
||||||
|
{ |
||||||
|
if (key == ':' || key == '}' || Char.IsWhiteSpace(key)) { |
||||||
|
return CompletionItemListKeyResult.InsertionKey; |
||||||
|
} else { |
||||||
|
return CompletionItemListKeyResult.NormalKey; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -1,63 +0,0 @@ |
|||||||
// <file>
|
|
||||||
// <copyright see="prj:///doc/copyright.txt"/>
|
|
||||||
// <license see="prj:///doc/license.txt"/>
|
|
||||||
// <owner name="Christian Hornung" email=""/>
|
|
||||||
// <version>$Revision$</version>
|
|
||||||
// </file>
|
|
||||||
|
|
||||||
using System; |
|
||||||
using System.Globalization; |
|
||||||
using System.Windows.Forms; |
|
||||||
|
|
||||||
using Hornung.ResourceToolkit.Gui; |
|
||||||
using Hornung.ResourceToolkit.ResourceFileContent; |
|
||||||
using ICSharpCode.Core; |
|
||||||
using ICSharpCode.NRefactory.PrettyPrinter; |
|
||||||
using ICSharpCode.SharpDevelop.Gui; |
|
||||||
using ICSharpCode.TextEditor; |
|
||||||
|
|
||||||
namespace Hornung.ResourceToolkit.CodeCompletion |
|
||||||
{ |
|
||||||
/// <summary>
|
|
||||||
/// Provides a code completion entry used to add a new string resource.
|
|
||||||
/// </summary>
|
|
||||||
public class NewResourceCodeCompletionData : ResourceCodeCompletionData |
|
||||||
{ |
|
||||||
|
|
||||||
readonly IResourceFileContent content; |
|
||||||
readonly string preEnteredName; |
|
||||||
|
|
||||||
public NewResourceCodeCompletionData(IResourceFileContent content, IOutputAstVisitor outputVisitor, string preEnteredName) |
|
||||||
: base(StringParser.Parse("${res:Hornung.ResourceToolkit.CodeCompletion.AddNewEntry}"), String.Format(CultureInfo.CurrentCulture, StringParser.Parse("${res:Hornung.ResourceToolkit.CodeCompletion.AddNewDescription}"), content.FileName), outputVisitor) |
|
||||||
{ |
|
||||||
this.content = content; |
|
||||||
this.preEnteredName = preEnteredName; |
|
||||||
} |
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Present a form to the user where he enters the name for the new
|
|
||||||
/// string resource and then insert the key value into the text editor.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="textArea">TextArea to insert the completion data in.</param>
|
|
||||||
/// <param name="ch">Character that should be inserted after the completion data.
|
|
||||||
/// \0 when no character should be inserted.</param>
|
|
||||||
/// <returns>Returns true when the insert action has processed the character
|
|
||||||
/// <paramref name="ch"/>; false when the character was not processed.</returns>
|
|
||||||
public override bool InsertAction(TextArea textArea, char ch) |
|
||||||
{ |
|
||||||
|
|
||||||
EditStringResourceDialog dialog = new EditStringResourceDialog(this.content, this.preEnteredName, null, true); |
|
||||||
dialog.Text = this.Description; |
|
||||||
if (dialog.ShowDialog(WorkbenchSingleton.MainWin32Window) != DialogResult.OK) { |
|
||||||
return false; |
|
||||||
} |
|
||||||
|
|
||||||
this.Text = dialog.Key; |
|
||||||
|
|
||||||
this.content.Add(dialog.Key, dialog.Value); |
|
||||||
|
|
||||||
return base.InsertAction(textArea, ch); |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
||||||
} |
|
@ -0,0 +1,50 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt"/>
|
||||||
|
// <license see="prj:///doc/license.txt"/>
|
||||||
|
// <owner name="Christian Hornung" email=""/>
|
||||||
|
// <version>$Revision$</version>
|
||||||
|
// </file>
|
||||||
|
|
||||||
|
using System; |
||||||
|
using System.Globalization; |
||||||
|
using System.Windows.Forms; |
||||||
|
|
||||||
|
using Hornung.ResourceToolkit.Gui; |
||||||
|
using Hornung.ResourceToolkit.ResourceFileContent; |
||||||
|
using ICSharpCode.Core; |
||||||
|
using ICSharpCode.NRefactory.PrettyPrinter; |
||||||
|
using ICSharpCode.SharpDevelop.Editor.CodeCompletion; |
||||||
|
using ICSharpCode.SharpDevelop.Gui; |
||||||
|
|
||||||
|
namespace Hornung.ResourceToolkit.CodeCompletion |
||||||
|
{ |
||||||
|
/// <summary>
|
||||||
|
/// Provides a code completion item used to add a new string resource.
|
||||||
|
/// </summary>
|
||||||
|
public sealed class NewResourceCodeCompletionItem : ResourceCodeCompletionItem |
||||||
|
{ |
||||||
|
readonly IResourceFileContent content; |
||||||
|
readonly string preEnteredName; |
||||||
|
|
||||||
|
public NewResourceCodeCompletionItem(IResourceFileContent content, IOutputAstVisitor outputVisitor, string preEnteredName) |
||||||
|
: base(StringParser.Parse("${res:Hornung.ResourceToolkit.CodeCompletion.AddNewEntry}"), String.Format(CultureInfo.CurrentCulture, StringParser.Parse("${res:Hornung.ResourceToolkit.CodeCompletion.AddNewDescription}"), content.FileName), outputVisitor) |
||||||
|
{ |
||||||
|
this.content = content; |
||||||
|
this.preEnteredName = preEnteredName; |
||||||
|
} |
||||||
|
|
||||||
|
public override void Complete(CompletionContext context) |
||||||
|
{ |
||||||
|
using (EditStringResourceDialog dialog = new EditStringResourceDialog(this.content, this.preEnteredName, null, true)) { |
||||||
|
dialog.Text = this.Description; |
||||||
|
if (dialog.ShowDialog(WorkbenchSingleton.MainWin32Window) != DialogResult.OK) { |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
this.content.Add(dialog.Key, dialog.Value); |
||||||
|
|
||||||
|
this.CompleteInternal(context, dialog.Key); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -1,66 +0,0 @@ |
|||||||
// <file>
|
|
||||||
// <copyright see="prj:///doc/copyright.txt"/>
|
|
||||||
// <license see="prj:///doc/license.txt"/>
|
|
||||||
// <owner name="Christian Hornung" email=""/>
|
|
||||||
// <version>$Revision$</version>
|
|
||||||
// </file>
|
|
||||||
|
|
||||||
using System; |
|
||||||
using ICSharpCode.NRefactory.Ast; |
|
||||||
using ICSharpCode.NRefactory.PrettyPrinter; |
|
||||||
using ICSharpCode.SharpDevelop; |
|
||||||
using ICSharpCode.TextEditor; |
|
||||||
using ICSharpCode.TextEditor.Gui.CompletionWindow; |
|
||||||
|
|
||||||
namespace Hornung.ResourceToolkit.CodeCompletion |
|
||||||
{ |
|
||||||
/// <summary>
|
|
||||||
/// Represents a code completion data entry for resource keys.
|
|
||||||
/// </summary>
|
|
||||||
public class ResourceCodeCompletionData : DefaultCompletionData |
|
||||||
{ |
|
||||||
|
|
||||||
readonly IOutputAstVisitor outputVisitor; |
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Initializes a new instance of the <see cref="ResourceCodeCompletionData" /> class.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="key">The resource key.</param>
|
|
||||||
/// <param name="description">The resource description.</param>
|
|
||||||
/// <param name="outputVisitor">The NRefactory output visitor to be used to generate the inserted code. If <c>null</c>, the key is inserted literally.</param>
|
|
||||||
public ResourceCodeCompletionData(string key, string description, IOutputAstVisitor outputVisitor) |
|
||||||
: base(key, description, ClassBrowserIconService.GotoArrow.ImageIndex) |
|
||||||
{ |
|
||||||
this.outputVisitor = outputVisitor; |
|
||||||
} |
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Insert the element represented by the completion data into the text
|
|
||||||
/// editor.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="textArea">TextArea to insert the completion data in.</param>
|
|
||||||
/// <param name="ch">Character that should be inserted after the completion data.
|
|
||||||
/// \0 when no character should be inserted.</param>
|
|
||||||
/// <returns>Returns true when the insert action has processed the character
|
|
||||||
/// <paramref name="ch"/>; false when the character was not processed.</returns>
|
|
||||||
public override bool InsertAction(TextArea textArea, char ch) |
|
||||||
{ |
|
||||||
string insertString; |
|
||||||
|
|
||||||
if (this.outputVisitor != null) { |
|
||||||
PrimitiveExpression pre = new PrimitiveExpression(this.Text, this.Text); |
|
||||||
pre.AcceptVisitor(this.outputVisitor, null); |
|
||||||
insertString = this.outputVisitor.Text; |
|
||||||
} else { |
|
||||||
insertString = this.Text; |
|
||||||
} |
|
||||||
|
|
||||||
textArea.InsertString(insertString); |
|
||||||
if (ch == insertString[insertString.Length - 1]) { |
|
||||||
return true; |
|
||||||
} |
|
||||||
return false; |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
||||||
} |
|
@ -1,72 +0,0 @@ |
|||||||
// <file>
|
|
||||||
// <copyright see="prj:///doc/copyright.txt"/>
|
|
||||||
// <license see="prj:///doc/license.txt"/>
|
|
||||||
// <owner name="Christian Hornung" email=""/>
|
|
||||||
// <version>$Revision$</version>
|
|
||||||
// </file>
|
|
||||||
|
|
||||||
using System; |
|
||||||
using System.Collections.Generic; |
|
||||||
using Hornung.ResourceToolkit.ResourceFileContent; |
|
||||||
using ICSharpCode.NRefactory.PrettyPrinter; |
|
||||||
using ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor; |
|
||||||
using ICSharpCode.TextEditor.Gui.CompletionWindow; |
|
||||||
|
|
||||||
namespace Hornung.ResourceToolkit.CodeCompletion |
|
||||||
{ |
|
||||||
/// <summary>
|
|
||||||
/// Provides code completion data for resource keys.
|
|
||||||
/// </summary>
|
|
||||||
public class ResourceCodeCompletionDataProvider : AbstractCompletionDataProvider |
|
||||||
{ |
|
||||||
readonly IResourceFileContent content; |
|
||||||
readonly IOutputAstVisitor outputVisitor; |
|
||||||
readonly string preEnteredName; |
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Initializes a new instance of the <see cref="ResourceCodeCompletionDataProvider" /> class.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="content">The resource file content to be presented to the user.</param>
|
|
||||||
/// <param name="outputVisitor">The NRefactory output visitor to be used to generate the inserted code. If <c>null</c>, the key is inserted literally.</param>
|
|
||||||
/// <param name="preEnteredName">The type name which should be pre-entered in the 'add new' dialog box if the user selects the 'add new' entry.</param>
|
|
||||||
public ResourceCodeCompletionDataProvider(IResourceFileContent content, IOutputAstVisitor outputVisitor, string preEnteredName) |
|
||||||
{ |
|
||||||
if (content == null) { |
|
||||||
throw new ArgumentNullException("content"); |
|
||||||
} |
|
||||||
this.content = content; |
|
||||||
this.outputVisitor = outputVisitor; |
|
||||||
this.preEnteredName = preEnteredName; |
|
||||||
this.InsertSpace = false; |
|
||||||
} |
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Generates the completion data. This method is called by the text editor control.
|
|
||||||
/// </summary>
|
|
||||||
public override ICompletionData[] GenerateCompletionData(string fileName, ICSharpCode.TextEditor.TextArea textArea, char charTyped) |
|
||||||
{ |
|
||||||
List<ICompletionData> list = new List<ICompletionData>(); |
|
||||||
|
|
||||||
list.Add(new NewResourceCodeCompletionData(this.content, this.outputVisitor, this.preEnteredName)); |
|
||||||
|
|
||||||
foreach (KeyValuePair<string, object> entry in this.content.Data) { |
|
||||||
list.Add(new ResourceCodeCompletionData(entry.Key, ResourceResolverService.FormatResourceDescription(this.content, entry.Key), this.outputVisitor)); |
|
||||||
} |
|
||||||
|
|
||||||
return list.ToArray(); |
|
||||||
} |
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets if pressing 'key' should trigger the insertion of the currently selected element.
|
|
||||||
/// </summary>
|
|
||||||
public override CompletionDataProviderKeyResult ProcessKey(char key) |
|
||||||
{ |
|
||||||
if (key == '.') { |
|
||||||
// don't auto-complete on pressing '.' (this character is commonly used in resource key names)
|
|
||||||
return CompletionDataProviderKeyResult.NormalKey; |
|
||||||
} |
|
||||||
return base.ProcessKey(key); |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
||||||
} |
|
@ -0,0 +1,58 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt"/>
|
||||||
|
// <license see="prj:///doc/license.txt"/>
|
||||||
|
// <owner name="Christian Hornung" email=""/>
|
||||||
|
// <version>$Revision$</version>
|
||||||
|
// </file>
|
||||||
|
|
||||||
|
using System; |
||||||
|
using ICSharpCode.NRefactory.Ast; |
||||||
|
using ICSharpCode.NRefactory.PrettyPrinter; |
||||||
|
using ICSharpCode.SharpDevelop; |
||||||
|
using ICSharpCode.SharpDevelop.Editor.CodeCompletion; |
||||||
|
|
||||||
|
namespace Hornung.ResourceToolkit.CodeCompletion |
||||||
|
{ |
||||||
|
/// <summary>
|
||||||
|
/// Represents a code completion item for resource keys.
|
||||||
|
/// </summary>
|
||||||
|
public class ResourceCodeCompletionItem : DefaultCompletionItem |
||||||
|
{ |
||||||
|
readonly IOutputAstVisitor outputVisitor; |
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="ResourceCodeCompletionItem" /> class.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="key">The resource key.</param>
|
||||||
|
/// <param name="description">The resource description.</param>
|
||||||
|
/// <param name="outputVisitor">The NRefactory output visitor to be used to generate the inserted code. If <c>null</c>, the key is inserted literally.</param>
|
||||||
|
public ResourceCodeCompletionItem(string key, string description, IOutputAstVisitor outputVisitor) |
||||||
|
: base(key) |
||||||
|
{ |
||||||
|
this.Description = description; |
||||||
|
this.Image = ClassBrowserIconService.Const; |
||||||
|
this.outputVisitor = outputVisitor; |
||||||
|
} |
||||||
|
|
||||||
|
public override void Complete(CompletionContext context) |
||||||
|
{ |
||||||
|
this.CompleteInternal(context, this.Text); |
||||||
|
} |
||||||
|
|
||||||
|
protected void CompleteInternal(CompletionContext context, string key) |
||||||
|
{ |
||||||
|
string insertString; |
||||||
|
|
||||||
|
if (this.outputVisitor != null) { |
||||||
|
PrimitiveExpression pre = new PrimitiveExpression(key, key); |
||||||
|
pre.AcceptVisitor(this.outputVisitor, null); |
||||||
|
insertString = this.outputVisitor.Text; |
||||||
|
} else { |
||||||
|
insertString = key; |
||||||
|
} |
||||||
|
|
||||||
|
context.Editor.Document.Replace(context.StartOffset, context.Length, insertString); |
||||||
|
context.EndOffset = context.StartOffset + insertString.Length; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,59 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt"/>
|
||||||
|
// <license see="prj:///doc/license.txt"/>
|
||||||
|
// <owner name="Christian Hornung" email=""/>
|
||||||
|
// <version>$Revision$</version>
|
||||||
|
// </file>
|
||||||
|
|
||||||
|
using System; |
||||||
|
using System.Collections.Generic; |
||||||
|
|
||||||
|
using Hornung.ResourceToolkit.ResourceFileContent; |
||||||
|
using ICSharpCode.NRefactory.PrettyPrinter; |
||||||
|
using ICSharpCode.SharpDevelop.Editor; |
||||||
|
using ICSharpCode.SharpDevelop.Editor.CodeCompletion; |
||||||
|
|
||||||
|
namespace Hornung.ResourceToolkit.CodeCompletion |
||||||
|
{ |
||||||
|
/// <summary>
|
||||||
|
/// Provides code completion data for resource keys.
|
||||||
|
/// </summary>
|
||||||
|
public sealed class ResourceCodeCompletionItemList : DefaultCompletionItemList |
||||||
|
{ |
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="ResourceCodeCompletionItemList" /> class.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="content">The resource file content to be presented to the user.</param>
|
||||||
|
/// <param name="outputVisitor">The NRefactory output visitor to be used to generate the inserted code. If <c>null</c>, the key is inserted literally.</param>
|
||||||
|
/// <param name="preEnteredName">The type name which should be pre-entered in the 'add new' dialog box if the user selects the 'add new' entry.</param>
|
||||||
|
public ResourceCodeCompletionItemList(IResourceFileContent content, IOutputAstVisitor outputVisitor, string preEnteredName) |
||||||
|
{ |
||||||
|
if (content == null) { |
||||||
|
throw new ArgumentNullException("content"); |
||||||
|
} |
||||||
|
|
||||||
|
this.GenerateCompletionItems(content, outputVisitor, preEnteredName); |
||||||
|
} |
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Generates the completion items.
|
||||||
|
/// </summary>
|
||||||
|
private void GenerateCompletionItems(IResourceFileContent content, IOutputAstVisitor outputVisitor, string preEnteredName) |
||||||
|
{ |
||||||
|
this.Items.Add(new NewResourceCodeCompletionItem(content, outputVisitor, preEnteredName)); |
||||||
|
|
||||||
|
foreach (KeyValuePair<string, object> entry in content.Data) { |
||||||
|
this.Items.Add(new ResourceCodeCompletionItem(entry.Key, ResourceResolverService.FormatResourceDescription(content, entry.Key), outputVisitor)); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public override CompletionItemListKeyResult ProcessInput(char key) |
||||||
|
{ |
||||||
|
if (key == '.') { |
||||||
|
// don't auto-complete on pressing '.' (this character is commonly used in resource key names)
|
||||||
|
return CompletionItemListKeyResult.NormalKey; |
||||||
|
} |
||||||
|
return base.ProcessInput(key); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue