Browse Source

- fixed compilation of tests

- code clean up

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/XmlEditor@4167 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Siegfried Pammer 16 years ago
parent
commit
b16addd829
  1. 2
      src/AddIns/DisplayBindings/XmlEditor/Project/Configuration/AssemblyInfo.cs
  2. 167
      src/AddIns/DisplayBindings/XmlEditor/Project/Src/Src/XPathNodeMatch.cs
  3. 60
      src/AddIns/DisplayBindings/XmlEditor/Project/Src/Src/XPathNodeTextMarker.cs
  4. 95
      src/AddIns/DisplayBindings/XmlEditor/Project/Src/Src/XmlAttributePropertyDescriptor.cs
  5. 94
      src/AddIns/DisplayBindings/XmlEditor/Project/Src/Src/XmlAttributeTypeDescriptor.cs
  6. 60
      src/AddIns/DisplayBindings/XmlEditor/Project/Src/Src/XmlCharacterDataTreeNode.cs
  7. 60
      src/AddIns/DisplayBindings/XmlEditor/Project/Src/Src/XmlCommentTreeNode.cs
  8. 119
      src/AddIns/DisplayBindings/XmlEditor/Project/Src/Src/XmlEditorAddInOptions.cs
  9. 99
      src/AddIns/DisplayBindings/XmlEditor/Project/Src/Src/XmlElementTreeNode.cs
  10. 157
      src/AddIns/DisplayBindings/XmlEditor/Project/Src/Src/XmlSchemaAssociation.cs
  11. 89
      src/AddIns/DisplayBindings/XmlEditor/Project/Src/Src/XmlSchemaAssociationListBoxItem.cs
  12. 1352
      src/AddIns/DisplayBindings/XmlEditor/Project/Src/Src/XmlSchemaCompletionData.cs
  13. 294
      src/AddIns/DisplayBindings/XmlEditor/Project/Src/Src/XmlSchemaCompletionDataCollection.cs
  14. 61
      src/AddIns/DisplayBindings/XmlEditor/Project/Src/Src/XmlSchemaListBoxItem.cs
  15. 218
      src/AddIns/DisplayBindings/XmlEditor/Project/Src/Src/XmlSchemaManager.cs
  16. 60
      src/AddIns/DisplayBindings/XmlEditor/Project/Src/Src/XmlTextTreeNode.cs
  17. 654
      src/AddIns/DisplayBindings/XmlEditor/Project/Src/Src/XmlTreeEditor.cs
  18. 924
      src/AddIns/DisplayBindings/XmlEditor/Project/Src/Src/XmlTreeViewContainerControl.cs
  19. 578
      src/AddIns/DisplayBindings/XmlEditor/Project/Src/Src/XmlTreeViewControl.cs
  20. 49
      src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlCodeCompletionBinding.cs
  21. 49
      src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlCompletionDataProvider.cs
  22. 10
      src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlTreeView.cs
  23. 2
      src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlTreeViewContainerControl.cs
  24. 21
      src/AddIns/DisplayBindings/XmlEditor/Test/Completion/FirstCompletionListItemSelectedTestFixture.cs
  25. 12
      src/AddIns/DisplayBindings/XmlEditor/Test/Completion/ProcessKeyTests.cs
  26. 11
      src/AddIns/DisplayBindings/XmlEditor/Test/Schema/AbstractElementTestFixture.cs
  27. 11
      src/AddIns/DisplayBindings/XmlEditor/Test/Schema/AllElementTestFixture.cs
  28. 11
      src/AddIns/DisplayBindings/XmlEditor/Test/Schema/AttributeAnnotationTestFixture.cs
  29. 7
      src/AddIns/DisplayBindings/XmlEditor/Test/Schema/AttributeGroupRefTestFixture.cs
  30. 7
      src/AddIns/DisplayBindings/XmlEditor/Test/Schema/AttributeRefTestFixture.cs
  31. 9
      src/AddIns/DisplayBindings/XmlEditor/Test/Schema/AttributeValueAnnotationTestFixture.cs
  32. 7
      src/AddIns/DisplayBindings/XmlEditor/Test/Schema/ChildElementAttributesTestFixture.cs
  33. 7
      src/AddIns/DisplayBindings/XmlEditor/Test/Schema/ChoiceTestFixture.cs
  34. 9
      src/AddIns/DisplayBindings/XmlEditor/Test/Schema/ComplexContentExtensionTestFixture.cs
  35. 7
      src/AddIns/DisplayBindings/XmlEditor/Test/Schema/DuplicateElementTestFixture.cs
  36. 14
      src/AddIns/DisplayBindings/XmlEditor/Test/Schema/ElementAnnotationTestFixture.cs
  37. 9
      src/AddIns/DisplayBindings/XmlEditor/Test/Schema/ElementRefAnnotationTestFixture.cs
  38. 9
      src/AddIns/DisplayBindings/XmlEditor/Test/Schema/ElementWithAttributeSchemaTestFixture.cs
  39. 7
      src/AddIns/DisplayBindings/XmlEditor/Test/Schema/EnumAttributeValueTestFixture.cs
  40. 19
      src/AddIns/DisplayBindings/XmlEditor/Test/Schema/ExtensionElementTestFixture.cs
  41. 9
      src/AddIns/DisplayBindings/XmlEditor/Test/Schema/GroupRefCompositorTestFixture.cs
  42. 9
      src/AddIns/DisplayBindings/XmlEditor/Test/Schema/GroupRefTestFixture.cs
  43. 7
      src/AddIns/DisplayBindings/XmlEditor/Test/Schema/MissingSchemaElementTestFixture.cs
  44. 14
      src/AddIns/DisplayBindings/XmlEditor/Test/Schema/NamespaceCompletionTestFixture.cs
  45. 7
      src/AddIns/DisplayBindings/XmlEditor/Test/Schema/NestedAttributeGroupRefTestFixture.cs
  46. 9
      src/AddIns/DisplayBindings/XmlEditor/Test/Schema/NestedChoiceTestFixture.cs
  47. 7
      src/AddIns/DisplayBindings/XmlEditor/Test/Schema/NestedElementSchemaTestFixture.cs
  48. 7
      src/AddIns/DisplayBindings/XmlEditor/Test/Schema/NestedSequenceTestFixture.cs
  49. 15
      src/AddIns/DisplayBindings/XmlEditor/Test/Schema/ReferencedElementsTestFixture.cs
  50. 13
      src/AddIns/DisplayBindings/XmlEditor/Test/Schema/RestrictionElementTestFixture.cs
  51. 17
      src/AddIns/DisplayBindings/XmlEditor/Test/Schema/SchemaTestFixtureBase.cs
  52. 7
      src/AddIns/DisplayBindings/XmlEditor/Test/Schema/SequencedChoiceTestFixture.cs
  53. 7
      src/AddIns/DisplayBindings/XmlEditor/Test/Schema/SimpleContentWithAttributeTestFixture.cs
  54. 9
      src/AddIns/DisplayBindings/XmlEditor/Test/Schema/SingleElementSchemaTestFixture.cs
  55. 22
      src/AddIns/DisplayBindings/XmlEditor/Test/Schema/TwoElementSchemaTestFixture.cs
  56. 9
      src/AddIns/DisplayBindings/XmlEditor/Test/Schema/XhtmlStrictSchemaTestFixture.cs
  57. 10
      src/AddIns/DisplayBindings/XmlEditor/Test/Tree/AddNewNodeDialogTestFixture.cs
  58. 12
      src/AddIns/DisplayBindings/XmlEditor/Test/Tree/OwnerStatusTestFixture.cs
  59. 10
      src/AddIns/DisplayBindings/XmlEditor/Test/Tree/XmlTreeViewClipboardHandlerTestFixture.cs
  60. 38
      src/AddIns/DisplayBindings/XmlEditor/Test/Utils/MockXmlViewContent.cs
  61. 165
      src/AddIns/DisplayBindings/XmlEditor/Test/XPathQuery/XPathNodeTextMarkerTests.cs
  62. 25
      src/AddIns/DisplayBindings/XmlEditor/Test/XmlEditor.Tests.csproj
  63. 8
      src/Main/Base/Project/Src/Editor/AvalonEdit/AvalonEditDocumentAdapter.cs

2
src/AddIns/DisplayBindings/XmlEditor/Project/Configuration/AssemblyInfo.cs

@ -22,6 +22,8 @@ using System.Runtime.InteropServices; @@ -22,6 +22,8 @@ using System.Runtime.InteropServices;
// If you need to expose a type to COM, use [ComVisible(true)] on that type.
[assembly: ComVisible(false)]
[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("XmlEditor.Tests")]
// The assembly version has following format :
//
// Major.Minor.Build.Revision

167
src/AddIns/DisplayBindings/XmlEditor/Project/Src/Src/XPathNodeMatch.cs

@ -1,167 +0,0 @@ @@ -1,167 +0,0 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
// <version>$Revision: 1662 $</version>
// </file>
using System;
using System.Xml;
using System.Xml.XPath;
namespace ICSharpCode.XmlEditor
{
/// <summary>
/// Stores an XmlNode and its associated line number and position after an
/// XPath query has been evaluated.
/// </summary>
public class XPathNodeMatch : IXmlLineInfo
{
int? lineNumber;
int linePosition;
string value;
string displayValue;
XPathNodeType nodeType;
/// <summary>
/// Creates an XPathNodeMatch from the navigator which should be position on the
/// node.
/// </summary>
/// <remarks>
/// We deliberately use the OuterXml when we find a Namespace since the
/// navigator location returned starts from the xmlns attribute.
/// </remarks>
public XPathNodeMatch(XPathNavigator currentNavigator)
{
SetLineNumbers(currentNavigator as IXmlLineInfo);
nodeType = currentNavigator.NodeType;
switch (nodeType) {
case XPathNodeType.Text:
SetTextValue(currentNavigator);
break;
case XPathNodeType.Comment:
SetCommentValue(currentNavigator);
break;
case XPathNodeType.Namespace:
SetNamespaceValue(currentNavigator);
break;
case XPathNodeType.Element:
SetElementValue(currentNavigator);
break;
case XPathNodeType.ProcessingInstruction:
SetProcessingInstructionValue(currentNavigator);
break;
case XPathNodeType.Attribute:
SetAttributeValue(currentNavigator);
break;
default:
value = currentNavigator.LocalName;
displayValue = value;
break;
}
}
/// <summary>
/// Line numbers are zero based.
/// </summary>
public int LineNumber {
get {
return lineNumber.GetValueOrDefault(0);
}
}
/// <summary>
/// Line positions are zero based.
/// </summary>
public int LinePosition {
get {
return linePosition;
}
}
public bool HasLineInfo()
{
return lineNumber.HasValue;
}
/// <summary>
/// Gets the text value of the node.
/// </summary>
public string Value {
get {
return value;
}
}
/// <summary>
/// Gets the node display value. This includes the angle brackets if it is
/// an element, for example.
/// </summary>
public string DisplayValue {
get {
return displayValue;
}
}
public XPathNodeType NodeType {
get {
return nodeType;
}
}
void SetElementValue(XPathNavigator navigator)
{
value = navigator.Name;
if (navigator.IsEmptyElement) {
displayValue = String.Concat("<", value, "/>");
} else {
displayValue = String.Concat("<", value, ">");
}
}
void SetTextValue(XPathNavigator navigator)
{
value = navigator.Value;
displayValue = value;
}
void SetCommentValue(XPathNavigator navigator)
{
value = navigator.Value;
displayValue = navigator.OuterXml;
}
void SetNamespaceValue(XPathNavigator navigator)
{
value = navigator.OuterXml;
displayValue = value;
}
void SetProcessingInstructionValue(XPathNavigator navigator)
{
value = navigator.Name;
displayValue = navigator.OuterXml;
}
void SetAttributeValue(XPathNavigator navigator)
{
value = navigator.Name;
displayValue = String.Concat("@", value);
}
/// <summary>
/// Takes one of the xml line number so the numbers are now zero
/// based instead of one based.
/// </summary>
/// <remarks>A namespace query (e.g. //namespace::*) will return
/// a line info of -1, -1 for the xml namespace. Which looks like
/// a bug in the XPathDocument class.</remarks>
void SetLineNumbers(IXmlLineInfo lineInfo)
{
if (lineInfo.HasLineInfo() && lineInfo.LineNumber > 0) {
lineNumber = lineInfo.LineNumber - 1;
linePosition = lineInfo.LinePosition - 1;
}
}
}
}

60
src/AddIns/DisplayBindings/XmlEditor/Project/Src/Src/XPathNodeTextMarker.cs

@ -1,60 +0,0 @@ @@ -1,60 +0,0 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
// <version>$Revision: 1965 $</version>
// </file>
using System;
using System.Drawing;
namespace ICSharpCode.XmlEditor
{
/*
/// <summary>
/// A text marker for an XPath query match.
/// </summary>
public class XPathNodeTextMarker : TextMarker
{
public static readonly Color MarkerBackColor = Color.FromArgb(159, 255, 162);
public XPathNodeTextMarker(int offset, XPathNodeMatch node) : base(offset, node.Value.Length, TextMarkerType.SolidBlock, MarkerBackColor)
{
}
/// <summary>
/// Adds markers for each XPathNodeMatch.
/// </summary>
public static void AddMarkers(MarkerStrategy markerStrategy, XPathNodeMatch[] nodes)
{
foreach (XPathNodeMatch node in nodes) {
AddMarker(markerStrategy, node);
}
}
/// <summary>
/// Adds a single marker for the XPathNodeMatch.
/// </summary>
public static void AddMarker(MarkerStrategy markerStrategy, XPathNodeMatch node)
{
if (node.HasLineInfo() && node.Value.Length > 0) {
LineSegment lineSegment = markerStrategy.Document.GetLineSegment(node.LineNumber);
markerStrategy.AddMarker(new XPathNodeTextMarker(lineSegment.Offset + node.LinePosition, node));
}
}
/// <summary>
/// Removes all the XPathNodeMarkers from the marker strategy.
/// </summary>
public static void RemoveMarkers(MarkerStrategy markerStrategy)
{
markerStrategy.RemoveAll(IsXPathNodeTextMarkerMatch);
}
static bool IsXPathNodeTextMarkerMatch(TextMarker marker)
{
return marker is XPathNodeTextMarker;
}
}
*/
}

95
src/AddIns/DisplayBindings/XmlEditor/Project/Src/Src/XmlAttributePropertyDescriptor.cs

@ -1,95 +0,0 @@ @@ -1,95 +0,0 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
// <version>$Revision: 1965 $</version>
// </file>
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Xml;
namespace ICSharpCode.XmlEditor
{
/// <summary>
/// Property descriptor for an XmlAttribute. This is used when displaying
/// an XmlAttribute in the property grid.
/// </summary>
public class XmlAttributePropertyDescriptor : PropertyDescriptor
{
XmlAttribute xmlAttribute;
public XmlAttributePropertyDescriptor(XmlAttribute xmlAttribute)
: base(xmlAttribute.LocalName, new Attribute[0])
{
this.xmlAttribute = xmlAttribute;
}
/// <summary>
/// Gets the property descriptors for the specified attributes.
/// </summary>
public static PropertyDescriptorCollection GetProperties(XmlAttributeCollection xmlAttributes)
{
List<PropertyDescriptor> properties = new List<PropertyDescriptor>();
foreach (XmlAttribute xmlAttribute in xmlAttributes) {
properties.Add(new XmlAttributePropertyDescriptor(xmlAttribute));
}
return new PropertyDescriptorCollection(properties.ToArray());
}
public override Type ComponentType {
get {
return typeof(String);
}
}
public override bool IsReadOnly {
get {
return false;
}
}
/// <summary>
/// Returns the property type in this case a string.
/// </summary>
public override Type PropertyType {
get {
return typeof(String);
}
}
public override bool CanResetValue(object component)
{
return false;
}
/// <summary>
/// Gets the value of the xml attribute.
/// </summary>
public override object GetValue(object component)
{
return xmlAttribute.Value;
}
public override void ResetValue(object component)
{
}
/// <summary>
/// Sets the xml attribute value.
/// </summary>
public override void SetValue(object component, object value)
{
xmlAttribute.Value = (String)value;
}
/// <summary>
/// If the current value has changed from the default value then this
/// method will return true.
/// </summary>
public override bool ShouldSerializeValue(object component)
{
return true;
}
}
}

94
src/AddIns/DisplayBindings/XmlEditor/Project/Src/Src/XmlAttributeTypeDescriptor.cs

