Browse Source

XamlBinding: fixed some minor issues

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@4394 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Siegfried Pammer 17 years ago
parent
commit
10753d32b2
  1. 3
      src/AddIns/BackendBindings/XamlBinding/XamlBinding.Tests/XamlBinding.Tests.csproj
  2. 12
      src/AddIns/BackendBindings/XamlBinding/XamlBinding/CompletionDataHelper.cs
  3. 17
      src/AddIns/BackendBindings/XamlBinding/XamlBinding/Utils.cs
  4. 6
      src/AddIns/BackendBindings/XamlBinding/XamlBinding/XamlCodeCompletionBinding.cs
  5. 2
      src/AddIns/BackendBindings/XamlBinding/XamlBinding/XamlContext.cs

3
src/AddIns/BackendBindings/XamlBinding/XamlBinding.Tests/XamlBinding.Tests.csproj

@ -85,7 +85,4 @@ @@ -85,7 +85,4 @@
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<Content Include="ProfilingSessions\Session20090705_103024.sdps" />
</ItemGroup>
</Project>

12
src/AddIns/BackendBindings/XamlBinding/XamlBinding/CompletionDataHelper.cs

@ -61,15 +61,14 @@ namespace ICSharpCode.XamlBinding @@ -61,15 +61,14 @@ namespace ICSharpCode.XamlBinding
XamlContextDescription description = XamlContextDescription.None;
Dictionary<string, string> xmlnsDefs;
QualifiedName active;
bool isParent;
QualifiedName active, parent;
int elementStartIndex;
Utils.LookUpInfoAtTarget(text, line, col, offset, out xmlnsDefs, out active, out isParent, out elementStartIndex);
Utils.LookUpInfoAtTarget(text, line, col, offset, out xmlnsDefs, out active, out parent, out elementStartIndex);
string wordBeforeIndex = text.GetWordBeforeOffset(offset);
if (active != null && !isParent)
if (active != null && parent != null)
description = XamlContextDescription.AtTag;
if (elementStartIndex > -1 &&
@ -93,6 +92,7 @@ namespace ICSharpCode.XamlBinding @@ -93,6 +92,7 @@ namespace ICSharpCode.XamlBinding
var context = new XamlContext() {
Description = description,
ActiveElement = active,
ParentElement = parent,
AttributeName = attribute,
AttributeValue = value,
RawAttributeValue = attributeValue,
@ -111,7 +111,7 @@ namespace ICSharpCode.XamlBinding @@ -111,7 +111,7 @@ namespace ICSharpCode.XamlBinding
if (offset < 0)
return null;
string elementName = text.GetWordAfterOffset(offset + 1);
string elementName = text.GetWordAfterOffset(offset + 1).Trim('>', '<');
string prefix = "";
string element = "";
@ -266,7 +266,7 @@ namespace ICSharpCode.XamlBinding @@ -266,7 +266,7 @@ namespace ICSharpCode.XamlBinding
var items = GetClassesFromContext(context);
var result = new List<ICompletionItem>();
var last = context.ActiveElement;
var last = context.ParentElement;
XamlCompilationUnit cu = context.ParseInformation.BestCompilationUnit as XamlCompilationUnit;

17
src/AddIns/BackendBindings/XamlBinding/XamlBinding/Utils.cs

@ -224,13 +224,12 @@ namespace ICSharpCode.XamlBinding @@ -224,13 +224,12 @@ namespace ICSharpCode.XamlBinding
}
public static void LookUpInfoAtTarget(string fileContent, int caretLine, int caretColumn, int offset,
out Dictionary<string, string> xmlns, out QualifiedName activeOrParent, out bool isParent, out int activeElementStartIndex)
out Dictionary<string, string> xmlns, out QualifiedName active, out QualifiedName parent, out int activeElementStartIndex)
{
var watch = new Stopwatch();
watch.Start();
Stack<QualifiedName> stack = new Stack<QualifiedName>();
isParent = false;
XmlTextReader r = new XmlTextReader(new StringReader(fileContent));
r.XmlResolver = null;
@ -254,12 +253,14 @@ namespace ICSharpCode.XamlBinding @@ -254,12 +253,14 @@ namespace ICSharpCode.XamlBinding
}
activeElementStartIndex = XmlParser.GetActiveElementStartIndex(fileContent, offset + 1);
activeOrParent = CompletionDataHelper.ResolveCurrentElement(fileContent, activeElementStartIndex, xmlns);
if (activeOrParent == null) {
activeOrParent = stack.PopOrDefault();
isParent = true;
}
active = CompletionDataHelper.ResolveCurrentElement(fileContent, activeElementStartIndex, xmlns);
parent = stack.PopOrDefault();
if (active == parent)
parent = stack.PopOrDefault();
if (active == null)
active = parent;
watch.Stop();

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

@ -138,9 +138,11 @@ namespace ICSharpCode.XamlBinding @@ -138,9 +138,11 @@ namespace ICSharpCode.XamlBinding
if (context.ActiveElement != null) {
if (!XmlParser.IsInsideAttributeValue(editor.Document.Text, editor.Caret.Offset) && context.Description != XamlContextDescription.InAttributeValue) {
var list = CompletionDataHelper.CreateListForContext(context) as XamlCompletionItemList;
string starter = editor.GetWordBeforeCaret().Trim('<', '>');
if (!string.IsNullOrEmpty(starter) && !starter.EndsWith(StringComparison.Ordinal, ' ', '\t', '\n', '\r'))
string starter = editor.Document.Text.GetWordBeforeOffset(editor.Caret.Offset).Trim('<', '>');
if (!string.IsNullOrEmpty(starter) && !starter.EndsWith(StringComparison.Ordinal, ' ', '\t', '\n', '\r')) {
list.SuggestedItem = list.Items.FirstOrDefault(item => item.Text.StartsWith(starter, StringComparison.OrdinalIgnoreCase));
list.PreselectionLength = starter.Length;
}
editor.ShowCompletionWindow(list);
return true;
} else {

2
src/AddIns/BackendBindings/XamlBinding/XamlBinding/XamlContext.cs

@ -20,6 +20,7 @@ namespace ICSharpCode.XamlBinding @@ -20,6 +20,7 @@ namespace ICSharpCode.XamlBinding
{
public class XamlContext : ExpressionContext {
public QualifiedName ActiveElement { get; set; }
public QualifiedName ParentElement { get; set; }
public string AttributeName { get; set; }
public AttributeValue AttributeValue { get; set; }
public string RawAttributeValue { get; set; }
@ -45,6 +46,7 @@ namespace ICSharpCode.XamlBinding @@ -45,6 +46,7 @@ namespace ICSharpCode.XamlBinding
this.AttributeName = context.AttributeName;
this.AttributeValue = context.AttributeValue;
this.Description = context.Description;
this.ParentElement = context.ParentElement;
this.ParseInformation = context.ParseInformation;
this.RawAttributeValue = context.RawAttributeValue;
this.ValueStartOffset = context.ValueStartOffset;

Loading…
Cancel
Save