Browse Source
git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@3950 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61shortcuts
8 changed files with 450 additions and 205 deletions
@ -0,0 +1,51 @@
@@ -0,0 +1,51 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Siegfried Pammer" email="sie_pam@gmx.at"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using ICSharpCode.XmlEditor; |
||||
using System; |
||||
using System.IO; |
||||
using System.Xml; |
||||
|
||||
namespace ICSharpCode.XamlBinding |
||||
{ |
||||
/// <summary>
|
||||
/// Description of Utils.
|
||||
/// </summary>
|
||||
public static class Utils |
||||
{ |
||||
public static bool HasMatchingEndTag(string tagname, string text, int offset) |
||||
{ |
||||
int index = XmlParser.GetActiveElementStartIndex(text, offset); |
||||
if (index == -1) |
||||
return false; |
||||
|
||||
text = text.Substring(index); |
||||
|
||||
XmlReader reader = XmlTextReader.Create(new StringReader(text)); |
||||
int startTags = 0; |
||||
try { |
||||
while (reader.Read()) { |
||||
switch (reader.NodeType) { |
||||
case XmlNodeType.Element: |
||||
startTags++; |
||||
break; |
||||
case XmlNodeType.EndElement: |
||||
startTags--; |
||||
if (startTags == 0 && tagname == reader.Name) { |
||||
return true; |
||||
} |
||||
break; |
||||
} |
||||
} |
||||
} catch (XmlException) { |
||||
return false; |
||||
} |
||||
|
||||
return false; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,91 @@
@@ -0,0 +1,91 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Siegfried Pammer" email="sie_pam@gmx.at"/>
|
||||
// <version>$Revision: 3731 $</version>
|
||||
// </file>
|
||||
|
||||
using ICSharpCode.SharpDevelop.Dom.Refactoring; |
||||
using System; |
||||
using System.Collections; |
||||
using System.Collections.Generic; |
||||
using System.Diagnostics; |
||||
using System.Linq; |
||||
using ICSharpCode.SharpDevelop; |
||||
using ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor; |
||||
using ICSharpCode.SharpDevelop.Dom; |
||||
using ICSharpCode.SharpDevelop.Gui; |
||||
using ICSharpCode.SharpDevelop.Project; |
||||
using ICSharpCode.TextEditor.Gui.CompletionWindow; |
||||
using ICSharpCode.XmlEditor; |
||||
|
||||
namespace ICSharpCode.XamlBinding |
||||
{ |
||||
sealed class XamlCompletionItemList : DefaultCompletionItemList |
||||
{ |
||||
public XamlCompletionItemList() |
||||
{ |
||||
} |
||||
|
||||
public override CompletionItemListKeyResult ProcessInput(char key) |
||||
{ |
||||
return base.ProcessInput(key); |
||||
} |
||||
|
||||
public override void Complete(CompletionContext context, ICompletionItem item) |
||||
{ |
||||
if (item is XamlCompletionItem) { |
||||
XamlCompletionItem cItem = item as XamlCompletionItem; |
||||
|
||||
if (cItem.Entity is IProperty) { |
||||
context.Editor.Document.Insert(context.EndOffset, "=\"\""); |
||||
context.Editor.Caret.Offset--; |
||||
XmlElementPath path = XmlParser.GetActiveElementStartPathAtIndex(context.Editor.Document.Text, context.Editor.Caret.Offset); |
||||
if (path != null && path.Elements.Count > 0) { |
||||
ICompletionItemList list = XamlCodeCompletionBinding.CreateListForContext(context.Editor, XamlContext.InAttributeValue, path, cItem.Entity); |
||||
context.Editor.ShowCompletionWindow(list); |
||||
} |
||||
} |
||||
|
||||
if (cItem.Entity is IEvent) { |
||||
context.Editor.Document.Insert(context.EndOffset, "=\"\""); |
||||
context.Editor.Caret.Offset--; |
||||
XmlElementPath path = XmlParser.GetActiveElementStartPathAtIndex(context.Editor.Document.Text, context.Editor.Caret.Offset); |
||||
if (path != null && path.Elements.Count > 0) { |
||||
ICompletionItemList list = XamlCodeCompletionBinding.CreateListForContext(context.Editor, XamlContext.InAttributeValue, path, cItem.Entity); |
||||
context.Editor.ShowCompletionWindow(list); |
||||
} |
||||
} |
||||
} else { |
||||
if (item is DefaultCompletionItem) { |
||||
if (item.Text == "<new event handler>") { // TODO : replace with translation string
|
||||
|
||||
} |
||||
} |
||||
} |
||||
|
||||
base.Complete(context, item); |
||||
} |
||||
|
||||
string CreateEventHandlerCode(CompletionContext context, out IMember lastMember) |
||||
{ |
||||
ParseInformation p = ParserService.GetParseInformation(context.Editor.FileName); |
||||
var unit = p.MostRecentCompilationUnit; |
||||
var loc = context.Editor.Document.OffsetToPosition(context.StartOffset); |
||||
IClass c = unit.GetInnermostClass(loc.Line, loc.Column); |
||||
CompoundClass compound = c.GetCompoundClass() as CompoundClass; |
||||
if (compound != null) { |
||||
foreach (IClass part in compound.Parts) { |
||||
RefactoringProvider provider = part.ProjectContent.Language.RefactoringProvider; |
||||
if (provider.SupportsCreateEventHandler) { |
||||
lastMember = part.Methods.Last(); |
||||
|
||||
//return provider.CreateEventHandler(;
|
||||
} |
||||
} |
||||
} |
||||
lastMember = null; |
||||
return string.Empty; |
||||
} |
||||
} |
||||
} |
@ -1,54 +0,0 @@
@@ -1,54 +0,0 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <author name="Daniel Grunwald"/>
|
||||
// <version>$Revision: 3494 $</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.Collections; |
||||
using System.Collections.Generic; |
||||
using System.Diagnostics; |
||||
using System.Linq; |
||||
|
||||
using ICSharpCode.SharpDevelop; |
||||
using ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor; |
||||
using ICSharpCode.SharpDevelop.Dom; |
||||
using ICSharpCode.SharpDevelop.Gui; |
||||
using ICSharpCode.SharpDevelop.Project; |
||||
using ICSharpCode.TextEditor.Gui.CompletionWindow; |
||||
|
||||
namespace ICSharpCode.XamlBinding |
||||
{ |
||||
sealed class XamlCompletionItemProvider : CtrlSpaceCompletionItemProvider |
||||
{ |
||||
public XamlCompletionItemProvider() |
||||
{ |
||||
} |
||||
|
||||
public XamlCompletionItemProvider(XamlExpressionContext context) |
||||
: base(context) |
||||
{ |
||||
} |
||||
|
||||
public override ICompletionItemList GenerateCompletionListForCompletionData(ArrayList arr, ExpressionContext context) |
||||
{ |
||||
DefaultCompletionItemList list = new DefaultCompletionItemList(); |
||||
list.Items.AddRange(base.GenerateCompletionListForCompletionData(arr, context).Items); |
||||
|
||||
if (context is XamlExpressionContext) { |
||||
XamlExpressionContext xContext = context as XamlExpressionContext; |
||||
|
||||
if (string.IsNullOrEmpty(xContext.AttributeName) && !xContext.InAttributeValue) { |
||||
list.Items.Add(new DefaultCompletionItem("!--")); |
||||
list.Items.Add(new DefaultCompletionItem("![CDATA[")); |
||||
list.Items.Add(new DefaultCompletionItem("?")); |
||||
} |
||||
} |
||||
|
||||
list.SortItems(); |
||||
|
||||
return list; |
||||
} |
||||
} |
||||
} |
Loading…
Reference in new issue