@ -1,94 +0,0 @@ @@ -1,94 +0,0 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
// <version>$Revision: 1965 $</version>
// </file>
using System;
using System.ComponentModel;
using System.Xml;
namespace ICSharpCode.XmlEditor
{
/// <summary>
/// Type descriptor that allows us to display properties in the property grid
/// for Xml attributes.
/// </summary>
public class XmlAttributeTypeDescriptor : ICustomTypeDescriptor
{
PropertyDescriptorCollection properties;
public XmlAttributeTypeDescriptor(XmlAttributeCollection xmlAttributes)
{
if (xmlAttributes != null) {
properties = XmlAttributePropertyDescriptor.GetProperties(xmlAttributes);
} else {
properties = new PropertyDescriptorCollection(new XmlAttributePropertyDescriptor[0]);
}
}
public AttributeCollection GetAttributes()
{
return null;
}
public string GetClassName()
{
return null;
}
public string GetComponentName()
{
return null;
}
public TypeConverter GetConverter()
{
return null;
}
public EventDescriptor GetDefaultEvent()
{
return null;
}
public PropertyDescriptor GetDefaultProperty()
{
return null;
}
public object GetEditor(Type editorBaseType)
{
return null;
}
public EventDescriptorCollection GetEvents()
{
return null;
}
public EventDescriptorCollection GetEvents(Attribute[] attributes)
{
return null;
}
public PropertyDescriptorCollection GetProperties()
{
return GetProperties(new Attribute[0]);
}
public PropertyDescriptorCollection GetProperties(Attribute[] attributes)
{
return properties;
}
/// <summary>
/// Returns this class instance.
/// </summary>
public object GetPropertyOwner(PropertyDescriptor pd)
{
return this;
}
}
}

60
src/AddIns/DisplayBindings/XmlEditor/Project/Src/Src/XmlCharacterDataTreeNode.cs

@ -1,60 +0,0 @@ @@ -1,60 +0,0 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
// <version>$Revision: 2128 $</version>
// </file>
using System;
using System.Xml;
using ICSharpCode.SharpDevelop.Gui;
namespace ICSharpCode.XmlEditor
{
/// <summary>
/// Base class for XmlTextTreeNodes and XmlCommentTreeNodes
/// </summary>
public abstract class XmlCharacterDataTreeNode : ExtTreeNode
{
XmlCharacterData characterData;
public XmlCharacterDataTreeNode(XmlCharacterData characterData)
{
this.characterData = characterData;
}
/// <summary>
/// Updates the display text based on changes in the
/// XmlCharacterData's InnerText associated with this node.
/// </summary>
public void Update()
{
Text = GetDisplayText(characterData.InnerText);
}
/// <summary>
/// Gets the text to display for this tree node.
/// </summary>
/// <remarks>If the text is a single line then it is returned, but
/// trimmed. If the text has multiple lines then the first line that
/// is not empty is returned. This line may have "..." appended to indicate
/// there is more text for this node that is not being displayed. The
/// "..." will be appended only if there are multiple lines containing
/// text.</remarks>
static string GetDisplayText(string s)
{
string[] lines = s.Trim().Split('\n');
for (int i = 0; i < lines.Length; ++i) {
string line = lines[i].Trim();
if (line.Length > 0) {
if (lines.Length == 1) {
return line;
} else {
return String.Concat(line, "...");
}
}
}
return String.Empty;
}
}
}

60
src/AddIns/DisplayBindings/XmlEditor/Project/Src/Src/XmlCommentTreeNode.cs

@ -1,60 +0,0 @@ @@ -1,60 +0,0 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
// <version>$Revision: 2164 $</version>
// </file>
using System;
using System.Xml;
using ICSharpCode.SharpDevelop.Gui;
namespace ICSharpCode.XmlEditor
{
/// <summary>
/// Represents an xml comment in the tree.
/// </summary>
public class XmlCommentTreeNode : XmlCharacterDataTreeNode
{
public const string XmlCommentTreeNodeImageKey = "XmlCommentTreeNodeImage";
public const string XmlCommentTreeNodeGhostImageKey = "XmlCommentTreeNodeGhostImage";
XmlComment comment;
public XmlCommentTreeNode(XmlComment comment)
: base(comment)
{
this.comment = comment;
ImageKey = XmlCommentTreeNodeImageKey;
SelectedImageKey = ImageKey;
Update();
}
/// <summary>
/// Gets the XmlComment associated with this tree node.
/// </summary>
public XmlComment XmlComment {
get {
return comment;
}
}
/// <summary>
/// Gets or sets whether to show the ghost image which is
/// displayed when cutting the node.
/// </summary>
public bool ShowGhostImage {
get {
return ImageKey == XmlCommentTreeNodeGhostImageKey;
}
set {
if (value) {
ImageKey = XmlCommentTreeNodeGhostImageKey;
} else {
ImageKey = XmlCommentTreeNodeImageKey;
}
SelectedImageKey = ImageKey;
}
}
}
}

119
src/AddIns/DisplayBindings/XmlEditor/Project/Src/Src/XmlEditorAddInOptions.cs

@ -1,119 +0,0 @@ @@ -1,119 +0,0 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
// <version>$Revision: 1965 $</version>
// </file>
using System;
using System.Diagnostics;
using ICSharpCode.Core;
namespace ICSharpCode.XmlEditor
{
/// <summary>
/// The Xml Editor add-in options.
/// </summary>
public static class XmlEditorAddInOptions
{
public static readonly string OptionsProperty = "XmlEditor.AddIn.Options";
public static readonly string ShowAttributesWhenFoldedPropertyName = "ShowAttributesWhenFolded";
public static readonly string ShowSchemaAnnotationPropertyName = "ShowSchemaAnnotation";
static Properties properties;
static XmlEditorAddInOptions()
{
properties = PropertyService.Get(OptionsProperty, new Properties());
}
static Properties Properties {
get {
Debug.Assert(properties != null);
return properties;
}
}
public static event PropertyChangedEventHandler PropertyChanged {
add { Properties.PropertyChanged += value; }
remove { Properties.PropertyChanged -= value; }
}
#region Properties
/// <summary>
/// Gets an association between a schema and a file extension.
/// </summary>
/// <remarks>
/// <para>The property will be an xml element when the SharpDevelopProperties.xml
/// is read on startup. The property will be a schema association
/// if the user changes the schema associated with the file
/// extension in tools->options.</para>
/// <para>The normal way of doing things is to
/// pass the GetProperty method a default value which auto-magically
/// turns the xml element into a schema association so we would not
/// have to check for both. In this case, however, I do not want
/// a default saved to the SharpDevelopProperties.xml file unless the user
/// makes a change using Tools->Options.</para>
/// <para>If we have a file extension that is currently missing a default
/// schema then if we ship the schema at a later date the association will
/// be updated by the code if the user has not changed the settings themselves.
/// </para>
/// <para>For example, the initial release of the xml editor add-in had
/// no default schema for .xsl files, by default it was associated with
/// no schema and this setting is saved if the user ever viewed the settings
/// in the tools->options dialog. Now, after the initial release the
/// .xsl schema was created and shipped with SharpDevelop, there is
/// no way to associate this schema to .xsl files by default since
/// the property exists in the SharpDevelopProperties.xml file.</para>
/// <para>An alternative way of doing this might be to have the
/// config info in the schema itself, which a special SharpDevelop
/// namespace. I believe this is what Visual Studio does. This
/// way is not as flexible since it requires the user to locate
/// the schema and change the association manually.</para>
/// </remarks>
public static XmlSchemaAssociation GetSchemaAssociation(string extension)
{
extension = extension.ToLower();
string property = Properties.Get("ext" + extension, String.Empty);
XmlSchemaAssociation association = null;
if (property.Length > 0) {
association = XmlSchemaAssociation.ConvertFromString(property);
}
// Use default?
if (association == null) {
association = XmlSchemaAssociation.GetDefaultAssociation(extension);
}
return association;
}
public static void SetSchemaAssociation(XmlSchemaAssociation association)
{
Properties.Set("ext" + association.Extension, association.ConvertToString());
}
public static bool ShowAttributesWhenFolded {
get {
return Properties.Get(ShowAttributesWhenFoldedPropertyName, false);
}
set {
Properties.Set(ShowAttributesWhenFoldedPropertyName, value);
}
}
public static bool ShowSchemaAnnotation {
get {
return Properties.Get(ShowSchemaAnnotationPropertyName, true);
}
set {
Properties.Set(ShowSchemaAnnotationPropertyName, value);
}
}
#endregion
}
}

99
src/AddIns/DisplayBindings/XmlEditor/Project/Src/Src/XmlElementTreeNode.cs

@ -1,99 +0,0 @@ @@ -1,99 +0,0 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
// <version>$Revision: 2164 $</version>
// </file>
using System;
using System.Xml;
using ICSharpCode.SharpDevelop.Gui;
namespace ICSharpCode.XmlEditor
{
/// <summary>
/// Represents an XmlElement in the Xml Tree.
/// </summary>
public class XmlElementTreeNode : ExtTreeNode
{
public const string XmlElementTreeNodeImageKey = "XmlElementTreeNodeImage";
public const string XmlElementTreeNodeGhostImageKey = "XmlElementTreeNodeGhostImage";
XmlElement element;
public XmlElementTreeNode(XmlElement element)
{
this.element = element;
Text = GetDisplayText(element);
Tag = element;
ImageKey = XmlElementTreeNodeImageKey;
if (element.HasChildNodes) {
// Add dummy node so that the tree node can be
// expanded in the tree view.
Nodes.Add(new ExtTreeNode());
}
}
/// <summary>
/// Gets the XmlElement associated with this tree node.
/// </summary>
public XmlElement XmlElement {
get {
return element;
}
}
/// <summary>
/// Gets or sets whether to show the ghost image which is
/// displayed when cutting the node.
/// </summary>
public bool ShowGhostImage {
get {
return ImageKey == XmlElementTreeNodeGhostImageKey;
}
set {
if (value) {
ImageKey = XmlElementTreeNodeGhostImageKey;
} else {
ImageKey = XmlElementTreeNodeImageKey;
}
SelectedImageKey = ImageKey;
}
}
/// <summary>
/// Adds child elements to this tree node.
/// </summary>
protected override void Initialize()
{
Nodes.Clear();
foreach (XmlNode childNode in element.ChildNodes) {
XmlElement childElement = childNode as XmlElement;
XmlText text = childNode as XmlText;
XmlComment comment = childNode as XmlComment;
if (childElement != null) {
XmlElementTreeNode treeNode = new XmlElementTreeNode(childElement);
treeNode.AddTo(this);
} else if (text != null) {
XmlTextTreeNode treeNode = new XmlTextTreeNode(text);
treeNode.AddTo(this);
} else if (comment != null) {
XmlCommentTreeNode treeNode = new XmlCommentTreeNode(comment);
treeNode.AddTo(this);
}
}
}
/// <summary>
/// Gets the tree node's text for the element.
/// </summary>
static string GetDisplayText(XmlElement element)
{
if (element.Prefix.Length > 0) {
return String.Concat(element.Prefix, ":", element.LocalName);
}
return element.LocalName;
}
}
}

157
src/AddIns/DisplayBindings/XmlEditor/Project/Src/Src/XmlSchemaAssociation.cs

@ -1,157 +0,0 @@ @@ -1,157 +0,0 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
// <version>$Revision: 1965 $</version>
// </file>
using System;
namespace ICSharpCode.XmlEditor
{
/// <summary>
/// Represents an association between an xml schema and a file extension.
/// </summary>
public class XmlSchemaAssociation //: IXmlConvertable
{
string namespaceUri = String.Empty;
string extension = String.Empty;
string namespacePrefix = String.Empty;
public XmlSchemaAssociation(string extension)
: this(extension, String.Empty, String.Empty)
{
}
public XmlSchemaAssociation(string extension, string namespaceUri)
: this(extension, namespaceUri, String.Empty)
{
}
public XmlSchemaAssociation(string extension, string namespaceUri, string namespacePrefix)
{
this.extension = extension;
this.namespaceUri = namespaceUri;
this.namespacePrefix = namespacePrefix;
}
public string NamespaceUri {
get {
return namespaceUri;
}
set {
namespaceUri = value;
}
}
/// <summary>
/// Gets or sets the file extension (e.g. '.xml').
/// </summary>
public string Extension {
get {
return extension;
}
set {
extension = value;
}
}
/// <summary>
/// Gets or sets the default namespace prefix that will be added
/// to the xml elements.
/// </summary>
public string NamespacePrefix {
get {
return namespacePrefix;
}
set {
namespacePrefix = value;
}
}
/// <summary>
/// Gets the default schema association for the file extension.
/// </summary>
/// <remarks>
/// These defaults are hard coded.
/// </remarks>
public static XmlSchemaAssociation GetDefaultAssociation(string extension)
{
XmlSchemaAssociation association = null;
switch (extension.ToLowerInvariant()) {
case ".wxs":
association = new XmlSchemaAssociation(extension, @"http://schemas.microsoft.com/wix/2003/01/wi");
break;
case ".config":
association = new XmlSchemaAssociation(extension, @"urn:app-config");
break;
case ".build":
association = new XmlSchemaAssociation(extension, @"http://nant.sf.net/release/0.85/nant.xsd");
break;
case ".addin":
association = new XmlSchemaAssociation(extension, @"http://www.icsharpcode.net/2005/addin");
break;
case ".xsl":
case ".xslt":
association = new XmlSchemaAssociation(extension, @"http://www.w3.org/1999/XSL/Transform", "xsl");
break;
case ".xsd":
association = new XmlSchemaAssociation(extension, @"http://www.w3.org/2001/XMLSchema", "xs");
break;
case ".manifest":
association = new XmlSchemaAssociation(extension, @"urn:schemas-microsoft-com:asm.v1");
break;
case ".xaml":
association = new XmlSchemaAssociation(extension, @"http://schemas.microsoft.com/winfx/avalon/2005");
break;
default:
association = new XmlSchemaAssociation(extension);
break;
}
return association;
}
/// <summary>
/// Two schema associations are considered equal if their file extension,
/// prefix and namespaceUri are the same.
/// </summary>
public override bool Equals(object obj)
{
bool equals = false;
XmlSchemaAssociation rhs = obj as XmlSchemaAssociation;
if (rhs != null) {
if ((this.namespacePrefix == rhs.namespacePrefix) &&
(this.extension == rhs.extension) &&
(this.namespaceUri == rhs.namespaceUri)) {
equals = true;
}
}
return equals;
}
public override int GetHashCode()
{
return (namespaceUri != null ? namespaceUri.GetHashCode() : 0) ^ (extension != null ? extension.GetHashCode() : 0) ^ (namespacePrefix != null ? namespacePrefix.GetHashCode() : 0);
}
/// <summary>
/// Creates an XmlSchemaAssociation from the saved xml.
/// </summary>
public static XmlSchemaAssociation ConvertFromString(string text)
{
string[] parts = text.Split(new char[] {'|'}, 3);
return new XmlSchemaAssociation(parts[0], parts[1], parts[2]);
}
public string ConvertToString()
{
return extension + "|" + namespaceUri + "|" + namespacePrefix;
}
}
}

89
src/AddIns/DisplayBindings/XmlEditor/Project/Src/Src/XmlSchemaAssociationListBoxItem.cs

@ -1,89 +0,0 @@ @@ -1,89 +0,0 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
// <version>$Revision: 1965 $</version>
// </file>
using System;
namespace ICSharpCode.XmlEditor
{
/// <summary>
/// Represents list box item showing the association between an xml schema
/// and a file extension.
/// </summary>
public class XmlSchemaAssociationListBoxItem
{
bool isDirty = false;
string namespaceUri = String.Empty;
string extension = String.Empty;
string namespacePrefix = String.Empty;
public XmlSchemaAssociationListBoxItem(string extension, string namespaceUri, string namespacePrefix)
{
this.extension = extension;
this.namespaceUri = namespaceUri;
this.namespacePrefix = namespacePrefix;
}
/// <summary>
/// Gets or sets whether this association has been changed by the user.
/// </summary>
public bool IsDirty {
get {
return isDirty;
}
set {
isDirty = value;
}
}
public string NamespaceUri {
get {
return namespaceUri;
}
set {
namespaceUri = value;
}
}
/// <summary>
/// Gets or sets the file extension (e.g. '.xml').
/// </summary>
public string Extension {
get {
return extension;
}
set {
extension = value;
}
}
/// <summary>
/// Gets or sets the default namespace prefix that will be added
/// to the xml elements.
/// </summary>
public string NamespacePrefix {
get {
return namespacePrefix;
}
set {
namespacePrefix = value;
}
}
/// <summary>
/// Returns the file extension so this can be sorted in a list box.
/// </summary>
/// <returns></returns>
public override string ToString()
{
return extension;
}
}
}

1352
src/AddIns/DisplayBindings/XmlEditor/Project/Src/Src/XmlSchemaCompletionData.cs

File diff suppressed because one or more lines are too long

294
src/AddIns/DisplayBindings/XmlEditor/Project/Src/Src/XmlSchemaCompletionDataCollection.cs

