diff --git a/src/AddIns/DisplayBindings/XmlEditor/Project/Configuration/AssemblyInfo.cs b/src/AddIns/DisplayBindings/XmlEditor/Project/Configuration/AssemblyInfo.cs
index edbfc51005..d5ead91fce 100644
--- a/src/AddIns/DisplayBindings/XmlEditor/Project/Configuration/AssemblyInfo.cs
+++ b/src/AddIns/DisplayBindings/XmlEditor/Project/Configuration/AssemblyInfo.cs
@@ -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
diff --git a/src/AddIns/DisplayBindings/XmlEditor/Project/Src/Src/XPathNodeMatch.cs b/src/AddIns/DisplayBindings/XmlEditor/Project/Src/Src/XPathNodeMatch.cs
deleted file mode 100644
index bbb9b6ca52..0000000000
--- a/src/AddIns/DisplayBindings/XmlEditor/Project/Src/Src/XPathNodeMatch.cs
+++ /dev/null
@@ -1,167 +0,0 @@
-//
-//
-//
-//
-// $Revision: 1662 $
-//
-
-using System;
-using System.Xml;
-using System.Xml.XPath;
-
-namespace ICSharpCode.XmlEditor
-{
- ///
- /// Stores an XmlNode and its associated line number and position after an
- /// XPath query has been evaluated.
- ///
- public class XPathNodeMatch : IXmlLineInfo
- {
- int? lineNumber;
- int linePosition;
- string value;
- string displayValue;
- XPathNodeType nodeType;
-
- ///
- /// Creates an XPathNodeMatch from the navigator which should be position on the
- /// node.
- ///
- ///
- /// We deliberately use the OuterXml when we find a Namespace since the
- /// navigator location returned starts from the xmlns attribute.
- ///
- 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;
- }
- }
-
- ///
- /// Line numbers are zero based.
- ///
- public int LineNumber {
- get {
- return lineNumber.GetValueOrDefault(0);
- }
- }
-
- ///
- /// Line positions are zero based.
- ///
- public int LinePosition {
- get {
- return linePosition;
- }
- }
-
- public bool HasLineInfo()
- {
- return lineNumber.HasValue;
- }
-
- ///
- /// Gets the text value of the node.
- ///
- public string Value {
- get {
- return value;
- }
- }
-
- ///
- /// Gets the node display value. This includes the angle brackets if it is
- /// an element, for example.
- ///
- 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);
- }
-
- ///
- /// Takes one of the xml line number so the numbers are now zero
- /// based instead of one based.
- ///
- /// 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.
- void SetLineNumbers(IXmlLineInfo lineInfo)
- {
- if (lineInfo.HasLineInfo() && lineInfo.LineNumber > 0) {
- lineNumber = lineInfo.LineNumber - 1;
- linePosition = lineInfo.LinePosition - 1;
- }
- }
- }
-}
diff --git a/src/AddIns/DisplayBindings/XmlEditor/Project/Src/Src/XPathNodeTextMarker.cs b/src/AddIns/DisplayBindings/XmlEditor/Project/Src/Src/XPathNodeTextMarker.cs
deleted file mode 100644
index dc38b58ba9..0000000000
--- a/src/AddIns/DisplayBindings/XmlEditor/Project/Src/Src/XPathNodeTextMarker.cs
+++ /dev/null
@@ -1,60 +0,0 @@
-//
-//
-//
-//
-// $Revision: 1965 $
-//
-
-using System;
-using System.Drawing;
-
-namespace ICSharpCode.XmlEditor
-{
-/*
- ///
- /// A text marker for an XPath query match.
- ///
- 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)
- {
- }
-
- ///
- /// Adds markers for each XPathNodeMatch.
- ///
- public static void AddMarkers(MarkerStrategy markerStrategy, XPathNodeMatch[] nodes)
- {
- foreach (XPathNodeMatch node in nodes) {
- AddMarker(markerStrategy, node);
- }
- }
-
- ///
- /// Adds a single marker for the XPathNodeMatch.
- ///
- 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));
- }
- }
-
- ///
- /// Removes all the XPathNodeMarkers from the marker strategy.
- ///
- public static void RemoveMarkers(MarkerStrategy markerStrategy)
- {
- markerStrategy.RemoveAll(IsXPathNodeTextMarkerMatch);
- }
-
- static bool IsXPathNodeTextMarkerMatch(TextMarker marker)
- {
- return marker is XPathNodeTextMarker;
- }
- }
- */
-}
diff --git a/src/AddIns/DisplayBindings/XmlEditor/Project/Src/Src/XmlAttributePropertyDescriptor.cs b/src/AddIns/DisplayBindings/XmlEditor/Project/Src/Src/XmlAttributePropertyDescriptor.cs
deleted file mode 100644
index 9875efde6d..0000000000
--- a/src/AddIns/DisplayBindings/XmlEditor/Project/Src/Src/XmlAttributePropertyDescriptor.cs
+++ /dev/null
@@ -1,95 +0,0 @@
-//
-//
-//
-//
-// $Revision: 1965 $
-//
-
-using System;
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.Xml;
-
-namespace ICSharpCode.XmlEditor
-{
- ///
- /// Property descriptor for an XmlAttribute. This is used when displaying
- /// an XmlAttribute in the property grid.
- ///
- public class XmlAttributePropertyDescriptor : PropertyDescriptor
- {
- XmlAttribute xmlAttribute;
- public XmlAttributePropertyDescriptor(XmlAttribute xmlAttribute)
- : base(xmlAttribute.LocalName, new Attribute[0])
- {
- this.xmlAttribute = xmlAttribute;
- }
-
- ///
- /// Gets the property descriptors for the specified attributes.
- ///
- public static PropertyDescriptorCollection GetProperties(XmlAttributeCollection xmlAttributes)
- {
- List properties = new List();
- 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;
- }
- }
-
- ///
- /// Returns the property type in this case a string.
- ///
- public override Type PropertyType {
- get {
- return typeof(String);
- }
- }
-
- public override bool CanResetValue(object component)
- {
- return false;
- }
-
- ///
- /// Gets the value of the xml attribute.
- ///
- public override object GetValue(object component)
- {
- return xmlAttribute.Value;
- }
-
- public override void ResetValue(object component)
- {
- }
-
- ///
- /// Sets the xml attribute value.
- ///
- public override void SetValue(object component, object value)
- {
- xmlAttribute.Value = (String)value;
- }
-
- ///
- /// If the current value has changed from the default value then this
- /// method will return true.
- ///
- public override bool ShouldSerializeValue(object component)
- {
- return true;
- }
- }
-}
diff --git a/src/AddIns/DisplayBindings/XmlEditor/Project/Src/Src/XmlAttributeTypeDescriptor.cs b/src/AddIns/DisplayBindings/XmlEditor/Project/Src/Src/XmlAttributeTypeDescriptor.cs
deleted file mode 100644
index 18a13f171b..0000000000
--- a/src/AddIns/DisplayBindings/XmlEditor/Project/Src/Src/XmlAttributeTypeDescriptor.cs
+++ /dev/null
@@ -1,94 +0,0 @@
-//
-//
-//
-//
-// $Revision: 1965 $
-//
-
-using System;
-using System.ComponentModel;
-using System.Xml;
-
-namespace ICSharpCode.XmlEditor
-{
- ///
- /// Type descriptor that allows us to display properties in the property grid
- /// for Xml attributes.
- ///
- 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;
- }
-
- ///
- /// Returns this class instance.
- ///
- public object GetPropertyOwner(PropertyDescriptor pd)
- {
- return this;
- }
- }
-}
diff --git a/src/AddIns/DisplayBindings/XmlEditor/Project/Src/Src/XmlCharacterDataTreeNode.cs b/src/AddIns/DisplayBindings/XmlEditor/Project/Src/Src/XmlCharacterDataTreeNode.cs
deleted file mode 100644
index 829b99fe33..0000000000
--- a/src/AddIns/DisplayBindings/XmlEditor/Project/Src/Src/XmlCharacterDataTreeNode.cs
+++ /dev/null
@@ -1,60 +0,0 @@
-//
-//
-//
-//
-// $Revision: 2128 $
-//
-
-using System;
-using System.Xml;
-using ICSharpCode.SharpDevelop.Gui;
-
-namespace ICSharpCode.XmlEditor
-{
- ///
- /// Base class for XmlTextTreeNodes and XmlCommentTreeNodes
- ///
- public abstract class XmlCharacterDataTreeNode : ExtTreeNode
- {
- XmlCharacterData characterData;
-
- public XmlCharacterDataTreeNode(XmlCharacterData characterData)
- {
- this.characterData = characterData;
- }
-
- ///
- /// Updates the display text based on changes in the
- /// XmlCharacterData's InnerText associated with this node.
- ///
- public void Update()
- {
- Text = GetDisplayText(characterData.InnerText);
- }
-
- ///
- /// Gets the text to display for this tree node.
- ///
- /// 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.
- 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;
- }
- }
-}
diff --git a/src/AddIns/DisplayBindings/XmlEditor/Project/Src/Src/XmlCommentTreeNode.cs b/src/AddIns/DisplayBindings/XmlEditor/Project/Src/Src/XmlCommentTreeNode.cs
deleted file mode 100644
index c4fe5a7661..0000000000
--- a/src/AddIns/DisplayBindings/XmlEditor/Project/Src/Src/XmlCommentTreeNode.cs
+++ /dev/null
@@ -1,60 +0,0 @@
-//
-//
-//
-//
-// $Revision: 2164 $
-//
-
-using System;
-using System.Xml;
-using ICSharpCode.SharpDevelop.Gui;
-
-namespace ICSharpCode.XmlEditor
-{
- ///
- /// Represents an xml comment in the tree.
- ///
- 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();
- }
-
- ///
- /// Gets the XmlComment associated with this tree node.
- ///
- public XmlComment XmlComment {
- get {
- return comment;
- }
- }
-
- ///
- /// Gets or sets whether to show the ghost image which is
- /// displayed when cutting the node.
- ///
- public bool ShowGhostImage {
- get {
- return ImageKey == XmlCommentTreeNodeGhostImageKey;
- }
- set {
- if (value) {
- ImageKey = XmlCommentTreeNodeGhostImageKey;
- } else {
- ImageKey = XmlCommentTreeNodeImageKey;
- }
- SelectedImageKey = ImageKey;
- }
- }
- }
-}
diff --git a/src/AddIns/DisplayBindings/XmlEditor/Project/Src/Src/XmlEditorAddInOptions.cs b/src/AddIns/DisplayBindings/XmlEditor/Project/Src/Src/XmlEditorAddInOptions.cs
deleted file mode 100644
index 9a442d416d..0000000000
--- a/src/AddIns/DisplayBindings/XmlEditor/Project/Src/Src/XmlEditorAddInOptions.cs
+++ /dev/null
@@ -1,119 +0,0 @@
-//
-//
-//
-//
-// $Revision: 1965 $
-//
-
-using System;
-using System.Diagnostics;
-using ICSharpCode.Core;
-
-namespace ICSharpCode.XmlEditor
-{
- ///
- /// The Xml Editor add-in options.
- ///
- 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
- ///
- /// Gets an association between a schema and a file extension.
- ///
- ///
- /// 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.
- /// 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.
- /// 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.
- ///
- /// 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.
- /// 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.
- ///
- 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
- }
-}
diff --git a/src/AddIns/DisplayBindings/XmlEditor/Project/Src/Src/XmlElementTreeNode.cs b/src/AddIns/DisplayBindings/XmlEditor/Project/Src/Src/XmlElementTreeNode.cs
deleted file mode 100644
index 2c932c066c..0000000000
--- a/src/AddIns/DisplayBindings/XmlEditor/Project/Src/Src/XmlElementTreeNode.cs
+++ /dev/null
@@ -1,99 +0,0 @@
-//
-//
-//
-//
-// $Revision: 2164 $
-//
-
-using System;
-using System.Xml;
-using ICSharpCode.SharpDevelop.Gui;
-
-namespace ICSharpCode.XmlEditor
-{
- ///
- /// Represents an XmlElement in the Xml Tree.
- ///
- 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());
- }
- }
-
- ///
- /// Gets the XmlElement associated with this tree node.
- ///
- public XmlElement XmlElement {
- get {
- return element;
- }
- }
-
- ///
- /// Gets or sets whether to show the ghost image which is
- /// displayed when cutting the node.
- ///
- public bool ShowGhostImage {
- get {
- return ImageKey == XmlElementTreeNodeGhostImageKey;
- }
- set {
- if (value) {
- ImageKey = XmlElementTreeNodeGhostImageKey;
- } else {
- ImageKey = XmlElementTreeNodeImageKey;
- }
- SelectedImageKey = ImageKey;
- }
- }
-
- ///
- /// Adds child elements to this tree node.
- ///
- 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);
- }
- }
- }
-
- ///
- /// Gets the tree node's text for the element.
- ///
- static string GetDisplayText(XmlElement element)
- {
- if (element.Prefix.Length > 0) {
- return String.Concat(element.Prefix, ":", element.LocalName);
- }
- return element.LocalName;
- }
- }
-}
diff --git a/src/AddIns/DisplayBindings/XmlEditor/Project/Src/Src/XmlSchemaAssociation.cs b/src/AddIns/DisplayBindings/XmlEditor/Project/Src/Src/XmlSchemaAssociation.cs
deleted file mode 100644
index cda6484e9b..0000000000
--- a/src/AddIns/DisplayBindings/XmlEditor/Project/Src/Src/XmlSchemaAssociation.cs
+++ /dev/null
@@ -1,157 +0,0 @@
-//
-//
-//
-//
-// $Revision: 1965 $
-//
-
-using System;
-
-namespace ICSharpCode.XmlEditor
-{
- ///
- /// Represents an association between an xml schema and a file extension.
- ///
- 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;
- }
- }
-
- ///
- /// Gets or sets the file extension (e.g. '.xml').
- ///
- public string Extension {
- get {
- return extension;
- }
-
- set {
- extension = value;
- }
- }
-
- ///
- /// Gets or sets the default namespace prefix that will be added
- /// to the xml elements.
- ///
- public string NamespacePrefix {
- get {
- return namespacePrefix;
- }
-
- set {
- namespacePrefix = value;
- }
- }
-
- ///
- /// Gets the default schema association for the file extension.
- ///
- ///
- /// These defaults are hard coded.
- ///
- 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;
- }
-
- ///
- /// Two schema associations are considered equal if their file extension,
- /// prefix and namespaceUri are the same.
- ///
- 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);
- }
-
- ///
- /// Creates an XmlSchemaAssociation from the saved xml.
- ///
- 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;
- }
- }
-}
diff --git a/src/AddIns/DisplayBindings/XmlEditor/Project/Src/Src/XmlSchemaAssociationListBoxItem.cs b/src/AddIns/DisplayBindings/XmlEditor/Project/Src/Src/XmlSchemaAssociationListBoxItem.cs
deleted file mode 100644
index 73c61175ff..0000000000
--- a/src/AddIns/DisplayBindings/XmlEditor/Project/Src/Src/XmlSchemaAssociationListBoxItem.cs
+++ /dev/null
@@ -1,89 +0,0 @@
-//
-//
-//
-//
-// $Revision: 1965 $
-//
-
-using System;
-
-namespace ICSharpCode.XmlEditor
-{
- ///
- /// Represents list box item showing the association between an xml schema
- /// and a file extension.
- ///
- 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;
- }
-
- ///
- /// Gets or sets whether this association has been changed by the user.
- ///
- public bool IsDirty {
- get {
- return isDirty;
- }
-
- set {
- isDirty = value;
- }
- }
-
- public string NamespaceUri {
- get {
- return namespaceUri;
- }
-
- set {
- namespaceUri = value;
- }
- }
-
- ///
- /// Gets or sets the file extension (e.g. '.xml').
- ///
- public string Extension {
- get {
- return extension;
- }
-
- set {
- extension = value;
- }
- }
-
- ///
- /// Gets or sets the default namespace prefix that will be added
- /// to the xml elements.
- ///
- public string NamespacePrefix {
- get {
- return namespacePrefix;
- }
-
- set {
- namespacePrefix = value;
- }
- }
-
- ///
- /// Returns the file extension so this can be sorted in a list box.
- ///
- ///
- public override string ToString()
- {
- return extension;
- }
- }
-}
diff --git a/src/AddIns/DisplayBindings/XmlEditor/Project/Src/Src/XmlSchemaCompletionData.cs b/src/AddIns/DisplayBindings/XmlEditor/Project/Src/Src/XmlSchemaCompletionData.cs
deleted file mode 100644
index 5f9e4c9304..0000000000
--- a/src/AddIns/DisplayBindings/XmlEditor/Project/Src/Src/XmlSchemaCompletionData.cs
+++ /dev/null
@@ -1,1352 +0,0 @@
-//
-//
-//
-//
-// $Revision: 1965 $
-//
-
-using ICSharpCode.XmlBinding;
-using System;
-using System.IO;
-using System.Text;
-using System.Xml;
-using System.Xml.Schema;
-using ICSharpCode.SharpDevelop.Editor;
-using ICSharpCode.XmlBinding.Parser;
-
-namespace ICSharpCode.XmlEditor
-{
- ///
- /// Holds the completion (intellisense) data for an xml schema.
- ///
- ///
- /// The XmlSchema class throws an exception if we attempt to load
- /// the xhtml1-strict.xsd schema. It does not like the fact that
- /// this schema redefines the xml namespace, even though this is
- /// allowed by the w3.org specification.
- ///
- public class XmlSchemaCompletionData
- {
- string namespaceUri = String.Empty;
- XmlSchema schema;
- string fileName = String.Empty;
- bool readOnly = false;
-
- ///
- /// Stores attributes that have been prohibited whilst the code
- /// generates the attribute completion data.
- ///
- XmlSchemaObjectCollection prohibitedAttributes = new XmlSchemaObjectCollection();
-
- public XmlSchemaCompletionData()
- {
- }
-
- ///
- /// Creates completion data from the schema passed in
- /// via the reader object.
- ///
- public XmlSchemaCompletionData(TextReader reader)
- {
- ReadSchema(String.Empty, reader);
- }
-
- ///
- /// Creates completion data from the schema passed in
- /// via the reader object.
- ///
- public XmlSchemaCompletionData(XmlTextReader reader)
- {
- reader.XmlResolver = null;
- ReadSchema(reader);
- }
-
- ///
- /// Creates the completion data from the specified schema file.
- ///
- public XmlSchemaCompletionData(string fileName) : this(String.Empty, fileName)
- {
- }
-
- ///
- /// Creates the completion data from the specified schema file and uses
- /// the specified baseUri to resolve any referenced schemas.
- ///
- public XmlSchemaCompletionData(string baseUri, string fileName)
- {
- StreamReader reader = new StreamReader(fileName, true);
- ReadSchema(baseUri, reader);
- this.fileName = fileName;
- }
-
- ///
- /// Gets the schema.
- ///
- public XmlSchema Schema {
- get {
- return schema;
- }
- }
-
- ///
- /// Read only schemas are those that are installed with
- /// SharpDevelop.
- ///
- public bool ReadOnly {
- get {
- return readOnly;
- }
-
- set {
- readOnly = value;
- }
- }
-
- ///
- /// Gets or sets the schema's file name.
- ///
- public string FileName {
- get {
- return fileName;
- }
- set {
- fileName = value;
- }
- }
-
- ///
- /// Gets the namespace URI for the schema.
- ///
- public string NamespaceUri {
- get {
- return namespaceUri;
- }
- }
-
- ///
- /// Converts the filename into a valid Uri.
- ///
- public static string GetUri(string fileName)
- {
- string uri = String.Empty;
-
- if (fileName != null) {
- if (fileName.Length > 0) {
- uri = String.Concat("file:///", fileName.Replace('\\', '/'));
- }
- }
-
- return uri;
- }
-
- ///
- /// Gets the possible root elements for an xml document using this schema.
- ///
- public ICompletionItemList GetElementCompletionData()
- {
- return GetElementCompletionData(String.Empty);
- }
-
- ///
- /// Gets the possible root elements for an xml document using this schema.
- ///
- public ICompletionItemList GetElementCompletionData(string namespacePrefix)
- {
- XmlCompletionItemCollection data = new XmlCompletionItemCollection();
-
- foreach (XmlSchemaElement element in schema.Elements.Values) {
- if (element.Name != null) {
- AddElement(data, element.Name, namespacePrefix, element.Annotation);
- } else {
- // Do not add reference element.
- }
- }
-
- var list = new XmlCompletionItemList();
- list.Items.AddRange(data.ToArray());
- list.SortItems();
-
- return list;
- }
-
- ///
- /// Gets the attribute completion data for the xml element that exists
- /// at the end of the specified path.
- ///
- public ICompletionItem[] GetAttributeCompletionData(XmlElementPath path)
- {
- XmlCompletionItemCollection data = new XmlCompletionItemCollection();
-
- // Locate matching element.
- XmlSchemaElement element = FindElement(path);
-
- // Get completion data.
- if (element != null) {
- prohibitedAttributes.Clear();
- data = GetAttributeCompletionData(element);
- }
-
- return data.ToArray();
- }
-
- ///
- /// Gets the child element completion data for the xml element that exists
- /// at the end of the specified path.
- ///
- public ICompletionItem[] GetChildElementCompletionData(XmlElementPath path)
- {
- XmlCompletionItemCollection data = new XmlCompletionItemCollection();
-
- // Locate matching element.
- XmlSchemaElement element = FindElement(path);
-
- // Get completion data.
- if (element != null) {
- data = GetChildElementCompletionData(element, path.Elements.LastPrefix);
- }
-
- return data.ToArray();
- }
-
- ///
- /// Gets the autocomplete data for the specified attribute value.
- ///
- public ICompletionItem[] GetAttributeValueCompletionData(XmlElementPath path, string name)
- {
- XmlCompletionItemCollection data = new XmlCompletionItemCollection();
-
- // Locate matching element.
- XmlSchemaElement element = FindElement(path);
-
- // Get completion data.
- if (element != null) {
- data = GetAttributeValueCompletionData(element, name);
- }
-
- return data.ToArray();
- }
-
- ///
- /// Finds the element that exists at the specified path.
- ///
- /// This method is not used when generating completion data,
- /// but is a useful method when locating an element so we can jump
- /// to its schema definition.
- /// if no element can be found.
- public XmlSchemaElement FindElement(XmlElementPath path)
- {
- XmlSchemaElement element = null;
- for (int i = 0; i < path.Elements.Count; ++i) {
- QualifiedName name = path.Elements[i];
- if (i == 0) {
- // Look for root element.
- element = FindElement(name);
- if (element == null) {
- break;
- }
- } else {
- element = FindChildElement(element, name);
- if (element == null) {
- break;
- }
- }
- }
- return element;
- }
-
- ///
- /// Finds an element in the schema.
- ///
- ///
- /// Only looks at the elements that are defined in the
- /// root of the schema so it will not find any elements
- /// that are defined inside any complex types.
- ///
- public XmlSchemaElement FindElement(QualifiedName name)
- {
- foreach (XmlSchemaElement element in schema.Elements.Values) {
- if (name.Equals(element.QualifiedName)) {
- return element;
- }
- }
- return null;
- }
-
- ///
- /// Finds the complex type with the specified name.
- ///
- public XmlSchemaComplexType FindComplexType(QualifiedName name)
- {
- XmlQualifiedName qualifiedName = new XmlQualifiedName(name.Name, name.Namespace);
- return FindNamedType(schema, qualifiedName);
- }
-
- ///
- /// Finds the specified attribute name given the element.
- ///
- /// This method is not used when generating completion data,
- /// but is a useful method when locating an attribute so we can jump
- /// to its schema definition.
- /// if no attribute can be found.
- public XmlSchemaAttribute FindAttribute(XmlSchemaElement element, string name)
- {
- XmlSchemaAttribute attribute = null;
- XmlSchemaComplexType complexType = GetElementAsComplexType(element);
- if (complexType != null) {
- attribute = FindAttribute(complexType, name);
- }
- return attribute;
- }
-
- ///
- /// Finds the attribute group with the specified name.
- ///
- public XmlSchemaAttributeGroup FindAttributeGroup(string name)
- {
- return FindAttributeGroup(schema, name);
- }
-
- ///
- /// Finds the simple type with the specified name.
- ///
- public XmlSchemaSimpleType FindSimpleType(string name)
- {
- XmlQualifiedName qualifiedName = new XmlQualifiedName(name, namespaceUri);
- return FindSimpleType(qualifiedName);
- }
-
- ///
- /// Finds the specified attribute in the schema. This method only checks
- /// the attributes defined in the root of the schema.
- ///
- public XmlSchemaAttribute FindAttribute(string name)
- {
- foreach (XmlSchemaAttribute attribute in schema.Attributes.Values) {
- if (attribute.Name == name) {
- return attribute;
- }
- }
- return null;
- }
-
- ///
- /// Finds the schema group with the specified name.
- ///
- public XmlSchemaGroup FindGroup(string name)
- {
- if (name != null) {
- foreach (XmlSchemaObject schemaObject in schema.Groups.Values) {
- XmlSchemaGroup group = schemaObject as XmlSchemaGroup;
- if (group != null) {
- if (group.Name == name) {
- return group;
- }
- }
- }
- }
- return null;
- }
-
- ///
- /// Takes the name and creates a qualified name using the namespace of this
- /// schema.
- ///
- /// If the name is of the form myprefix:mytype then the correct
- /// namespace is determined from the prefix. If the name is not of this
- /// form then no prefix is added.
- public QualifiedName CreateQualifiedName(string name)
- {
- int index = name.IndexOf(":");
- if (index >= 0) {
- string prefix = name.Substring(0, index);
- name = name.Substring(index + 1);
- foreach (XmlQualifiedName xmlQualifiedName in schema.Namespaces.ToArray()) {
- if (xmlQualifiedName.Name == prefix) {
- return new QualifiedName(name, xmlQualifiedName.Namespace, prefix);
- }
- }
- }
-
- // Default behaviour just return the name with the namespace uri.
- return new QualifiedName(name, namespaceUri);
- }
-
- ///
- /// Converts the element to a complex type if possible.
- ///
- public XmlSchemaComplexType GetElementAsComplexType(XmlSchemaElement element)
- {
- XmlSchemaComplexType complexType = element.SchemaType as XmlSchemaComplexType;
- if (complexType == null) {
- complexType = FindNamedType(schema, element.SchemaTypeName);
- }
- return complexType;
- }
-
- ///
- /// Handler for schema validation errors.
- ///
- void SchemaValidation(object source, ValidationEventArgs e)
- {
- // Do nothing.
- }
-
- ///
- /// Loads the schema.
- ///
- void ReadSchema(XmlReader reader)
- {
- try {
- schema = XmlSchema.Read(reader, new ValidationEventHandler(SchemaValidation));
- schema.Compile(new ValidationEventHandler(SchemaValidation));
-
- namespaceUri = schema.TargetNamespace;
- } finally {
- reader.Close();
- }
- }
-
- void ReadSchema(string baseUri, TextReader reader)
- {
- XmlTextReader xmlReader = new XmlTextReader(baseUri, reader);
-
- // Setting the resolver to null allows us to
- // load the xhtml1-strict.xsd without any exceptions if
- // the referenced dtds exist in the same folder as the .xsd
- // file. If this is not set to null the dtd files are looked
- // for in the assembly's folder.
- xmlReader.XmlResolver = null;
- ReadSchema(xmlReader);
- }
-
- ///
- /// Finds an element in the schema.
- ///
- ///
- /// Only looks at the elements that are defined in the
- /// root of the schema so it will not find any elements
- /// that are defined inside any complex types.
- ///
- XmlSchemaElement FindElement(XmlQualifiedName name)
- {
- XmlSchemaElement matchedElement = null;
- foreach (XmlSchemaElement element in schema.Elements.Values) {
- if (name.Equals(element.QualifiedName)) {
- matchedElement = element;
- break;
- }
- }
-
- return matchedElement;
- }
-
- XmlCompletionItemCollection GetChildElementCompletionData(XmlSchemaElement element, string prefix)
- {
- XmlCompletionItemCollection data = new XmlCompletionItemCollection();
-
- XmlSchemaComplexType complexType = GetElementAsComplexType(element);
-
- if (complexType != null) {
- data = GetChildElementCompletionData(complexType, prefix);
- }
-
- return data;
- }
-
- XmlCompletionItemCollection GetChildElementCompletionData(XmlSchemaComplexType complexType, string prefix)
- {
- XmlCompletionItemCollection data = new XmlCompletionItemCollection();
-
- XmlSchemaSequence sequence = complexType.Particle as XmlSchemaSequence;
- XmlSchemaChoice choice = complexType.Particle as XmlSchemaChoice;
- XmlSchemaGroupRef groupRef = complexType.Particle as XmlSchemaGroupRef;
- XmlSchemaComplexContent complexContent = complexType.ContentModel as XmlSchemaComplexContent;
- XmlSchemaAll all = complexType.Particle as XmlSchemaAll;
-
- if (sequence != null) {
- data = GetChildElementCompletionData(sequence.Items, prefix);
- } else if (choice != null) {
- data = GetChildElementCompletionData(choice.Items, prefix);
- } else if (complexContent != null) {
- data = GetChildElementCompletionData(complexContent, prefix);
- } else if (groupRef != null) {
- data = GetChildElementCompletionData(groupRef, prefix);
- } else if (all != null) {
- data = GetChildElementCompletionData(all.Items, prefix);
- }
-
- return data;
- }
-
- XmlCompletionItemCollection GetChildElementCompletionData(XmlSchemaObjectCollection items, string prefix)
- {
- XmlCompletionItemCollection data = new XmlCompletionItemCollection();
-
- foreach (XmlSchemaObject schemaObject in items) {
-
- XmlSchemaElement childElement = schemaObject as XmlSchemaElement;
- XmlSchemaSequence childSequence = schemaObject as XmlSchemaSequence;
- XmlSchemaChoice childChoice = schemaObject as XmlSchemaChoice;
- XmlSchemaGroupRef groupRef = schemaObject as XmlSchemaGroupRef;
-
- if (childElement != null) {
- string name = childElement.Name;
- if (name == null) {
- name = childElement.RefName.Name;
- XmlSchemaElement element = FindElement(childElement.RefName);
- if (element != null) {
- if (element.IsAbstract) {
- AddSubstitionGroupElements(data, element.QualifiedName, prefix);
- } else {
- AddElement(data, name, prefix, element.Annotation);
- }
- } else {
- AddElement(data, name, prefix, childElement.Annotation);
- }
- } else {
- AddElement(data, name, prefix, childElement.Annotation);
- }
- } else if (childSequence != null) {
- AddElements(data, GetChildElementCompletionData(childSequence.Items, prefix));
- } else if (childChoice != null) {
- AddElements(data, GetChildElementCompletionData(childChoice.Items, prefix));
- } else if (groupRef != null) {
- AddElements(data, GetChildElementCompletionData(groupRef, prefix));
- }
- }
-
- return data;
- }
-
- XmlCompletionItemCollection GetChildElementCompletionData(XmlSchemaComplexContent complexContent, string prefix)
- {
- XmlCompletionItemCollection data = new XmlCompletionItemCollection();
-
- XmlSchemaComplexContentExtension extension = complexContent.Content as XmlSchemaComplexContentExtension;
- if (extension != null) {
- data = GetChildElementCompletionData(extension, prefix);
- } else {
- XmlSchemaComplexContentRestriction restriction = complexContent.Content as XmlSchemaComplexContentRestriction;
- if (restriction != null) {
- data = GetChildElementCompletionData(restriction, prefix);
- }
- }
-
- return data;
- }
-
- XmlCompletionItemCollection GetChildElementCompletionData(XmlSchemaComplexContentExtension extension, string prefix)
- {
- XmlCompletionItemCollection data = new XmlCompletionItemCollection();
-
- XmlSchemaComplexType complexType = FindNamedType(schema, extension.BaseTypeName);
- if (complexType != null) {
- data = GetChildElementCompletionData(complexType, prefix);
- }
-
- // Add any elements.
- if (extension.Particle != null) {
- XmlSchemaSequence sequence = extension.Particle as XmlSchemaSequence;
- XmlSchemaChoice choice = extension.Particle as XmlSchemaChoice;
- XmlSchemaGroupRef groupRef = extension.Particle as XmlSchemaGroupRef;
-
- if(sequence != null) {
- data.AddRange(GetChildElementCompletionData(sequence.Items, prefix));
- } else if (choice != null) {
- data.AddRange(GetChildElementCompletionData(choice.Items, prefix));
- } else if (groupRef != null) {
- data.AddRange(GetChildElementCompletionData(groupRef, prefix));
- }
- }
-
- return data;
- }
-
- XmlCompletionItemCollection GetChildElementCompletionData(XmlSchemaGroupRef groupRef, string prefix)
- {
- XmlCompletionItemCollection data = new XmlCompletionItemCollection();
-
- XmlSchemaGroup group = FindGroup(groupRef.RefName.Name);
- if (group != null) {
- XmlSchemaSequence sequence = group.Particle as XmlSchemaSequence;
- XmlSchemaChoice choice = group.Particle as XmlSchemaChoice;
-
- if(sequence != null) {
- data = GetChildElementCompletionData(sequence.Items, prefix);
- } else if (choice != null) {
- data = GetChildElementCompletionData(choice.Items, prefix);
- }
- }
-
- return data;
- }
-
- XmlCompletionItemCollection GetChildElementCompletionData(XmlSchemaComplexContentRestriction restriction, string prefix)
- {
- XmlCompletionItemCollection data = new XmlCompletionItemCollection();
-
- // Add any elements.
- if (restriction.Particle != null) {
- XmlSchemaSequence sequence = restriction.Particle as XmlSchemaSequence;
- XmlSchemaChoice choice = restriction.Particle as XmlSchemaChoice;
- XmlSchemaGroupRef groupRef = restriction.Particle as XmlSchemaGroupRef;
-
- if(sequence != null) {
- data = GetChildElementCompletionData(sequence.Items, prefix);
- } else if (choice != null) {
- data = GetChildElementCompletionData(choice.Items, prefix);
- } else if (groupRef != null) {
- data = GetChildElementCompletionData(groupRef, prefix);
- }
- }
-
- return data;
- }
-
- ///
- /// Adds an element completion data to the collection if it does not
- /// already exist.
- ///
- void AddElement(XmlCompletionItemCollection data, string name, string prefix, string documentation)
- {
- if (!data.Contains(name)) {
- if (prefix.Length > 0) {
- name = String.Concat(prefix, ":", name);
- }
- XmlCompletionItem item = new XmlCompletionItem(name, documentation);
- data.Add(item);
- }
- }
-
- ///
- /// Adds an element completion data to the collection if it does not
- /// already exist.
- ///
- void AddElement(XmlCompletionItemCollection data, string name, string prefix, XmlSchemaAnnotation annotation)
- {
- // Get any annotation documentation.
- string documentation = GetDocumentation(annotation);
-
- AddElement(data, name, prefix, documentation);
- }
-
- ///
- /// Adds elements to the collection if it does not already exist.
- ///
- void AddElements(XmlCompletionItemCollection lhs, XmlCompletionItemCollection rhs)
- {
- foreach (XmlCompletionItem data in rhs) {
- if (!lhs.Contains(data)) {
- lhs.Add(data);
- }
- }
- }
-
- ///
- /// Gets the documentation from the annotation element.
- ///
- ///
- /// All documentation elements are added. All text nodes inside
- /// the documentation element are added.
- ///
- string GetDocumentation(XmlSchemaAnnotation annotation)
- {
- string documentation = String.Empty;
-
- if (annotation != null) {
- StringBuilder documentationBuilder = new StringBuilder();
- foreach (XmlSchemaObject schemaObject in annotation.Items) {
- XmlSchemaDocumentation schemaDocumentation = schemaObject as XmlSchemaDocumentation;
- if (schemaDocumentation != null) {
- foreach (XmlNode node in schemaDocumentation.Markup) {
- XmlText textNode = node as XmlText;
- if (textNode != null) {
- if (textNode.Data != null) {
- if (textNode.Data.Length > 0) {
- documentationBuilder.Append(textNode.Data);
- }
- }
- }
- }
- }
- }
-
- documentation = documentationBuilder.ToString();
- }
-
- return documentation;
- }
-
- XmlCompletionItemCollection GetAttributeCompletionData(XmlSchemaElement element)
- {
- XmlCompletionItemCollection data = new XmlCompletionItemCollection();
-
- XmlSchemaComplexType complexType = GetElementAsComplexType(element);
-
- if (complexType != null) {
- data.AddRange(GetAttributeCompletionData(complexType));
- }
-
- return data;
- }
-
- XmlCompletionItemCollection GetAttributeCompletionData(XmlSchemaComplexContentRestriction restriction)
- {
- XmlCompletionItemCollection data = new XmlCompletionItemCollection();
-
- data.AddRange(GetAttributeCompletionData(restriction.Attributes));
-
- XmlSchemaComplexType baseComplexType = FindNamedType(schema, restriction.BaseTypeName);
- if (baseComplexType != null) {
- data.AddRange(GetAttributeCompletionData(baseComplexType));
- }
-
- return data;
- }
-
- XmlCompletionItemCollection GetAttributeCompletionData(XmlSchemaComplexType complexType)
- {
- XmlCompletionItemCollection data = new XmlCompletionItemCollection();
-
- data = GetAttributeCompletionData(complexType.Attributes);
-
- // Add any complex content attributes.
- XmlSchemaComplexContent complexContent = complexType.ContentModel as XmlSchemaComplexContent;
- if (complexContent != null) {
- XmlSchemaComplexContentExtension extension = complexContent.Content as XmlSchemaComplexContentExtension;
- XmlSchemaComplexContentRestriction restriction = complexContent.Content as XmlSchemaComplexContentRestriction;
- if (extension != null) {
- data.AddRange(GetAttributeCompletionData(extension));
- } else if (restriction != null) {
- data.AddRange(GetAttributeCompletionData(restriction));
- }
- } else {
- XmlSchemaSimpleContent simpleContent = complexType.ContentModel as XmlSchemaSimpleContent;
- if (simpleContent != null) {
- data.AddRange(GetAttributeCompletionData(simpleContent));
- }
- }
-
- return data;
- }
-
- XmlCompletionItemCollection GetAttributeCompletionData(XmlSchemaComplexContentExtension extension)
- {
- XmlCompletionItemCollection data = new XmlCompletionItemCollection();
-
- data.AddRange(GetAttributeCompletionData(extension.Attributes));
- XmlSchemaComplexType baseComplexType = FindNamedType(schema, extension.BaseTypeName);
- if (baseComplexType != null) {
- data.AddRange(GetAttributeCompletionData(baseComplexType));
- }
-
- return data;
- }
-
- XmlCompletionItemCollection GetAttributeCompletionData(XmlSchemaSimpleContent simpleContent)
- {
- XmlCompletionItemCollection data = new XmlCompletionItemCollection();
-
- XmlSchemaSimpleContentExtension extension = simpleContent.Content as XmlSchemaSimpleContentExtension;
- if (extension != null) {
- data.AddRange(GetAttributeCompletionData(extension));
- }
-
- return data;
- }
-
- XmlCompletionItemCollection GetAttributeCompletionData(XmlSchemaSimpleContentExtension extension)
- {
- XmlCompletionItemCollection data = new XmlCompletionItemCollection();
-
- data.AddRange(GetAttributeCompletionData(extension.Attributes));
-
- return data;
- }
-
- XmlCompletionItemCollection GetAttributeCompletionData(XmlSchemaObjectCollection attributes)
- {
- XmlCompletionItemCollection data = new XmlCompletionItemCollection();
-
- foreach (XmlSchemaObject schemaObject in attributes) {
- XmlSchemaAttribute attribute = schemaObject as XmlSchemaAttribute;
- XmlSchemaAttributeGroupRef attributeGroupRef = schemaObject as XmlSchemaAttributeGroupRef;
- if (attribute != null) {
- if (!IsProhibitedAttribute(attribute)) {
- AddAttribute(data, attribute);
- } else {
- prohibitedAttributes.Add(attribute);
- }
- } else if (attributeGroupRef != null) {
- data.AddRange(GetAttributeCompletionData(attributeGroupRef));
- }
- }
- return data;
- }
-
- ///
- /// Checks that the attribute is prohibited or has been flagged
- /// as prohibited previously.
- ///
- bool IsProhibitedAttribute(XmlSchemaAttribute attribute)
- {
- bool prohibited = false;
- if (attribute.Use == XmlSchemaUse.Prohibited) {
- prohibited = true;
- } else {
- foreach (XmlSchemaAttribute prohibitedAttribute in prohibitedAttributes) {
- if (prohibitedAttribute.QualifiedName == attribute.QualifiedName) {
- prohibited = true;
- break;
- }
- }
- }
-
- return prohibited;
- }
-
- ///
- /// Adds an attribute to the completion data collection.
- ///
- ///
- /// Note the special handling of xml:lang attributes.
- ///
- void AddAttribute(XmlCompletionItemCollection data, XmlSchemaAttribute attribute)
- {
- string name = attribute.Name;
- if (name == null) {
- if (attribute.RefName.Namespace == "http://www.w3.org/XML/1998/namespace") {
- name = String.Concat("xml:", attribute.RefName.Name);
- }
- }
-
- if (name != null) {
- string documentation = GetDocumentation(attribute.Annotation);
- XmlCompletionItem completionData = new XmlCompletionItem(name, documentation, XmlCompletionItem.DataType.XmlAttribute);
- data.Add(completionData);
- }
- }
-
- ///
- /// Gets attribute completion data from a group ref.
- ///
- XmlCompletionItemCollection GetAttributeCompletionData(XmlSchemaAttributeGroupRef groupRef)
- {
- XmlCompletionItemCollection data = new XmlCompletionItemCollection();
- XmlSchemaAttributeGroup group = FindAttributeGroup(schema, groupRef.RefName.Name);
- if (group != null) {
- data = GetAttributeCompletionData(group.Attributes);
- }
-
- return data;
- }
-
- static XmlSchemaComplexType FindNamedType(XmlSchema schema, XmlQualifiedName name)
- {
- XmlSchemaComplexType matchedComplexType = null;
-
- if (name != null) {
- foreach (XmlSchemaObject schemaObject in schema.Items) {
- XmlSchemaComplexType complexType = schemaObject as XmlSchemaComplexType;
- if (complexType != null) {
- if (complexType.QualifiedName == name) {
- matchedComplexType = complexType;
- break;
- }
- }
- }
-
- // Try included schemas.
- if (matchedComplexType == null) {
- foreach (XmlSchemaExternal external in schema.Includes) {
- XmlSchemaInclude include = external as XmlSchemaInclude;
- if (include != null) {
- if (include.Schema != null) {
- matchedComplexType = FindNamedType(include.Schema, name);
- }
- }
- }
- }
- }
-
- return matchedComplexType;
- }
-
- ///
- /// Finds an element that matches the specified
- /// from the children of the given .
- ///
- XmlSchemaElement FindChildElement(XmlSchemaElement element, QualifiedName name)
- {
- XmlSchemaElement matchedElement = null;
-
- XmlSchemaComplexType complexType = GetElementAsComplexType(element);
- if (complexType != null) {
- matchedElement = FindChildElement(complexType, name);
- }
-
- return matchedElement;
- }
-
- XmlSchemaElement FindChildElement(XmlSchemaComplexType complexType, QualifiedName name)
- {
- XmlSchemaElement matchedElement = null;
-
- XmlSchemaSequence sequence = complexType.Particle as XmlSchemaSequence;
- XmlSchemaChoice choice = complexType.Particle as XmlSchemaChoice;
- XmlSchemaGroupRef groupRef = complexType.Particle as XmlSchemaGroupRef;
- XmlSchemaAll all = complexType.Particle as XmlSchemaAll;
- XmlSchemaComplexContent complexContent = complexType.ContentModel as XmlSchemaComplexContent;
-
- if (sequence != null) {
- matchedElement = FindElement(sequence.Items, name);
- } else if (choice != null) {
- matchedElement = FindElement(choice.Items, name);
- } else if (complexContent != null) {
- XmlSchemaComplexContentExtension extension = complexContent.Content as XmlSchemaComplexContentExtension;
- XmlSchemaComplexContentRestriction restriction = complexContent.Content as XmlSchemaComplexContentRestriction;
- if (extension != null) {
- matchedElement = FindChildElement(extension, name);
- } else if (restriction != null) {
- matchedElement = FindChildElement(restriction, name);
- }
- } else if (groupRef != null) {
- matchedElement = FindElement(groupRef, name);
- } else if (all != null) {
- matchedElement = FindElement(all.Items, name);
- }
-
- return matchedElement;
- }
-
- ///
- /// Finds the named child element contained in the extension element.
- ///
- XmlSchemaElement FindChildElement(XmlSchemaComplexContentExtension extension, QualifiedName name)
- {
- XmlSchemaElement matchedElement = null;
-
- XmlSchemaComplexType complexType = FindNamedType(schema, extension.BaseTypeName);
- if (complexType != null) {
- matchedElement = FindChildElement(complexType, name);
-
- if (matchedElement == null) {
-
- XmlSchemaSequence sequence = extension.Particle as XmlSchemaSequence;
- XmlSchemaChoice choice = extension.Particle as XmlSchemaChoice;
- XmlSchemaGroupRef groupRef = extension.Particle as XmlSchemaGroupRef;
-
- if (sequence != null) {
- matchedElement = FindElement(sequence.Items, name);
- } else if (choice != null) {
- matchedElement = FindElement(choice.Items, name);
- } else if (groupRef != null) {
- matchedElement = FindElement(groupRef, name);
- }
- }
- }
-
- return matchedElement;
- }
-
- ///
- /// Finds the named child element contained in the restriction element.
- ///
- XmlSchemaElement FindChildElement(XmlSchemaComplexContentRestriction restriction, QualifiedName name)
- {
- XmlSchemaElement matchedElement = null;
- XmlSchemaSequence sequence = restriction.Particle as XmlSchemaSequence;
- XmlSchemaGroupRef groupRef = restriction.Particle as XmlSchemaGroupRef;
-
- if (sequence != null) {
- matchedElement = FindElement(sequence.Items, name);
- } else if (groupRef != null) {
- matchedElement = FindElement(groupRef, name);
- }
-
- return matchedElement;
- }
-
- ///
- /// Finds the element in the collection of schema objects.
- ///
- XmlSchemaElement FindElement(XmlSchemaObjectCollection items, QualifiedName name)
- {
- XmlSchemaElement matchedElement = null;
-
- foreach (XmlSchemaObject schemaObject in items) {
- XmlSchemaElement element = schemaObject as XmlSchemaElement;
- XmlSchemaSequence sequence = schemaObject as XmlSchemaSequence;
- XmlSchemaChoice choice = schemaObject as XmlSchemaChoice;
- XmlSchemaGroupRef groupRef = schemaObject as XmlSchemaGroupRef;
-
- if (element != null) {
- if (element.Name != null) {
- if (name.Name == element.Name) {
- matchedElement = element;
- }
- } else if (element.RefName != null) {
- if (name.Name == element.RefName.Name) {
- matchedElement = FindElement(element.RefName);
- } else {
- // Abstract element?
- XmlSchemaElement abstractElement = FindElement(element.RefName);
- if (abstractElement != null && abstractElement.IsAbstract) {
- matchedElement = FindSubstitutionGroupElement(abstractElement.QualifiedName, name);
- }
- }
- }
- } else if (sequence != null) {
- matchedElement = FindElement(sequence.Items, name);
- } else if (choice != null) {
- matchedElement = FindElement(choice.Items, name);
- } else if (groupRef != null) {
- matchedElement = FindElement(groupRef, name);
- }
-
- // Did we find a match?
- if (matchedElement != null) {
- break;
- }
- }
-
- return matchedElement;
- }
-
- XmlSchemaElement FindElement(XmlSchemaGroupRef groupRef, QualifiedName name)
- {
- XmlSchemaElement matchedElement = null;
-
- XmlSchemaGroup group = FindGroup(groupRef.RefName.Name);
- if (group != null) {
- XmlSchemaSequence sequence = group.Particle as XmlSchemaSequence;
- XmlSchemaChoice choice = group.Particle as XmlSchemaChoice;
-
- if(sequence != null) {
- matchedElement = FindElement(sequence.Items, name);
- } else if (choice != null) {
- matchedElement = FindElement(choice.Items, name);
- }
- }
-
- return matchedElement;
- }
-
- static XmlSchemaAttributeGroup FindAttributeGroup(XmlSchema schema, string name)
- {
- XmlSchemaAttributeGroup matchedGroup = null;
-
- if (name != null) {
- foreach (XmlSchemaObject schemaObject in schema.Items) {
-
- XmlSchemaAttributeGroup group = schemaObject as XmlSchemaAttributeGroup;
- if (group != null) {
- if (group.Name == name) {
- matchedGroup = group;
- break;
- }
- }
- }
-
- // Try included schemas.
- if (matchedGroup == null) {
- foreach (XmlSchemaExternal external in schema.Includes) {
- XmlSchemaInclude include = external as XmlSchemaInclude;
- if (include != null) {
- if (include.Schema != null) {
- matchedGroup = FindAttributeGroup(include.Schema, name);
- }
- }
- }
- }
- }
-
- return matchedGroup;
- }
-
- XmlCompletionItemCollection GetAttributeValueCompletionData(XmlSchemaElement element, string name)
- {
- XmlCompletionItemCollection data = new XmlCompletionItemCollection();
-
- XmlSchemaComplexType complexType = GetElementAsComplexType(element);
- if (complexType != null) {
- XmlSchemaAttribute attribute = FindAttribute(complexType, name);
- if (attribute != null) {
- data.AddRange(GetAttributeValueCompletionData(attribute));
- }
- }
-
- return data;
- }
-
- XmlCompletionItemCollection GetAttributeValueCompletionData(XmlSchemaAttribute attribute)
- {
- XmlCompletionItemCollection data = new XmlCompletionItemCollection();
-
- if (attribute.SchemaType != null) {
- XmlSchemaSimpleTypeRestriction simpleTypeRestriction = attribute.SchemaType.Content as XmlSchemaSimpleTypeRestriction;
- if (simpleTypeRestriction != null) {
- data.AddRange(GetAttributeValueCompletionData(simpleTypeRestriction));
- }
- } else if (attribute.AttributeSchemaType != null) {
- XmlSchemaSimpleType simpleType = attribute.AttributeSchemaType as XmlSchemaSimpleType;
-
- if (simpleType != null) {
- if (simpleType.Name == "boolean") {
- data.AddRange(GetBooleanAttributeValueCompletionData());
- } else {
- data.AddRange(GetAttributeValueCompletionData(simpleType));
- }
- }
- }
-
- return data;
- }
-
- XmlCompletionItemCollection GetAttributeValueCompletionData(XmlSchemaSimpleTypeRestriction simpleTypeRestriction)
- {
- XmlCompletionItemCollection data = new XmlCompletionItemCollection();
-
- foreach (XmlSchemaObject schemaObject in simpleTypeRestriction.Facets) {
- XmlSchemaEnumerationFacet enumFacet = schemaObject as XmlSchemaEnumerationFacet;
- if (enumFacet != null) {
- AddAttributeValue(data, enumFacet.Value, enumFacet.Annotation);
- }
- }
-
- return data;
- }
-
- XmlCompletionItemCollection GetAttributeValueCompletionData(XmlSchemaSimpleTypeUnion union)
- {
- XmlCompletionItemCollection data = new XmlCompletionItemCollection();
-
- foreach (XmlSchemaObject schemaObject in union.BaseTypes) {
- XmlSchemaSimpleType simpleType = schemaObject as XmlSchemaSimpleType;
- if (simpleType != null) {
- data.AddRange(GetAttributeValueCompletionData(simpleType));
- }
- }
-
- return data;
- }
-
- XmlCompletionItemCollection GetAttributeValueCompletionData(XmlSchemaSimpleType simpleType)
- {
- XmlCompletionItemCollection data = new XmlCompletionItemCollection();
-
- XmlSchemaSimpleTypeRestriction simpleTypeRestriction = simpleType.Content as XmlSchemaSimpleTypeRestriction;
- XmlSchemaSimpleTypeUnion union = simpleType.Content as XmlSchemaSimpleTypeUnion;
- XmlSchemaSimpleTypeList list = simpleType.Content as XmlSchemaSimpleTypeList;
-
- if (simpleTypeRestriction != null) {
- data.AddRange(GetAttributeValueCompletionData(simpleTypeRestriction));
- } else if (union != null) {
- data.AddRange(GetAttributeValueCompletionData(union));
- } else if (list != null) {
- data.AddRange(GetAttributeValueCompletionData(list));
- }
-
- return data;
- }
-
- XmlCompletionItemCollection GetAttributeValueCompletionData(XmlSchemaSimpleTypeList list)
- {
- XmlCompletionItemCollection data = new XmlCompletionItemCollection();
-
- if (list.ItemType != null) {
- data.AddRange(GetAttributeValueCompletionData(list.ItemType));
- } else if (list.ItemTypeName != null) {
- XmlSchemaSimpleType simpleType = FindSimpleType(list.ItemTypeName);
- if (simpleType != null) {
- data.AddRange(GetAttributeValueCompletionData(simpleType));
- }
- }
-
- return data;
- }
-
- ///
- /// Gets the set of attribute values for an xs:boolean type.
- ///
- XmlCompletionItemCollection GetBooleanAttributeValueCompletionData()
- {
- XmlCompletionItemCollection data = new XmlCompletionItemCollection();
-
- AddAttributeValue(data, "0");
- AddAttributeValue(data, "1");
- AddAttributeValue(data, "true");
- AddAttributeValue(data, "false");
-
- return data;
- }
-
- XmlSchemaAttribute FindAttribute(XmlSchemaComplexType complexType, string name)
- {
- XmlSchemaAttribute matchedAttribute = null;
-
- matchedAttribute = FindAttribute(complexType.Attributes, name);
-
- if (matchedAttribute == null) {
- XmlSchemaComplexContent complexContent = complexType.ContentModel as XmlSchemaComplexContent;
- if (complexContent != null) {
- matchedAttribute = FindAttribute(complexContent, name);
- }
- }
-
- return matchedAttribute;
- }
-
- XmlSchemaAttribute FindAttribute(XmlSchemaObjectCollection schemaObjects, string name)
- {
- XmlSchemaAttribute matchedAttribute = null;
-
- foreach (XmlSchemaObject schemaObject in schemaObjects) {
- XmlSchemaAttribute attribute = schemaObject as XmlSchemaAttribute;
- XmlSchemaAttributeGroupRef groupRef = schemaObject as XmlSchemaAttributeGroupRef;
-
- if (attribute != null) {
- if (attribute.Name == name) {
- matchedAttribute = attribute;
- break;
- }
- } else if (groupRef != null) {
- matchedAttribute = FindAttribute(groupRef, name);
- if (matchedAttribute != null) {
- break;
- }
- }
- }
-
- return matchedAttribute;
- }
-
- XmlSchemaAttribute FindAttribute(XmlSchemaAttributeGroupRef groupRef, string name)
- {
- XmlSchemaAttribute matchedAttribute = null;
-
- if (groupRef.RefName != null) {
- XmlSchemaAttributeGroup group = FindAttributeGroup(schema, groupRef.RefName.Name);
- if (group != null) {
- matchedAttribute = FindAttribute(group.Attributes, name);
- }
- }
-
- return matchedAttribute;
- }
-
- XmlSchemaAttribute FindAttribute(XmlSchemaComplexContent complexContent, string name)
- {
- XmlSchemaAttribute matchedAttribute = null;
-
- XmlSchemaComplexContentExtension extension = complexContent.Content as XmlSchemaComplexContentExtension;
- XmlSchemaComplexContentRestriction restriction = complexContent.Content as XmlSchemaComplexContentRestriction;
-
- if (extension != null) {
- matchedAttribute = FindAttribute(extension, name);
- } else if (restriction != null) {
- matchedAttribute = FindAttribute(restriction, name);
- }
-
- return matchedAttribute;
- }
-
- XmlSchemaAttribute FindAttribute(XmlSchemaComplexContentExtension extension, string name)
- {
- return FindAttribute(extension.Attributes, name);
- }
-
- XmlSchemaAttribute FindAttribute(XmlSchemaComplexContentRestriction restriction, string name)
- {
- XmlSchemaAttribute matchedAttribute = FindAttribute(restriction.Attributes, name);
-
- if (matchedAttribute == null) {
- XmlSchemaComplexType complexType = FindNamedType(schema, restriction.BaseTypeName);
- if (complexType != null) {
- matchedAttribute = FindAttribute(complexType, name);
- }
- }
-
- return matchedAttribute;
- }
-
- ///
- /// Adds an attribute value to the completion data collection.
- ///
- void AddAttributeValue(XmlCompletionItemCollection data, string valueText)
- {
- XmlCompletionItem completionData = new XmlCompletionItem(valueText, XmlCompletionItem.DataType.XmlAttributeValue);
- data.Add(completionData);
- }
-
- ///
- /// Adds an attribute value to the completion data collection.
- ///
- void AddAttributeValue(XmlCompletionItemCollection data, string valueText, XmlSchemaAnnotation annotation)
- {
- string documentation = GetDocumentation(annotation);
- XmlCompletionItem completionData = new XmlCompletionItem(valueText, documentation, XmlCompletionItem.DataType.XmlAttributeValue);
- data.Add(completionData);
- }
-
- ///
- /// Adds an attribute value to the completion data collection.
- ///
- void AddAttributeValue(XmlCompletionItemCollection data, string valueText, string description)
- {
- XmlCompletionItem completionData = new XmlCompletionItem(valueText, description, XmlCompletionItem.DataType.XmlAttributeValue);
- data.Add(completionData);
- }
-
- XmlSchemaSimpleType FindSimpleType(XmlQualifiedName name)
- {
- XmlSchemaSimpleType matchedSimpleType = null;
-
- foreach (XmlSchemaObject schemaObject in schema.SchemaTypes.Values) {
- XmlSchemaSimpleType simpleType = schemaObject as XmlSchemaSimpleType;
- if (simpleType != null) {
- if (simpleType.QualifiedName == name) {
- matchedSimpleType = simpleType;
- break;
- }
- }
- }
-
- return matchedSimpleType;
- }
-
- ///
- /// Adds any elements that have the specified substitution group.
- ///
- void AddSubstitionGroupElements(XmlCompletionItemCollection data, XmlQualifiedName group, string prefix)
- {
- foreach (XmlSchemaElement element in schema.Elements.Values) {
- if (element.SubstitutionGroup == group) {
- AddElement(data, element.Name, prefix, element.Annotation);
- }
- }
- }
-
- ///
- /// Looks for the substitution group element of the specified name.
- ///
- XmlSchemaElement FindSubstitutionGroupElement(XmlQualifiedName group, QualifiedName name)
- {
- XmlSchemaElement matchedElement = null;
-
- foreach (XmlSchemaElement element in schema.Elements.Values) {
- if (element.SubstitutionGroup == group) {
- if (element.Name != null) {
- if (element.Name == name.Name) {
- matchedElement = element;
- break;
- }
- }
- }
- }
-
- return matchedElement;
- }
- }
-}
-
\ No newline at end of file
diff --git a/src/AddIns/DisplayBindings/XmlEditor/Project/Src/Src/XmlSchemaCompletionDataCollection.cs b/src/AddIns/DisplayBindings/XmlEditor/Project/Src/Src/XmlSchemaCompletionDataCollection.cs
deleted file mode 100644
index ff03c1b143..0000000000
--- a/src/AddIns/DisplayBindings/XmlEditor/Project/Src/Src/XmlSchemaCompletionDataCollection.cs
+++ /dev/null
@@ -1,294 +0,0 @@
-//
-//
-//
-//
-// $Revision: 1965 $
-//
-
-using ICSharpCode.XmlBinding;
-using System;
-using System.Collections.Generic;
-using ICSharpCode.Core;
-using ICSharpCode.SharpDevelop.Editor;
-
-namespace ICSharpCode.XmlEditor
-{
- ///
- /// A collection that stores objects.
- ///
- [Serializable()]
- public class XmlSchemaCompletionDataCollection : System.Collections.CollectionBase {
-
- ///
- /// Initializes a new instance of .
- ///
- public XmlSchemaCompletionDataCollection()
- {
- }
-
- ///
- /// Initializes a new instance of based on another .
- ///
- ///
- /// A from which the contents are copied
- ///
- public XmlSchemaCompletionDataCollection(XmlSchemaCompletionDataCollection val)
- {
- this.AddRange(val);
- }
-
- ///
- /// Initializes a new instance of containing any array of objects.
- ///
- ///
- /// A array of objects with which to intialize the collection
- ///
- public XmlSchemaCompletionDataCollection(XmlSchemaCompletionData[] val)
- {
- this.AddRange(val);
- }
-
- ///
- /// Represents the entry at the specified index of the .
- ///
- /// The zero-based index of the entry to locate in the collection.
- /// The entry at the specified index of the collection.
- /// is outside the valid range of indexes for the collection.
- 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;
- }
-
- ///
- /// Represents the entry with the specified namespace URI.
- ///
- /// The schema's namespace URI.
- /// The entry with the specified namespace URI.
- public XmlSchemaCompletionData this[string namespaceUri] {
- get {
- return GetItem(namespaceUri);
- }
- }
-
- ///
- /// Adds a with the specified value to the
- /// .
- ///
- /// The to add.
- /// The index at which the new element was inserted.
- ///
- public int Add(XmlSchemaCompletionData val)
- {
- return List.Add(val);
- }
-
- ///
- /// Copies the elements of an array to the end of the .
- ///
- ///
- /// An array of type containing the objects to add to the collection.
- ///
- ///
- public void AddRange(XmlSchemaCompletionData[] val)
- {
- for (int i = 0; i < val.Length; i++) {
- this.Add(val[i]);
- }
- }
-
- ///
- /// Adds the contents of another to the end of the collection.
- ///
- ///
- /// A containing the objects to add to the collection.
- ///
- ///
- public void AddRange(XmlSchemaCompletionDataCollection val)
- {
- for (int i = 0; i < val.Count; i++)
- {
- this.Add(val[i]);
- }
- }
-
- ///
- /// Gets a value indicating whether the
- /// contains the specified .
- ///
- /// The to locate.
- ///
- /// if the is contained in the collection;
- /// otherwise, .
- ///
- ///
- public bool Contains(XmlSchemaCompletionData val)
- {
- return List.Contains(val);
- }
-
- ///
- /// Copies the values to a one-dimensional instance at the
- /// specified index.
- ///
- /// The one-dimensional that is the destination of the values copied from .
- /// The index in where copying begins.
- ///
- /// is multidimensional.
- /// -or-
- /// The number of elements in the is greater than
- /// the available space between and the end of
- /// .
- ///
- /// is .
- /// is less than 's lowbound.
- ///
- public void CopyTo(XmlSchemaCompletionData[] array, int index)
- {
- List.CopyTo(array, index);
- }
-
- ///
- /// Returns the index of a in
- /// the .
- ///
- /// The to locate.
- ///
- /// The index of the of in the
- /// , if found; otherwise, -1.
- ///
- ///
- public int IndexOf(XmlSchemaCompletionData val)
- {
- return List.IndexOf(val);
- }
-
- ///
- /// Inserts a into the at the specified index.
- ///
- /// The zero-based index where should be inserted.
- /// The to insert.
- ///
- public void Insert(int index, XmlSchemaCompletionData val)
- {
- List.Insert(index, val);
- }
-
- ///
- /// Returns an enumerator that can iterate through the .
- ///
- ///
- public new XmlSchemaCompletionDataEnumerator GetEnumerator()
- {
- return new XmlSchemaCompletionDataEnumerator(this);
- }
-
- ///
- /// Removes a specific from the .
- ///
- /// The to remove from the .
- /// is not found in the Collection.
- public void Remove(XmlSchemaCompletionData val)
- {
- List.Remove(val);
- }
-
- ///
- /// Gets the schema completion data with the same filename.
- ///
- /// if no matching schema found.
- public XmlSchemaCompletionData GetSchemaFromFileName(string fileName)
- {
- foreach (XmlSchemaCompletionData schema in this) {
- if (FileUtility.IsEqualFileName(schema.FileName, fileName)) {
- return schema;
- }
- }
- return null;
- }
-
- ///
- /// Enumerator that can iterate through a XmlSchemaCompletionDataCollection.
- ///
- ///
- ///
- ///
- public class XmlSchemaCompletionDataEnumerator : System.Collections.IEnumerator
- {
- System.Collections.IEnumerator baseEnumerator;
- System.Collections.IEnumerable temp;
-
- ///
- /// Initializes a new instance of .
- ///
- public XmlSchemaCompletionDataEnumerator(XmlSchemaCompletionDataCollection mappings)
- {
- this.temp = ((System.Collections.IEnumerable)(mappings));
- this.baseEnumerator = temp.GetEnumerator();
- }
-
- ///
- /// Gets the current in the .
- ///
- public XmlSchemaCompletionData Current {
- get {
- return ((XmlSchemaCompletionData)(baseEnumerator.Current));
- }
- }
-
- object System.Collections.IEnumerator.Current {
- get {
- return baseEnumerator.Current;
- }
- }
-
- ///
- /// Advances the enumerator to the next of the .
- ///
- public bool MoveNext()
- {
- return baseEnumerator.MoveNext();
- }
-
- ///
- /// Sets the enumerator to its initial position, which is before the first element in the .
- ///
- 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;
- }
- }
-}
diff --git a/src/AddIns/DisplayBindings/XmlEditor/Project/Src/Src/XmlSchemaListBoxItem.cs b/src/AddIns/DisplayBindings/XmlEditor/Project/Src/Src/XmlSchemaListBoxItem.cs
deleted file mode 100644
index ac9ee8062a..0000000000
--- a/src/AddIns/DisplayBindings/XmlEditor/Project/Src/Src/XmlSchemaListBoxItem.cs
+++ /dev/null
@@ -1,61 +0,0 @@
-//
-//
-//
-//
-// $Revision: 915 $
-//
-
-using System;
-using System.Windows.Controls;
-using System.Windows.Media;
-
-namespace ICSharpCode.XmlEditor
-{
- ///
- /// A schema item shown in the tools options dialog.
- ///
- public class XmlSchemaListBoxItem
- {
- string namespaceUri = String.Empty;
- bool readOnly = false;
-
- ///
- /// Creates a new list box item.
- ///
- ///
- /// A readonly list box item is used for system schemas, those that
- /// are installed with SharpDevelop.
- ///
- 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;
- }
- }
-
- ///
- /// Returns the namespace Uri so the list box item is sorted correctly.
- ///
- ///
- public override string ToString()
- {
- return namespaceUri;
- }
- }
-}
diff --git a/src/AddIns/DisplayBindings/XmlEditor/Project/Src/Src/XmlSchemaManager.cs b/src/AddIns/DisplayBindings/XmlEditor/Project/Src/Src/XmlSchemaManager.cs
deleted file mode 100644
index 9d8699107f..0000000000
--- a/src/AddIns/DisplayBindings/XmlEditor/Project/Src/Src/XmlSchemaManager.cs
+++ /dev/null
@@ -1,218 +0,0 @@
-//
-//
-//
-//
-// $Revision: 1965 $
-//
-
-using System;
-using System.IO;
-using System.Runtime.InteropServices;
-
-using ICSharpCode.Core;
-
-namespace ICSharpCode.XmlEditor
-{
-
- ///
- /// Keeps track of all the schemas that the Xml Editor is aware
- /// of.
- ///
- 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;
-
- ///
- /// Determines whether the specified namespace is actually the W3C namespace for
- /// XSD files.
- ///
- public static bool IsXmlSchemaNamespace(string schemaNamespace)
- {
- return schemaNamespace == XmlSchemaNamespace;
- }
-
- ///
- /// Gets the schemas that SharpDevelop knows about.
- ///
- public static XmlSchemaCompletionDataCollection SchemaCompletionDataItems {
- get {
- if (schemas == null) {
- schemas = new XmlSchemaCompletionDataCollection();
- manager = new XmlSchemaManager();
- ReadSchemas();
- }
-
- return schemas;
- }
- }
-
- ///
- /// Gets the schema completion data that is associated with the
- /// specified file extension.
- ///
- 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;
- }
-
- ///
- /// Gets the namespace prefix that is associated with the
- /// specified file extension.
- ///
- public static string GetNamespacePrefix(string extension)
- {
- string prefix = String.Empty;
-
- XmlSchemaAssociation association = XmlEditorAddInOptions.GetSchemaAssociation(extension);
- if (association != null) {
- prefix = association.NamespacePrefix;
- }
-
- return prefix;
- }
-
- ///
- /// Removes the schema with the specified namespace from the
- /// user schemas folder and removes the completion data.
- ///
- 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();
- }
- }
-
- ///
- /// Adds the schema to the user schemas folder and makes the
- /// schema available to the xml editor.
- ///
- 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);
- }
- }
-
- ///
- /// Reads the system and user added schemas.
- ///
- static void ReadSchemas()
- {
- // MSBuild schemas are in framework directory:
- ReadSchemas(RuntimeEnvironment.GetRuntimeDirectory(), true);
- ReadSchemas(SchemaFolder, true);
- ReadSchemas(UserSchemaFolder, false);
- }
-
- ///
- /// Reads all .xsd files in the specified folder.
- ///
- static void ReadSchemas(string folder, bool readOnly)
- {
- if (Directory.Exists(folder)) {
- foreach (string fileName in Directory.GetFiles(folder, "*.xsd")) {
- ReadSchema(fileName, readOnly);
- }
- }
- }
-
- ///
- /// Reads an individual schema and adds it to the collection.
- ///
- ///
- /// If the schema namespace exists in the collection it is not added.
- ///
- 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);
- }
- }
-
- ///
- /// Gets the folder where the schemas for all users on the
- /// local machine are stored.
- ///
- static string SchemaFolder {
- get {
- return Path.Combine(PropertyService.DataDirectory, "schemas");
- }
- }
-
- ///
- /// Gets the folder where schemas are stored for an individual user.
- ///
- static string UserSchemaFolder {
- get {
- return Path.Combine(PropertyService.ConfigDirectory, "schemas");
- }
- }
-
- ///
- /// Should really pass schema info with the event.
- ///
- static void OnUserSchemaAdded()
- {
- if (UserSchemaAdded != null) {
- UserSchemaAdded(manager, new EventArgs());
- }
- }
-
- ///
- /// Should really pass schema info with the event.
- ///
- static void OnUserSchemaRemoved()
- {
- if (UserSchemaRemoved != null) {
- UserSchemaRemoved(manager, new EventArgs());
- }
- }
- }
-}
diff --git a/src/AddIns/DisplayBindings/XmlEditor/Project/Src/Src/XmlTextTreeNode.cs b/src/AddIns/DisplayBindings/XmlEditor/Project/Src/Src/XmlTextTreeNode.cs
deleted file mode 100644
index d30dbe4fcb..0000000000
--- a/src/AddIns/DisplayBindings/XmlEditor/Project/Src/Src/XmlTextTreeNode.cs
+++ /dev/null
@@ -1,60 +0,0 @@
-//
-//
-//
-//
-// $Revision: 2164 $
-//
-
-using System;
-using System.Xml;
-using ICSharpCode.SharpDevelop.Gui;
-
-namespace ICSharpCode.XmlEditor
-{
- ///
- /// Represents an XmlText node in the tree.
- ///
- 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();
- }
-
- ///
- /// Gets the XmlText associated with this tree node.
- ///
- public XmlText XmlText {
- get {
- return xmlText;
- }
- }
-
- ///
- /// Gets or sets whether to show the ghost image which is
- /// displayed when cutting the node.
- ///
- public bool ShowGhostImage {
- get {
- return ImageKey == XmlTextTreeNodeGhostImageKey;
- }
- set {
- if (value) {
- ImageKey = XmlTextTreeNodeGhostImageKey;
- } else {
- ImageKey = XmlTextTreeNodeImageKey;
- }
- SelectedImageKey = ImageKey;
- }
- }
- }
-}
diff --git a/src/AddIns/DisplayBindings/XmlEditor/Project/Src/Src/XmlTreeEditor.cs b/src/AddIns/DisplayBindings/XmlEditor/Project/Src/Src/XmlTreeEditor.cs
deleted file mode 100644
index d9a71ef311..0000000000
--- a/src/AddIns/DisplayBindings/XmlEditor/Project/Src/Src/XmlTreeEditor.cs
+++ /dev/null
@@ -1,654 +0,0 @@
-//
-//
-//
-//
-// $Revision: 3908 $
-//
-
-using ICSharpCode.XmlBinding.Parser;
-using System;
-using System.Collections.Generic;
-using System.Net;
-using System.Xml;
-using ICSharpCode.Core;
-
-namespace ICSharpCode.XmlEditor
-{
- ///
- /// The class that is responsible for controlling the editing of the
- /// Xml tree view.
- ///
- public class XmlTreeEditor
- {
- IXmlTreeView view;
- XmlDocument document;
- //XmlCompletionDataProvider completionDataProvider;
- XmlNode copiedNode;
- XmlNode cutNode;
-
- public XmlTreeEditor(IXmlTreeView view/*, XmlCompletionDataProvider completionDataProvider*/)
- {
- this.view = view;
- //this.completionDataProvider = completionDataProvider;
- }
-
- ///
- /// Loads the xml into the editor.
- ///
- public void LoadXml(string xml)
- {
- try {
- document = new XmlDocument();
- document.XmlResolver = null;
- document.LoadXml(xml);
- view.Document = document;
- } catch (XmlException ex) {
- view.ShowXmlIsNotWellFormedMessage(ex);
- } catch (WebException ex) {
- LoggingService.Debug(ex.ToString());
- view.ShowErrorMessage(ex.Message);
- }
- }
-
- ///
- /// Gets the Xml document being edited.
- ///
- public XmlDocument Document {
- get {
- return document;
- }
- }
-
- ///
- /// The selected tree node in the view has changed.
- ///
- public void SelectedNodeChanged()
- {
- XmlElement selectedElement = view.SelectedElement;
- XmlText selectedTextNode = view.SelectedTextNode;
- XmlComment selectedComment = view.SelectedComment;
- if (selectedTextNode != null) {
- view.ClearAttributes();
- view.ShowTextContent(selectedTextNode.InnerText);
- } else if (selectedElement != null) {
- view.TextContent = String.Empty;
- view.ShowAttributes(selectedElement.Attributes);
- } else if (selectedComment != null) {
- view.ClearAttributes();
- view.ShowTextContent(selectedComment.InnerText);
- } else {
- view.ClearAttributes();
- view.TextContent = String.Empty;
- }
- }
-
- ///
- /// The attribute value has changed.
- ///
- public void AttributeValueChanged()
- {
- view.IsDirty = true;
- }
-
- ///
- /// Adds one or more new attribute to the selected element.
- ///
- public void AddAttribute()
- {
- XmlElement selectedElement = view.SelectedElement;
- if (selectedElement != null) {
- string[] attributesNames = GetMissingAttributes(selectedElement);
- string[] selectedAttributeNames = view.SelectNewAttributes(attributesNames);
- if (selectedAttributeNames.Length > 0) {
- foreach (string attributeName in selectedAttributeNames) {
- selectedElement.SetAttribute(attributeName, String.Empty);
- }
- view.IsDirty = true;
- view.ShowAttributes(selectedElement.Attributes);
- }
- }
- }
-
- ///
- /// Removes the selected attribute from the xml document.
- ///
- public void RemoveAttribute()
- {
- XmlElement selectedElement = view.SelectedElement;
- if (selectedElement != null) {
- string attribute = view.SelectedAttribute;
- if (attribute != null) {
- selectedElement.RemoveAttribute(attribute);
- view.IsDirty = true;
- view.ShowAttributes(selectedElement.Attributes);
- }
- }
- }
-
- ///
- /// The text content has been changed in the view.
- ///
- public void TextContentChanged()
- {
- XmlText textNode = view.SelectedTextNode;
- XmlComment comment = view.SelectedComment;
- if (textNode != null) {
- view.IsDirty = true;
- textNode.InnerText = view.TextContent;
- view.UpdateTextNode(textNode);
- } else if (comment != null) {
- view.IsDirty = true;
- comment.InnerText = view.TextContent;
- view.UpdateComment(comment);
- }
- }
-
- ///
- /// Adds a new child element to the selected element.
- ///
- public void AppendChildElement()
- {
- XmlElement selectedElement = view.SelectedElement;
- if (selectedElement != null) {
- string[] elementNames = GetChildElements(selectedElement);
- string[] selectedElementNames = view.SelectNewElements(elementNames);
- if (selectedElementNames.Length > 0) {
- view.IsDirty = true;
- foreach (string elementName in selectedElementNames) {
- XmlElement newElement = document.CreateElement(elementName, selectedElement.NamespaceURI);
- AppendChildElement(selectedElement, newElement);
- }
- }
- }
- }
-
- ///
- /// Inserts an element before the currently selected element.
- ///
- public void InsertElementBefore()
- {
- XmlElement parentElement = null;
- XmlNode selectedNode = view.SelectedElement;
- if (selectedNode == null) {
- selectedNode = view.SelectedComment;
- }
- if (selectedNode != null) {
- parentElement = selectedNode.ParentNode as XmlElement;
- }
-
- if (parentElement != null) {
- string[] elementNames = GetChildElements(parentElement);
- string[] selectedElementNames = view.SelectNewElements(elementNames);
- if (selectedElementNames.Length > 0) {
- view.IsDirty = true;
- foreach (string elementName in selectedElementNames) {
- XmlElement newElement = document.CreateElement(elementName, parentElement.NamespaceURI);
- parentElement.InsertBefore(newElement, selectedNode);
- view.InsertElementBefore(newElement);
- }
- }
- }
- }
-
- ///
- /// Inserts an element after the currently selected element.
- ///
- public void InsertElementAfter()
- {
- XmlElement parentElement = null;
- XmlNode selectedNode = view.SelectedElement;
- if (selectedNode == null) {
- selectedNode = view.SelectedComment;
- }
- if (selectedNode != null) {
- parentElement = selectedNode.ParentNode as XmlElement;
- }
-
- if (parentElement != null) {
- string[] elementNames = GetChildElements(parentElement);
- string[] selectedElementNames = view.SelectNewElements(elementNames);
- if (selectedElementNames.Length > 0) {
- view.IsDirty = true;
- foreach (string elementName in selectedElementNames) {
- XmlElement newElement = document.CreateElement(elementName, parentElement.NamespaceURI);
- parentElement.InsertAfter(newElement, selectedNode);
- view.InsertElementAfter(newElement);
- }
- }
- }
- }
-
- ///
- /// Adds a child text node to the current selected element.
- ///
- public void AppendChildTextNode()
- {
- AppendChildTextNode(document.CreateTextNode(String.Empty));
- }
-
- ///
- /// Inserts a text node before the currently selected node.
- ///
- public void InsertTextNodeBefore()
- {
- // Get the currently selected text node or element.
- XmlNode selectedNode = GetSelectedCommentOrElementOrTextNode();
-
- // Insert the text node before the selected node.
- if (selectedNode != null) {
- XmlElement parentElement = selectedNode.ParentNode as XmlElement;
- if (parentElement != null) {
- XmlText textNode = document.CreateTextNode(String.Empty);
- parentElement.InsertBefore(textNode, selectedNode);
- view.IsDirty = true;
- view.InsertTextNodeBefore(textNode);
- }
- }
- }
-
- ///
- /// Inserts a text node after the currently selected node.
- ///
- public void InsertTextNodeAfter()
- {
- // Get the currently selected text node or element.
- XmlNode selectedNode = GetSelectedCommentOrElementOrTextNode();
-
- // Insert the text node after the selected node.
- if (selectedNode != null) {
- XmlElement parentElement = selectedNode.ParentNode as XmlElement;
- if (parentElement != null) {
- XmlText textNode = document.CreateTextNode(String.Empty);
- parentElement.InsertAfter(textNode, selectedNode);
- view.IsDirty = true;
- view.InsertTextNodeAfter(textNode);
- }
- }
- }
-
- ///
- /// Adds a child comment node to the current selected element.
- ///
- public void AppendChildComment()
- {
- XmlComment comment = document.CreateComment(String.Empty);
- AppendChildComment(comment);
- }
-
- ///
- /// Inserts a comment before the selected node.
- ///
- public void InsertCommentBefore()
- {
- XmlNode node = GetSelectedCommentOrElementOrTextNode();
- if (node != null) {
- XmlNode parentNode = node.ParentNode;
- XmlComment comment = document.CreateComment(String.Empty);
- parentNode.InsertBefore(comment, node);
- view.IsDirty = true;
- view.InsertCommentBefore(comment);
- }
- }
-
- ///
- /// Inserts a comment after the selected node.
- ///
- public void InsertCommentAfter()
- {
- XmlNode node = GetSelectedCommentOrElementOrTextNode();
- if (node != null) {
- XmlNode parentNode = node.ParentNode;
- XmlComment comment = document.CreateComment(String.Empty);
- parentNode.InsertAfter(comment, node);
- view.IsDirty = true;
- view.InsertCommentAfter(comment);
- }
- }
-
- ///
- /// Deletes the selected tree node from the xml document.
- ///
- public void Delete()
- {
- XmlNode selectedNode = view.SelectedNode;
- XmlElement selectedElement = selectedNode as XmlElement;
- XmlComment selectedComment = selectedNode as XmlComment;
- XmlText selectedText = selectedNode as XmlText;
- if (selectedElement != null) {
- RemoveElement(selectedElement);
- } else if (selectedComment != null) {
- RemoveComment(selectedComment);
- } else if (selectedText != null) {
- RemoveTextNode(selectedText);
- }
- }
-
- ///
- /// Copies the selected node.
- ///
- public void Copy()
- {
- copiedNode = view.SelectedNode;
- if (cutNode != null) {
- view.HideCut(cutNode);
- }
- }
-
- ///
- /// Pastes the copied or cut node as a child of the selected node.
- ///
- public void Paste()
- {
- if (IsPasteEnabled) {
- if (copiedNode != null) {
- AppendChildCopy(copiedNode);
- } else {
- CutAndPasteNode(cutNode);
- }
- }
- }
-
- ///
- /// Cuts the selected node.
- ///
- public void Cut()
- {
- cutNode = view.SelectedNode;
- if (cutNode != null) {
- view.ShowCut(cutNode);
- }
- copiedNode = null;
- }
-
- ///
- /// Gets whether the cut method is enabled.
- ///
- public bool IsCutEnabled {
- get {
- XmlNode selectedNode = view.SelectedNode;
- return selectedNode != null && document.DocumentElement != selectedNode;
- }
- }
-
- ///
- /// Gets whether the copy method is enabled.
- ///
- public bool IsCopyEnabled {
- get {
- return view.SelectedNode != null;
- }
- }
-
- ///
- /// Gets whether the paste method is enabled.
- ///
- public bool IsPasteEnabled {
- get {
- XmlNode destinationNode = view.SelectedNode;
- if (destinationNode != null) {
- XmlNode sourceNode = copiedNode ?? cutNode;
- if (sourceNode != null) {
- return GetPasteEnabled(sourceNode, destinationNode);
- }
- }
- return false;
- }
- }
-
- ///
- /// Gets whether the delete method is enabled.
- ///
- public bool IsDeleteEnabled {
- get {
- return view.SelectedNode != null;
- }
- }
-
- ///
- /// Gets the missing attributes for the specified element based
- /// on its associated schema.
- ///
- string[] GetMissingAttributes(XmlElement element)
- {
- XmlElementPath elementPath = GetElementPath(element);
- // TODO : implement
- List attributes = new List();
-// XmlSchemaCompletionData schemaCompletionData = completionDataProvider.FindSchema(elementPath);
-// if (schemaCompletionData != null) {
-// ICompletionData[] completionData = schemaCompletionData.GetAttributeCompletionData(elementPath);
-// foreach (ICompletionData attributeCompletionData in completionData) {
-// // Ignore existing attributes.
-// string attributeName = attributeCompletionData.Text;
-// if (!element.HasAttribute(attributeName)) {
-// attributes.Add(attributeName);
-// }
-// }
-// }
- return attributes.ToArray();
- }
-
- ///
- /// Returns the path to the specified element starting from the
- /// root element.
- ///
- XmlElementPath GetElementPath(XmlElement element)
- {
- XmlElementPath path = new XmlElementPath();
- XmlElement parentElement = element;
- while (parentElement != null) {
- QualifiedName name = new QualifiedName(parentElement.LocalName, parentElement.NamespaceURI, parentElement.Prefix);
- path.Elements.Insert(0, name);
-
- // Move to parent element.
- parentElement = parentElement.ParentNode as XmlElement;
- }
- return path;
- }
-
- ///
- /// Returns a list of elements that can be children of the
- /// specified element.
- ///
- string[] GetChildElements(XmlElement element)
- {
- XmlElementPath elementPath = GetElementPath(element);
-
- List elements = new List();
-// XmlSchemaCompletionData schemaCompletionData = completionDataProvider.FindSchema(elementPath);
-// if (schemaCompletionData != null) {
-// ICompletionData[] completionData = schemaCompletionData.GetChildElementCompletionData(elementPath);
-// foreach (ICompletionData elementCompletionData in completionData) {
-// elements.Add(elementCompletionData.Text);
-// }
-// }
- return elements.ToArray();
- }
-
- ///
- /// Gets the current comment or element or text node
- /// from the view.
- ///
- XmlNode GetSelectedCommentOrElementOrTextNode()
- {
- XmlNode node = view.SelectedComment;
- if (node != null) {
- return node;
- }
- return GetSelectedElementOrTextNode();
- }
-
- ///
- /// Gets the currently selected element or text node.
- ///
- XmlNode GetSelectedElementOrTextNode()
- {
- XmlNode node = view.SelectedTextNode;
- if (node != null) {
- return node;
- }
- return view.SelectedElement;
- }
-
- ///
- /// Appends the specified element as a child to the selected element.
- ///
- void AppendChildElement(XmlElement element)
- {
- AppendChildElement(view.SelectedElement, element);
- }
-
- ///
- /// Appends the specified element as a child to the selected element.
- ///
- void AppendChildElement(XmlElement selectedElement, XmlElement element)
- {
- selectedElement.AppendChild(element);
- view.AppendChildElement(element);
- view.IsDirty = true;
- }
-
- ///
- /// Removes the specified element from the document.
- ///
- void RemoveElement(XmlElement element)
- {
- XmlNode parentNode = element.ParentNode;
- parentNode.RemoveChild(element);
- view.IsDirty = true;
- view.RemoveElement(element);
- }
-
- ///
- /// Removes the specified comment from the document.
- ///
- void RemoveComment(XmlComment comment)
- {
- XmlNode parentNode = comment.ParentNode;
- parentNode.RemoveChild(comment);
- view.IsDirty = true;
- view.RemoveComment(comment);
- }
-
- ///
- /// Removes the specified text node from the document.
- ///
- void RemoveTextNode(XmlText textNode)
- {
- XmlNode parentNode = textNode.ParentNode;
- parentNode.RemoveChild(textNode);
- view.IsDirty = true;
- view.RemoveTextNode(textNode);
- }
-
- ///
- /// Gets whether the source node can be pasted as a child
- /// node of the destination node.
- ///
- static bool GetPasteEnabled(XmlNode source, XmlNode destination)
- {
- if (source is XmlElement || source is XmlText || source is XmlComment) {
- return destination is XmlElement;
- }
- return false;
- }
-
- ///
- /// Takes a copy of the node and appends it to the selected
- /// node.
- ///
- void AppendChildCopy(XmlNode nodeToCopy)
- {
- if (nodeToCopy is XmlElement) {
- XmlElement copy = (XmlElement)nodeToCopy.CloneNode(true);
- AppendChildElement(copy);
- } else if (nodeToCopy is XmlText) {
- XmlText copy = (XmlText)nodeToCopy.CloneNode(true);
- AppendChildTextNode(copy);
- } else if (nodeToCopy is XmlComment) {
- XmlComment copy = (XmlComment)nodeToCopy.CloneNode(true);
- AppendChildComment(copy);
- }
- }
-
- ///
- /// Appends the specified text node to the currently selected element.
- ///
- void AppendChildTextNode(XmlText textNode)
- {
- XmlElement selectedElement = view.SelectedElement;
- if (selectedElement != null) {
- selectedElement.AppendChild(textNode);
- view.IsDirty = true;
- view.AppendChildTextNode(textNode);
- }
- }
-
- ///
- /// Cuts from the tree and pastes it to the currently selected node.
- ///
- void CutAndPasteNode(XmlNode node)
- {
- XmlElement cutElement = node as XmlElement;
- XmlText cutTextNode = node as XmlText;
- XmlComment cutCommentNode = node as XmlComment;
- if (cutElement != null) {
- CutAndPasteElement(cutElement);
- } else if (cutTextNode != null) {
- CutAndPasteTextNode(cutTextNode);
- } else if (cutCommentNode != null) {
- CutAndPasteComment(cutCommentNode);
- }
- cutNode = null;
- }
-
- ///
- /// Cuts the element from the document and pastes it as a child
- /// of the selected element.
- ///
- void CutAndPasteElement(XmlElement element)
- {
- if (element != view.SelectedElement) {
- view.RemoveElement(element);
- AppendChildElement(element);
- } else {
- // Pasting to the same cut element so just
- // change the tree icon back to the uncut state.
- view.HideCut(element);
- }
- }
-
- ///
- /// Cuts the text node from the document and appends it as a child
- /// of the currently selected element.
- ///
- void CutAndPasteTextNode(XmlText text)
- {
- view.RemoveTextNode(text);
- AppendChildTextNode(text);
- }
-
- ///
- /// Appends the specified comment to the currently selected element.
- ///
- void AppendChildComment(XmlComment comment)
- {
- XmlElement selectedElement = view.SelectedElement;
- if (selectedElement != null) {
- selectedElement.AppendChild(comment);
- view.IsDirty = true;
- view.AppendChildComment(comment);
- }
- }
-
- ///
- /// Cuts the comment node from the document and appends it as a child
- /// of the currently selected element.
- ///
- void CutAndPasteComment(XmlComment comment)
- {
- view.RemoveComment(comment);
- AppendChildComment(comment);
- }
- }
-}
-
\ No newline at end of file
diff --git a/src/AddIns/DisplayBindings/XmlEditor/Project/Src/Src/XmlTreeViewContainerControl.cs b/src/AddIns/DisplayBindings/XmlEditor/Project/Src/Src/XmlTreeViewContainerControl.cs
deleted file mode 100644
index c75fa06e43..0000000000
--- a/src/AddIns/DisplayBindings/XmlEditor/Project/Src/Src/XmlTreeViewContainerControl.cs
+++ /dev/null
@@ -1,924 +0,0 @@
-//
-//
-//
-//
-// $Revision: 3623 $
-//
-
-using System;
-using System.ComponentModel;
-using System.Drawing;
-using System.Windows.Forms;
-using System.Xml;
-
-using ICSharpCode.Core;
-using ICSharpCode.SharpDevelop;
-using ICSharpCode.SharpDevelop.Gui;
-
-namespace ICSharpCode.XmlEditor
-{
- ///
- /// This user control holds both the XmlTreeViewControl and the
- /// attributes property grid in a split container. This is separate from
- /// the XmlTreeView class so we can use the forms designer to design this control.
- ///
- public class XmlTreeViewContainerControl : System.Windows.Forms.UserControl, IXmlTreeView, IOwnerState, IClipboardHandler
- {
- XmlTreeEditor editor;
- bool dirty;
- bool errorMessageTextBoxVisible;
- bool attributesGridVisible = true;
- bool textBoxVisible;
-
- [Flags]
- public enum XmlTreeViewContainerControlState {
- Nothing = 0,
- ElementSelected = 1,
- RootElementSelected = 2,
- AttributeSelected = 4,
- TextNodeSelected = 8,
- CommentSelected = 16
- }
-
- public event EventHandler DirtyChanged;
-
- public XmlTreeViewContainerControl()
- {
- InitializeComponent();
- InitImages();
- }
-
- ///
- /// Gets the current XmlTreeViewContainerControlState.
- ///
- public Enum InternalState {
- get {
- XmlTreeViewContainerControlState state = XmlTreeViewContainerControlState.Nothing;
- if (SelectedElement != null) {
- state |= XmlTreeViewContainerControlState.ElementSelected;
- if (SelectedElement == Document.DocumentElement) {
- state |= XmlTreeViewContainerControlState.RootElementSelected;
- }
- }
- if (SelectedAttribute != null) {
- state |= XmlTreeViewContainerControlState.AttributeSelected;
- }
- if (SelectedTextNode != null) {
- state = XmlTreeViewContainerControlState.TextNodeSelected;
- }
- if (SelectedComment != null) {
- state = XmlTreeViewContainerControlState.CommentSelected;
- }
- return state;
- }
- }
-
- ///
- /// Gets the property grid that displays attributes for the
- /// selected xml element.
- ///
- public PropertyGrid AttributesGrid {
- get {
- return attributesGrid;
- }
- }
-
- ///
- /// Gets or sets whether the xml document needs saving.
- ///
- public bool IsDirty {
- get {
- return dirty;
- }
- set {
- bool previousDirty = dirty;
- dirty = value;
- OnXmlChanged(previousDirty);
- }
- }
-
- ///
- /// Gets or sets the error message to display.
- ///
- public string ErrorMessage {
- get {
- return errorMessageTextBox.Text;
- }
- set {
- errorMessageTextBox.Text = value;
- }
- }
-
- ///
- /// Gets or sets whether the error message is visible. When visible the
- /// error message text box replaces the property grid.
- ///
- public bool IsErrorMessageTextBoxVisible {
- get {
- return errorMessageTextBoxVisible;
- }
- set {
- errorMessageTextBoxVisible = value;
- if (value) {
- errorMessageTextBox.BringToFront();
- errorMessageTextBox.TabStop = true;;
- IsAttributesGridVisible = false;
- IsTextBoxVisible = false;
- } else {
- errorMessageTextBox.SendToBack();
- errorMessageTextBox.TabStop = false;
- }
- }
- }
-
- ///
- /// Gets the XmlTreeView in the container.
- ///
- public XmlTreeViewControl TreeView {
- get {
- return xmlElementTreeView;
- }
- }
-
- public void ShowXmlIsNotWellFormedMessage(XmlException ex)
- {
- ShowErrorMessage(ex.Message);
- }
-
- public void ShowErrorMessage(string message)
- {
- xmlElementTreeView.Clear();
- ErrorMessage = message;
- IsErrorMessageTextBoxVisible = true;
- }
-
- ///
- /// Displays the specified xml as a tree.
- ///
- public void LoadXml(string xml/*, XmlCompletionDataProvider completionDataProvider*/)
- {
- textBox.Clear();
- IsAttributesGridVisible = true;
- ClearAttributes();
-
- editor = new XmlTreeEditor(this);
- editor.LoadXml(xml);
-
- // Expand document element node.
- if (xmlElementTreeView.Nodes.Count > 0) {
- xmlElementTreeView.Nodes[0].Expand();
- }
- }
-
- ///
- /// Gets or sets the xml document to be shown in this
- /// container control.
- ///
- public XmlDocument Document {
- get {
- return editor.Document;
- }
- set {
- xmlElementTreeView.Document = value;
- }
- }
-
- ///
- /// Shows the attributes.
- ///
- public void ShowAttributes(XmlAttributeCollection attributes)
- {
- IsAttributesGridVisible = true;
- attributesGrid.SelectedObject = new XmlAttributeTypeDescriptor(attributes);
- }
-
- ///
- /// Clears all the attributes currently on display.
- ///
- public void ClearAttributes()
- {
- attributesGrid.SelectedObject = null;
- }
-
- ///
- /// Shows the xml element's text content after the user has
- /// selected the text node.
- ///
- public void ShowTextContent(string text)
- {
- IsTextBoxVisible = true;
- textBox.Text = text;
- }
-
- ///
- /// Gets or sets the text of the text node or
- /// comment node currently on display.
- ///
- public string TextContent {
- get {
- return textBox.Text;
- }
- set {
- textBox.Text = value;
- }
- }
-
- ///
- /// Gets the currently selected node based on what is selected in
- /// the tree. This does not return the selected attribute.
- ///
- public XmlNode SelectedNode {
- get {
- XmlElement selectedElement = SelectedElement;
- if (selectedElement != null) {
- return selectedElement;
- }
-
- XmlText selectedTextNode = SelectedTextNode;
- if (selectedTextNode != null) {
- return selectedTextNode;
- }
-
- return SelectedComment;
- }
- }
-
- ///
- /// Gets the element currently selected.
- ///
- public XmlElement SelectedElement {
- get {
- return xmlElementTreeView.SelectedElement;
- }
- }
-
- ///
- /// Gets the text node currently selected.
- ///
- public XmlText SelectedTextNode {
- get {
- return xmlElementTreeView.SelectedTextNode;
- }
- }
-
- ///
- /// Gets the comment node currently selected.
- ///
- public XmlComment SelectedComment {
- get {
- return xmlElementTreeView.SelectedComment;
- }
- }
-
- ///
- /// Gets the name of the attribute currently selected.
- ///
- public string SelectedAttribute {
- get {
- GridItem gridItem = attributesGrid.SelectedGridItem;
- if (IsAttributesGridVisible && gridItem != null && gridItem.PropertyDescriptor != null) {
- return gridItem.PropertyDescriptor.Name;
- }
- return null;
- }
- }
-
- ///
- /// Shows the add attribute dialog so the user can add a new
- /// attribute to the XML tree.
- ///
- public void AddAttribute()
- {
- editor.AddAttribute();
- }
-
- ///
- /// Shows the add attribute dialog so the user can choose one or more
- /// new attributes to be added to the selected element.
- ///
- /// The list of attributes the user
- /// can choose from.
- /// The attributes selected by the user.
- public string[] SelectNewAttributes(string[] attributes)
- {
- using (IAddXmlNodeDialog addAttributeDialog = CreateAddAttributeDialog(attributes)) {
- if (addAttributeDialog.ShowDialog() == DialogResult.OK) {
- return addAttributeDialog.GetNames();
- }
- return new string[0];
- }
- }
-
- ///
- /// Removes the currently selected attribute.
- ///
- public void RemoveAttribute()
- {
- editor.RemoveAttribute();
- }
-
- ///
- /// Shows the add element dialog so the user can choose one or more
- /// new elements to be added to the selected element.
- ///
- /// The list of elements the user
- /// can choose from.
- /// The elements selected by the user.
- public string[] SelectNewElements(string[] elements)
- {
- using (IAddXmlNodeDialog addElementDialog = CreateAddElementDialog(elements)) {
- if (addElementDialog.ShowDialog() == DialogResult.OK) {
- return addElementDialog.GetNames();
- }
- return new string[0];
- }
- }
-
- ///
- /// Appends a new child element to the currently selected element.
- ///
- public void AppendChildElement(XmlElement element)
- {
- xmlElementTreeView.AppendChildElement(element);
- }
-
- ///
- /// Adds a new child element to the selected element.
- ///
- public void AddChildElement()
- {
- editor.AppendChildElement();
- }
-
- ///
- /// Inserts an element before the currently selected element.
- ///
- public void InsertElementBefore()
- {
- editor.InsertElementBefore();
- }
-
- ///
- /// Inserts the specified element before the currently selected
- /// element.
- ///
- public void InsertElementBefore(XmlElement element)
- {
- xmlElementTreeView.InsertElementBefore(element);
- }
-
- ///
- /// Inserts an element after the currently selected element.
- ///
- public void InsertElementAfter()
- {
- editor.InsertElementAfter();
- }
-
- ///
- /// Inserts the specified element after the currently selected
- /// element.
- ///
- public void InsertElementAfter(XmlElement element)
- {
- xmlElementTreeView.InsertElementAfter(element);
- }
-
- ///
- /// Removes the specified element from the tree.
- ///
- public void RemoveElement(XmlElement element)
- {
- xmlElementTreeView.RemoveElement(element);
- }
-
- ///
- /// Appends a new text node to the currently selected
- /// element.
- ///
- public void AppendChildTextNode(XmlText textNode)
- {
- xmlElementTreeView.AppendChildTextNode(textNode);
- }
-
- ///
- /// Appends a new text node to the currently selected
- /// element.
- ///
- public void AppendChildTextNode()
- {
- editor.AppendChildTextNode();
- }
-
- ///
- /// Inserts a new text node before the currently selected
- /// node.
- ///
- public void InsertTextNodeBefore()
- {
- editor.InsertTextNodeBefore();
- }
-
- ///
- /// Inserts a new text node before the currently selected
- /// node.
- ///
- public void InsertTextNodeBefore(XmlText textNode)
- {
- xmlElementTreeView.InsertTextNodeBefore(textNode);
- }
-
- ///
- /// Inserts a new text node after the currently selected
- /// node.
- ///
- public void InsertTextNodeAfter()
- {
- editor.InsertTextNodeAfter();
- }
-
- ///
- /// Inserts a new text node after the currently selected
- /// node.
- ///
- public void InsertTextNodeAfter(XmlText textNode)
- {
- xmlElementTreeView.InsertTextNodeAfter(textNode);
- }
-
- ///
- /// Removes the currently selected text node.
- ///
- public void RemoveTextNode(XmlText textNode)
- {
- xmlElementTreeView.RemoveTextNode(textNode);
- }
-
- ///
- /// Updates the corresponding tree node's text.
- ///
- public void UpdateTextNode(XmlText textNode)
- {
- xmlElementTreeView.UpdateTextNode(textNode);
- }
-
- ///
- /// Updates the corresponding tree node's text.
- ///
- public void UpdateComment(XmlComment comment)
- {
- xmlElementTreeView.UpdateComment(comment);
- }
-
- ///
- /// Appends a new child comment node to the currently selected
- /// element.
- ///
- public void AppendChildComment(XmlComment comment)
- {
- xmlElementTreeView.AppendChildComment(comment);
- }
-
- ///
- /// Appends a new child comment node to the currently selected
- /// element.
- ///
- public void AppendChildComment()
- {
- editor.AppendChildComment();
- }
-
- ///
- /// Removes the specified xml comment from the tree.
- ///
- public void RemoveComment(XmlComment comment)
- {
- xmlElementTreeView.RemoveComment(comment);
- }
-
- ///
- /// Inserts the comment before the currently selected node.
- ///
- public void InsertCommentBefore(XmlComment comment)
- {
- xmlElementTreeView.InsertCommentBefore(comment);
- }
-
- ///
- /// Inserts a comment before the currently selected node.
- ///
- public void InsertCommentBefore()
- {
- editor.InsertCommentBefore();
- }
-
- ///
- /// Inserts the comment after the currently selected node.
- ///
- public void InsertCommentAfter(XmlComment comment)
- {
- xmlElementTreeView.InsertCommentAfter(comment);
- }
-
- ///
- /// Inserts a comment after the currently selected node.
- ///
- public void InsertCommentAfter()
- {
- editor.InsertCommentAfter();
- }
-
- ///
- /// Updates the view to show that the specified node is going
- /// to be cut.
- ///
- public void ShowCut(XmlNode node)
- {
- xmlElementTreeView.ShowCut(node);
- }
-
- ///
- /// Updates the view so that the specified node is not displayed
- /// as being cut.
- ///
- public void HideCut(XmlNode node)
- {
- xmlElementTreeView.HideCut(node);
- }
-
- #region IClipboardHandler implementation
-
- ///
- /// Gets whether cutting is enabled.
- ///
- public bool EnableCut {
- get {
- return editor.IsCutEnabled;
- }
- }
-
- ///
- /// Gets whether copying is enabled.
- ///
- public bool EnableCopy {
- get {
- return editor.IsCopyEnabled;
- }
- }
-
- ///
- /// Gets whether pasting is enabled.
- ///
- public bool EnablePaste {
- get {
- return editor.IsPasteEnabled;
- }
- }
-
- ///
- /// Gets whether deleting is enabled.
- ///
- public bool EnableDelete {
- get {
- return editor.IsDeleteEnabled;
- }
- }
-
- ///
- /// Currently not possible to select all tree nodes so this
- /// always returns false.
- ///
- public bool EnableSelectAll {
- get {
- return false;
- }
- }
-
- ///
- /// Cuts the selected tree node.
- ///
- public void Cut()
- {
- editor.Cut();
- }
-
- ///
- /// Copies the selected tree node.
- ///
- public void Copy()
- {
- editor.Copy();
- }
-
- ///
- /// Pastes the selected tree node.
- ///
- public void Paste()
- {
- editor.Paste();
- }
-
- ///
- /// Deletes the selected tree node.
- ///
- public void Delete()
- {
- editor.Delete();
- }
-
- ///
- /// Selects all tree nodes. Currently not supported.
- ///
- public void SelectAll()
- {
- }
-
- #endregion
-
- ///
- /// Disposes resources used by the control.
- ///
- /// true if managed resources should be disposed; otherwise, false.
- protected override void Dispose(bool disposing)
- {
- if (disposing) {
- if (components != null) {
- components.Dispose();
- }
- }
- base.Dispose(disposing);
- }
-
- ///
- /// Creates a new AddElementDialog.
- ///
- /// The element names to be listed in the
- /// dialog.
- protected virtual IAddXmlNodeDialog CreateAddElementDialog(string[] elementNames)
- {
- AddXmlNodeDialog dialog = new AddXmlNodeDialog(elementNames);
- dialog.Text = StringParser.Parse("${res:ICSharpCode.XmlEditor.AddElementDialog.Title}");
- dialog.CustomNameLabelText = StringParser.Parse("${res:ICSharpCode.XmlEditor.AddElementDialog.CustomElementLabel}");
- return dialog;
- }
-
- ///
- /// Creates a new AddAttributeDialog.
- ///
- /// The attribute names to be listed in the
- /// dialog.
- protected virtual IAddXmlNodeDialog CreateAddAttributeDialog(string[] attributeNames)
- {
- AddXmlNodeDialog dialog = new AddXmlNodeDialog(attributeNames);
- dialog.Text = StringParser.Parse("${res:ICSharpCode.XmlEditor.AddAttributeDialog.Title}");
- dialog.CustomNameLabelText = StringParser.Parse("${res:ICSharpCode.XmlEditor.AddAttributeDialog.CustomAttributeLabel}");
- return dialog;
- }
-
- ///
- /// Deletes the selected node.
- ///
- protected void XmlElementTreeViewDeleteKeyPressed(object source, EventArgs e)
- {
- Delete();
- }
-
- #region Forms Designer generated code
-
- ///
- /// Designer variable used to keep track of non-visual components.
- ///
- System.ComponentModel.IContainer components = null;
-
- ///
- /// This method is required for Windows Forms designer support.
- /// Do not change the method contents inside the source code editor. The Forms designer might
- /// not be able to load this method if it was changed manually.
- ///
- void InitializeComponent()
- {
- this.components = new System.ComponentModel.Container();
- ICSharpCode.SharpDevelop.Gui.ExtTreeViewComparer extTreeViewComparer1 = new ICSharpCode.SharpDevelop.Gui.ExtTreeViewComparer();
- this.splitContainer = new System.Windows.Forms.SplitContainer();
- this.xmlElementTreeView = new ICSharpCode.XmlEditor.XmlTreeViewControl();
- this.attributesGrid = new System.Windows.Forms.PropertyGrid();
- this.errorMessageTextBox = new System.Windows.Forms.RichTextBox();
- this.textBox = new System.Windows.Forms.RichTextBox();
- this.splitContainer.Panel1.SuspendLayout();
- this.splitContainer.Panel2.SuspendLayout();
- this.splitContainer.SuspendLayout();
- this.SuspendLayout();
- //
- // splitContainer
- //
- this.splitContainer.Dock = System.Windows.Forms.DockStyle.Fill;
- this.splitContainer.Location = new System.Drawing.Point(0, 0);
- this.splitContainer.Name = "splitContainer";
- //
- // splitContainer.Panel1
- //
- this.splitContainer.Panel1.Controls.Add(this.xmlElementTreeView);
- //
- // splitContainer.Panel2
- //
- this.splitContainer.Panel2.Controls.Add(this.attributesGrid);
- this.splitContainer.Panel2.Controls.Add(this.errorMessageTextBox);
- this.splitContainer.Panel2.Controls.Add(this.textBox);
- this.splitContainer.Size = new System.Drawing.Size(562, 326);
- this.splitContainer.SplitterDistance = 185;
- this.splitContainer.SplitterWidth = 2;
- this.splitContainer.TabIndex = 0;
- this.splitContainer.TabStop = false;
- //
- // xmlElementTreeView
- //
- this.xmlElementTreeView.AllowDrop = true;
- this.xmlElementTreeView.CanClearSelection = true;
- this.xmlElementTreeView.Dock = System.Windows.Forms.DockStyle.Fill;
- this.xmlElementTreeView.Document = null;
- this.xmlElementTreeView.DrawMode = System.Windows.Forms.TreeViewDrawMode.OwnerDrawText;
- this.xmlElementTreeView.HideSelection = false;
- this.xmlElementTreeView.ImageIndex = 0;
- this.xmlElementTreeView.IsSorted = false;
- this.xmlElementTreeView.Location = new System.Drawing.Point(0, 0);
- this.xmlElementTreeView.Name = "xmlElementTreeView";
- this.xmlElementTreeView.NodeSorter = extTreeViewComparer1;
- this.xmlElementTreeView.SelectedImageIndex = 0;
- this.xmlElementTreeView.Size = new System.Drawing.Size(185, 326);
- this.xmlElementTreeView.TabIndex = 0;
- this.xmlElementTreeView.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.XmlElementTreeViewAfterSelect);
- this.xmlElementTreeView.DeleteKeyPressed += new System.EventHandler(this.XmlElementTreeViewDeleteKeyPressed);
- //
- // attributesGrid
- //
- this.attributesGrid.Dock = System.Windows.Forms.DockStyle.Fill;
- this.attributesGrid.HelpVisible = false;
- this.attributesGrid.Location = new System.Drawing.Point(0, 0);
- this.attributesGrid.Name = "attributesGrid";
- this.attributesGrid.PropertySort = System.Windows.Forms.PropertySort.Alphabetical;
- this.attributesGrid.Size = new System.Drawing.Size(375, 326);
- this.attributesGrid.TabIndex = 1;
- this.attributesGrid.ToolbarVisible = false;
- this.attributesGrid.PropertyValueChanged += new System.Windows.Forms.PropertyValueChangedEventHandler(this.AttributesGridPropertyValueChanged);
- //
- // errorMessageTextBox
- //
- this.errorMessageTextBox.Dock = System.Windows.Forms.DockStyle.Fill;
- this.errorMessageTextBox.Location = new System.Drawing.Point(0, 0);
- this.errorMessageTextBox.Name = "errorMessageTextBox";
- this.errorMessageTextBox.Size = new System.Drawing.Size(375, 326);
- this.errorMessageTextBox.TabIndex = 0;
- this.errorMessageTextBox.TabStop = false;
- this.errorMessageTextBox.Text = "";
- //
- // textBox
- //
- this.textBox.Dock = System.Windows.Forms.DockStyle.Fill;
- this.textBox.Location = new System.Drawing.Point(0, 0);
- this.textBox.Name = "textBox";
- this.textBox.Size = new System.Drawing.Size(375, 326);
- this.textBox.TabIndex = 2;
- this.textBox.TabStop = false;
- this.textBox.Text = "";
- this.textBox.TextChanged += new System.EventHandler(this.TextBoxTextChanged);
- //
- // XmlTreeViewContainerControl
- //
- this.Controls.Add(this.splitContainer);
- this.Name = "XmlTreeViewContainerControl";
- this.Size = new System.Drawing.Size(562, 326);
- this.splitContainer.Panel1.ResumeLayout(false);
- this.splitContainer.Panel2.ResumeLayout(false);
- this.splitContainer.ResumeLayout(false);
- this.ResumeLayout(false);
- }
- private System.Windows.Forms.RichTextBox textBox;
- private System.Windows.Forms.PropertyGrid attributesGrid;
- private System.Windows.Forms.RichTextBox errorMessageTextBox;
- private ICSharpCode.XmlEditor.XmlTreeViewControl xmlElementTreeView;
- private System.Windows.Forms.SplitContainer splitContainer;
-
- #endregion
-
- ///
- /// This method is protected only so we can easily test
- /// what happens when this method is called. Triggering
- /// a TextChanged event is difficult to do from unit tests.
- /// You can trigger it it by setting the textBox's Rtf property.
- ///
- protected void TextBoxTextChanged(object sender, EventArgs e)
- {
- if (editor != null) {
- bool previousIsDirty = dirty;
- editor.TextContentChanged();
- OnXmlChanged(previousIsDirty);
- }
- }
-
- ///
- /// This method is protected so we can test it.
- ///
- protected void XmlElementTreeViewAfterSelect(object sender, TreeViewEventArgs e)
- {
- editor.SelectedNodeChanged();
- }
-
- ///
- /// This method is protected so we can test it.
- ///
- protected void AttributesGridPropertyValueChanged(object s, PropertyValueChangedEventArgs e)
- {
- bool previousIsDirty = dirty;
- editor.AttributeValueChanged();
- OnXmlChanged(previousIsDirty);
- }
-
- ///
- /// Creates an image list that will be used for the XmlTreeViewControl.
- ///
- void InitImages()
- {
- if (components == null) {
- components = new Container();
- }
- ImageList images = new ImageList(components);
-
- // Add xml element tree node images.
- Image xmlElementImage = Image.FromStream(typeof(XmlTreeViewContainerControl).Assembly.GetManifestResourceStream("ICSharpCode.XmlBinding.Resources.XmlElementTreeNodeIcon.png"));
- images.Images.Add(XmlElementTreeNode.XmlElementTreeNodeImageKey, xmlElementImage);
- images.Images.Add(XmlElementTreeNode.XmlElementTreeNodeGhostImageKey, IconService.GetGhostBitmap(new Bitmap(xmlElementImage)));
-
- // Add text tree node images.
- Image xmlTextImage = Image.FromStream(typeof(XmlTreeViewContainerControl).Assembly.GetManifestResourceStream("ICSharpCode.XmlBinding.Resources.XmlTextTreeNodeIcon.png"));
- images.Images.Add(XmlTextTreeNode.XmlTextTreeNodeImageKey, xmlTextImage);
- images.Images.Add(XmlTextTreeNode.XmlTextTreeNodeGhostImageKey, IconService.GetGhostBitmap(new Bitmap(xmlTextImage)));
-
- // Add comment tree node images.
- Image xmlCommentImage = Image.FromStream(typeof(XmlTreeViewContainerControl).Assembly.GetManifestResourceStream("ICSharpCode.XmlBinding.Resources.XmlCommentTreeNodeIcon.png"));
- images.Images.Add(XmlCommentTreeNode.XmlCommentTreeNodeImageKey, xmlCommentImage);
- images.Images.Add(XmlCommentTreeNode.XmlCommentTreeNodeGhostImageKey, IconService.GetGhostBitmap(new Bitmap(xmlCommentImage)));
-
- xmlElementTreeView.ImageList = images;
- }
-
- ///
- /// Raises the dirty changed event if the dirty flag has changed.
- ///
- void OnXmlChanged(bool previousIsDirty)
- {
- if (previousIsDirty != dirty) {
- OnDirtyChanged();
- }
- }
-
- ///
- /// Raises the DirtyChanged event.
- ///
- void OnDirtyChanged()
- {
- if (DirtyChanged != null) {
- DirtyChanged(this, new EventArgs());
- }
- }
-
- ///
- /// Gets or sets whether the attributes grid is visible.
- ///
- bool IsAttributesGridVisible {
- get {
- return attributesGridVisible;
- }
- set {
- attributesGridVisible = value;
- if (value) {
- attributesGrid.BringToFront();
- attributesGrid.TabStop = true;
- IsTextBoxVisible = false;
- IsErrorMessageTextBoxVisible = false;
- } else {
- attributesGrid.SendToBack();
- attributesGrid.TabStop = false;
- }
- }
- }
-
- ///
- /// Gets or sets whether the text node text box is visible.
- ///
- bool IsTextBoxVisible {
- set {
- textBoxVisible = value;
- if (value) {
- textBox.BringToFront();
- textBox.TabStop = true;
- IsAttributesGridVisible = false;
- IsErrorMessageTextBoxVisible = false;
- } else {
- textBox.SendToBack();
- textBox.TabStop = false;
- }
- }
- }
- }
-}
-
\ No newline at end of file
diff --git a/src/AddIns/DisplayBindings/XmlEditor/Project/Src/Src/XmlTreeViewControl.cs b/src/AddIns/DisplayBindings/XmlEditor/Project/Src/Src/XmlTreeViewControl.cs
deleted file mode 100644
index 641877f97d..0000000000
--- a/src/AddIns/DisplayBindings/XmlEditor/Project/Src/Src/XmlTreeViewControl.cs
+++ /dev/null
@@ -1,578 +0,0 @@
-//
-//
-//
-//
-// $Revision: 2741 $
-//
-
-using System;
-using System.ComponentModel;
-using System.Windows.Forms;
-using System.Xml;
-
-using ICSharpCode.Core;
-using ICSharpCode.SharpDevelop.Gui;
-
-namespace ICSharpCode.XmlEditor
-{
- ///
- /// 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.
- ///
- public class XmlTreeViewControl : ExtTreeView
- {
- const string ViewStatePropertyName = "XmlTreeViewControl.ViewState";
-
- XmlDocument document;
-
- enum InsertionMode {
- Before = 0,
- After = 1
- }
-
- ///
- /// Raised when the delete key is pressed.
- ///
- public event EventHandler DeleteKeyPressed;
-
- public XmlTreeViewControl()
- {
- }
-
- ///
- /// Gets or sets the xml document currently being displayed.
- ///
- [Browsable(false)]
- public XmlDocument Document {
- get {
- return document;
- }
- set {
- document = value;
-
- // Update display.
- BeginUpdate();
- try {
- ShowDocument();
- } finally {
- EndUpdate();
- }
- }
- }
-
- ///
- /// Gets the selected element in the tree.
- ///
- public XmlElement SelectedElement {
- get {
- XmlElementTreeNode xmlElementTreeNode = SelectedElementNode;
- if (xmlElementTreeNode != null) {
- return xmlElementTreeNode.XmlElement;
- }
- return null;
- }
- }
-
- ///
- /// Determines whether an element is selected in the tree.
- ///
- public bool IsElementSelected {
- get {
- return SelectedElement != null;
- }
- }
-
- ///
- /// Gets the selected text node in the tree.
- ///
- public XmlText SelectedTextNode {
- get {
- XmlTextTreeNode xmlTextTreeNode = SelectedNode as XmlTextTreeNode;
- if (xmlTextTreeNode != null) {
- return xmlTextTreeNode.XmlText;
- }
- return null;
- }
- }
-
- ///
- /// Gets the selected comment node in the tree.
- ///
- public XmlComment SelectedComment {
- get {
- XmlCommentTreeNode commentTreeNode = SelectedNode as XmlCommentTreeNode;
- if (commentTreeNode != null) {
- return commentTreeNode.XmlComment;
- }
- return null;
- }
- }
-
- ///
- /// Determines whether a text node is selected in the tree.
- ///
- public bool IsTextNodeSelected {
- get {
- return SelectedTextNode != null;
- }
- }
-
- ///
- /// Saves the current state of the tree.
- ///
- public void SaveViewState(Properties properties)
- {
- properties.Set(ViewStatePropertyName, TreeViewHelper.GetViewStateString(this));
- }
-
- ///
- /// Restores the node state of the tree.
- ///
- public void RestoreViewState(Properties properties)
- {
- TreeViewHelper.ApplyViewStateString(properties.Get(ViewStatePropertyName, String.Empty), this);
- }
-
- ///
- /// Appends a new child element to the currently selected node.
- ///
- public void AppendChildElement(XmlElement element)
- {
- XmlElementTreeNode selectedNode = SelectedElementNode;
- if (selectedNode != null) {
- XmlElementTreeNode newNode = new XmlElementTreeNode(element);
- newNode.AddTo(selectedNode);
- selectedNode.Expand();
- }
- }
-
- ///
- /// Appends a new child text node to the currently selected element.
- ///
- public void AppendChildTextNode(XmlText textNode)
- {
- XmlElementTreeNode selectedNode = SelectedElementNode;
- if (selectedNode != null) {
- XmlTextTreeNode newNode = new XmlTextTreeNode(textNode);
- newNode.AddTo(selectedNode);
- selectedNode.Expand();
- }
- }
-
- ///
- /// Inserts a new element node before the currently selected
- /// node.
- ///
- public void InsertElementBefore(XmlElement element)
- {
- InsertElement(element, InsertionMode.Before);
- }
-
- ///
- /// Inserts a new element node after the currently selected
- /// node.
- ///
- public void InsertElementAfter(XmlElement element)
- {
- InsertElement(element, InsertionMode.After);
- }
-
- ///
- /// Removes the specified element from the tree.
- ///
- public void RemoveElement(XmlElement element)
- {
- XmlElementTreeNode node = FindElement(element);
- if (node != null) {
- node.Remove();
- }
- }
-
- ///
- /// Removes the specified text node from the tree.
- ///
- public void RemoveTextNode(XmlText textNode)
- {
- XmlTextTreeNode node = FindTextNode(textNode);
- if (node != null) {
- node.Remove();
- }
- }
-
- ///
- /// Inserts a text node before the currently selected
- /// node.
- ///
- public void InsertTextNodeBefore(XmlText textNode)
- {
- InsertTextNode(textNode, InsertionMode.Before);
- }
-
- ///
- /// Inserts a text node after the currently selected
- /// node.
- ///
- public void InsertTextNodeAfter(XmlText textNode)
- {
- InsertTextNode(textNode, InsertionMode.After);
- }
-
- ///
- /// Updates the corresponding tree node's text based on
- /// the textNode's value.
- ///
- public void UpdateTextNode(XmlText textNode)
- {
- XmlTextTreeNode node = FindTextNode(textNode);
- if (node != null) {
- node.Update();
- }
- }
-
- ///
- /// Updates the corresponding tree node's text based on
- /// the comment's value.
- ///
- public void UpdateComment(XmlComment comment)
- {
- XmlCommentTreeNode node = FindComment(comment);
- if (node != null) {
- node.Update();
- }
- }
-
- ///
- /// Appends a new child comment node to the currently selected element.
- ///
- public void AppendChildComment(XmlComment comment)
- {
- XmlElementTreeNode selectedNode = SelectedElementNode;
- if (selectedNode != null) {
- XmlCommentTreeNode newNode = new XmlCommentTreeNode(comment);
- newNode.AddTo(selectedNode);
- selectedNode.Expand();
- }
- }
-
- ///
- /// Removes the specified comment from the tree.
- ///
- public void RemoveComment(XmlComment comment)
- {
- XmlCommentTreeNode node = FindComment(comment);
- if (node != null) {
- node.Remove();
- }
- }
-
- ///
- /// Inserts a comment node before the currently selected
- /// node.
- ///
- public void InsertCommentBefore(XmlComment comment)
- {
- InsertComment(comment, InsertionMode.Before);
- }
-
- ///
- /// Inserts a comment node after the currently selected
- /// node.
- ///
- public void InsertCommentAfter(XmlComment comment)
- {
- InsertComment(comment, InsertionMode.After);
- }
-
- ///
- /// Updates the image so the corresponding tree node shows that
- /// it is in the process of being cut.
- ///
- public void ShowCut(XmlNode node)
- {
- ShowCut(node, true);
- }
-
- ///
- /// Updates the image so the corresponding tree node no longer
- /// shows it is in the process of being cut.
- ///
- public void HideCut(XmlNode node)
- {
- ShowCut(node, false);
- }
-
- ///
- /// 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.
- ///
- protected override void OnMouseDown(MouseEventArgs e)
- {
- base.OnMouseDown(e);
- if (SelectedNode == null) {
- this.OnAfterSelect(new TreeViewEventArgs(null, TreeViewAction.ByMouse));
- }
- }
-
- ///
- /// Raises the DeleteKeyPressed event.
- ///
- 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);
- }
-
- ///
- /// Displays the document in the xml tree.
- ///
- 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;
- }
- }
- }
- }
-
- ///
- /// Returns the selected xml element tree node.
- ///
- XmlElementTreeNode SelectedElementNode {
- get {
- return SelectedNode as XmlElementTreeNode;
- }
- }
-
- ///
- /// Inserts a new element node either before or after the
- /// currently selected element node.
- ///
- 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);
- }
- }
-
- ///
- /// Inserts a new text node either before or after the
- /// currently selected node.
- ///
- 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);
- }
- }
-
- ///
- /// Inserts a new comment node either before or after the
- /// currently selected node.
- ///
- 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);
- }
- }
- }
-
- ///
- /// Looks at all the nodes in the tree view and returns the
- /// tree node that represents the specified element.
- ///
- 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;
- }
-
- ///
- /// Finds the corresponding XmlElementTreeNode.
- ///
- XmlElementTreeNode FindElement(XmlElement element)
- {
- XmlElementTreeNode selectedElementTreeNode = SelectedNode as XmlElementTreeNode;
- if (selectedElementTreeNode != null && selectedElementTreeNode.XmlElement == element) {
- return selectedElementTreeNode;
- } else {
- return FindElement(element, Nodes);
- }
- }
-
- ///
- /// Looks at all the nodes in the tree view and returns the
- /// tree node that represents the specified text node.
- ///
- 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;
- }
-
- ///
- /// Finds the specified text node in the tree.
- ///
- XmlTextTreeNode FindTextNode(XmlText textNode)
- {
- XmlTextTreeNode selectedTextTreeNode = SelectedNode as XmlTextTreeNode;
- if (selectedTextTreeNode != null && selectedTextTreeNode.XmlText == textNode) {
- return selectedTextTreeNode;
- } else {
- return FindTextNode(textNode, Nodes);
- }
- }
-
- ///
- /// Looks at all the nodes in the tree view and returns the
- /// tree node that represents the specified comment node.
- ///
- 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;
- }
-
- ///
- /// Locates the specified comment in the tree.
- ///
- XmlCommentTreeNode FindComment(XmlComment comment)
- {
- XmlCommentTreeNode selectedCommentTreeNode = SelectedNode as XmlCommentTreeNode;
- if (selectedCommentTreeNode != null && selectedCommentTreeNode.XmlComment == comment) {
- return selectedCommentTreeNode;
- } else {
- return FindComment(comment, Nodes);
- }
- }
-
- ///
- /// Shows the corresponding tree node with the ghosted image
- /// that indicates it is being cut.
- ///
- void ShowCutElement(XmlElement element, bool showGhostImage)
- {
- XmlElementTreeNode node = FindElement(element);
- node.ShowGhostImage = showGhostImage;
- }
-
- ///
- /// Shows the corresponding tree node with the ghosted image
- /// that indicates it is being cut.
- ///
- void ShowCutTextNode(XmlText textNode, bool showGhostImage)
- {
- XmlTextTreeNode node = FindTextNode(textNode);
- node.ShowGhostImage = showGhostImage;
- }
-
- ///
- /// Shows the corresponding tree node with the ghosted image
- /// that indicates it is being cut.
- ///
- void ShowCutComment(XmlComment comment, bool showGhostImage)
- {
- XmlCommentTreeNode node = FindComment(comment);
- node.ShowGhostImage = showGhostImage;
- }
-
- ///
- /// Shows the cut node with a ghost image.
- ///
- /// True if the node should be
- /// shown with the ghost image.
- 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);
- }
- }
- }
-}
diff --git a/src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlCodeCompletionBinding.cs b/src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlCodeCompletionBinding.cs
index 832da6fd79..caa4690f20 100644
--- a/src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlCodeCompletionBinding.cs
+++ b/src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlCodeCompletionBinding.cs
@@ -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)
diff --git a/src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlCompletionDataProvider.cs b/src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlCompletionDataProvider.cs
index ef8df1e31f..cf2455101e 100644
--- a/src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlCompletionDataProvider.cs
+++ b/src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlCompletionDataProvider.cs
@@ -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;
+ }
+
///
/// Finds the schema given the xml element path.
///
@@ -65,7 +112,7 @@ namespace ICSharpCode.XmlEditor
}
///
- /// Gets the schema completion data that was created from the specified
+ /// Gets the schema completion data that was created from the specified
/// schema filename.
///
public XmlSchemaCompletionData FindSchemaFromFileName(string fileName)
diff --git a/src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlTreeView.cs b/src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlTreeView.cs
index 170393ded0..d1f29baf9d 100644
--- a/src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlTreeView.cs
+++ b/src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlTreeView.cs
@@ -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();
}
}
diff --git a/src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlTreeViewContainerControl.cs b/src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlTreeViewContainerControl.cs
index 12bb8d0fb9..62ad4fbe71 100644
--- a/src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlTreeViewContainerControl.cs
+++ b/src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlTreeViewContainerControl.cs
@@ -30,7 +30,7 @@ namespace ICSharpCode.XmlEditor
bool attributesGridVisible = true;
[Flags]
- enum XmlTreeViewContainerControlStates {
+ internal enum XmlTreeViewContainerControlStates {
None = 0,
ElementSelected = 1,
RootElementSelected = 2,
diff --git a/src/AddIns/DisplayBindings/XmlEditor/Test/Completion/FirstCompletionListItemSelectedTestFixture.cs b/src/AddIns/DisplayBindings/XmlEditor/Test/Completion/FirstCompletionListItemSelectedTestFixture.cs
index f7f1852278..36af7a9dca 100644
--- a/src/AddIns/DisplayBindings/XmlEditor/Test/Completion/FirstCompletionListItemSelectedTestFixture.cs
+++ b/src/AddIns/DisplayBindings/XmlEditor/Test/Completion/FirstCompletionListItemSelectedTestFixture.cs
@@ -5,7 +5,9 @@
// $Revision: 3490 $
//
+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
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
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;
}
///
@@ -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);
}
///
@@ -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
[Test]
public void SelectedCompletionDataMatches()
{
- List items = new List(completionDataItems);
- items.Sort(DefaultCompletionData.Compare);
+ List items = completionDataItems.Items.OrderBy(item => item.Text).ToList();
Assert.AreEqual(items[0].Text, selectedCompletionData.Text);
}
}
diff --git a/src/AddIns/DisplayBindings/XmlEditor/Test/Completion/ProcessKeyTests.cs b/src/AddIns/DisplayBindings/XmlEditor/Test/Completion/ProcessKeyTests.cs
index a9a8b7c794..1a83b829a5 100644
--- a/src/AddIns/DisplayBindings/XmlEditor/Test/Completion/ProcessKeyTests.cs
+++ b/src/AddIns/DisplayBindings/XmlEditor/Test/Completion/ProcessKeyTests.cs
@@ -5,9 +5,9 @@
// $Revision: 2760 $
//
+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
[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("", '<');
}
///
@@ -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));
}
}
}
diff --git a/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/AbstractElementTestFixture.cs b/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/AbstractElementTestFixture.cs
index e410c4604b..694606bb85 100644
--- a/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/AbstractElementTestFixture.cs
+++ b/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/AbstractElementTestFixture.cs
@@ -5,11 +5,12 @@
// $Revision: 915 $
//
+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
[TestFixture]
public class AbstractElementTestFixture : SchemaTestFixtureBase
{
- ICompletionData[] itemsElementChildren;
- ICompletionData[] fileElementAttributes;
- ICompletionData[] fileElementChildren;
+ ICompletionItem[] itemsElementChildren;
+ ICompletionItem[] fileElementAttributes;
+ ICompletionItem[] fileElementChildren;
public override void FixtureInit()
{
diff --git a/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/AllElementTestFixture.cs b/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/AllElementTestFixture.cs
index c0c2c3c7df..ba45507622 100644
--- a/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/AllElementTestFixture.cs
+++ b/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/AllElementTestFixture.cs
@@ -5,11 +5,12 @@
// $Revision: 1388 $
//
+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
[TestFixture]
public class AllElementTestFixture : SchemaTestFixtureBase
{
- ICompletionData[] personElementChildren;
- ICompletionData[] firstNameAttributes;
- ICompletionData[] firstNameElementChildren;
+ ICompletionItem[] personElementChildren;
+ ICompletionItem[] firstNameAttributes;
+ ICompletionItem[] firstNameElementChildren;
public override void FixtureInit()
{
diff --git a/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/AttributeAnnotationTestFixture.cs b/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/AttributeAnnotationTestFixture.cs
index f7911188d6..7e9a573630 100644
--- a/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/AttributeAnnotationTestFixture.cs
+++ b/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/AttributeAnnotationTestFixture.cs
@@ -5,12 +5,13 @@
// $Revision: 915 $
//
-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
[TestFixture]
public class AttributeAnnotationTestFixture : SchemaTestFixtureBase
{
- ICompletionData[] fooAttributeCompletionData;
- ICompletionData[] barAttributeCompletionData;
+ ICompletionItem[] fooAttributeCompletionData;
+ ICompletionItem[] barAttributeCompletionData;
public override void FixtureInit()
{
diff --git a/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/AttributeGroupRefTestFixture.cs b/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/AttributeGroupRefTestFixture.cs
index 3b4ab5243f..acee46f14a 100644
--- a/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/AttributeGroupRefTestFixture.cs
+++ b/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/AttributeGroupRefTestFixture.cs
@@ -5,11 +5,12 @@
// $Revision: 915 $
//
+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
[TestFixture]
public class AttributeGroupRefTestFixture : SchemaTestFixtureBase
{
- ICompletionData[] attributeCompletionData;
+ ICompletionItem[] attributeCompletionData;
public override void FixtureInit()
{
diff --git a/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/AttributeRefTestFixture.cs b/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/AttributeRefTestFixture.cs
index 4c2a3fbfa1..65f07e7076 100644
--- a/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/AttributeRefTestFixture.cs
+++ b/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/AttributeRefTestFixture.cs
@@ -5,11 +5,12 @@
// $Revision: 915 $
//
+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
[TestFixture]
public class AttributeRefTestFixture : SchemaTestFixtureBase
{
- ICompletionData[] attributes;
+ ICompletionItem[] attributes;
public override void FixtureInit()
{
diff --git a/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/AttributeValueAnnotationTestFixture.cs b/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/AttributeValueAnnotationTestFixture.cs
index f7132a849f..647c87a6cd 100644
--- a/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/AttributeValueAnnotationTestFixture.cs
+++ b/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/AttributeValueAnnotationTestFixture.cs
@@ -5,12 +5,13 @@
// $Revision: 915 $
//
-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
[TestFixture]
public class AttributeValueAnnotationTestFixture : SchemaTestFixtureBase
{
- ICompletionData[] barAttributeValuesCompletionData;
+ ICompletionItem[] barAttributeValuesCompletionData;
public override void FixtureInit()
{
diff --git a/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/ChildElementAttributesTestFixture.cs b/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/ChildElementAttributesTestFixture.cs
index 6df5a7019a..104e01b83d 100644
--- a/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/ChildElementAttributesTestFixture.cs
+++ b/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/ChildElementAttributesTestFixture.cs
@@ -5,11 +5,12 @@
// $Revision: 915 $
//
+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
[TestFixture]
public class ChildElementAttributesTestFixture : SchemaTestFixtureBase
{
- ICompletionData[] attributes;
+ ICompletionItem[] attributes;
public override void FixtureInit()
{
diff --git a/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/ChoiceTestFixture.cs b/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/ChoiceTestFixture.cs
index f174a24a70..5c4ebd3b16 100644
--- a/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/ChoiceTestFixture.cs
+++ b/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/ChoiceTestFixture.cs
@@ -5,11 +5,12 @@
// $Revision: 915 $
//
+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
[TestFixture]
public class ChoiceTestFixture : SchemaTestFixtureBase
{
- ICompletionData[] noteChildElements;
+ ICompletionItem[] noteChildElements;
public override void FixtureInit()
{
diff --git a/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/ComplexContentExtensionTestFixture.cs b/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/ComplexContentExtensionTestFixture.cs
index 8e76c6736f..57b649c5cf 100644
--- a/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/ComplexContentExtensionTestFixture.cs
+++ b/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/ComplexContentExtensionTestFixture.cs
@@ -5,11 +5,12 @@
// $Revision: 915 $
//
+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
[TestFixture]
public class ComplexContentExtensionTestFixture : SchemaTestFixtureBase
{
- ICompletionData[] bodyChildElements;
- ICompletionData[] bodyAttributes;
+ ICompletionItem[] bodyChildElements;
+ ICompletionItem[] bodyAttributes;
public override void FixtureInit()
{
diff --git a/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/DuplicateElementTestFixture.cs b/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/DuplicateElementTestFixture.cs
index 72a43927d3..3196383e20 100644
--- a/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/DuplicateElementTestFixture.cs
+++ b/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/DuplicateElementTestFixture.cs
@@ -5,11 +5,12 @@
// $Revision: 915 $
//
+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
[TestFixture]
public class DuplicateElementTestFixture : SchemaTestFixtureBase
{
- ICompletionData[] htmlChildElements;
+ ICompletionItem[] htmlChildElements;
public override void FixtureInit()
{
diff --git a/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/ElementAnnotationTestFixture.cs b/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/ElementAnnotationTestFixture.cs
index e005bd5f76..c164d481ec 100644
--- a/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/ElementAnnotationTestFixture.cs
+++ b/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/ElementAnnotationTestFixture.cs
@@ -5,12 +5,14 @@
// $Revision: 915 $
//
-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
[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
[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]
diff --git a/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/ElementRefAnnotationTestFixture.cs b/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/ElementRefAnnotationTestFixture.cs
index a69920bf82..5e6a6de24e 100644
--- a/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/ElementRefAnnotationTestFixture.cs
+++ b/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/ElementRefAnnotationTestFixture.cs
@@ -5,12 +5,13 @@
// $Revision: 915 $
//
-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
[TestFixture]
public class ElementRefAnnotationTestFixture : SchemaTestFixtureBase
{
- ICompletionData[] fooChildElementCompletionData;
+ ICompletionItem[] fooChildElementCompletionData;
public override void FixtureInit()
{
diff --git a/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/ElementWithAttributeSchemaTestFixture.cs b/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/ElementWithAttributeSchemaTestFixture.cs
index 26cadef91f..f74faa7fb2 100644
--- a/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/ElementWithAttributeSchemaTestFixture.cs
+++ b/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/ElementWithAttributeSchemaTestFixture.cs
@@ -5,11 +5,12 @@
// $Revision: 915 $
//
+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
[TestFixture]
public class ElementWithAttributeSchemaTestFixture : SchemaTestFixtureBase
{
- ICompletionData[] attributeCompletionData;
+ ICompletionItem[] attributeCompletionData;
string attributeName;
public override void FixtureInit()
@@ -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.");
}
diff --git a/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/EnumAttributeValueTestFixture.cs b/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/EnumAttributeValueTestFixture.cs
index c74211beb0..f47702b401 100644
--- a/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/EnumAttributeValueTestFixture.cs
+++ b/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/EnumAttributeValueTestFixture.cs
@@ -5,11 +5,12 @@
// $Revision: 915 $
//
+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
[TestFixture]
public class EnumAttributeValueTestFixture : SchemaTestFixtureBase
{
- ICompletionData[] attributeValues;
+ ICompletionItem[] attributeValues;
public override void FixtureInit()
{
diff --git a/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/ExtensionElementTestFixture.cs b/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/ExtensionElementTestFixture.cs
index 2ed0bf8689..c1bfb802fb 100644
--- a/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/ExtensionElementTestFixture.cs
+++ b/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/ExtensionElementTestFixture.cs
@@ -5,11 +5,12 @@
// $Revision: 915 $
//
+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
[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()
{
diff --git a/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/GroupRefCompositorTestFixture.cs b/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/GroupRefCompositorTestFixture.cs
index f2c2c5373d..556ae8c485 100644
--- a/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/GroupRefCompositorTestFixture.cs
+++ b/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/GroupRefCompositorTestFixture.cs
@@ -5,11 +5,12 @@
// $Revision: 915 $
//
+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
[TestFixture]
public class GroupRefAsCompositorTestFixture : SchemaTestFixtureBase
{
- ICompletionData[] rootChildElements;
- ICompletionData[] fooAttributes;
+ ICompletionItem[] rootChildElements;
+ ICompletionItem[] fooAttributes;
public override void FixtureInit()
{
diff --git a/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/GroupRefTestFixture.cs b/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/GroupRefTestFixture.cs
index bcf6fe041f..46f393b3f7 100644
--- a/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/GroupRefTestFixture.cs
+++ b/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/GroupRefTestFixture.cs
@@ -5,11 +5,12 @@
// $Revision: 915 $
//
+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
[TestFixture]
public class GroupRefTestFixture : SchemaTestFixtureBase
{
- ICompletionData[] childElements;
- ICompletionData[] paraAttributes;
+ ICompletionItem[] childElements;
+ ICompletionItem[] paraAttributes;
public override void FixtureInit()
{
diff --git a/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/MissingSchemaElementTestFixture.cs b/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/MissingSchemaElementTestFixture.cs
index 8683cb73a7..cf8f56cbc5 100644
--- a/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/MissingSchemaElementTestFixture.cs
+++ b/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/MissingSchemaElementTestFixture.cs
@@ -5,18 +5,19 @@
// $Revision: 1228 $
//
+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()
{
diff --git a/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/NamespaceCompletionTestFixture.cs b/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/NamespaceCompletionTestFixture.cs
index 854ec7963d..d6f1e36f3e 100644
--- a/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/NamespaceCompletionTestFixture.cs
+++ b/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/NamespaceCompletionTestFixture.cs
@@ -5,11 +5,13 @@
// $Revision: 915 $
//
+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
[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
[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)
diff --git a/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/NestedAttributeGroupRefTestFixture.cs b/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/NestedAttributeGroupRefTestFixture.cs
index 93655c8c48..dd43c7f090 100644
--- a/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/NestedAttributeGroupRefTestFixture.cs
+++ b/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/NestedAttributeGroupRefTestFixture.cs
@@ -5,11 +5,12 @@
// $Revision: 915 $
//
+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
[TestFixture]
public class NestedAttributeGroupRefTestFixture : SchemaTestFixtureBase
{
- ICompletionData[] attributeCompletionData;
+ ICompletionItem[] attributeCompletionData;
public override void FixtureInit()
{
diff --git a/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/NestedChoiceTestFixture.cs b/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/NestedChoiceTestFixture.cs
index 2edb52b923..d6554c2a1c 100644
--- a/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/NestedChoiceTestFixture.cs
+++ b/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/NestedChoiceTestFixture.cs
@@ -5,11 +5,12 @@
// $Revision: 915 $
//
+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
[TestFixture]
public class NestedChoiceTestFixture : SchemaTestFixtureBase
{
- ICompletionData[] noteChildElements;
- ICompletionData[] titleChildElements;
+ ICompletionItem[] noteChildElements;
+ ICompletionItem[] titleChildElements;
public override void FixtureInit()
{
diff --git a/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/NestedElementSchemaTestFixture.cs b/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/NestedElementSchemaTestFixture.cs
index e319622399..7e3f188f56 100644
--- a/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/NestedElementSchemaTestFixture.cs
+++ b/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/NestedElementSchemaTestFixture.cs
@@ -5,11 +5,12 @@
// $Revision: 915 $
//
+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
public class NestedElementSchemaTestFixture : SchemaTestFixtureBase
{
XmlElementPath noteElementPath;
- ICompletionData[] elementData;
+ ICompletionItem[] elementData;
public override void FixtureInit()
{
diff --git a/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/NestedSequenceTestFixture.cs b/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/NestedSequenceTestFixture.cs
index 77c62e34b3..88606ed691 100644
--- a/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/NestedSequenceTestFixture.cs
+++ b/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/NestedSequenceTestFixture.cs
@@ -5,11 +5,12 @@
// $Revision: 915 $
//
+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
[TestFixture]
public class NestedSequenceSchemaTestFixture : SchemaTestFixtureBase
{
- ICompletionData[] noteChildElements;
+ ICompletionItem[] noteChildElements;
public override void FixtureInit()
{
diff --git a/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/ReferencedElementsTestFixture.cs b/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/ReferencedElementsTestFixture.cs
index ced55e74b3..6af6988444 100644
--- a/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/ReferencedElementsTestFixture.cs
+++ b/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/ReferencedElementsTestFixture.cs
@@ -5,19 +5,20 @@
// $Revision: 915 $
//
+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
[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
[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
[Test]
public void ShipToHasAddressChildElement()
{
- ICompletionData[] data = SchemaCompletionData.GetChildElementCompletionData(shipToPath);
+ ICompletionItem[] data = SchemaCompletionData.GetChildElementCompletionData(shipToPath);
Assert.IsTrue(SchemaTestFixtureBase.Contains(data, "address"),
"Incorrect child element name.");
}
diff --git a/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/RestrictionElementTestFixture.cs b/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/RestrictionElementTestFixture.cs
index c5c454154d..1c96f77fa1 100644
--- a/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/RestrictionElementTestFixture.cs
+++ b/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/RestrictionElementTestFixture.cs
@@ -5,11 +5,12 @@
// $Revision: 915 $
//
+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
[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()
{
diff --git a/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/SchemaTestFixtureBase.cs b/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/SchemaTestFixtureBase.cs
index d9b9c70a49..7ab94d0c16 100644
--- a/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/SchemaTestFixtureBase.cs
+++ b/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/SchemaTestFixtureBase.cs
@@ -5,11 +5,12 @@
// $Revision: 1683 $
//
+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
///
/// Checks whether the specified name exists in the completion data.
///
- 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
/// Checks whether the completion data specified by name has
/// the correct description.
///
- 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
/// Gets a count of the number of occurrences of a particular name
/// in the completion data.
///
- 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;
}
diff --git a/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/SequencedChoiceTestFixture.cs b/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/SequencedChoiceTestFixture.cs
index 3604150944..cf003d73ec 100644
--- a/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/SequencedChoiceTestFixture.cs
+++ b/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/SequencedChoiceTestFixture.cs
@@ -5,11 +5,12 @@
// $Revision: 915 $
//
+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
[TestFixture]
public class SequencedChoiceTestFixture : SchemaTestFixtureBase
{
- ICompletionData[] noteChildElements;
+ ICompletionItem[] noteChildElements;
public override void FixtureInit()
{
diff --git a/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/SimpleContentWithAttributeTestFixture.cs b/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/SimpleContentWithAttributeTestFixture.cs
index 04d34d3c79..4e4fa85ec1 100644
--- a/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/SimpleContentWithAttributeTestFixture.cs
+++ b/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/SimpleContentWithAttributeTestFixture.cs
@@ -5,11 +5,12 @@
// $Revision: 915 $
//
+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
[TestFixture]
public class SimpleContentWithAttributeSchemaTestFixture : SchemaTestFixtureBase
{
- ICompletionData[] attributeCompletionData;
+ ICompletionItem[] attributeCompletionData;
public override void FixtureInit()
{
diff --git a/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/SingleElementSchemaTestFixture.cs b/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/SingleElementSchemaTestFixture.cs
index c46f766005..20e740dbff 100644
--- a/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/SingleElementSchemaTestFixture.cs
+++ b/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/SingleElementSchemaTestFixture.cs
@@ -5,11 +5,12 @@
// $Revision: 915 $
//
+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
[TestFixture]
public class SingleElementSchemaTestFixture : SchemaTestFixtureBase
{
- ICompletionData[] childElementCompletionData;
- ICompletionData[] attributeCompletionData;
+ ICompletionItem[] childElementCompletionData;
+ ICompletionItem[] attributeCompletionData;
public override void FixtureInit()
{
diff --git a/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/TwoElementSchemaTestFixture.cs b/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/TwoElementSchemaTestFixture.cs
index b6aaacdf47..8967067391 100644
--- a/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/TwoElementSchemaTestFixture.cs
+++ b/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/TwoElementSchemaTestFixture.cs
@@ -5,11 +5,11 @@
// $Revision: 915 $
//
-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
[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
[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
[Test]
public void NoteElementHasChildElement()
{
- ICompletionData[] childElementCompletionData
+ ICompletionItem[] childElementCompletionData
= SchemaCompletionData.GetChildElementCompletionData(noteElementPath);
Assert.AreEqual(1, childElementCompletionData.Length,
@@ -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
[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.");
}
diff --git a/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/XhtmlStrictSchemaTestFixture.cs b/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/XhtmlStrictSchemaTestFixture.cs
index f8c7bffaf6..1d9b91029a 100644
--- a/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/XhtmlStrictSchemaTestFixture.cs
+++ b/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/XhtmlStrictSchemaTestFixture.cs
@@ -5,12 +5,13 @@
// $Revision: 915 $
//
-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
{
XmlSchemaCompletionData schemaCompletionData;
XmlElementPath h1Path;
- ICompletionData[] h1Attributes;
+ ICompletionItem[] h1Attributes;
string namespaceURI = "http://www.w3.org/1999/xhtml";
[TestFixtureSetUp]
diff --git a/src/AddIns/DisplayBindings/XmlEditor/Test/Tree/AddNewNodeDialogTestFixture.cs b/src/AddIns/DisplayBindings/XmlEditor/Test/Tree/AddNewNodeDialogTestFixture.cs
index 2ba19b3d54..a75c1e3d6b 100644
--- a/src/AddIns/DisplayBindings/XmlEditor/Test/Tree/AddNewNodeDialogTestFixture.cs
+++ b/src/AddIns/DisplayBindings/XmlEditor/Test/Tree/AddNewNodeDialogTestFixture.cs
@@ -183,7 +183,7 @@ namespace XmlEditor.Tests.Tree
customNameTextBox.Text = "";
dialog.CallCustomNameTextBoxTextChanged();
- string error = dialog.GetError();
+ string error = dialog.ErrorText;
string expectedError = null;
try {
@@ -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
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
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
dialog.CallCustomNameTextBoxTextChanged();
Assert.IsTrue(okButton.Enabled);
- Assert.AreEqual(0, dialog.GetError().Length);
+ Assert.AreEqual(0, dialog.ErrorText.Length);
}
[Test]
diff --git a/src/AddIns/DisplayBindings/XmlEditor/Test/Tree/OwnerStatusTestFixture.cs b/src/AddIns/DisplayBindings/XmlEditor/Test/Tree/OwnerStatusTestFixture.cs
index fa7b23c6d9..605789b06f 100644
--- a/src/AddIns/DisplayBindings/XmlEditor/Test/Tree/OwnerStatusTestFixture.cs
+++ b/src/AddIns/DisplayBindings/XmlEditor/Test/Tree/OwnerStatusTestFixture.cs
@@ -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
{
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
{
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
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
{
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
{
treeView.SelectedNode = commentTreeNode;
- Assert.AreEqual(XmlTreeViewContainerControl.XmlTreeViewContainerControlState.CommentSelected,
+ Assert.AreEqual(XmlTreeViewContainerControl.XmlTreeViewContainerControlStates.CommentSelected,
treeViewContainer.InternalState,
"OwnerState should be CommentSelected.");
}
diff --git a/src/AddIns/DisplayBindings/XmlEditor/Test/Tree/XmlTreeViewClipboardHandlerTestFixture.cs b/src/AddIns/DisplayBindings/XmlEditor/Test/Tree/XmlTreeViewClipboardHandlerTestFixture.cs
index 8c50dab8df..f8de3cae82 100644
--- a/src/AddIns/DisplayBindings/XmlEditor/Test/Tree/XmlTreeViewClipboardHandlerTestFixture.cs
+++ b/src/AddIns/DisplayBindings/XmlEditor/Test/Tree/XmlTreeViewClipboardHandlerTestFixture.cs
@@ -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
{
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 = "";
+ xmlView.GetDocumentForFile(null).Text = "";
openedFile.SwitchToView(view);
htmlTreeNode = treeView.Nodes[0] as XmlElementTreeNode;
diff --git a/src/AddIns/DisplayBindings/XmlEditor/Test/Utils/MockXmlViewContent.cs b/src/AddIns/DisplayBindings/XmlEditor/Test/Utils/MockXmlViewContent.cs
new file mode 100644
index 0000000000..d718719f40
--- /dev/null
+++ b/src/AddIns/DisplayBindings/XmlEditor/Test/Utils/MockXmlViewContent.cs
@@ -0,0 +1,38 @@
+//
+//
+//
+//
+// $Revision$
+//
+
+using System;
+using ICSharpCode.SharpDevelop;
+using ICSharpCode.SharpDevelop.Editor;
+using ICSharpCode.SharpDevelop.Gui;
+
+namespace XmlEditor.Tests.Utils
+{
+ ///
+ /// Description of MockXmlViewContent.
+ ///
+ 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;
+ }
+ }
+}
diff --git a/src/AddIns/DisplayBindings/XmlEditor/Test/XPathQuery/XPathNodeTextMarkerTests.cs b/src/AddIns/DisplayBindings/XmlEditor/Test/XPathQuery/XPathNodeTextMarkerTests.cs
index 71c5adc421..87bbb45b6b 100644
--- a/src/AddIns/DisplayBindings/XmlEditor/Test/XPathQuery/XPathNodeTextMarkerTests.cs
+++ b/src/AddIns/DisplayBindings/XmlEditor/Test/XPathQuery/XPathNodeTextMarkerTests.cs
@@ -19,87 +19,88 @@ namespace XmlEditor.Tests.XPathQuery
{
[TestFixture]
public class XPathNodeTextMarkerTests
- {
- [Test]
- public void OneNodeMarked()
- {
- string xml = "";
- XPathNodeMatch[] nodes = XmlView.SelectNodes(xml, "//root");
-
- IDocument doc = MockDocument.Create();
- doc.TextContent = xml;
- MarkerStrategy markerStrategy = new MarkerStrategy(doc);
- XPathNodeTextMarker.AddMarkers(markerStrategy, nodes);
-
- List markers = new List();
- foreach (TextMarker marker in markerStrategy.TextMarker) {
- markers.Add(marker);
- }
-
- // Remove markers.
- XPathNodeTextMarker.RemoveMarkers(markerStrategy);
- List markersAfterRemove = new List();
- 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);
- }
-
- ///
- /// Tests that XPathNodeMatch with an empty string value are not marked since
- /// the MarkerStrategy cannot use a TextMarker with a length of 0.
- ///
- [Test]
- public void EmptyCommentNode()
- {
- string xml = "";
- XPathNodeMatch[] nodes = XmlView.SelectNodes(xml, "//comment()");
-
- IDocument doc = MockDocument.Create();
- doc.TextContent = xml;
- MarkerStrategy markerStrategy = new MarkerStrategy(doc);
- XPathNodeTextMarker.AddMarkers(markerStrategy, nodes);
-
- List markers = new List();
- foreach (TextMarker marker in markerStrategy.TextMarker) {
- markers.Add(marker);
- }
-
- Assert.AreEqual(0, markers.Count);
- Assert.AreEqual(1, nodes.Length);
- }
-
- ///
- /// 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.
- ///
- [Test]
- public void NamespaceQuery()
- {
- string xml = "\r\n" +
- "";
- XPathNodeMatch[] nodes = XmlView.SelectNodes(xml, "//namespace::*");
-
- IDocument doc = MockDocument.Create();
- doc.TextContent = xml;
- MarkerStrategy markerStrategy = new MarkerStrategy(doc);
- XPathNodeTextMarker.AddMarkers(markerStrategy, nodes);
-
- List markers = new List();
- 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 = "";
+// XPathNodeMatch[] nodes = XmlView.SelectNodes(xml, "//root");
+//
+// IDocument doc = MockDocument.Create();
+// doc.TextContent = xml;
+// MarkerStrategy markerStrategy = new MarkerStrategy(doc);
+// XPathNodeTextMarker.AddMarkers(markerStrategy, nodes);
+//
+// List markers = new List();
+// foreach (TextMarker marker in markerStrategy.TextMarker) {
+// markers.Add(marker);
+// }
+//
+// // Remove markers.
+// XPathNodeTextMarker.RemoveMarkers(markerStrategy);
+// List markersAfterRemove = new List();
+// 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);
+// }
+//
+// ///
+// /// Tests that XPathNodeMatch with an empty string value are not marked since
+// /// the MarkerStrategy cannot use a TextMarker with a length of 0.
+// ///
+// [Test]
+// public void EmptyCommentNode()
+// {
+// string xml = "";
+// XPathNodeMatch[] nodes = XmlView.SelectNodes(xml, "//comment()");
+//
+// IDocument doc = MockDocument.Create();
+// doc.TextContent = xml;
+// MarkerStrategy markerStrategy = new MarkerStrategy(doc);
+// XPathNodeTextMarker.AddMarkers(markerStrategy, nodes);
+//
+// List markers = new List();
+// foreach (TextMarker marker in markerStrategy.TextMarker) {
+// markers.Add(marker);
+// }
+//
+// Assert.AreEqual(0, markers.Count);
+// Assert.AreEqual(1, nodes.Length);
+// }
+//
+// ///
+// /// 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.
+// ///
+// [Test]
+// public void NamespaceQuery()
+// {
+// string xml = "\r\n" +
+// "";
+// XPathNodeMatch[] nodes = XmlView.SelectNodes(xml, "//namespace::*");
+//
+// IDocument doc = MockDocument.Create();
+// doc.TextContent = xml;
+// MarkerStrategy markerStrategy = new MarkerStrategy(doc);
+// XPathNodeTextMarker.AddMarkers(, nodes);
+//
+// List markers = new List();
+// foreach (TextMarker marker in markerStrategy.TextMarker) {
+// markers.Add(marker);
+// }
+// Assert.AreEqual(0, markers.Count);
+// Assert.AreEqual(1, nodes.Length);
+// }
}
}
diff --git a/src/AddIns/DisplayBindings/XmlEditor/Test/XmlEditor.Tests.csproj b/src/AddIns/DisplayBindings/XmlEditor/Test/XmlEditor.Tests.csproj
index 6d3889c1b3..b3f0931b05 100644
--- a/src/AddIns/DisplayBindings/XmlEditor/Test/XmlEditor.Tests.csproj
+++ b/src/AddIns/DisplayBindings/XmlEditor/Test/XmlEditor.Tests.csproj
@@ -1,4 +1,4 @@
-
+
Debug
AnyCPU
@@ -19,21 +19,32 @@
False
False
True
+ C:\Users\Siegfried\AppData\Roaming\ICSharpCode/SharpDevelop3.0\Settings.SourceAnalysis
+ v3.5
+ true
- true
false
- true
false
DEBUG
+
+ 4194304
+ 4096
+
+
+ 3.5
+
+
+ 3.5
+
@@ -41,6 +52,9 @@
..\..\..\..\Tools\NUnit\nunit.framework.dll
False
+
+ 3.5
+
@@ -100,6 +114,7 @@
+
@@ -190,6 +205,10 @@
{857CA1A3-FC88-4BE0-AB6A-D1EE772AB288}
ICSharpCode.Core.WinForms
+
+ {924EE450-603D-49C1-A8E5-4AFAA31CE6F3}
+ ICSharpCode.SharpDevelop.Dom
+
{6B717BD1-CD5E-498C-A42E-9E6A4584DC48}
XmlEditor
diff --git a/src/Main/Base/Project/Src/Editor/AvalonEdit/AvalonEditDocumentAdapter.cs b/src/Main/Base/Project/Src/Editor/AvalonEdit/AvalonEditDocumentAdapter.cs
index 49424b947e..520c992077 100644
--- a/src/Main/Base/Project/Src/Editor/AvalonEdit/AvalonEditDocumentAdapter.cs
+++ b/src/Main/Base/Project/Src/Editor/AvalonEdit/AvalonEditDocumentAdapter.cs
@@ -33,6 +33,14 @@ namespace ICSharpCode.SharpDevelop.Editor
this.parentServiceProvider = parentServiceProvider;
}
+ ///
+ /// Used in Unit Tests
+ ///
+ public AvalonEditDocumentAdapter()
+ {
+ this.document = new TextDocument();
+ }
+
sealed class LineAdapter : IDocumentLine
{
readonly DocumentLine line;