@ -1,294 +0,0 @@ @@ -1,294 +0,0 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
// <version>$Revision: 1965 $</version>
// </file>
using ICSharpCode.XmlBinding;
using System;
using System.Collections.Generic;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Editor;
namespace ICSharpCode.XmlEditor
{
/// <summary>
/// A collection that stores <see cref='XmlSchemaCompletionData'/> objects.
/// </summary>
[Serializable()]
public class XmlSchemaCompletionDataCollection : System.Collections.CollectionBase {
/// <summary>
/// Initializes a new instance of <see cref='XmlSchemaCompletionDataCollection'/>.
/// </summary>
public XmlSchemaCompletionDataCollection()
{
}
/// <summary>
/// Initializes a new instance of <see cref='XmlSchemaCompletionDataCollection'/> based on another <see cref='XmlSchemaCompletionDataCollection'/>.
/// </summary>
/// <param name='val'>
/// A <see cref='XmlSchemaCompletionDataCollection'/> from which the contents are copied
/// </param>
public XmlSchemaCompletionDataCollection(XmlSchemaCompletionDataCollection val)
{
this.AddRange(val);
}
/// <summary>
/// Initializes a new instance of <see cref='XmlSchemaCompletionDataCollection'/> containing any array of <see cref='XmlSchemaCompletionData'/> objects.
/// </summary>
/// <param name='val'>
/// A array of <see cref='XmlSchemaCompletionData'/> objects with which to intialize the collection
/// </param>
public XmlSchemaCompletionDataCollection(XmlSchemaCompletionData[] val)
{
this.AddRange(val);
}
/// <summary>
/// Represents the entry at the specified index of the <see cref='XmlSchemaCompletionData'/>.
/// </summary>
/// <param name='index'>The zero-based index of the entry to locate in the collection.</param>
/// <value>The entry at the specified index of the collection.</value>
/// <exception cref='ArgumentOutOfRangeException'><paramref name='index'/> is outside the valid range of indexes for the collection.</exception>
public XmlSchemaCompletionData this[int index] {
get {
return ((XmlSchemaCompletionData)(List[index]));
}
set {
List[index] = value;
}
}
public ICompletionItemList GetNamespaceCompletionData()
{
XmlCompletionItemList list = new XmlCompletionItemList();
foreach (XmlSchemaCompletionData schema in this) {
XmlCompletionItem completionData = new XmlCompletionItem(schema.NamespaceUri, XmlCompletionItem.DataType.NamespaceUri);
list.Items.Add(completionData);
}
list.SortItems();
return list;
}
/// <summary>
/// Represents the <see cref='XmlSchemaCompletionData'/> entry with the specified namespace URI.
/// </summary>
/// <param name='namespaceUri'>The schema's namespace URI.</param>
/// <value>The entry with the specified namespace URI.</value>
public XmlSchemaCompletionData this[string namespaceUri] {
get {
return GetItem(namespaceUri);
}
}
/// <summary>
/// Adds a <see cref='XmlSchemaCompletionData'/> with the specified value to the
/// <see cref='XmlSchemaCompletionDataCollection'/>.
/// </summary>
/// <param name='val'>The <see cref='XmlSchemaCompletionData'/> to add.</param>
/// <returns>The index at which the new element was inserted.</returns>
/// <seealso cref='XmlSchemaCompletionDataCollection.AddRange'/>
public int Add(XmlSchemaCompletionData val)
{
return List.Add(val);
}
/// <summary>
/// Copies the elements of an array to the end of the <see cref='XmlSchemaCompletionDataCollection'/>.
/// </summary>
/// <param name='val'>
/// An array of type <see cref='XmlSchemaCompletionData'/> containing the objects to add to the collection.
/// </param>
/// <seealso cref='XmlSchemaCompletionDataCollection.Add'/>
public void AddRange(XmlSchemaCompletionData[] val)
{
for (int i = 0; i < val.Length; i++) {
this.Add(val[i]);
}
}
/// <summary>
/// Adds the contents of another <see cref='XmlSchemaCompletionDataCollection'/> to the end of the collection.
/// </summary>
/// <param name='val'>
/// A <see cref='XmlSchemaCompletionDataCollection'/> containing the objects to add to the collection.
/// </param>
/// <seealso cref='XmlSchemaCompletionDataCollection.Add'/>
public void AddRange(XmlSchemaCompletionDataCollection val)
{
for (int i = 0; i < val.Count; i++)
{
this.Add(val[i]);
}
}
/// <summary>
/// Gets a value indicating whether the
/// <see cref='XmlSchemaCompletionDataCollection'/> contains the specified <see cref='XmlSchemaCompletionData'/>.
/// </summary>
/// <param name='val'>The <see cref='XmlSchemaCompletionData'/> to locate.</param>
/// <returns>
/// <see langword='true'/> if the <see cref='XmlSchemaCompletionData'/> is contained in the collection;
/// otherwise, <see langword='false'/>.
/// </returns>
/// <seealso cref='XmlSchemaCompletionDataCollection.IndexOf'/>
public bool Contains(XmlSchemaCompletionData val)
{
return List.Contains(val);
}
/// <summary>
/// Copies the <see cref='XmlSchemaCompletionDataCollection'/> values to a one-dimensional <see cref='Array'/> instance at the
/// specified index.
/// </summary>
/// <param name='array'>The one-dimensional <see cref='Array'/> that is the destination of the values copied from <see cref='XmlSchemaCompletionDataCollection'/>.</param>
/// <param name='index'>The index in <paramref name='array'/> where copying begins.</param>
/// <exception cref='ArgumentException'>
/// <para><paramref name='array'/> is multidimensional.</para>
/// <para>-or-</para>
/// <para>The number of elements in the <see cref='XmlSchemaCompletionDataCollection'/> is greater than
/// the available space between <paramref name='arrayIndex'/> and the end of
/// <paramref name='array'/>.</para>
/// </exception>
/// <exception cref='ArgumentNullException'><paramref name='array'/> is <see langword='null'/>. </exception>
/// <exception cref='ArgumentOutOfRangeException'><paramref name='arrayIndex'/> is less than <paramref name='array'/>'s lowbound. </exception>
/// <seealso cref='Array'/>
public void CopyTo(XmlSchemaCompletionData[] array, int index)
{
List.CopyTo(array, index);
}
/// <summary>
/// Returns the index of a <see cref='XmlSchemaCompletionData'/> in
/// the <see cref='XmlSchemaCompletionDataCollection'/>.
/// </summary>
/// <param name='val'>The <see cref='XmlSchemaCompletionData'/> to locate.</param>
/// <returns>
/// The index of the <see cref='XmlSchemaCompletionData'/> of <paramref name='val'/> in the
/// <see cref='XmlSchemaCompletionDataCollection'/>, if found; otherwise, -1.
/// </returns>
/// <seealso cref='XmlSchemaCompletionDataCollection.Contains'/>
public int IndexOf(XmlSchemaCompletionData val)
{
return List.IndexOf(val);
}
/// <summary>
/// Inserts a <see cref='XmlSchemaCompletionData'/> into the <see cref='XmlSchemaCompletionDataCollection'/> at the specified index.
/// </summary>
/// <param name='index'>The zero-based index where <paramref name='val'/> should be inserted.</param>
/// <param name='val'>The <see cref='XmlSchemaCompletionData'/> to insert.</param>
/// <seealso cref='XmlSchemaCompletionDataCollection.Add'/>
public void Insert(int index, XmlSchemaCompletionData val)
{
List.Insert(index, val);
}
/// <summary>
/// Returns an enumerator that can iterate through the <see cref='XmlSchemaCompletionDataCollection'/>.
/// </summary>
/// <seealso cref='IEnumerator'/>
public new XmlSchemaCompletionDataEnumerator GetEnumerator()
{
return new XmlSchemaCompletionDataEnumerator(this);
}
/// <summary>
/// Removes a specific <see cref='XmlSchemaCompletionData'/> from the <see cref='XmlSchemaCompletionDataCollection'/>.
/// </summary>
/// <param name='val'>The <see cref='XmlSchemaCompletionData'/> to remove from the <see cref='XmlSchemaCompletionDataCollection'/>.</param>
/// <exception cref='ArgumentException'><paramref name='val'/> is not found in the Collection.</exception>
public void Remove(XmlSchemaCompletionData val)
{
List.Remove(val);
}
/// <summary>
/// Gets the schema completion data with the same filename.
/// </summary>
/// <returns><see langword="null"/> if no matching schema found.</returns>
public XmlSchemaCompletionData GetSchemaFromFileName(string fileName)
{
foreach (XmlSchemaCompletionData schema in this) {
if (FileUtility.IsEqualFileName(schema.FileName, fileName)) {
return schema;
}
}
return null;
}
/// <summary>
/// Enumerator that can iterate through a XmlSchemaCompletionDataCollection.
/// </summary>
/// <seealso cref='IEnumerator'/>
/// <seealso cref='XmlSchemaCompletionDataCollection'/>
/// <seealso cref='XmlSchemaCompletionData'/>
public class XmlSchemaCompletionDataEnumerator : System.Collections.IEnumerator
{
System.Collections.IEnumerator baseEnumerator;
System.Collections.IEnumerable temp;
/// <summary>
/// Initializes a new instance of <see cref='XmlSchemaCompletionDataEnumerator'/>.
/// </summary>
public XmlSchemaCompletionDataEnumerator(XmlSchemaCompletionDataCollection mappings)
{
this.temp = ((System.Collections.IEnumerable)(mappings));
this.baseEnumerator = temp.GetEnumerator();
}
/// <summary>
/// Gets the current <see cref='XmlSchemaCompletionData'/> in the <seealso cref='XmlSchemaCompletionDataCollection'/>.
/// </summary>
public XmlSchemaCompletionData Current {
get {
return ((XmlSchemaCompletionData)(baseEnumerator.Current));
}
}
object System.Collections.IEnumerator.Current {
get {
return baseEnumerator.Current;
}
}
/// <summary>
/// Advances the enumerator to the next <see cref='XmlSchemaCompletionData'/> of the <see cref='XmlSchemaCompletionDataCollection'/>.
/// </summary>
public bool MoveNext()
{
return baseEnumerator.MoveNext();
}
/// <summary>
/// Sets the enumerator to its initial position, which is before the first element in the <see cref='XmlSchemaCompletionDataCollection'/>.
/// </summary>
public void Reset()
{
baseEnumerator.Reset();
}
}
XmlSchemaCompletionData GetItem(string namespaceUri)
{
XmlSchemaCompletionData matchedItem = null;
foreach(XmlSchemaCompletionData item in this)
{
if (item.NamespaceUri == namespaceUri) {
matchedItem = item;
break;
}
}
return matchedItem;
}
}
}

61
src/AddIns/DisplayBindings/XmlEditor/Project/Src/Src/XmlSchemaListBoxItem.cs

@ -1,61 +0,0 @@ @@ -1,61 +0,0 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
// <version>$Revision: 915 $</version>
// </file>
using System;
using System.Windows.Controls;
using System.Windows.Media;
namespace ICSharpCode.XmlEditor
{
/// <summary>
/// A schema item shown in the tools options dialog.
/// </summary>
public class XmlSchemaListBoxItem
{
string namespaceUri = String.Empty;
bool readOnly = false;
/// <summary>
/// Creates a new list box item.
/// </summary>
/// <remarks>
/// A readonly list box item is used for system schemas, those that
/// are installed with SharpDevelop.
/// </remarks>
public XmlSchemaListBoxItem(string namespaceUri, bool readOnly)
{
this.namespaceUri = namespaceUri;
this.readOnly = readOnly;
}
public XmlSchemaListBoxItem(string namespaceUri)
: this(namespaceUri, false)
{
}
public string NamespaceUri {
get {
return namespaceUri;
}
}
public bool ReadOnly {
get {
return readOnly;
}
}
/// <summary>
/// Returns the namespace Uri so the list box item is sorted correctly.
/// </summary>
/// <returns></returns>
public override string ToString()
{
return namespaceUri;
}
}
}

218
src/AddIns/DisplayBindings/XmlEditor/Project/Src/Src/XmlSchemaManager.cs

@ -1,218 +0,0 @@ @@ -1,218 +0,0 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
// <version>$Revision: 1965 $</version>
// </file>
using System;
using System.IO;
using System.Runtime.InteropServices;
using ICSharpCode.Core;
namespace ICSharpCode.XmlEditor
{
/// <summary>
/// Keeps track of all the schemas that the Xml Editor is aware
/// of.
/// </summary>
public class XmlSchemaManager
{
public const string XmlSchemaNamespace = "http://www.w3.org/2001/XMLSchema";
static XmlSchemaCompletionDataCollection schemas = null;
static XmlSchemaManager manager = null;
public static event EventHandler UserSchemaAdded;
public static event EventHandler UserSchemaRemoved;
/// <summary>
/// Determines whether the specified namespace is actually the W3C namespace for
/// XSD files.
/// </summary>
public static bool IsXmlSchemaNamespace(string schemaNamespace)
{
return schemaNamespace == XmlSchemaNamespace;
}
/// <summary>
/// Gets the schemas that SharpDevelop knows about.
/// </summary>
public static XmlSchemaCompletionDataCollection SchemaCompletionDataItems {
get {
if (schemas == null) {
schemas = new XmlSchemaCompletionDataCollection();
manager = new XmlSchemaManager();
ReadSchemas();
}
return schemas;
}
}
/// <summary>
/// Gets the schema completion data that is associated with the
/// specified file extension.
/// </summary>
public static XmlSchemaCompletionData GetSchemaCompletionData(string extension)
{
XmlSchemaCompletionData data = null;
XmlSchemaAssociation association = XmlEditorAddInOptions.GetSchemaAssociation(extension);
if (association != null) {
if (association.NamespaceUri.Length > 0) {
data = SchemaCompletionDataItems[association.NamespaceUri];
}
}
return data;
}
/// <summary>
/// Gets the namespace prefix that is associated with the
/// specified file extension.
/// </summary>
public static string GetNamespacePrefix(string extension)
{
string prefix = String.Empty;
XmlSchemaAssociation association = XmlEditorAddInOptions.GetSchemaAssociation(extension);
if (association != null) {
prefix = association.NamespacePrefix;
}
return prefix;
}
/// <summary>
/// Removes the schema with the specified namespace from the
/// user schemas folder and removes the completion data.
/// </summary>
public static void RemoveUserSchema(string namespaceUri)
{
XmlSchemaCompletionData schemaData = SchemaCompletionDataItems[namespaceUri];
if (schemaData != null) {
if (File.Exists(schemaData.FileName)) {
File.Delete(schemaData.FileName);
}
SchemaCompletionDataItems.Remove(schemaData);
OnUserSchemaRemoved();
}
}
/// <summary>
/// Adds the schema to the user schemas folder and makes the
/// schema available to the xml editor.
/// </summary>
public static void AddUserSchema(XmlSchemaCompletionData schemaData)
{
if (SchemaCompletionDataItems[schemaData.NamespaceUri] == null) {
if (!Directory.Exists(UserSchemaFolder)) {
Directory.CreateDirectory(UserSchemaFolder);
}
string fileName = Path.GetFileName(schemaData.FileName);
string destinationFileName = Path.Combine(UserSchemaFolder, fileName);
File.Copy(schemaData.FileName, destinationFileName);
schemaData.FileName = destinationFileName;
SchemaCompletionDataItems.Add(schemaData);
OnUserSchemaAdded();
} else {
LoggingService.Warn("Trying to add a schema that already exists. Namespace=" + schemaData.NamespaceUri);
}
}
/// <summary>
/// Reads the system and user added schemas.
/// </summary>
static void ReadSchemas()
{
// MSBuild schemas are in framework directory:
ReadSchemas(RuntimeEnvironment.GetRuntimeDirectory(), true);
ReadSchemas(SchemaFolder, true);
ReadSchemas(UserSchemaFolder, false);
}
/// <summary>
/// Reads all .xsd files in the specified folder.
/// </summary>
static void ReadSchemas(string folder, bool readOnly)
{
if (Directory.Exists(folder)) {
foreach (string fileName in Directory.GetFiles(folder, "*.xsd")) {
ReadSchema(fileName, readOnly);
}
}
}
/// <summary>
/// Reads an individual schema and adds it to the collection.
/// </summary>
/// <remarks>
/// If the schema namespace exists in the collection it is not added.
/// </remarks>
static void ReadSchema(string fileName, bool readOnly)
{
try {
string baseUri = XmlSchemaCompletionData.GetUri(fileName);
XmlSchemaCompletionData data = new XmlSchemaCompletionData(baseUri, fileName);
if (data.NamespaceUri != null) {
if (schemas[data.NamespaceUri] == null) {
data.ReadOnly = readOnly;
schemas.Add(data);
} else {
// Namespace already exists.
LoggingService.Warn("Ignoring duplicate schema namespace " + data.NamespaceUri);
}
} else {
// Namespace is null.
LoggingService.Warn("Ignoring schema with no namespace " + data.FileName);
}
} catch (Exception ex) {
LoggingService.Warn("Unable to read schema '" + fileName + "'. ", ex);
}
}
/// <summary>
/// Gets the folder where the schemas for all users on the
/// local machine are stored.
/// </summary>
static string SchemaFolder {
get {
return Path.Combine(PropertyService.DataDirectory, "schemas");
}
}
/// <summary>
/// Gets the folder where schemas are stored for an individual user.
/// </summary>
static string UserSchemaFolder {
get {
return Path.Combine(PropertyService.ConfigDirectory, "schemas");
}
}
/// <summary>
/// Should really pass schema info with the event.
/// </summary>
static void OnUserSchemaAdded()
{
if (UserSchemaAdded != null) {
UserSchemaAdded(manager, new EventArgs());
}
}
/// <summary>
/// Should really pass schema info with the event.
/// </summary>
static void OnUserSchemaRemoved()
{
if (UserSchemaRemoved != null) {
UserSchemaRemoved(manager, new EventArgs());
}
}
}
}

60
src/AddIns/DisplayBindings/XmlEditor/Project/Src/Src/XmlTextTreeNode.cs

@ -1,60 +0,0 @@ @@ -1,60 +0,0 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
// <version>$Revision: 2164 $</version>
// </file>
using System;
using System.Xml;
using ICSharpCode.SharpDevelop.Gui;
namespace ICSharpCode.XmlEditor
{
/// <summary>
/// Represents an XmlText node in the tree.
/// </summary>
public class XmlTextTreeNode : XmlCharacterDataTreeNode
{
public const string XmlTextTreeNodeImageKey = "XmlTextTreeNodeImage";
public const string XmlTextTreeNodeGhostImageKey = "XmlTextTreeNodeGhostImage";
XmlText xmlText;
public XmlTextTreeNode(XmlText xmlText)
: base(xmlText)
{
this.xmlText = xmlText;
ImageKey = XmlTextTreeNodeImageKey;
SelectedImageKey = ImageKey;
Update();
}
/// <summary>
/// Gets the XmlText associated with this tree node.
/// </summary>
public XmlText XmlText {
get {
return xmlText;
}
}
/// <summary>
/// Gets or sets whether to show the ghost image which is
/// displayed when cutting the node.
/// </summary>
public bool ShowGhostImage {
get {
return ImageKey == XmlTextTreeNodeGhostImageKey;
}
set {
if (value) {
ImageKey = XmlTextTreeNodeGhostImageKey;
} else {
ImageKey = XmlTextTreeNodeImageKey;
}
SelectedImageKey = ImageKey;
}
}
}
}

654
src/AddIns/DisplayBindings/XmlEditor/Project/Src/Src/XmlTreeEditor.cs

File diff suppressed because one or more lines are too long

924
src/AddIns/DisplayBindings/XmlEditor/Project/Src/Src/XmlTreeViewContainerControl.cs

File diff suppressed because one or more lines are too long

578
src/AddIns/DisplayBindings/XmlEditor/Project/Src/Src/XmlTreeViewControl.cs

@ -1,578 +0,0 @@ @@ -1,578 +0,0 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
// <version>$Revision: 2741 $</version>
// </file>
using System;
using System.ComponentModel;
using System.Windows.Forms;
using System.Xml;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Gui;
namespace ICSharpCode.XmlEditor
{
/// <summary>
/// Displays a tree of XML elements. This is a separate control so it can
/// be unit tested. It has no SharpDevelop specific parts, for example,
/// the context menus are defined in the XmlTreeViewContainerControl.
/// </summary>
public class XmlTreeViewControl : ExtTreeView
{
const string ViewStatePropertyName = "XmlTreeViewControl.ViewState";
XmlDocument document;
enum InsertionMode {
Before = 0,
After = 1
}
/// <summary>
/// Raised when the delete key is pressed.
/// </summary>
public event EventHandler DeleteKeyPressed;
public XmlTreeViewControl()
{
}
/// <summary>
/// Gets or sets the xml document currently being displayed.
/// </summary>
[Browsable(false)]
public XmlDocument Document {
get {
return document;
}
set {
document = value;
// Update display.
BeginUpdate();
try {
ShowDocument();
} finally {
EndUpdate();
}
}
}
/// <summary>
/// Gets the selected element in the tree.
/// </summary>
public XmlElement SelectedElement {
get {
XmlElementTreeNode xmlElementTreeNode = SelectedElementNode;
if (xmlElementTreeNode != null) {
return xmlElementTreeNode.XmlElement;
}
return null;
}
}
/// <summary>
/// Determines whether an element is selected in the tree.
/// </summary>
public bool IsElementSelected {
get {
return SelectedElement != null;
}
}
/// <summary>
/// Gets the selected text node in the tree.
/// </summary>
public XmlText SelectedTextNode {
get {
XmlTextTreeNode xmlTextTreeNode = SelectedNode as XmlTextTreeNode;
if (xmlTextTreeNode != null) {
return xmlTextTreeNode.XmlText;
}
return null;
}
}
/// <summary>
/// Gets the selected comment node in the tree.
/// </summary>
public XmlComment SelectedComment {
get {
XmlCommentTreeNode commentTreeNode = SelectedNode as XmlCommentTreeNode;
if (commentTreeNode != null) {
return commentTreeNode.XmlComment;
}
return null;
}
}
/// <summary>
/// Determines whether a text node is selected in the tree.
/// </summary>
public bool IsTextNodeSelected {
get {
return SelectedTextNode != null;
}
}
/// <summary>
/// Saves the current state of the tree.
/// </summary>
public void SaveViewState(Properties properties)
{
properties.Set(ViewStatePropertyName, TreeViewHelper.GetViewStateString(this));
}
/// <summary>
/// Restores the node state of the tree.
/// </summary>
public void RestoreViewState(Properties properties)
{
TreeViewHelper.ApplyViewStateString(properties.Get(ViewStatePropertyName, String.Empty), this);
}
/// <summary>
/// Appends a new child element to the currently selected node.
/// </summary>
public void AppendChildElement(XmlElement element)
{
XmlElementTreeNode selectedNode = SelectedElementNode;
if (selectedNode != null) {
XmlElementTreeNode newNode = new XmlElementTreeNode(element);
newNode.AddTo(selectedNode);
selectedNode.Expand();
}
}
/// <summary>
/// Appends a new child text node to the currently selected element.
/// </summary>
public void AppendChildTextNode(XmlText textNode)
{
XmlElementTreeNode selectedNode = SelectedElementNode;
if (selectedNode != null) {
XmlTextTreeNode newNode = new XmlTextTreeNode(textNode);
newNode.AddTo(selectedNode);
selectedNode.Expand();
}
}
/// <summary>
/// Inserts a new element node before the currently selected
/// node.
/// </summary>
public void InsertElementBefore(XmlElement element)
{
InsertElement(element, InsertionMode.Before);
}
/// <summary>
/// Inserts a new element node after the currently selected
/// node.
/// </summary>
public void InsertElementAfter(XmlElement element)
{
InsertElement(element, InsertionMode.After);
}
/// <summary>
/// Removes the specified element from the tree.
/// </summary>
public void RemoveElement(XmlElement element)
{
XmlElementTreeNode node = FindElement(element);
if (node != null) {
node.Remove();
}
}
/// <summary>
/// Removes the specified text node from the tree.
/// </summary>
public void RemoveTextNode(XmlText textNode)
{
XmlTextTreeNode node = FindTextNode(textNode);
if (node != null) {
node.Remove();
}
}
/// <summary>
/// Inserts a text node before the currently selected
/// node.
/// </summary>
public void InsertTextNodeBefore(XmlText textNode)
{
InsertTextNode(textNode, InsertionMode.Before);
}
/// <summary>
/// Inserts a text node after the currently selected
/// node.
/// </summary>
public void InsertTextNodeAfter(XmlText textNode)
{
InsertTextNode(textNode, InsertionMode.After);
}
/// <summary>
/// Updates the corresponding tree node's text based on
/// the textNode's value.
/// </summary>
public void UpdateTextNode(XmlText textNode)
{
XmlTextTreeNode node = FindTextNode(textNode);
if (node != null) {
node.Update();
}
}
/// <summary>
/// Updates the corresponding tree node's text based on
/// the comment's value.
/// </summary>
public void UpdateComment(XmlComment comment)
{
XmlCommentTreeNode node = FindComment(comment);
if (node != null) {
node.Update();
}
}
/// <summary>
/// Appends a new child comment node to the currently selected element.
/// </summary>
public void AppendChildComment(XmlComment comment)
{
XmlElementTreeNode selectedNode = SelectedElementNode;
if (selectedNode != null) {
XmlCommentTreeNode newNode = new XmlCommentTreeNode(comment);
newNode.AddTo(selectedNode);
selectedNode.Expand();
}
}
/// <summary>
/// Removes the specified comment from the tree.
/// </summary>
public void RemoveComment(XmlComment comment)
{
XmlCommentTreeNode node = FindComment(comment);
if (node != null) {
node.Remove();
}
}
/// <summary>
/// Inserts a comment node before the currently selected
/// node.
/// </summary>
public void InsertCommentBefore(XmlComment comment)
{
InsertComment(comment, InsertionMode.Before);
}
/// <summary>
/// Inserts a comment node after the currently selected
/// node.
/// </summary>
public void InsertCommentAfter(XmlComment comment)
{
InsertComment(comment, InsertionMode.After);
}
/// <summary>
/// Updates the image so the corresponding tree node shows that
/// it is in the process of being cut.
/// </summary>
public void ShowCut(XmlNode node)
{
ShowCut(node, true);
}
/// <summary>
/// Updates the image so the corresponding tree node no longer
/// shows it is in the process of being cut.
/// </summary>
public void HideCut(XmlNode node)
{
ShowCut(node, false);
}
/// <summary>
/// If no node is selected after a mouse click then we make
/// sure the AfterSelect event is fired. Standard behaviour is
/// for the AfterSelect event not to be fired when the user
/// deselects all tree nodes.
/// </summary>
protected override void OnMouseDown(MouseEventArgs e)
{
base.OnMouseDown(e);
if (SelectedNode == null) {
this.OnAfterSelect(new TreeViewEventArgs(null, TreeViewAction.ByMouse));
}
}
/// <summary>
/// Raises the DeleteKeyPressed event.
/// </summary>
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
if (keyData == Keys.Delete && DeleteKeyPressed != null) {
DeleteKeyPressed(this, new EventArgs());
}
return base.ProcessCmdKey(ref msg, keyData);
}
/// <summary>
/// Displays the document in the xml tree.
/// </summary>
void ShowDocument()
{
Nodes.Clear();
if (document != null) {
foreach (XmlNode node in document.ChildNodes) {
switch (node.NodeType) {
case XmlNodeType.Element:
XmlElementTreeNode elementNode = new XmlElementTreeNode((XmlElement)node);
elementNode.AddTo(this);
break;
case XmlNodeType.Comment:
XmlCommentTreeNode commentNode = new XmlCommentTreeNode((XmlComment)node);
commentNode.AddTo(this);
break;
}
}
}
}
/// <summary>
/// Returns the selected xml element tree node.
/// </summary>
XmlElementTreeNode SelectedElementNode {
get {
return SelectedNode as XmlElementTreeNode;
}
}
/// <summary>
/// Inserts a new element node either before or after the
/// currently selected element node.
/// </summary>
void InsertElement(XmlElement element, InsertionMode insertionMode)
{
ExtTreeNode selectedNode = (ExtTreeNode)SelectedNode;
if (selectedNode != null) {
XmlElementTreeNode parentNode = (XmlElementTreeNode)selectedNode.Parent;
XmlElementTreeNode newNode = new XmlElementTreeNode(element);
int index = parentNode.Nodes.IndexOf(selectedNode);
if (insertionMode == InsertionMode.After) {
index++;
}
newNode.Insert(index, parentNode);
}
}
/// <summary>
/// Inserts a new text node either before or after the
/// currently selected node.
/// </summary>
void InsertTextNode(XmlText textNode, InsertionMode insertionMode)
{
ExtTreeNode selectedNode = (ExtTreeNode)SelectedNode;
if (selectedNode != null) {
XmlElementTreeNode parentNode = (XmlElementTreeNode)selectedNode.Parent;
XmlTextTreeNode newNode = new XmlTextTreeNode(textNode);
int index = parentNode.Nodes.IndexOf(selectedNode);
if (insertionMode == InsertionMode.After) {
index++;
}
newNode.Insert(index, parentNode);
}
}
/// <summary>
/// Inserts a new comment node either before or after the
/// currently selected node.
/// </summary>
void InsertComment(XmlComment comment, InsertionMode insertionMode)
{
ExtTreeNode selectedNode = (ExtTreeNode)SelectedNode;
if (selectedNode != null) {
ExtTreeNode parentNode = (ExtTreeNode)selectedNode.Parent;
XmlCommentTreeNode newNode = new XmlCommentTreeNode(comment);
int index = 0;
if (parentNode != null) {
index = parentNode.Nodes.IndexOf(selectedNode);
} else {
index = Nodes.IndexOf(selectedNode);
}
if (insertionMode == InsertionMode.After) {
index++;
}
if (parentNode != null) {
newNode.Insert(index, parentNode);
} else {
newNode.Insert(index, this);
}
}
}
/// <summary>
/// Looks at all the nodes in the tree view and returns the
/// tree node that represents the specified element.
/// </summary>
XmlElementTreeNode FindElement(XmlElement element, TreeNodeCollection nodes)
{
foreach (ExtTreeNode node in nodes) {
XmlElementTreeNode elementTreeNode = node as XmlElementTreeNode;
if (elementTreeNode != null) {
if (elementTreeNode.XmlElement == element) {
return elementTreeNode;
}
// Look for a match in the element's child nodes.
XmlElementTreeNode childElementTreeNode = FindElement(element, elementTreeNode.Nodes);
if (childElementTreeNode != null) {
return childElementTreeNode;
}
}
}
return null;
}
/// <summary>
/// Finds the corresponding XmlElementTreeNode.
/// </summary>
XmlElementTreeNode FindElement(XmlElement element)
{
XmlElementTreeNode selectedElementTreeNode = SelectedNode as XmlElementTreeNode;
if (selectedElementTreeNode != null && selectedElementTreeNode.XmlElement == element) {
return selectedElementTreeNode;
} else {
return FindElement(element, Nodes);
}
}
/// <summary>
/// Looks at all the nodes in the tree view and returns the
/// tree node that represents the specified text node.
/// </summary>
XmlTextTreeNode FindTextNode(XmlText textNode, TreeNodeCollection nodes)
{
foreach (ExtTreeNode node in nodes) {
XmlTextTreeNode textTreeNode = node as XmlTextTreeNode;
if (textTreeNode != null) {
if (textTreeNode.XmlText == textNode) {
return textTreeNode;
}
} else {
// Look for a match in the node's child nodes.
XmlTextTreeNode childTextTreeNode = FindTextNode(textNode, node.Nodes);
if (childTextTreeNode != null) {
return childTextTreeNode;
}
}
}
return null;
}
/// <summary>
/// Finds the specified text node in the tree.
/// </summary>
XmlTextTreeNode FindTextNode(XmlText textNode)
{
XmlTextTreeNode selectedTextTreeNode = SelectedNode as XmlTextTreeNode;
if (selectedTextTreeNode != null && selectedTextTreeNode.XmlText == textNode) {
return selectedTextTreeNode;
} else {
return FindTextNode(textNode, Nodes);
}
}
/// <summary>
/// Looks at all the nodes in the tree view and returns the
/// tree node that represents the specified comment node.
/// </summary>
XmlCommentTreeNode FindComment(XmlComment comment, TreeNodeCollection nodes)
{
foreach (ExtTreeNode node in nodes) {
XmlCommentTreeNode commentTreeNode = node as XmlCommentTreeNode;
if (commentTreeNode != null) {
if (commentTreeNode.XmlComment == comment) {
return commentTreeNode;
}
} else {
// Look for a match in the node's child nodes.
XmlCommentTreeNode childCommentTreeNode = FindComment(comment, node.Nodes);
if (childCommentTreeNode != null) {
return childCommentTreeNode;
}
}
}
return null;
}
/// <summary>
/// Locates the specified comment in the tree.
/// </summary>
XmlCommentTreeNode FindComment(XmlComment comment)
{
XmlCommentTreeNode selectedCommentTreeNode = SelectedNode as XmlCommentTreeNode;
if (selectedCommentTreeNode != null && selectedCommentTreeNode.XmlComment == comment) {
return selectedCommentTreeNode;
} else {
return FindComment(comment, Nodes);
}
}
/// <summary>
/// Shows the corresponding tree node with the ghosted image
/// that indicates it is being cut.
/// </summary>
void ShowCutElement(XmlElement element, bool showGhostImage)
{
XmlElementTreeNode node = FindElement(element);
node.ShowGhostImage = showGhostImage;
}
/// <summary>
/// Shows the corresponding tree node with the ghosted image
/// that indicates it is being cut.
/// </summary>
void ShowCutTextNode(XmlText textNode, bool showGhostImage)
{
XmlTextTreeNode node = FindTextNode(textNode);
node.ShowGhostImage = showGhostImage;
}
/// <summary>
/// Shows the corresponding tree node with the ghosted image
/// that indicates it is being cut.
/// </summary>
void ShowCutComment(XmlComment comment, bool showGhostImage)
{
XmlCommentTreeNode node = FindComment(comment);
node.ShowGhostImage = showGhostImage;
}
/// <summary>
/// Shows the cut node with a ghost image.
/// </summary>
/// <param name="showGhostImage">True if the node should be
/// shown with the ghost image.</param>
void ShowCut(XmlNode node, bool showGhostImage)
{
if (node is XmlElement) {
ShowCutElement((XmlElement)node, showGhostImage);
} else if (node is XmlText) {
ShowCutTextNode((XmlText)node, showGhostImage);
} else if (node is XmlComment) {
ShowCutComment((XmlComment)node, showGhostImage);
}
}
}
}

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

@ -42,51 +42,12 @@ namespace ICSharpCode.XmlEditor @@ -42,51 +42,12 @@ namespace ICSharpCode.XmlEditor
defaultSchemaCompletionData,
defaultNamespacePrefix);
switch (ch) {
case '=':
// Namespace completion.
if (XmlParser.IsNamespaceDeclaration(text, text.Length)) {
editor.ShowCompletionWindow(XmlSchemaManager.SchemaCompletionDataItems.GetNamespaceCompletionData());
return CodeCompletionKeyPressResult.Completed;
}
break;
case '<':
// Child element completion.
XmlElementPath parentPath = XmlParser.GetParentElementPath(text);
if (parentPath.Elements.Count > 0) {
editor.ShowCompletionWindow(provider.GetChildElementCompletionData(parentPath));
return CodeCompletionKeyPressResult.Completed;
} else if (defaultSchemaCompletionData != null) {
editor.ShowCompletionWindow(defaultSchemaCompletionData.GetElementCompletionData(defaultNamespacePrefix));
return CodeCompletionKeyPressResult.Completed;
}
break;
case ' ':
// Attribute completion.
if (!XmlParser.IsInsideAttributeValue(text, text.Length)) {
XmlElementPath path = XmlParser.GetActiveElementStartPath(text, text.Length);
if (path.Elements.Count > 0) {
editor.ShowCompletionWindow(provider.GetAttributeCompletionData(path));
return CodeCompletionKeyPressResult.Completed;
}
}
break;
default:
// Attribute value completion.
if (XmlParser.IsAttributeValueChar(ch)) {
string attributeName = XmlParser.GetAttributeName(text, text.Length);
if (attributeName.Length > 0) {
XmlElementPath elementPath = XmlParser.GetActiveElementStartPath(text, text.Length);
if (elementPath.Elements.Count > 0) {
editor.ShowCompletionWindow(provider.GetAttributeValueCompletionData(elementPath, attributeName));
return CodeCompletionKeyPressResult.CompletedIncludeKeyInCompletion;
}
}
}
break;
}
editor.ShowCompletionWindow(provider.GenerateCompletionData(text, ch));
return CodeCompletionKeyPressResult.None;
if (ch == '<' || ch == ' ' || ch == '=')
return CodeCompletionKeyPressResult.Completed;
else
return CodeCompletionKeyPressResult.CompletedIncludeKeyInCompletion;
}
public bool CtrlSpace(ITextEditor editor)

49
src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlCompletionDataProvider.cs

@ -30,6 +30,53 @@ namespace ICSharpCode.XmlEditor @@ -30,6 +30,53 @@ namespace ICSharpCode.XmlEditor
this.defaultNamespacePrefix = defaultNamespacePrefix;
}
public ICompletionItemList GenerateCompletionData(string fileContent, char charTyped)
{
string text = String.Concat(fileContent, charTyped);
switch (charTyped) {
case '=':
// Namespace intellisense.
if (XmlParser.IsNamespaceDeclaration(text, text.Length)) {
return schemaCompletionDataItems.GetNamespaceCompletionData();
}
break;
case '<':
// Child element intellisense.
XmlElementPath parentPath = XmlParser.GetParentElementPath(text);
if (parentPath.Elements.Count > 0) {
return GetChildElementCompletionData(parentPath);
} else if (defaultSchemaCompletionData != null) {
return defaultSchemaCompletionData.GetElementCompletionData(defaultNamespacePrefix);
}
break;
case ' ':
// Attribute intellisense.
if (!XmlParser.IsInsideAttributeValue(text, text.Length)) {
XmlElementPath path = XmlParser.GetActiveElementStartPath(text, text.Length);
if (path.Elements.Count > 0) {
return GetAttributeCompletionData(path);
}
}
break;
default:
// Attribute value intellisense.
if (XmlParser.IsAttributeValueChar(charTyped)) {
string attributeName = XmlParser.GetAttributeName(text, text.Length);
if (attributeName.Length > 0) {
XmlElementPath elementPath = XmlParser.GetActiveElementStartPath(text, text.Length);
if (elementPath.Elements.Count > 0) {
return GetAttributeValueCompletionData(elementPath, attributeName);
}
}
}
break;
}
return null;
}
/// <summary>
/// Finds the schema given the xml element path.
/// </summary>
@ -65,7 +112,7 @@ namespace ICSharpCode.XmlEditor @@ -65,7 +112,7 @@ namespace ICSharpCode.XmlEditor
}
/// <summary>
/// Gets the schema completion data that was created from the specified
/// Gets the schema completion data that was created from the specified
/// schema filename.
/// </summary>
public XmlSchemaCompletionData FindSchemaFromFileName(string fileName)

10
src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlTreeView.cs

@ -131,21 +131,21 @@ namespace ICSharpCode.XmlEditor @@ -131,21 +131,21 @@ namespace ICSharpCode.XmlEditor
protected override void LoadFromPrimary()
{
ITextEditorProvider provider = this.PrimaryViewContent as ITextEditorProvider;
treeViewContainer.LoadXml(provider.TextEditor.Document.Text, XmlView.GetProvider(Path.GetExtension(provider.TextEditor.FileName)));
IFileDocumentProvider provider = this.PrimaryViewContent as IFileDocumentProvider;
treeViewContainer.LoadXml(provider.GetDocumentForFile(this.PrimaryFile).Text, XmlView.GetProvider(Path.GetExtension(this.PrimaryFileName)));
}
protected override void SaveToPrimary()
{
// Do not modify text in the primary view if the data is not well-formed XML
if (!treeViewContainer.IsErrorMessageTextBoxVisible) {
ITextEditorProvider provider = this.PrimaryViewContent as ITextEditorProvider;
if (!treeViewContainer.IsErrorMessageTextBoxVisible && treeViewContainer.IsDirty) {
IFileDocumentProvider provider = this.PrimaryViewContent as IFileDocumentProvider;
StringWriter str = new StringWriter(CultureInfo.InvariantCulture);
XmlTextWriter writer = new XmlTextWriter(str);
writer.Formatting = Formatting.Indented;
treeViewContainer.Document.WriteTo(writer);
provider.TextEditor.Document.Text = str.ToString();
provider.GetDocumentForFile(this.PrimaryFile).Text = str.ToString();
}
}

2
src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlTreeViewContainerControl.cs

@ -30,7 +30,7 @@ namespace ICSharpCode.XmlEditor @@ -30,7 +30,7 @@ namespace ICSharpCode.XmlEditor
bool attributesGridVisible = true;
[Flags]
enum XmlTreeViewContainerControlStates {
internal enum XmlTreeViewContainerControlStates {
None = 0,
ElementSelected = 1,
RootElementSelected = 2,

21
src/AddIns/DisplayBindings/XmlEditor/Test/Completion/FirstCompletionListItemSelectedTestFixture.cs

@ -5,7 +5,9 @@ @@ -5,7 +5,9 @@
// <version>$Revision: 3490 $</version>
// </file>
using ICSharpCode.SharpDevelop.Editor;
using System;
using System.Linq;
using System.Collections.Generic;
using System.Windows.Forms;
using ICSharpCode.TextEditor;
@ -27,8 +29,8 @@ namespace XmlEditor.Tests.Completion @@ -27,8 +29,8 @@ namespace XmlEditor.Tests.Completion
public class FirstCompletionListItemSelectedTestFixture
{
XmlCompletionDataProvider provider;
ICompletionData selectedCompletionData;
ICompletionData[] completionDataItems;
ICompletionItem selectedCompletionData;
ICompletionItemList completionDataItems;
[TestFixtureSetUp]
public void SetUpFixture()
@ -38,12 +40,8 @@ namespace XmlEditor.Tests.Completion @@ -38,12 +40,8 @@ namespace XmlEditor.Tests.Completion
schemas.Add(schema);
provider = new XmlCompletionDataProvider(schemas, schema, String.Empty);
TextEditorControl textEditor = new TextEditorControl();
completionDataItems = provider.GenerateCompletionData(@"C:\Test.xml", textEditor.ActiveTextAreaControl.TextArea, '<');
using (CodeCompletionWindow completionWindow = CodeCompletionWindow.ShowCompletionWindow(null, textEditor, @"C:\Test.xml", provider, '<')) {
CodeCompletionListView listView = (CodeCompletionListView)completionWindow.Controls[0];
selectedCompletionData = listView.SelectedCompletionData;
completionWindow.Close();
}
completionDataItems = provider.GenerateCompletionData("", '<');
selectedCompletionData = completionDataItems.SuggestedItem;
}
/// <summary>
@ -54,7 +52,7 @@ namespace XmlEditor.Tests.Completion @@ -54,7 +52,7 @@ namespace XmlEditor.Tests.Completion
public void HasGeneratedCompletionDataItems()
{
Assert.IsNotNull(completionDataItems);
Assert.IsTrue(completionDataItems.Length > 0);
Assert.IsTrue(completionDataItems.Items.ToArray().Length > 0);
}
/// <summary>
@ -64,7 +62,7 @@ namespace XmlEditor.Tests.Completion @@ -64,7 +62,7 @@ namespace XmlEditor.Tests.Completion
[Test]
public void DefaultIndex()
{
Assert.AreEqual(0, provider.DefaultIndex);
Assert.True(completionDataItems.Items.FirstOrDefault() == selectedCompletionData);
}
[Test]
@ -81,8 +79,7 @@ namespace XmlEditor.Tests.Completion @@ -81,8 +79,7 @@ namespace XmlEditor.Tests.Completion
[Test]
public void SelectedCompletionDataMatches()
{
List<ICompletionData> items = new List<ICompletionData>(completionDataItems);
items.Sort(DefaultCompletionData.Compare);
List<ICompletionItem> items = completionDataItems.Items.OrderBy(item => item.Text).ToList();
Assert.AreEqual(items[0].Text, selectedCompletionData.Text);
}
}

12
src/AddIns/DisplayBindings/XmlEditor/Test/Completion/ProcessKeyTests.cs

@ -5,9 +5,9 @@ @@ -5,9 +5,9 @@
// <version>$Revision: 2760 $</version>
// </file>
using ICSharpCode.SharpDevelop.Editor;
using System;
using System.Windows.Forms;
using ICSharpCode.TextEditor.Gui.CompletionWindow;
using ICSharpCode.XmlEditor;
using NUnit.Framework;
@ -20,13 +20,13 @@ namespace XmlEditor.Tests.Completion @@ -20,13 +20,13 @@ namespace XmlEditor.Tests.Completion
[TestFixture]
public class ProcessKeyTests
{
XmlCompletionDataProvider provider;
ICompletionItemList list;
[SetUp]
public void Init()
{
XmlSchemaCompletionDataCollection schemas = new XmlSchemaCompletionDataCollection();
provider = new XmlCompletionDataProvider(schemas, null, null);
list = new XmlCompletionDataProvider(schemas, null, null).GenerateCompletionData("", '<');
}
/// <summary>
@ -35,19 +35,19 @@ namespace XmlEditor.Tests.Completion @@ -35,19 +35,19 @@ namespace XmlEditor.Tests.Completion
[Test]
public void SpaceChar()
{
Assert.AreEqual(CompletionDataProviderKeyResult.NormalKey, provider.ProcessKey(' '));
Assert.AreEqual(CompletionDataProviderKeyResult.NormalKey, list.ProcessInput(' '));
}
[Test]
public void TabChar()
{
Assert.AreEqual(CompletionDataProviderKeyResult.InsertionKey, provider.ProcessKey('\t'));
Assert.AreEqual(CompletionDataProviderKeyResult.InsertionKey, list.ProcessInput('\t'));
}
[Test]
public void ReturnChar()
{
Assert.AreEqual(CompletionDataProviderKeyResult.InsertionKey, provider.ProcessKey((char)Keys.Return));
Assert.AreEqual(CompletionDataProviderKeyResult.InsertionKey, list.ProcessInput((char)Keys.Return));
}
}
}

11
src/AddIns/DisplayBindings/XmlEditor/Test/Schema/AbstractElementTestFixture.cs

@ -5,11 +5,12 @@ @@ -5,11 +5,12 @@
// <version>$Revision: 915 $</version>
// </file>
using ICSharpCode.SharpDevelop.Editor;
using System;
using System.IO;
using ICSharpCode.TextEditor.Gui.CompletionWindow;
using ICSharpCode.XmlEditor;
using NUnit.Framework;
using System;
using System.IO;
namespace XmlEditor.Tests.Schema
{
@ -19,9 +20,9 @@ namespace XmlEditor.Tests.Schema @@ -19,9 +20,9 @@ namespace XmlEditor.Tests.Schema
[TestFixture]
public class AbstractElementTestFixture : SchemaTestFixtureBase
{
ICompletionData[] itemsElementChildren;
ICompletionData[] fileElementAttributes;
ICompletionData[] fileElementChildren;
ICompletionItem[] itemsElementChildren;
ICompletionItem[] fileElementAttributes;
ICompletionItem[] fileElementChildren;
public override void FixtureInit()
{

11
src/AddIns/DisplayBindings/XmlEditor/Test/Schema/AllElementTestFixture.cs

@ -5,11 +5,12 @@ @@ -5,11 +5,12 @@
// <version>$Revision: 1388 $</version>
// </file>
using ICSharpCode.SharpDevelop.Editor;
using System;
using System.IO;
using ICSharpCode.TextEditor.Gui.CompletionWindow;
using ICSharpCode.XmlEditor;
using NUnit.Framework;
using System;
using System.IO;
namespace XmlEditor.Tests.Schema
{
@ -20,9 +21,9 @@ namespace XmlEditor.Tests.Schema @@ -20,9 +21,9 @@ namespace XmlEditor.Tests.Schema
[TestFixture]
public class AllElementTestFixture : SchemaTestFixtureBase
{
ICompletionData[] personElementChildren;
ICompletionData[] firstNameAttributes;
ICompletionData[] firstNameElementChildren;
ICompletionItem[] personElementChildren;
ICompletionItem[] firstNameAttributes;
ICompletionItem[] firstNameElementChildren;
public override void FixtureInit()
{

11
src/AddIns/DisplayBindings/XmlEditor/Test/Schema/AttributeAnnotationTestFixture.cs

@ -5,12 +5,13 @@ @@ -5,12 +5,13 @@
// <version>$Revision: 915 $</version>
// </file>
using ICSharpCode.TextEditor.Gui.CompletionWindow;
using ICSharpCode.XmlEditor;
using NUnit.Framework;
using ICSharpCode.SharpDevelop.Editor;
using System;
using System.IO;
using System.Xml;
using ICSharpCode.TextEditor.Gui.CompletionWindow;
using ICSharpCode.XmlEditor;
using NUnit.Framework;
namespace XmlEditor.Tests.Schema
{
@ -21,8 +22,8 @@ namespace XmlEditor.Tests.Schema @@ -21,8 +22,8 @@ namespace XmlEditor.Tests.Schema
[TestFixture]
public class AttributeAnnotationTestFixture : SchemaTestFixtureBase
{
ICompletionData[] fooAttributeCompletionData;
ICompletionData[] barAttributeCompletionData;
ICompletionItem[] fooAttributeCompletionData;
ICompletionItem[] barAttributeCompletionData;
public override void FixtureInit()
{

7
src/AddIns/DisplayBindings/XmlEditor/Test/Schema/AttributeGroupRefTestFixture.cs

@ -5,11 +5,12 @@ @@ -5,11 +5,12 @@
// <version>$Revision: 915 $</version>
// </file>
using ICSharpCode.SharpDevelop.Editor;
using System;
using System.IO;
using ICSharpCode.TextEditor.Gui.CompletionWindow;
using ICSharpCode.XmlEditor;
using NUnit.Framework;
using System;
using System.IO;
namespace XmlEditor.Tests.Schema
{
@ -19,7 +20,7 @@ namespace XmlEditor.Tests.Schema @@ -19,7 +20,7 @@ namespace XmlEditor.Tests.Schema
[TestFixture]
public class AttributeGroupRefTestFixture : SchemaTestFixtureBase
{
ICompletionData[] attributeCompletionData;
ICompletionItem[] attributeCompletionData;
public override void FixtureInit()
{

7
src/AddIns/DisplayBindings/XmlEditor/Test/Schema/AttributeRefTestFixture.cs

@ -5,11 +5,12 @@ @@ -5,11 +5,12 @@
// <version>$Revision: 915 $</version>
// </file>
using ICSharpCode.SharpDevelop.Editor;
using System;
using System.IO;
using ICSharpCode.TextEditor.Gui.CompletionWindow;
using ICSharpCode.XmlEditor;
using NUnit.Framework;
using System;
using System.IO;
namespace XmlEditor.Tests.Schema
{
@ -19,7 +20,7 @@ namespace XmlEditor.Tests.Schema @@ -19,7 +20,7 @@ namespace XmlEditor.Tests.Schema
[TestFixture]
public class AttributeRefTestFixture : SchemaTestFixtureBase
{
ICompletionData[] attributes;
ICompletionItem[] attributes;
public override void FixtureInit()
{

9
src/AddIns/DisplayBindings/XmlEditor/Test/Schema/AttributeValueAnnotationTestFixture.cs

@ -5,12 +5,13 @@ @@ -5,12 +5,13 @@
// <version>$Revision: 915 $</version>
// </file>
using ICSharpCode.TextEditor.Gui.CompletionWindow;
using ICSharpCode.XmlEditor;
using NUnit.Framework;
using ICSharpCode.SharpDevelop.Editor;
using System;
using System.IO;
using System.Xml;
using ICSharpCode.TextEditor.Gui.CompletionWindow;
using ICSharpCode.XmlEditor;
using NUnit.Framework;
namespace XmlEditor.Tests.Schema
{
@ -21,7 +22,7 @@ namespace XmlEditor.Tests.Schema @@ -21,7 +22,7 @@ namespace XmlEditor.Tests.Schema
[TestFixture]
public class AttributeValueAnnotationTestFixture : SchemaTestFixtureBase
{
ICompletionData[] barAttributeValuesCompletionData;
ICompletionItem[] barAttributeValuesCompletionData;
public override void FixtureInit()
{

7
src/AddIns/DisplayBindings/XmlEditor/Test/Schema/ChildElementAttributesTestFixture.cs

@ -5,11 +5,12 @@ @@ -5,11 +5,12 @@
// <version>$Revision: 915 $</version>
// </file>
using ICSharpCode.SharpDevelop.Editor;
using System;
using System.IO;
using ICSharpCode.TextEditor.Gui.CompletionWindow;
using ICSharpCode.XmlEditor;
using NUnit.Framework;
using System;
using System.IO;
namespace XmlEditor.Tests.Schema
{
@ -19,7 +20,7 @@ namespace XmlEditor.Tests.Schema @@ -19,7 +20,7 @@ namespace XmlEditor.Tests.Schema
[TestFixture]
public class ChildElementAttributesTestFixture : SchemaTestFixtureBase
{
ICompletionData[] attributes;
ICompletionItem[] attributes;
public override void FixtureInit()
{

7
src/AddIns/DisplayBindings/XmlEditor/Test/Schema/ChoiceTestFixture.cs

@ -5,11 +5,12 @@ @@ -5,11 +5,12 @@
// <version>$Revision: 915 $</version>
// </file>
using ICSharpCode.SharpDevelop.Editor;
using System;
using System.IO;
using ICSharpCode.TextEditor.Gui.CompletionWindow;
using ICSharpCode.XmlEditor;
using NUnit.Framework;
using System;
using System.IO;
namespace XmlEditor.Tests.Schema
{
@ -20,7 +21,7 @@ namespace XmlEditor.Tests.Schema @@ -20,7 +21,7 @@ namespace XmlEditor.Tests.Schema
[TestFixture]
public class ChoiceTestFixture : SchemaTestFixtureBase
{
ICompletionData[] noteChildElements;
ICompletionItem[] noteChildElements;
public override void FixtureInit()
{

9
src/AddIns/DisplayBindings/XmlEditor/Test/Schema/ComplexContentExtensionTestFixture.cs

@ -5,11 +5,12 @@ @@ -5,11 +5,12 @@
// <version>$Revision: 915 $</version>
// </file>
using ICSharpCode.SharpDevelop.Editor;
using System;
using System.IO;
using ICSharpCode.TextEditor.Gui.CompletionWindow;
using ICSharpCode.XmlEditor;
using NUnit.Framework;
using System;
using System.IO;
namespace XmlEditor.Tests.Schema
{
@ -19,8 +20,8 @@ namespace XmlEditor.Tests.Schema @@ -19,8 +20,8 @@ namespace XmlEditor.Tests.Schema
[TestFixture]
public class ComplexContentExtensionTestFixture : SchemaTestFixtureBase
{
ICompletionData[] bodyChildElements;
ICompletionData[] bodyAttributes;
ICompletionItem[] bodyChildElements;
ICompletionItem[] bodyAttributes;
public override void FixtureInit()
{

7
src/AddIns/DisplayBindings/XmlEditor/Test/Schema/DuplicateElementTestFixture.cs

@ -5,11 +5,12 @@ @@ -5,11 +5,12 @@
// <version>$Revision: 915 $</version>
// </file>
using ICSharpCode.SharpDevelop.Editor;
using System;
using System.IO;
using ICSharpCode.TextEditor.Gui.CompletionWindow;
using ICSharpCode.XmlEditor;
using NUnit.Framework;
using System;
using System.IO;
namespace XmlEditor.Tests.Schema
{
@ -19,7 +20,7 @@ namespace XmlEditor.Tests.Schema @@ -19,7 +20,7 @@ namespace XmlEditor.Tests.Schema
[TestFixture]
public class DuplicateElementTestFixture : SchemaTestFixtureBase
{
ICompletionData[] htmlChildElements;
ICompletionItem[] htmlChildElements;
public override void FixtureInit()
{

14
src/AddIns/DisplayBindings/XmlEditor/Test/Schema/ElementAnnotationTestFixture.cs

@ -5,12 +5,14 @@ @@ -5,12 +5,14 @@
// <version>$Revision: 915 $</version>
// </file>
using ICSharpCode.TextEditor.Gui.CompletionWindow;
using ICSharpCode.XmlEditor;
using NUnit.Framework;
using ICSharpCode.SharpDevelop.Editor;
using System;
using System.Linq;
using System.IO;
using System.Xml;
using ICSharpCode.TextEditor.Gui.CompletionWindow;
using ICSharpCode.XmlEditor;
using NUnit.Framework;
namespace XmlEditor.Tests.Schema
{
@ -21,8 +23,8 @@ namespace XmlEditor.Tests.Schema @@ -21,8 +23,8 @@ namespace XmlEditor.Tests.Schema
[TestFixture]
public class ElementAnnotationTestFixture : SchemaTestFixtureBase
{
ICompletionData[] fooChildElementCompletionData;
ICompletionData[] rootElementCompletionData;
ICompletionItem[] fooChildElementCompletionData;
ICompletionItemList rootElementCompletionData;
public override void FixtureInit()
{
@ -37,7 +39,7 @@ namespace XmlEditor.Tests.Schema @@ -37,7 +39,7 @@ namespace XmlEditor.Tests.Schema
[Test]
public void RootElementDocumentation()
{
Assert.AreEqual("Documentation for foo element.", rootElementCompletionData[0].Description);
Assert.AreEqual("Documentation for foo element.", rootElementCompletionData.Items.ToArray()[0].Description);
}
[Test]

9
src/AddIns/DisplayBindings/XmlEditor/Test/Schema/ElementRefAnnotationTestFixture.cs

@ -5,12 +5,13 @@ @@ -5,12 +5,13 @@
// <version>$Revision: 915 $</version>
// </file>
using ICSharpCode.TextEditor.Gui.CompletionWindow;
using ICSharpCode.XmlEditor;
using NUnit.Framework;
using ICSharpCode.SharpDevelop.Editor;
using System;
using System.IO;
using System.Xml;
using ICSharpCode.TextEditor.Gui.CompletionWindow;
using ICSharpCode.XmlEditor;
using NUnit.Framework;
namespace XmlEditor.Tests.Schema
{
@ -21,7 +22,7 @@ namespace XmlEditor.Tests.Schema @@ -21,7 +22,7 @@ namespace XmlEditor.Tests.Schema
[TestFixture]
public class ElementRefAnnotationTestFixture : SchemaTestFixtureBase
{
ICompletionData[] fooChildElementCompletionData;
ICompletionItem[] fooChildElementCompletionData;
public override void FixtureInit()
{

9
src/AddIns/DisplayBindings/XmlEditor/Test/Schema/ElementWithAttributeSchemaTestFixture.cs

@ -5,11 +5,12 @@ @@ -5,11 +5,12 @@
// <version>$Revision: 915 $</version>
// </file>
using ICSharpCode.SharpDevelop.Editor;
using System;
using System.IO;
using ICSharpCode.TextEditor.Gui.CompletionWindow;
using ICSharpCode.XmlEditor;
using NUnit.Framework;
using System;
using System.IO;
namespace XmlEditor.Tests.Schema
{
@ -19,7 +20,7 @@ namespace XmlEditor.Tests.Schema @@ -19,7 +20,7 @@ namespace XmlEditor.Tests.Schema
[TestFixture]
public class ElementWithAttributeSchemaTestFixture : SchemaTestFixtureBase
{
ICompletionData[] attributeCompletionData;
ICompletionItem[] attributeCompletionData;
string attributeName;
public override void FixtureInit()
@ -48,7 +49,7 @@ namespace XmlEditor.Tests.Schema @@ -48,7 +49,7 @@ namespace XmlEditor.Tests.Schema
{
XmlElementPath path = new XmlElementPath();
path.Elements.Add(new QualifiedName("foobar", "http://www.w3schools.com"));
ICompletionData[] attributes = SchemaCompletionData.GetAttributeCompletionData(path);
ICompletionItem[] attributes = SchemaCompletionData.GetAttributeCompletionData(path);
Assert.AreEqual(0, attributes.Length, "Should not find attributes for unknown element.");
}

7
src/AddIns/DisplayBindings/XmlEditor/Test/Schema/EnumAttributeValueTestFixture.cs

@ -5,11 +5,12 @@ @@ -5,11 +5,12 @@
// <version>$Revision: 915 $</version>
// </file>
using ICSharpCode.SharpDevelop.Editor;
using System;
using System.IO;
using ICSharpCode.TextEditor.Gui.CompletionWindow;
using ICSharpCode.XmlEditor;
using NUnit.Framework;
using System;
using System.IO;
namespace XmlEditor.Tests.Schema
{
@ -19,7 +20,7 @@ namespace XmlEditor.Tests.Schema @@ -19,7 +20,7 @@ namespace XmlEditor.Tests.Schema
[TestFixture]
public class EnumAttributeValueTestFixture : SchemaTestFixtureBase
{
ICompletionData[] attributeValues;
ICompletionItem[] attributeValues;
public override void FixtureInit()
{

19
src/AddIns/DisplayBindings/XmlEditor/Test/Schema/ExtensionElementTestFixture.cs

@ -5,11 +5,12 @@ @@ -5,11 +5,12 @@
// <version>$Revision: 915 $</version>
// </file>
using ICSharpCode.SharpDevelop.Editor;
using System;
using System.IO;
using ICSharpCode.TextEditor.Gui.CompletionWindow;
using ICSharpCode.XmlEditor;
using NUnit.Framework;
using System;
using System.IO;
namespace XmlEditor.Tests.Schema
{
@ -19,13 +20,13 @@ namespace XmlEditor.Tests.Schema @@ -19,13 +20,13 @@ namespace XmlEditor.Tests.Schema
[TestFixture]
public class ExtensionElementTestFixture : SchemaTestFixtureBase
{
ICompletionData[] schemaChildElements;
ICompletionData[] annotationChildElements;
ICompletionData[] annotationAttributes;
ICompletionData[] includeAttributes;
ICompletionData[] appInfoAttributes;
ICompletionData[] schemaAttributes;
ICompletionData[] fooAttributes;
ICompletionItem[] schemaChildElements;
ICompletionItem[] annotationChildElements;
ICompletionItem[] annotationAttributes;
ICompletionItem[] includeAttributes;
ICompletionItem[] appInfoAttributes;
ICompletionItem[] schemaAttributes;
ICompletionItem[] fooAttributes;
public override void FixtureInit()
{

9
src/AddIns/DisplayBindings/XmlEditor/Test/Schema/GroupRefCompositorTestFixture.cs

@ -5,11 +5,12 @@ @@ -5,11 +5,12 @@
// <version>$Revision: 915 $</version>
// </file>
using ICSharpCode.SharpDevelop.Editor;
using System;
using System.IO;
using ICSharpCode.TextEditor.Gui.CompletionWindow;
using ICSharpCode.XmlEditor;
using NUnit.Framework;
using System;
using System.IO;
namespace XmlEditor.Tests.Schema
{
@ -23,8 +24,8 @@ namespace XmlEditor.Tests.Schema @@ -23,8 +24,8 @@ namespace XmlEditor.Tests.Schema
[TestFixture]
public class GroupRefAsCompositorTestFixture : SchemaTestFixtureBase
{
ICompletionData[] rootChildElements;
ICompletionData[] fooAttributes;
ICompletionItem[] rootChildElements;
ICompletionItem[] fooAttributes;
public override void FixtureInit()
{

9
src/AddIns/DisplayBindings/XmlEditor/Test/Schema/GroupRefTestFixture.cs

@ -5,11 +5,12 @@ @@ -5,11 +5,12 @@
// <version>$Revision: 915 $</version>
// </file>
using ICSharpCode.SharpDevelop.Editor;
using System;
using System.IO;
using ICSharpCode.TextEditor.Gui.CompletionWindow;
using ICSharpCode.XmlEditor;
using NUnit.Framework;
using System;
using System.IO;
namespace XmlEditor.Tests.Schema
{
@ -19,8 +20,8 @@ namespace XmlEditor.Tests.Schema @@ -19,8 +20,8 @@ namespace XmlEditor.Tests.Schema
[TestFixture]
public class GroupRefTestFixture : SchemaTestFixtureBase
{
ICompletionData[] childElements;
ICompletionData[] paraAttributes;
ICompletionItem[] childElements;
ICompletionItem[] paraAttributes;
public override void FixtureInit()
{

7
src/AddIns/DisplayBindings/XmlEditor/Test/Schema/MissingSchemaElementTestFixture.cs

@ -5,18 +5,19 @@ @@ -5,18 +5,19 @@
// <version>$Revision: 1228 $</version>
// </file>
using ICSharpCode.SharpDevelop.Editor;
using System;
using System.IO;
using ICSharpCode.TextEditor.Gui.CompletionWindow;
using ICSharpCode.XmlEditor;
using NUnit.Framework;
using System;
using System.IO;
namespace XmlEditor.Tests.Schema
{
[TestFixture]
public class MissingSchemaElementTestFixture : SchemaTestFixtureBase
{
ICompletionData[] barElementAttributes;
ICompletionItem[] barElementAttributes;
public override void FixtureInit()
{

14
src/AddIns/DisplayBindings/XmlEditor/Test/Schema/NamespaceCompletionTestFixture.cs

@ -5,11 +5,13 @@ @@ -5,11 +5,13 @@
// <version>$Revision: 915 $</version>
// </file>
using ICSharpCode.SharpDevelop.Editor;
using System;
using System.Linq;
using System.IO;
using ICSharpCode.TextEditor.Gui.CompletionWindow;
using ICSharpCode.XmlEditor;
using NUnit.Framework;
using System;
using System.IO;
namespace XmlEditor.Tests.Schema
{
@ -20,7 +22,7 @@ namespace XmlEditor.Tests.Schema @@ -20,7 +22,7 @@ namespace XmlEditor.Tests.Schema
[TestFixture]
public class NamespaceCompletionTestFixture
{
ICompletionData[] namespaceCompletionData;
ICompletionItemList namespaceCompletionData;
string firstNamespace = "http://foo.com/foo.xsd";
string secondNamespace = "http://bar.com/bar.xsd";
@ -42,20 +44,20 @@ namespace XmlEditor.Tests.Schema @@ -42,20 +44,20 @@ namespace XmlEditor.Tests.Schema
[Test]
public void NamespaceCount()
{
Assert.AreEqual(2, namespaceCompletionData.Length,
Assert.AreEqual(2, namespaceCompletionData.Items.ToArray().Length,
"Should be 2 namespaces.");
}
[Test]
public void ContainsFirstNamespace()
{
Assert.IsTrue(SchemaTestFixtureBase.Contains(namespaceCompletionData, firstNamespace));
Assert.IsTrue(SchemaTestFixtureBase.Contains(namespaceCompletionData.Items.ToArray(), firstNamespace));
}
[Test]
public void ContainsSecondNamespace()
{
Assert.IsTrue(SchemaTestFixtureBase.Contains(namespaceCompletionData, secondNamespace));
Assert.IsTrue(SchemaTestFixtureBase.Contains(namespaceCompletionData.Items.ToArray(), secondNamespace));
}
string GetSchema(string namespaceURI)

7
src/AddIns/DisplayBindings/XmlEditor/Test/Schema/NestedAttributeGroupRefTestFixture.cs

@ -5,11 +5,12 @@ @@ -5,11 +5,12 @@
// <version>$Revision: 915 $</version>
// </file>
using ICSharpCode.SharpDevelop.Editor;
using System;
using System.IO;
using ICSharpCode.TextEditor.Gui.CompletionWindow;
using ICSharpCode.XmlEditor;
using NUnit.Framework;
using System;
using System.IO;
namespace XmlEditor.Tests.Schema
{
@ -19,7 +20,7 @@ namespace XmlEditor.Tests.Schema @@ -19,7 +20,7 @@ namespace XmlEditor.Tests.Schema
[TestFixture]
public class NestedAttributeGroupRefTestFixture : SchemaTestFixtureBase
{
ICompletionData[] attributeCompletionData;
ICompletionItem[] attributeCompletionData;
public override void FixtureInit()
{

9
src/AddIns/DisplayBindings/XmlEditor/Test/Schema/NestedChoiceTestFixture.cs

@ -5,11 +5,12 @@ @@ -5,11 +5,12 @@
// <version>$Revision: 915 $</version>
// </file>
using ICSharpCode.SharpDevelop.Editor;
using System;
using System.IO;
using ICSharpCode.TextEditor.Gui.CompletionWindow;
using ICSharpCode.XmlEditor;
using NUnit.Framework;
using System;
using System.IO;
namespace XmlEditor.Tests.Schema
{
@ -20,8 +21,8 @@ namespace XmlEditor.Tests.Schema @@ -20,8 +21,8 @@ namespace XmlEditor.Tests.Schema
[TestFixture]
public class NestedChoiceTestFixture : SchemaTestFixtureBase
{
ICompletionData[] noteChildElements;
ICompletionData[] titleChildElements;
ICompletionItem[] noteChildElements;
ICompletionItem[] titleChildElements;
public override void FixtureInit()
{

7
src/AddIns/DisplayBindings/XmlEditor/Test/Schema/NestedElementSchemaTestFixture.cs

@ -5,11 +5,12 @@ @@ -5,11 +5,12 @@
// <version>$Revision: 915 $</version>
// </file>
using ICSharpCode.SharpDevelop.Editor;
using System;
using System.IO;
using ICSharpCode.TextEditor.Gui.CompletionWindow;
using ICSharpCode.XmlEditor;
using NUnit.Framework;
using System;
using System.IO;
namespace XmlEditor.Tests.Schema
{
@ -17,7 +18,7 @@ namespace XmlEditor.Tests.Schema @@ -17,7 +18,7 @@ namespace XmlEditor.Tests.Schema
public class NestedElementSchemaTestFixture : SchemaTestFixtureBase
{
XmlElementPath noteElementPath;
ICompletionData[] elementData;
ICompletionItem[] elementData;
public override void FixtureInit()
{

7
src/AddIns/DisplayBindings/XmlEditor/Test/Schema/NestedSequenceTestFixture.cs

@ -5,11 +5,12 @@ @@ -5,11 +5,12 @@
// <version>$Revision: 915 $</version>
// </file>
using ICSharpCode.SharpDevelop.Editor;
using System;
using System.IO;
using ICSharpCode.TextEditor.Gui.CompletionWindow;
using ICSharpCode.XmlEditor;
using NUnit.Framework;
using System;
using System.IO;
namespace XmlEditor.Tests.Schema
{
@ -20,7 +21,7 @@ namespace XmlEditor.Tests.Schema @@ -20,7 +21,7 @@ namespace XmlEditor.Tests.Schema
[TestFixture]
public class NestedSequenceSchemaTestFixture : SchemaTestFixtureBase
{
ICompletionData[] noteChildElements;
ICompletionItem[] noteChildElements;
public override void FixtureInit()
{

15
src/AddIns/DisplayBindings/XmlEditor/Test/Schema/ReferencedElementsTestFixture.cs

@ -5,19 +5,20 @@ @@ -5,19 +5,20 @@
// <version>$Revision: 915 $</version>
// </file>
using ICSharpCode.SharpDevelop.Editor;
using System;
using System.IO;
using ICSharpCode.TextEditor.Gui.CompletionWindow;
using ICSharpCode.XmlEditor;
using NUnit.Framework;
using System;
using System.IO;
namespace XmlEditor.Tests.Schema
{
[TestFixture]
public class ReferencedElementsTestFixture : SchemaTestFixtureBase
{
ICompletionData[] shipOrderAttributes;
ICompletionData[] shipToAttributes;
ICompletionItem[] shipOrderAttributes;
ICompletionItem[] shipToAttributes;
XmlElementPath shipToPath;
XmlElementPath shipOrderPath;
@ -75,7 +76,7 @@ namespace XmlEditor.Tests.Schema @@ -75,7 +76,7 @@ namespace XmlEditor.Tests.Schema
[Test]
public void ShipOrderHasShipToChildElement()
{
ICompletionData[] data = SchemaCompletionData.GetChildElementCompletionData(shipOrderPath);
ICompletionItem[] data = SchemaCompletionData.GetChildElementCompletionData(shipOrderPath);
Assert.IsTrue(SchemaTestFixtureBase.Contains(data, "shipto"),
"Incorrect child element name.");
}
@ -90,7 +91,7 @@ namespace XmlEditor.Tests.Schema @@ -90,7 +91,7 @@ namespace XmlEditor.Tests.Schema
[Test]
public void ShipToHasNameChildElement()
{
ICompletionData[] data = SchemaCompletionData.GetChildElementCompletionData(shipToPath);
ICompletionItem[] data = SchemaCompletionData.GetChildElementCompletionData(shipToPath);
Assert.IsTrue(SchemaTestFixtureBase.Contains(data, "name"),
"Incorrect child element name.");
}
@ -98,7 +99,7 @@ namespace XmlEditor.Tests.Schema @@ -98,7 +99,7 @@ namespace XmlEditor.Tests.Schema
[Test]
public void ShipToHasAddressChildElement()
{
ICompletionData[] data = SchemaCompletionData.GetChildElementCompletionData(shipToPath);
ICompletionItem[] data = SchemaCompletionData.GetChildElementCompletionData(shipToPath);
Assert.IsTrue(SchemaTestFixtureBase.Contains(data, "address"),
"Incorrect child element name.");
}

13
src/AddIns/DisplayBindings/XmlEditor/Test/Schema/RestrictionElementTestFixture.cs

@ -5,11 +5,12 @@ @@ -5,11 +5,12 @@
// <version>$Revision: 915 $</version>
// </file>
using ICSharpCode.SharpDevelop.Editor;
using System;
using System.IO;
using ICSharpCode.TextEditor.Gui.CompletionWindow;
using ICSharpCode.XmlEditor;
using NUnit.Framework;
using System;
using System.IO;
namespace XmlEditor.Tests.Schema
{
@ -19,10 +20,10 @@ namespace XmlEditor.Tests.Schema @@ -19,10 +20,10 @@ namespace XmlEditor.Tests.Schema
[TestFixture]
public class RestrictionElementTestFixture : SchemaTestFixtureBase
{
ICompletionData[] childElements;
ICompletionData[] attributes;
ICompletionData[] annotationChildElements;
ICompletionData[] choiceChildElements;
ICompletionItem[] childElements;
ICompletionItem[] attributes;
ICompletionItem[] annotationChildElements;
ICompletionItem[] choiceChildElements;
public override void FixtureInit()
{

17
src/AddIns/DisplayBindings/XmlEditor/Test/Schema/SchemaTestFixtureBase.cs

@ -5,11 +5,12 @@ @@ -5,11 +5,12 @@
// <version>$Revision: 1683 $</version>
// </file>
using ICSharpCode.SharpDevelop.Editor;
using System;
using System.IO;
using ICSharpCode.TextEditor.Gui.CompletionWindow;
using ICSharpCode.XmlEditor;
using NUnit.Framework;
using System;
using System.IO;
namespace XmlEditor.Tests.Schema
{
@ -53,11 +54,11 @@ namespace XmlEditor.Tests.Schema @@ -53,11 +54,11 @@ namespace XmlEditor.Tests.Schema
/// <summary>
/// Checks whether the specified name exists in the completion data.
/// </summary>
public static bool Contains(ICompletionData[] items, string name)
public static bool Contains(ICompletionItem[] items, string name)
{
bool Contains = false;
foreach (ICompletionData data in items) {
foreach (ICompletionItem data in items) {
if (data.Text == name) {
Contains = true;
break;
@ -71,11 +72,11 @@ namespace XmlEditor.Tests.Schema @@ -71,11 +72,11 @@ namespace XmlEditor.Tests.Schema
/// Checks whether the completion data specified by name has
/// the correct description.
/// </summary>
public static bool ContainsDescription(ICompletionData[] items, string name, string description)
public static bool ContainsDescription(ICompletionItem[] items, string name, string description)
{
bool Contains = false;
foreach (ICompletionData data in items) {
foreach (ICompletionItem data in items) {
if (data.Text == name) {
if (data.Description == description) {
Contains = true;
@ -91,11 +92,11 @@ namespace XmlEditor.Tests.Schema @@ -91,11 +92,11 @@ namespace XmlEditor.Tests.Schema
/// Gets a count of the number of occurrences of a particular name
/// in the completion data.
/// </summary>
public static int GetItemCount(ICompletionData[] items, string name)
public static int GetItemCount(ICompletionItem[] items, string name)
{
int count = 0;
foreach (ICompletionData data in items) {
foreach (ICompletionItem data in items) {
if (data.Text == name) {
++count;
}

7
src/AddIns/DisplayBindings/XmlEditor/Test/Schema/SequencedChoiceTestFixture.cs

@ -5,11 +5,12 @@ @@ -5,11 +5,12 @@
// <version>$Revision: 915 $</version>
// </file>
using ICSharpCode.SharpDevelop.Editor;
using System;
using System.IO;
using ICSharpCode.TextEditor.Gui.CompletionWindow;
using ICSharpCode.XmlEditor;
using NUnit.Framework;
using System;
using System.IO;
namespace XmlEditor.Tests.Schema
{
@ -20,7 +21,7 @@ namespace XmlEditor.Tests.Schema @@ -20,7 +21,7 @@ namespace XmlEditor.Tests.Schema
[TestFixture]
public class SequencedChoiceTestFixture : SchemaTestFixtureBase
{
ICompletionData[] noteChildElements;
ICompletionItem[] noteChildElements;
public override void FixtureInit()
{

7
src/AddIns/DisplayBindings/XmlEditor/Test/Schema/SimpleContentWithAttributeTestFixture.cs

@ -5,11 +5,12 @@ @@ -5,11 +5,12 @@
// <version>$Revision: 915 $</version>
// </file>
using ICSharpCode.SharpDevelop.Editor;
using System;
using System.IO;
using ICSharpCode.TextEditor.Gui.CompletionWindow;
using ICSharpCode.XmlEditor;
using NUnit.Framework;
using System;
using System.IO;
namespace XmlEditor.Tests.Schema
{
@ -19,7 +20,7 @@ namespace XmlEditor.Tests.Schema @@ -19,7 +20,7 @@ namespace XmlEditor.Tests.Schema
[TestFixture]
public class SimpleContentWithAttributeSchemaTestFixture : SchemaTestFixtureBase
{
ICompletionData[] attributeCompletionData;
ICompletionItem[] attributeCompletionData;
public override void FixtureInit()
{

9
src/AddIns/DisplayBindings/XmlEditor/Test/Schema/SingleElementSchemaTestFixture.cs

@ -5,11 +5,12 @@ @@ -5,11 +5,12 @@
// <version>$Revision: 915 $</version>
// </file>
using ICSharpCode.SharpDevelop.Editor;
using System;
using System.IO;
using ICSharpCode.TextEditor.Gui.CompletionWindow;
using ICSharpCode.XmlEditor;
using NUnit.Framework;
using System;
using System.IO;
namespace XmlEditor.Tests.Schema
{
@ -20,8 +21,8 @@ namespace XmlEditor.Tests.Schema @@ -20,8 +21,8 @@ namespace XmlEditor.Tests.Schema
[TestFixture]
public class SingleElementSchemaTestFixture : SchemaTestFixtureBase
{
ICompletionData[] childElementCompletionData;
ICompletionData[] attributeCompletionData;
ICompletionItem[] childElementCompletionData;
ICompletionItem[] attributeCompletionData;
public override void FixtureInit()
{

22
src/AddIns/DisplayBindings/XmlEditor/Test/Schema/TwoElementSchemaTestFixture.cs

@ -5,11 +5,11 @@ @@ -5,11 +5,11 @@
// <version>$Revision: 915 $</version>
// </file>
using ICSharpCode.TextEditor.Gui.CompletionWindow;
using System;
using System.Linq;
using ICSharpCode.SharpDevelop.Editor;
using ICSharpCode.XmlEditor;
using NUnit.Framework;
using System;
using System.IO;
namespace XmlEditor.Tests.Schema
{
@ -39,7 +39,7 @@ namespace XmlEditor.Tests.Schema @@ -39,7 +39,7 @@ namespace XmlEditor.Tests.Schema
[Test]
public void TextElementHasOneAttribute()
{
ICompletionData[] attributesCompletionData = SchemaCompletionData.GetAttributeCompletionData(textElementPath);
ICompletionItem[] attributesCompletionData = SchemaCompletionData.GetAttributeCompletionData(textElementPath);
Assert.AreEqual(1, attributesCompletionData.Length,
"Should have 1 text attribute.");
@ -48,7 +48,7 @@ namespace XmlEditor.Tests.Schema @@ -48,7 +48,7 @@ namespace XmlEditor.Tests.Schema
[Test]
public void TextElementAttributeName()
{
ICompletionData[] attributesCompletionData = SchemaCompletionData.GetAttributeCompletionData(textElementPath);
ICompletionItem[] attributesCompletionData = SchemaCompletionData.GetAttributeCompletionData(textElementPath);
Assert.IsTrue(SchemaTestFixtureBase.Contains(attributesCompletionData, "foo"),
"Unexpected text attribute name.");
}
@ -56,7 +56,7 @@ namespace XmlEditor.Tests.Schema @@ -56,7 +56,7 @@ namespace XmlEditor.Tests.Schema
[Test]
public void NoteElementHasChildElement()
{
ICompletionData[] childElementCompletionData
ICompletionItem[] childElementCompletionData
= SchemaCompletionData.GetChildElementCompletionData(noteElementPath);
Assert.AreEqual(1, childElementCompletionData.Length,
@ -66,7 +66,7 @@ namespace XmlEditor.Tests.Schema @@ -66,7 +66,7 @@ namespace XmlEditor.Tests.Schema
[Test]
public void NoteElementHasNoAttributes()
{
ICompletionData[] attributeCompletionData
ICompletionItem[] attributeCompletionData
= SchemaCompletionData.GetAttributeCompletionData(noteElementPath);
Assert.AreEqual(0, attributeCompletionData.Length,
@ -76,19 +76,19 @@ namespace XmlEditor.Tests.Schema @@ -76,19 +76,19 @@ namespace XmlEditor.Tests.Schema
[Test]
public void OneRootElement()
{
ICompletionData[] elementCompletionData
ICompletionItemList elementCompletionData
= SchemaCompletionData.GetElementCompletionData();
Assert.AreEqual(1, elementCompletionData.Length, "Should be 1 root element.");
Assert.AreEqual(1, elementCompletionData.Items.ToArray().Length, "Should be 1 root element.");
}
[Test]
public void RootElementIsNote()
{
ICompletionData[] elementCompletionData
ICompletionItemList elementCompletionData
= SchemaCompletionData.GetElementCompletionData();
Assert.IsTrue(Contains(elementCompletionData, "note"),
Assert.IsTrue(Contains(elementCompletionData.Items.ToArray(), "note"),
"Should be called note.");
}

9
src/AddIns/DisplayBindings/XmlEditor/Test/Schema/XhtmlStrictSchemaTestFixture.cs

@ -5,12 +5,13 @@ @@ -5,12 +5,13 @@
// <version>$Revision: 915 $</version>
// </file>
using ICSharpCode.TextEditor.Gui.CompletionWindow;
using ICSharpCode.XmlEditor;
using NUnit.Framework;
using ICSharpCode.SharpDevelop.Editor;
using System;
using System.IO;
using System.Xml;
using ICSharpCode.TextEditor.Gui.CompletionWindow;
using ICSharpCode.XmlEditor;
using NUnit.Framework;
using XmlEditor.Tests.Utils;
namespace XmlEditor.Tests.Schema
@ -23,7 +24,7 @@ namespace XmlEditor.Tests.Schema @@ -23,7 +24,7 @@ namespace XmlEditor.Tests.Schema
{
XmlSchemaCompletionData schemaCompletionData;
XmlElementPath h1Path;
ICompletionData[] h1Attributes;
ICompletionItem[] h1Attributes;
string namespaceURI = "http://www.w3.org/1999/xhtml";
[TestFixtureSetUp]

10
src/AddIns/DisplayBindings/XmlEditor/Test/Tree/AddNewNodeDialogTestFixture.cs

@ -183,7 +183,7 @@ namespace XmlEditor.Tests.Tree @@ -183,7 +183,7 @@ namespace XmlEditor.Tests.Tree
customNameTextBox.Text = "<element>";
dialog.CallCustomNameTextBoxTextChanged();
string error = dialog.GetError();
string error = dialog.ErrorText;
string expectedError = null;
try {
@ -202,7 +202,7 @@ namespace XmlEditor.Tests.Tree @@ -202,7 +202,7 @@ namespace XmlEditor.Tests.Tree
customNameTextBox.Text = "xsl:test:this";
dialog.CallCustomNameTextBoxTextChanged();
string error = dialog.GetError();
string error = dialog.ErrorText;
Assert.IsFalse(okButton.Enabled);
Assert.IsTrue(error.Length > 0);
}
@ -213,7 +213,7 @@ namespace XmlEditor.Tests.Tree @@ -213,7 +213,7 @@ namespace XmlEditor.Tests.Tree
customNameTextBox.Text = "xsl:test";
dialog.CallCustomNameTextBoxTextChanged();
string error = dialog.GetError();
string error = dialog.ErrorText;
Assert.IsTrue(okButton.Enabled);
Assert.AreEqual(0, error.Length);
}
@ -224,7 +224,7 @@ namespace XmlEditor.Tests.Tree @@ -224,7 +224,7 @@ namespace XmlEditor.Tests.Tree
customNameTextBox.Text = ":test";
dialog.CallCustomNameTextBoxTextChanged();
string error = dialog.GetError();
string error = dialog.ErrorText;
Assert.IsFalse(okButton.Enabled);
Assert.IsTrue(error.Length > 0);
}
@ -237,7 +237,7 @@ namespace XmlEditor.Tests.Tree @@ -237,7 +237,7 @@ namespace XmlEditor.Tests.Tree
dialog.CallCustomNameTextBoxTextChanged();
Assert.IsTrue(okButton.Enabled);
Assert.AreEqual(0, dialog.GetError().Length);
Assert.AreEqual(0, dialog.ErrorText.Length);
}
[Test]

12
src/AddIns/DisplayBindings/XmlEditor/Test/Tree/OwnerStatusTestFixture.cs

@ -69,7 +69,7 @@ namespace XmlEditor.Tests.Tree @@ -69,7 +69,7 @@ namespace XmlEditor.Tests.Tree
{
treeView.SelectedNode = null;
Assert.AreEqual(XmlTreeViewContainerControl.XmlTreeViewContainerControlState.Nothing,
Assert.AreEqual(XmlTreeViewContainerControl.XmlTreeViewContainerControlStates.None,
treeViewContainer.InternalState,
"OwnerState should be Nothing.");
}
@ -79,7 +79,7 @@ namespace XmlEditor.Tests.Tree @@ -79,7 +79,7 @@ namespace XmlEditor.Tests.Tree
{
treeView.SelectedNode = htmlTreeNode;
Assert.AreEqual(XmlTreeViewContainerControl.XmlTreeViewContainerControlState.RootElementSelected | XmlTreeViewContainerControl.XmlTreeViewContainerControlState.ElementSelected,
Assert.AreEqual(XmlTreeViewContainerControl.XmlTreeViewContainerControlStates.RootElementSelected | XmlTreeViewContainerControl.XmlTreeViewContainerControlStates.ElementSelected,
treeViewContainer.InternalState,
"OwnerState should be RootElementSelected and ElementSelected.");
}
@ -89,7 +89,7 @@ namespace XmlEditor.Tests.Tree @@ -89,7 +89,7 @@ namespace XmlEditor.Tests.Tree
{
treeView.SelectedNode = bodyTreeNode;
Assert.AreEqual(XmlTreeViewContainerControl.XmlTreeViewContainerControlState.ElementSelected,
Assert.AreEqual(XmlTreeViewContainerControl.XmlTreeViewContainerControlStates.ElementSelected,
treeViewContainer.InternalState,
"OwnerState should be ElementSelected.");
}
@ -103,7 +103,7 @@ namespace XmlEditor.Tests.Tree @@ -103,7 +103,7 @@ namespace XmlEditor.Tests.Tree
Assert.IsNotNull(treeViewContainer.AttributesGrid.SelectedGridItem,
"Sanity check - should have a grid item selected.");
Assert.AreEqual(XmlTreeViewContainerControl.XmlTreeViewContainerControlState.ElementSelected | XmlTreeViewContainerControl.XmlTreeViewContainerControlState.AttributeSelected,
Assert.AreEqual(XmlTreeViewContainerControl.XmlTreeViewContainerControlStates.ElementSelected | XmlTreeViewContainerControl.XmlTreeViewContainerControlStates.AttributeSelected,
treeViewContainer.InternalState,
"OwnerState should be ElementSelected and AttributeSelected.");
}
@ -113,7 +113,7 @@ namespace XmlEditor.Tests.Tree @@ -113,7 +113,7 @@ namespace XmlEditor.Tests.Tree
{
treeView.SelectedNode = textTreeNode;
Assert.AreEqual(XmlTreeViewContainerControl.XmlTreeViewContainerControlState.TextNodeSelected,
Assert.AreEqual(XmlTreeViewContainerControl.XmlTreeViewContainerControlStates.TextNodeSelected,
treeViewContainer.InternalState,
"OwnerState should be TextNodeSelected.");
}
@ -123,7 +123,7 @@ namespace XmlEditor.Tests.Tree @@ -123,7 +123,7 @@ namespace XmlEditor.Tests.Tree
{
treeView.SelectedNode = commentTreeNode;
Assert.AreEqual(XmlTreeViewContainerControl.XmlTreeViewContainerControlState.CommentSelected,
Assert.AreEqual(XmlTreeViewContainerControl.XmlTreeViewContainerControlStates.CommentSelected,
treeViewContainer.InternalState,
"OwnerState should be CommentSelected.");
}

10
src/AddIns/DisplayBindings/XmlEditor/Test/Tree/XmlTreeViewClipboardHandlerTestFixture.cs

@ -23,7 +23,7 @@ namespace XmlEditor.Tests.Tree @@ -23,7 +23,7 @@ namespace XmlEditor.Tests.Tree
[TestFixture]
public class XmlTreeViewClipboardHandlerTestFixture
{
XmlView xmlView;
MockXmlViewContent xmlView;
XmlTreeView view;
XmlTreeViewContainerControl treeViewContainer;
XmlTreeViewControl treeView;
@ -37,14 +37,12 @@ namespace XmlEditor.Tests.Tree @@ -37,14 +37,12 @@ namespace XmlEditor.Tests.Tree
{
MockOpenedFile openedFile = new MockOpenedFile("test.xml");
XmlSchemaCompletionDataCollection schemas = new XmlSchemaCompletionDataCollection();
xmlView = new XmlView(new DefaultTextEditorProperties(), schemas);
xmlView.SetPrimaryFileUnitTestMode(openedFile);
view = new XmlTreeView(xmlView, null, null);
xmlView = new MockXmlViewContent();
view = new XmlTreeView(xmlView);
treeViewContainer = (XmlTreeViewContainerControl)view.Control;
treeView = treeViewContainer.TreeView;
clipboardHandler = view as IClipboardHandler;
xmlView.XmlEditor.Text = "<html><body><p></p></body></html>";
xmlView.GetDocumentForFile(null).Text = "<html><body><p></p></body></html>";
openedFile.SwitchToView(view);
htmlTreeNode = treeView.Nodes[0] as XmlElementTreeNode;

38
src/AddIns/DisplayBindings/XmlEditor/Test/Utils/MockXmlViewContent.cs

@ -0,0 +1,38 @@ @@ -0,0 +1,38 @@
// <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 System;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Editor;
using ICSharpCode.SharpDevelop.Gui;
namespace XmlEditor.Tests.Utils
{
/// <summary>
/// Description of MockXmlViewContent.
/// </summary>
public class MockXmlViewContent : AbstractViewContent, IFileDocumentProvider
{
AvalonEditDocumentAdapter document;
public MockXmlViewContent()
{
this.document = new AvalonEditDocumentAdapter();
}
public override object Control {
get {
throw new NotImplementedException();
}
}
public IDocument GetDocumentForFile(OpenedFile file)
{
return document;
}
}
}

165
src/AddIns/DisplayBindings/XmlEditor/Test/XPathQuery/XPathNodeTextMarkerTests.cs

@ -19,87 +19,88 @@ namespace XmlEditor.Tests.XPathQuery @@ -19,87 +19,88 @@ namespace XmlEditor.Tests.XPathQuery
{
[TestFixture]
public class XPathNodeTextMarkerTests
{
[Test]
public void OneNodeMarked()
{
string xml = "<root><foo/></root>";
XPathNodeMatch[] nodes = XmlView.SelectNodes(xml, "//root");
IDocument doc = MockDocument.Create();
doc.TextContent = xml;
MarkerStrategy markerStrategy = new MarkerStrategy(doc);
XPathNodeTextMarker.AddMarkers(markerStrategy, nodes);
List<TextMarker> markers = new List<TextMarker>();
foreach (TextMarker marker in markerStrategy.TextMarker) {
markers.Add(marker);
}
// Remove markers.
XPathNodeTextMarker.RemoveMarkers(markerStrategy);
List<TextMarker> markersAfterRemove = new List<TextMarker>();
foreach (TextMarker markerAfterRemove in markerStrategy.TextMarker) {
markers.Add(markerAfterRemove);
}
XPathNodeTextMarker xpathNodeTextMarker = (XPathNodeTextMarker)markers[0];
Assert.AreEqual(1, markers.Count);
Assert.AreEqual(1, xpathNodeTextMarker.Offset);
Assert.AreEqual(4, xpathNodeTextMarker.Length);
Assert.AreEqual(TextMarkerType.SolidBlock, xpathNodeTextMarker.TextMarkerType);
Assert.AreEqual(0, markersAfterRemove.Count);
Assert.AreEqual(XPathNodeTextMarker.MarkerBackColor, xpathNodeTextMarker.Color);
}
/// <summary>
/// Tests that XPathNodeMatch with an empty string value are not marked since
/// the MarkerStrategy cannot use a TextMarker with a length of 0.
/// </summary>
[Test]
public void EmptyCommentNode()
{
string xml = "<!----><root/>";
XPathNodeMatch[] nodes = XmlView.SelectNodes(xml, "//comment()");
IDocument doc = MockDocument.Create();
doc.TextContent = xml;
MarkerStrategy markerStrategy = new MarkerStrategy(doc);
XPathNodeTextMarker.AddMarkers(markerStrategy, nodes);
List<TextMarker> markers = new List<TextMarker>();
foreach (TextMarker marker in markerStrategy.TextMarker) {
markers.Add(marker);
}
Assert.AreEqual(0, markers.Count);
Assert.AreEqual(1, nodes.Length);
}
/// <summary>
/// Note that the XPathDocument.SelectNodes call returns a bad XPathNode set
/// back. It finds a namespace node at 0, 0, even though it uses one based
/// line information, it should really return false from HasLineInfo, but it
/// does not. In our XPathNodeMatch we return false from HasLineInfo.
/// </summary>
[Test]
public void NamespaceQuery()
{
string xml = "<?xml version='1.0'?>\r\n" +
"<Xml1></Xml1>";
XPathNodeMatch[] nodes = XmlView.SelectNodes(xml, "//namespace::*");
IDocument doc = MockDocument.Create();
doc.TextContent = xml;
MarkerStrategy markerStrategy = new MarkerStrategy(doc);
XPathNodeTextMarker.AddMarkers(markerStrategy, nodes);
List<TextMarker> markers = new List<TextMarker>();
foreach (TextMarker marker in markerStrategy.TextMarker) {
markers.Add(marker);
}
Assert.AreEqual(0, markers.Count);
Assert.AreEqual(1, nodes.Length);
}
{
// TODO : reimplement tests using new mock classes
// [Test]
// public void OneNodeMarked()
// {
// string xml = "<root><foo/></root>";
// XPathNodeMatch[] nodes = XmlView.SelectNodes(xml, "//root");
//
// IDocument doc = MockDocument.Create();
// doc.TextContent = xml;
// MarkerStrategy markerStrategy = new MarkerStrategy(doc);
// XPathNodeTextMarker.AddMarkers(markerStrategy, nodes);
//
// List<TextMarker> markers = new List<TextMarker>();
// foreach (TextMarker marker in markerStrategy.TextMarker) {
// markers.Add(marker);
// }
//
// // Remove markers.
// XPathNodeTextMarker.RemoveMarkers(markerStrategy);
// List<TextMarker> markersAfterRemove = new List<TextMarker>();
// foreach (TextMarker markerAfterRemove in markerStrategy.TextMarker) {
// markers.Add(markerAfterRemove);
// }
//
// XPathNodeTextMarker xpathNodeTextMarker = (XPathNodeTextMarker)markers[0];
// Assert.AreEqual(1, markers.Count);
// Assert.AreEqual(1, xpathNodeTextMarker.Offset);
// Assert.AreEqual(4, xpathNodeTextMarker.Length);
// Assert.AreEqual(TextMarkerType.SolidBlock, xpathNodeTextMarker.TextMarkerType);
// Assert.AreEqual(0, markersAfterRemove.Count);
// Assert.AreEqual(XPathNodeTextMarker.MarkerBackColor, xpathNodeTextMarker.Color);
// }
//
// /// <summary>
// /// Tests that XPathNodeMatch with an empty string value are not marked since
// /// the MarkerStrategy cannot use a TextMarker with a length of 0.
// /// </summary>
// [Test]
// public void EmptyCommentNode()
// {
// string xml = "<!----><root/>";
// XPathNodeMatch[] nodes = XmlView.SelectNodes(xml, "//comment()");
//
// IDocument doc = MockDocument.Create();
// doc.TextContent = xml;
// MarkerStrategy markerStrategy = new MarkerStrategy(doc);
// XPathNodeTextMarker.AddMarkers(markerStrategy, nodes);
//
// List<TextMarker> markers = new List<TextMarker>();
// foreach (TextMarker marker in markerStrategy.TextMarker) {
// markers.Add(marker);
// }
//
// Assert.AreEqual(0, markers.Count);
// Assert.AreEqual(1, nodes.Length);
// }
//
// /// <summary>
// /// Note that the XPathDocument.SelectNodes call returns a bad XPathNode set
// /// back. It finds a namespace node at 0, 0, even though it uses one based
// /// line information, it should really return false from HasLineInfo, but it
// /// does not. In our XPathNodeMatch we return false from HasLineInfo.
// /// </summary>
// [Test]
// public void NamespaceQuery()
// {
// string xml = "<?xml version='1.0'?>\r\n" +
// "<Xml1></Xml1>";
// XPathNodeMatch[] nodes = XmlView.SelectNodes(xml, "//namespace::*");
//
// IDocument doc = MockDocument.Create();
// doc.TextContent = xml;
// MarkerStrategy markerStrategy = new MarkerStrategy(doc);
// XPathNodeTextMarker.AddMarkers(, nodes);
//
// List<TextMarker> markers = new List<TextMarker>();
// foreach (TextMarker marker in markerStrategy.TextMarker) {
// markers.Add(marker);
// }
// Assert.AreEqual(0, markers.Count);
// Assert.AreEqual(1, nodes.Length);
// }
}
}

25
src/AddIns/DisplayBindings/XmlEditor/Test/XmlEditor.Tests.csproj

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@ -19,21 +19,32 @@ @@ -19,21 +19,32 @@
<Optimize>False</Optimize>
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow>
<SourceAnalysisOverrideSettingsFile>C:\Users\Siegfried\AppData\Roaming\ICSharpCode/SharpDevelop3.0\Settings.SourceAnalysis</SourceAnalysisOverrideSettingsFile>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<DebugSymbols>true</DebugSymbols>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<DefineConstants>DEBUG</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Platform)' == 'AnyCPU' ">
<BaseAddress>4194304</BaseAddress>
<FileAlignment>4096</FileAlignment>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data" />
<Reference Include="System.Data.DataSetExtensions">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
@ -41,6 +52,9 @@ @@ -41,6 +52,9 @@
<HintPath>..\..\..\..\Tools\NUnit\nunit.framework.dll</HintPath>
<SpecificVersion>False</SpecificVersion>
</Reference>
<Reference Include="System.Xml.Linq">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="AssemblyInfo.cs" />
@ -100,6 +114,7 @@ @@ -100,6 +114,7 @@
<Compile Include="Utils\DerivedXmlTreeViewContainerControl.cs" />
<Compile Include="Utils\MockAddXmlNodeDialog.cs" />
<Compile Include="Utils\MockOpenedFile.cs" />
<Compile Include="Utils\MockXmlViewContent.cs" />
<Compile Include="Utils\ResourceManager.cs" />
<Compile Include="Schema\XhtmlStrictSchemaTestFixture.cs" />
<Compile Include="Schema\XsdSchemaTestFixture.cs" />
@ -190,6 +205,10 @@ @@ -190,6 +205,10 @@
<Project>{857CA1A3-FC88-4BE0-AB6A-D1EE772AB288}</Project>
<Name>ICSharpCode.Core.WinForms</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\..\Main\ICSharpCode.SharpDevelop.Dom\Project\ICSharpCode.SharpDevelop.Dom.csproj">
<Project>{924EE450-603D-49C1-A8E5-4AFAA31CE6F3}</Project>
<Name>ICSharpCode.SharpDevelop.Dom</Name>
</ProjectReference>
<ProjectReference Include="..\Project\XmlEditor.csproj">
<Project>{6B717BD1-CD5E-498C-A42E-9E6A4584DC48}</Project>
<Name>XmlEditor</Name>

8
src/Main/Base/Project/Src/Editor/AvalonEdit/AvalonEditDocumentAdapter.cs

@ -33,6 +33,14 @@ namespace ICSharpCode.SharpDevelop.Editor @@ -33,6 +33,14 @@ namespace ICSharpCode.SharpDevelop.Editor
this.parentServiceProvider = parentServiceProvider;
}
/// <summary>
/// Used in Unit Tests
/// </summary>
public AvalonEditDocumentAdapter()
{
this.document = new TextDocument();
}
sealed class LineAdapter : IDocumentLine
{
readonly DocumentLine line;

Loading…
Cancel
Save