Browse Source

Moved xpath code and goto schema definition code out of XmlView class.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@5336 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
pull/1/head
Matt Ward 16 years ago
parent
commit
c486bd0db8
  1. 1
      src/AddIns/DisplayBindings/XmlEditor/Project/Src/GoToSchemaDefinitionCommand.cs
  2. 11
      src/AddIns/DisplayBindings/XmlEditor/Project/Src/RegisteredXmlSchemas.cs
  3. 27
      src/AddIns/DisplayBindings/XmlEditor/Project/Src/RemoveXPathHighlightingCommand.cs
  4. 66
      src/AddIns/DisplayBindings/XmlEditor/Project/Src/SelectedXmlElement.cs
  5. 9
      src/AddIns/DisplayBindings/XmlEditor/Project/Src/XPathNodeMatch.cs
  6. 37
      src/AddIns/DisplayBindings/XmlEditor/Project/Src/XPathNodeTextMarker.cs
  7. 66
      src/AddIns/DisplayBindings/XmlEditor/Project/Src/XPathQuery.cs
  8. 175
      src/AddIns/DisplayBindings/XmlEditor/Project/Src/XPathQueryControl.cs
  9. 25
      src/AddIns/DisplayBindings/XmlEditor/Project/Src/XPathQueryPad.cs
  10. 214
      src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlSchemaDefinition.cs
  11. 60
      src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlSchemaObjectLocation.cs
  12. 220
      src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlView.cs
  13. 6
      src/AddIns/DisplayBindings/XmlEditor/Project/XmlEditor.addin
  14. 4
      src/AddIns/DisplayBindings/XmlEditor/Project/XmlEditor.csproj
  15. 5
      src/AddIns/DisplayBindings/XmlEditor/Test/FindSchemaObject/AttributeGroupReferenceSelectedTestFixture.cs
  16. 3
      src/AddIns/DisplayBindings/XmlEditor/Test/FindSchemaObject/AttributeReferenceSelectedTestFixture.cs
  17. 5
      src/AddIns/DisplayBindings/XmlEditor/Test/FindSchemaObject/AttributeSelectedTestFixture.cs
  18. 3
      src/AddIns/DisplayBindings/XmlEditor/Test/FindSchemaObject/AttributeTypeSelectedTestFixture.cs
  19. 7
      src/AddIns/DisplayBindings/XmlEditor/Test/FindSchemaObject/ElementReferenceSelectedTestFixture.cs
  20. 3
      src/AddIns/DisplayBindings/XmlEditor/Test/FindSchemaObject/ElementReferenceWithPrefixSelectedTestFixture.cs
  21. 20
      src/AddIns/DisplayBindings/XmlEditor/Test/FindSchemaObject/ElementSelectedTestFixture.cs
  22. 3
      src/AddIns/DisplayBindings/XmlEditor/Test/FindSchemaObject/ElementTypeSelectedTestFixture.cs
  23. 3
      src/AddIns/DisplayBindings/XmlEditor/Test/FindSchemaObject/ElementTypeWithPrefixSelectedTestFixture.cs
  24. 66
      src/AddIns/DisplayBindings/XmlEditor/Test/FindSchemaObject/FindSelectedAttributeInTextEditorTestFixture.cs
  25. 66
      src/AddIns/DisplayBindings/XmlEditor/Test/FindSchemaObject/FindSelectedAttributeValueInTextEditorTestFixture.cs
  26. 66
      src/AddIns/DisplayBindings/XmlEditor/Test/FindSchemaObject/FindSelectedElementInTextEditorTestFixture.cs
  27. 3
      src/AddIns/DisplayBindings/XmlEditor/Test/FindSchemaObject/GroupReferenceSelectedTestFixture.cs
  28. 54
      src/AddIns/DisplayBindings/XmlEditor/Test/FindSchemaObject/NullSchemaObjectPassedToSchemaObjectLocationTestFixture.cs
  29. 38
      src/AddIns/DisplayBindings/XmlEditor/Test/FindSchemaObject/SchemaObjectLocationFileNameTests.cs
  30. 59
      src/AddIns/DisplayBindings/XmlEditor/Test/FindSchemaObject/SchemaObjectLocationJumpToTests.cs
  31. 6
      src/AddIns/DisplayBindings/XmlEditor/Test/Schema/XmlSchemaNamespaceTests.cs
  32. 55
      src/AddIns/DisplayBindings/XmlEditor/Test/Utils/DerivedXmlSchemaObjectLocation.cs
  33. 31
      src/AddIns/DisplayBindings/XmlEditor/Test/Utils/MockTextEditorProviderViewContent.cs
  34. 166
      src/AddIns/DisplayBindings/XmlEditor/Test/Utils/MockViewContent.cs
  35. 194
      src/AddIns/DisplayBindings/XmlEditor/Test/Utils/MockWorkbench.cs
  36. 5
      src/AddIns/DisplayBindings/XmlEditor/Test/Utils/MockXmlViewContent.cs
  37. 80
      src/AddIns/DisplayBindings/XmlEditor/Test/Utils/Tests/DerivedXmlSchemaObjectLocationTests.cs
  38. 55
      src/AddIns/DisplayBindings/XmlEditor/Test/Utils/Tests/XPathNodeMatchComparisonResultTests.cs
  39. 131
      src/AddIns/DisplayBindings/XmlEditor/Test/Utils/Tests/XPathNodeMatchComparisonTests.cs
  40. 72
      src/AddIns/DisplayBindings/XmlEditor/Test/Utils/XPathNodeMatchComparison.cs
  41. 46
      src/AddIns/DisplayBindings/XmlEditor/Test/Utils/XPathNodeMatchComparisonResult.cs
  42. 2
      src/AddIns/DisplayBindings/XmlEditor/Test/XPath/EncodeXPathParameterTests.cs
  43. 4
      src/AddIns/DisplayBindings/XmlEditor/Test/XPath/GetNamespacesFromListViewTestFixture.cs
  44. 2
      src/AddIns/DisplayBindings/XmlEditor/Test/XPath/NamespaceGridColumnWidthsLoadedTestFixture.cs
  45. 4
      src/AddIns/DisplayBindings/XmlEditor/Test/XPath/NamespacePropertiesLoaded.cs
  46. 2
      src/AddIns/DisplayBindings/XmlEditor/Test/XPath/NamespacePropertiesSaved.cs
  47. 68
      src/AddIns/DisplayBindings/XmlEditor/Test/XPath/NamespaceXPathQueryTestFixture.cs
  48. 84
      src/AddIns/DisplayBindings/XmlEditor/Test/XPath/RemoveXPathHighlightingCommandTestFixture.cs
  49. 209
      src/AddIns/DisplayBindings/XmlEditor/Test/XPath/RunXPathQueryTests.cs
  50. 73
      src/AddIns/DisplayBindings/XmlEditor/Test/XPath/SingleXPathQueryElementMarkedTestFixture.cs
  51. 61
      src/AddIns/DisplayBindings/XmlEditor/Test/XPath/XPathNodeTextMarkerTests.cs
  52. 2
      src/AddIns/DisplayBindings/XmlEditor/Test/XPath/XPathQueryHistoryTestFixture.cs
  53. 2
      src/AddIns/DisplayBindings/XmlEditor/Test/XPath/XPathResultsListViewColumnWidthsTestFixture.cs
  54. 2
      src/AddIns/DisplayBindings/XmlEditor/Test/XPath/XmlNamespaceTests.cs
  55. 2
      src/AddIns/DisplayBindings/XmlEditor/Test/XPath/XmlNamespaceToStringTests.cs
  56. 175
      src/AddIns/DisplayBindings/XmlEditor/Test/XPathQuery/RunXPathQueryTests.cs
  57. 42
      src/AddIns/DisplayBindings/XmlEditor/Test/XmlEditor.Tests.csproj
  58. 10
      src/AddIns/DisplayBindings/XmlEditor/XmlEditor.sln

1
src/AddIns/DisplayBindings/XmlEditor/Project/Src/GoToSchemaDefinitionCommand.cs

@ -21,7 +21,6 @@ namespace ICSharpCode.XmlEditor @@ -21,7 +21,6 @@ namespace ICSharpCode.XmlEditor
public override void Run()
{
XmlView xmlView = XmlView.ActiveXmlView;
if (xmlView != null) {
xmlView.GoToSchemaDefinition();
}

11
src/AddIns/DisplayBindings/XmlEditor/Project/Src/RegisteredXmlSchemas.cs

@ -19,8 +19,6 @@ namespace ICSharpCode.XmlEditor @@ -19,8 +19,6 @@ namespace ICSharpCode.XmlEditor
/// </summary>
public class RegisteredXmlSchemas : IXmlSchemaCompletionDataFactory
{
public const string XmlSchemaNamespace = "http://www.w3.org/2001/XMLSchema";
List<string> readOnlySchemaFolders = new List<string>();
string userDefinedSchemaFolder;
XmlSchemaCompletionCollection schemas = new XmlSchemaCompletionCollection();
@ -47,15 +45,6 @@ namespace ICSharpCode.XmlEditor @@ -47,15 +45,6 @@ namespace ICSharpCode.XmlEditor
{
this.factory = this;
}
/// <summary>
/// Determines whether the specified namespace is actually the W3C namespace for
/// XSD files.
/// </summary>
public static bool IsXmlSchemaNamespace(string schemaNamespace)
{
return schemaNamespace == XmlSchemaNamespace;
}
public XmlSchemaCompletionCollection Schemas {
get { return schemas; }

27
src/AddIns/DisplayBindings/XmlEditor/Project/Src/RemoveXPathHighlightingCommand.cs

@ -7,14 +7,39 @@ @@ -7,14 +7,39 @@
using System;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Editor;
using ICSharpCode.SharpDevelop.Gui;
namespace ICSharpCode.XmlEditor
{
public class RemoveXPathHighlightingCommand : AbstractMenuCommand
{
IWorkbench workbench;
public RemoveXPathHighlightingCommand(IWorkbench workbench)
{
this.workbench = workbench;
}
public RemoveXPathHighlightingCommand()
: this(WorkbenchSingleton.Workbench)
{
}
public override void Run()
{
XPathQueryPad.RemoveXPathHighlighting();
RemoveXPathNodeTextMarkers();
}
public void RemoveXPathNodeTextMarkers()
{
foreach (IViewContent view in workbench.ViewContentCollection) {
ITextEditorProvider textEditorProvider = view as ITextEditorProvider;
if (textEditorProvider != null) {
XPathNodeTextMarker marker = new XPathNodeTextMarker(textEditorProvider.TextEditor.Document);
marker.RemoveMarkers();
}
}
}
}
}

66
src/AddIns/DisplayBindings/XmlEditor/Project/Src/SelectedXmlElement.cs

@ -0,0 +1,66 @@ @@ -0,0 +1,66 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
// <version>$Revision$</version>
// </file>
using System;
using ICSharpCode.SharpDevelop.Editor;
namespace ICSharpCode.XmlEditor
{
public class SelectedXmlElement
{
XmlElementPath path = new XmlElementPath();
string selectedAttribute = String.Empty;
string selectedAttributeValue = String.Empty;
public SelectedXmlElement(ITextEditor textEditor)
: this(textEditor.Document.Text, textEditor.Caret.Offset)
{
}
public SelectedXmlElement(string xml, int index)
{
FindSelectedElement(xml, index);
FindSelectedAttribute(xml, index);
FindSelectedAttributeValue(xml, index);
}
void FindSelectedElement(string xml, int index)
{
path = XmlParser.GetActiveElementStartPathAtIndex(xml, index);
}
void FindSelectedAttribute(string xml, int index)
{
selectedAttribute = XmlParser.GetAttributeNameAtIndex(xml, index);
}
void FindSelectedAttributeValue(string xml, int index)
{
selectedAttributeValue = XmlParser.GetAttributeValueAtIndex(xml, index);
}
public XmlElementPath Path {
get { return path; }
}
public string SelectedAttribute {
get { return selectedAttribute; }
}
public bool HasSelectedAttribute {
get { return selectedAttribute.Length > 0; }
}
public string SelectedAttributeValue {
get { return selectedAttributeValue; }
}
public bool HasSelectedAttributeValue {
get { return selectedAttributeValue.Length > 0; }
}
}
}

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

@ -61,6 +61,15 @@ namespace ICSharpCode.XmlEditor @@ -61,6 +61,15 @@ namespace ICSharpCode.XmlEditor
}
}
public XPathNodeMatch(string nodeValue, string displayValue, int? lineNumber, int linePosition, XPathNodeType nodeType)
{
this.nodeValue = nodeValue;
this.displayValue = displayValue;
this.lineNumber = lineNumber;
this.linePosition = linePosition;
this.nodeType = nodeType;
}
/// <summary>
/// Line numbers are zero based.
/// </summary>

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

@ -6,7 +6,6 @@ @@ -6,7 +6,6 @@
// </file>
using System;
using System.Linq;
using System.Collections.Generic;
using System.Windows.Media;
@ -17,28 +16,30 @@ namespace ICSharpCode.XmlEditor @@ -17,28 +16,30 @@ namespace ICSharpCode.XmlEditor
/// <summary>
/// Creates and removes text marker for an XPath query match.
/// </summary>
public static class XPathNodeTextMarker
public class XPathNodeTextMarker
{
public static readonly Color MarkerBackColor = Color.FromArgb(255, 159, 255, 162);
/// <summary>
/// Adds markers for each XPathNodeMatch.
/// </summary>
public static void AddMarkers(IDocument document, XPathNodeMatch[] nodes)
IDocument document;
ITextMarkerService markerService;
public XPathNodeTextMarker(IDocument document)
{
this.document = document;
markerService = document.GetService(typeof(ITextMarkerService)) as ITextMarkerService;
}
public void AddMarkers(XPathNodeMatch[] nodes)
{
foreach (XPathNodeMatch node in nodes) {
AddMarker(document, node);
AddMarker(node);
}
}
/// <summary>
/// Adds a single marker for the XPathNodeMatch.
/// </summary>
public static void AddMarker(IDocument document, XPathNodeMatch node)
public void AddMarker(XPathNodeMatch node)
{
if (node.HasLineInfo() && node.Value.Length > 0) {
int offset = document.PositionToOffset(node.LineNumber + 1, node.LinePosition + 1);
ITextMarkerService markerService = document.GetService(typeof(ITextMarkerService)) as ITextMarkerService;
if (markerService != null) {
ITextMarker marker = markerService.Create(offset, node.Value.Length);
marker.Tag = typeof(XPathNodeTextMarker);
@ -47,15 +48,17 @@ namespace ICSharpCode.XmlEditor @@ -47,15 +48,17 @@ namespace ICSharpCode.XmlEditor
}
}
/// <summary>
/// Removes all the XPathNodeMarkers from the marker strategy.
/// </summary>
public static void RemoveMarkers(IDocument document)
public void RemoveMarkers()
{
ITextMarkerService markerService = document.GetService(typeof(ITextMarkerService)) as ITextMarkerService;
if (markerService != null) {
markerService.RemoveAll(marker => (Type)marker.Tag == typeof(XPathNodeTextMarker));
markerService.RemoveAll(IsXPathNodeTextMarker);
}
}
bool IsXPathNodeTextMarker(ITextMarker marker)
{
return (Type)marker.Tag == typeof(XPathNodeTextMarker);
}
}
}

66
src/AddIns/DisplayBindings/XmlEditor/Project/Src/XPathQuery.cs

@ -0,0 +1,66 @@ @@ -0,0 +1,66 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
// <version>$Revision$</version>
// </file>
using System;
using System.Collections.Generic;
using System.IO;
using System.Xml;
using System.Xml.XPath;
using ICSharpCode.SharpDevelop.Editor;
namespace ICSharpCode.XmlEditor
{
public class XPathQuery
{
string xml;
XmlNamespaceCollection namespaces;
public XPathQuery(string xml)
: this(xml, new XmlNamespaceCollection())
{
}
public XPathQuery(ITextEditor textEditor, XmlNamespaceCollection namespaces)
: this(textEditor.Document.Text, namespaces)
{
}
public XPathQuery(string xml, XmlNamespaceCollection namespaces)
{
this.xml = xml;
this.namespaces = namespaces;
}
/// <summary>
/// Finds the xml nodes that match the specified xpath.
/// </summary>
/// <returns>An array of XPathNodeMatch items. These include line number
/// and line position information aswell as the node found.</returns>
public XPathNodeMatch[] FindNodes(string xpath)
{
XmlTextReader xmlReader = new XmlTextReader(new StringReader(xml));
xmlReader.XmlResolver = null;
XPathDocument doc = new XPathDocument(xmlReader);
XPathNavigator navigator = doc.CreateNavigator();
// Add namespaces.
XmlNamespaceManager namespaceManager = new XmlNamespaceManager(navigator.NameTable);
foreach (XmlNamespace xmlNamespace in namespaces) {
namespaceManager.AddNamespace(xmlNamespace.Prefix, xmlNamespace.Name);
}
// Run the xpath query.
XPathNodeIterator iterator = navigator.Select(xpath, namespaceManager);
List<XPathNodeMatch> nodes = new List<XPathNodeMatch>();
while (iterator.MoveNext()) {
nodes.Add(new XPathNodeMatch(iterator.Current));
}
return nodes.ToArray();
}
}
}

175
src/AddIns/DisplayBindings/XmlEditor/Project/Src/XPathQueryControl.cs

@ -54,7 +54,7 @@ namespace ICSharpCode.XmlEditor @@ -54,7 +54,7 @@ namespace ICSharpCode.XmlEditor
InitializeComponent();
InitStrings();
InitImageList();
xPathComboBox.KeyDown += XPathComboBoxKeyDown;
xpathComboBox.KeyDown += XPathComboBoxKeyDown;
InitAutoCompleteMode();
}
@ -69,9 +69,9 @@ namespace ICSharpCode.XmlEditor @@ -69,9 +69,9 @@ namespace ICSharpCode.XmlEditor
/// <summary>
/// Gets the list of namespaces in the namespace list.
/// </summary>
public ReadOnlyCollection<XmlNamespace> GetNamespaces()
public XmlNamespaceCollection GetNamespaces()
{
List<XmlNamespace> namespaces = new List<XmlNamespace>();
XmlNamespaceCollection namespaces = new XmlNamespaceCollection();
for (int i = 0; i < namespacesDataGridView.Rows.Count - 1; ++i) {
DataGridViewRow row = namespacesDataGridView.Rows[i];
string prefix = GetPrefix(row);
@ -82,25 +82,19 @@ namespace ICSharpCode.XmlEditor @@ -82,25 +82,19 @@ namespace ICSharpCode.XmlEditor
namespaces.Add(new XmlNamespace(prefix, uri));
}
}
return new ReadOnlyCollection<XmlNamespace>(namespaces);
return namespaces;
}
public DataGridView NamespacesDataGridView {
get {
return namespacesDataGridView;
}
get { return namespacesDataGridView; }
}
public ListView XPathResultsListView {
get {
return xPathResultsListView;
}
get { return xPathResultsListView; }
}
public ComboBox XPathComboBox {
get {
return xPathComboBox;
}
get { return xpathComboBox; }
}
/// <summary>
@ -111,75 +105,88 @@ namespace ICSharpCode.XmlEditor @@ -111,75 +105,88 @@ namespace ICSharpCode.XmlEditor
{
Properties properties = new Properties();
// Save namespaces.
properties.Set(NamespacesProperty, GetNamespaceStringArray());
SaveNamespaces(properties);
SaveNamespaceDataGridColumnWidths(properties);
SaveXPathResultsListViewColumnWidths(properties);
SaveXPathQueryHistory(properties);
// Save namespace data grid column widths.
return properties;
}
void SaveNamespaces(Properties properties)
{
properties.Set(NamespacesProperty, GetNamespaceStringArray());
}
void SaveNamespaceDataGridColumnWidths(Properties properties)
{
properties.Set<int>(PrefixColumnWidthProperty, prefixColumn.Width);
// Save xpath results list view column widths.
}
void SaveXPathResultsListViewColumnWidths(Properties properties)
{
properties.Set<int>(MatchColumnWidthProperty, matchColumnHeader.Width);
properties.Set<int>(LineColumnWidthProperty, lineColumnHeader.Width);
// Save xpath query history.
}
void SaveXPathQueryHistory(Properties properties)
{
properties.Set(XPathComboBoxTextProperty, XPathComboBox.Text);
properties.Set(XPathComboBoxItemsProperty, GetXPathHistory());
return properties;
}
/// <summary>
/// Reloads the state of the control.
/// </summary>
public void SetMemento(Properties memento)
public void SetMemento(Properties properties)
{
ignoreXPathTextChanges = true;
try {
// Set namespaces.
string[] namespaces = memento.Get(NamespacesProperty, new string[0]);
foreach (string ns in namespaces) {
XmlNamespace xmlNamespace = XmlNamespace.FromString(ns);
AddNamespace(xmlNamespace.Prefix, xmlNamespace.Name);
}
// Set namespace data grid column widths.
prefixColumn.Width = memento.Get<int>(PrefixColumnWidthProperty, 50);
// Set xpath results list view column widths.
matchColumnHeader.Width = memento.Get<int>(MatchColumnWidthProperty, 432);
lineColumnHeader.Width = memento.Get<int>(LineColumnWidthProperty, 60);
// Set xpath query history.
XPathComboBox.Text = memento.Get(XPathComboBoxTextProperty, string.Empty);
string[] xpaths = memento.Get(XPathComboBoxItemsProperty, new string[0]);
foreach (string xpath in xpaths) {
xPathComboBox.Items.Add(xpath);
}
LoadNamespaces(properties);
LoadNamespaceDataGridColumnWidths(properties);
LoadXPathResultsListViewColumnWidths(properties);
LoadXPathQueryHistory(properties);
} finally {
ignoreXPathTextChanges = false;
}
}
/// <summary>
/// Called when the active workbench window has changed.
/// </summary>
public void ActiveWindowChanged()
void LoadNamespaces(Properties properties)
{
UpdateQueryButtonState();
string[] namespaces = properties.Get(NamespacesProperty, new string[0]);
foreach (string ns in namespaces) {
XmlNamespace xmlNamespace = XmlNamespace.FromString(ns);
AddNamespace(xmlNamespace.Prefix, xmlNamespace.Name);
}
}
void LoadNamespaceDataGridColumnWidths(Properties properties)
{
prefixColumn.Width = properties.Get<int>(PrefixColumnWidthProperty, 50);
}
void LoadXPathResultsListViewColumnWidths(Properties properties)
{
matchColumnHeader.Width = properties.Get<int>(MatchColumnWidthProperty, 432);
lineColumnHeader.Width = properties.Get<int>(LineColumnWidthProperty, 60);
}
void LoadXPathQueryHistory(Properties properties)
{
XPathComboBox.Text = properties.Get(XPathComboBoxTextProperty, string.Empty);
string[] xpaths = properties.Get(XPathComboBoxItemsProperty, new string[0]);
foreach (string xpath in xpaths) {
xpathComboBox.Items.Add(xpath);
}
}
/// <summary>
/// Removes all the XPath Node markers from all the open documents.
/// Called when the active workbench window has changed.
/// </summary>
public static void RemoveXPathNodeTextMarkers()
public void ActiveWindowChanged()
{
foreach (IViewContent view in WorkbenchSingleton.Workbench.ViewContentCollection) {
ITextEditorProvider textEditorProvider = view as ITextEditorProvider;
if (textEditorProvider != null) {
XPathNodeTextMarker.RemoveMarkers(textEditorProvider.TextEditor.Document);
}
}
UpdateQueryButtonState();
}
/// <summary>
@ -212,7 +219,7 @@ namespace ICSharpCode.XmlEditor @@ -212,7 +219,7 @@ namespace ICSharpCode.XmlEditor
{
this.components = new System.ComponentModel.Container();
this.xPathLabel = new System.Windows.Forms.Label();
this.xPathComboBox = new System.Windows.Forms.ComboBox();
this.xpathComboBox = new System.Windows.Forms.ComboBox();
this.queryButton = new System.Windows.Forms.Button();
this.tabControl = new System.Windows.Forms.TabControl();
this.xPathResultsTabPage = new System.Windows.Forms.TabPage();
@ -241,15 +248,15 @@ namespace ICSharpCode.XmlEditor @@ -241,15 +248,15 @@ namespace ICSharpCode.XmlEditor
//
// xPathComboBox
//
this.xPathComboBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
this.xpathComboBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.xPathComboBox.FormattingEnabled = true;
this.xPathComboBox.Location = new System.Drawing.Point(55, 3);
this.xPathComboBox.Name = "xPathComboBox";
this.xPathComboBox.Size = new System.Drawing.Size(438, 21);
this.xPathComboBox.TabIndex = 1;
this.xPathComboBox.TextChanged += new System.EventHandler(this.XPathComboBoxTextChanged);
this.xPathComboBox.KeyDown += new System.Windows.Forms.KeyEventHandler(this.XPathComboBoxKeyDown);
this.xpathComboBox.FormattingEnabled = true;
this.xpathComboBox.Location = new System.Drawing.Point(55, 3);
this.xpathComboBox.Name = "xPathComboBox";
this.xpathComboBox.Size = new System.Drawing.Size(438, 21);
this.xpathComboBox.TabIndex = 1;
this.xpathComboBox.TextChanged += new System.EventHandler(this.XPathComboBoxTextChanged);
this.xpathComboBox.KeyDown += new System.Windows.Forms.KeyEventHandler(this.XPathComboBoxKeyDown);
//
// queryButton
//
@ -366,7 +373,7 @@ namespace ICSharpCode.XmlEditor @@ -366,7 +373,7 @@ namespace ICSharpCode.XmlEditor
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.tabControl);
this.Controls.Add(this.queryButton);
this.Controls.Add(this.xPathComboBox);
this.Controls.Add(this.xpathComboBox);
this.Controls.Add(this.xPathLabel);
this.Name = "XPathQueryControl";
this.Size = new System.Drawing.Size(572, 238);
@ -387,7 +394,7 @@ namespace ICSharpCode.XmlEditor @@ -387,7 +394,7 @@ namespace ICSharpCode.XmlEditor
private System.Windows.Forms.TabPage xPathResultsTabPage;
private System.Windows.Forms.TabControl tabControl;
private System.Windows.Forms.Button queryButton;
private System.Windows.Forms.ComboBox xPathComboBox;
private System.Windows.Forms.ComboBox xpathComboBox;
private System.Windows.Forms.Label xPathLabel;
#endregion
@ -405,9 +412,7 @@ namespace ICSharpCode.XmlEditor @@ -405,9 +412,7 @@ namespace ICSharpCode.XmlEditor
}
bool IsXPathQueryEntered {
get {
return xPathComboBox.Text.Length > 0;
}
get { return xpathComboBox.Text.Length > 0; }
}
void QueryButtonClick(object sender, EventArgs e)
@ -423,18 +428,19 @@ namespace ICSharpCode.XmlEditor @@ -423,18 +428,19 @@ namespace ICSharpCode.XmlEditor
}
try {
// TODO : markers are currently not supported in AvalonEdit.
fileName = xmlView.File.FileName;
// Clear previous XPath results.
ClearResults();
XPathNodeTextMarker.RemoveMarkers(xmlView.TextEditor.Document);
XPathNodeTextMarker marker = new XPathNodeTextMarker(xmlView.TextEditor.Document);
marker.RemoveMarkers();
// Run XPath query.
XPathNodeMatch[] nodes = xmlView.SelectNodes(xPathComboBox.Text, GetNamespaces());
XPathQuery query = new XPathQuery(xmlView.TextEditor, GetNamespaces());
XPathNodeMatch[] nodes = query.FindNodes(xpathComboBox.Text);
if (nodes.Length > 0) {
AddXPathResults(nodes);
XPathNodeTextMarker.AddMarkers(xmlView.TextEditor.Document, nodes);
marker.AddMarkers(nodes);
} else {
AddNoXPathResult();
}
@ -552,7 +558,7 @@ namespace ICSharpCode.XmlEditor @@ -552,7 +558,7 @@ namespace ICSharpCode.XmlEditor
} else if (xmlException != null) {
MoveCaretToXmlException(moveCaret, xmlException);
} else if (xpathException != null && moveCaret == MoveCaret.ByJumping) {
xPathComboBox.Focus();
xpathComboBox.Focus();
}
}
}
@ -621,11 +627,10 @@ namespace ICSharpCode.XmlEditor @@ -621,11 +627,10 @@ namespace ICSharpCode.XmlEditor
/// <summary>
/// Gets the previously used XPath queries from the combo box drop down list.
/// </summary>
/// <returns></returns>
string [] GetXPathHistory()
{
List<string> xpaths = new List<string>();
foreach (string xpath in xPathComboBox.Items) {
foreach (string xpath in xpathComboBox.Items) {
xpaths.Add(xpath);
}
return xpaths.ToArray();
@ -640,7 +645,7 @@ namespace ICSharpCode.XmlEditor @@ -640,7 +645,7 @@ namespace ICSharpCode.XmlEditor
if (prefix != null) {
return prefix;
}
return string.Empty;
return String.Empty;
}
/// <summary>
@ -652,7 +657,7 @@ namespace ICSharpCode.XmlEditor @@ -652,7 +657,7 @@ namespace ICSharpCode.XmlEditor
if (ns != null) {
return ns;
}
return string.Empty;
return String.Empty;
}
/// <summary>
@ -660,11 +665,11 @@ namespace ICSharpCode.XmlEditor @@ -660,11 +665,11 @@ namespace ICSharpCode.XmlEditor
/// </summary>
void AddXPathToHistory()
{
string newXPath = xPathComboBox.Text;
if (!xPathComboBox.Items.Contains(newXPath)) {
xPathComboBox.Items.Insert(0, newXPath);
if (xPathComboBox.Items.Count > xpathQueryHistoryLimit) {
xPathComboBox.Items.RemoveAt(xpathQueryHistoryLimit);
string newXPath = xpathComboBox.Text;
if (!xpathComboBox.Items.Contains(newXPath)) {
xpathComboBox.Items.Insert(0, newXPath);
if (xpathComboBox.Items.Count > xpathQueryHistoryLimit) {
xpathComboBox.Items.RemoveAt(xpathQueryHistoryLimit);
}
}
}

25
src/AddIns/DisplayBindings/XmlEditor/Project/Src/XPathQueryPad.cs

@ -16,32 +16,28 @@ namespace ICSharpCode.XmlEditor @@ -16,32 +16,28 @@ namespace ICSharpCode.XmlEditor
{
public const string XPathQueryControlProperties = "XPathQueryControl.Options";
XPathQueryControl xPathQueryControl;
XPathQueryControl xpathQueryControl;
bool disposed;
static XPathQueryPad instance;
public XPathQueryPad()
{
xPathQueryControl = new XPathQueryControl();
xpathQueryControl = new XPathQueryControl();
WorkbenchSingleton.Workbench.ActiveViewContentChanged += ActiveViewContentChanged;
Properties properties = PropertyService.Get(XPathQueryControlProperties, new Properties());
xPathQueryControl.SetMemento(properties);
xpathQueryControl.SetMemento(properties);
instance = this;
}
public static XPathQueryPad Instance {
get {
return instance;
}
get { return instance; }
}
/// <summary>
/// The <see cref="System.Windows.Forms.Control"/> representing the pad.
/// </summary>
public override object Control {
get {
return xPathQueryControl;
}
get { return xpathQueryControl; }
}
public override void Dispose()
@ -49,20 +45,15 @@ namespace ICSharpCode.XmlEditor @@ -49,20 +45,15 @@ namespace ICSharpCode.XmlEditor
if (!disposed) {
disposed = true;
WorkbenchSingleton.Workbench.ActiveViewContentChanged -= ActiveViewContentChanged;
Properties properties = xPathQueryControl.CreateMemento();
Properties properties = xpathQueryControl.CreateMemento();
PropertyService.Set(XPathQueryControlProperties, properties);
xPathQueryControl.Dispose();
xpathQueryControl.Dispose();
}
}
public static void RemoveXPathHighlighting()
{
XPathQueryControl.RemoveXPathNodeTextMarkers();
}
void ActiveViewContentChanged(object source, EventArgs e)
{
xPathQueryControl.ActiveWindowChanged();
xpathQueryControl.ActiveWindowChanged();
}
}
}

214
src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlSchemaDefinition.cs

@ -0,0 +1,214 @@ @@ -0,0 +1,214 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
// <version>$Revision$</version>
// </file>
using System;
using System.Xml;
using System.Xml.Schema;
namespace ICSharpCode.XmlEditor
{
public class XmlSchemaDefinition
{
public const string XmlSchemaNamespace = "http://www.w3.org/2001/XMLSchema";
XmlSchemaCompletionCollection schemas;
XmlSchemaCompletion currentSchema;
SelectedXmlElement selectedElement;
public XmlSchemaDefinition(XmlSchemaCompletionCollection schemas, XmlSchemaCompletion currentSchema)
{
this.schemas = schemas;
this.currentSchema = currentSchema;
}
/// <summary>
/// Determines whether the specified namespace is actually the W3C namespace for
/// XSD files.
/// </summary>
public static bool IsXmlSchemaNamespace(string schemaNamespace)
{
return schemaNamespace == XmlSchemaNamespace;
}
public XmlSchemaObjectLocation GetSelectedSchemaObjectLocation(string xml, int index)
{
XmlSchemaObject schemaObject = GetSelectedSchemaObject(xml, index);
return new XmlSchemaObjectLocation(schemaObject);
}
/// <summary>
/// Gets the XmlSchemaObject that defines the currently selected xml element or
/// attribute.
/// </summary>
/// <param name="text">The complete xml text.</param>
/// <param name="index">The current cursor index.</param>
/// <param name="currentSchemaCompletionData">This is the schema completion data for the
/// schema currently being displayed. This can be null if the document is
/// not a schema.</param>
public XmlSchemaObject GetSelectedSchemaObject(string xml, int index)
{
FindSelectedElement(xml, index);
return GetSelectedSchemaObject();
}
XmlSchemaObject GetSelectedSchemaObject()
{
XmlSchemaCompletion schemaForSelectedElement = FindSchemaForSelectedElement();
if (schemaForSelectedElement == null) {
return null;
}
XmlSchemaElement selectedSchemaElement = FindSchemaObjectForSelectedElement(schemaForSelectedElement);
if (selectedSchemaElement == null) {
return null;
}
if (selectedElement.HasSelectedAttribute) {
XmlSchemaAttribute attribute = FindSchemaObjectForSelectedAttribute(schemaForSelectedElement, selectedSchemaElement);
if (attribute == null) {
return selectedSchemaElement;
}
if (selectedElement.HasSelectedAttributeValue) {
XmlSchemaObject schemaObject = FindSchemaObjectReferencedByAttributeValue(selectedSchemaElement, attribute);
if (schemaObject != null) {
return schemaObject;
}
}
return attribute;
}
return selectedSchemaElement;
}
void FindSelectedElement(string xml, int index)
{
selectedElement = new SelectedXmlElement(xml, index);
}
XmlSchemaCompletion FindSchemaForSelectedElement()
{
return schemas[selectedElement.Path.GetRootNamespace()];
}
XmlSchemaElement FindSchemaObjectForSelectedElement(XmlSchemaCompletion schemaForSelectedElement)
{
return schemaForSelectedElement.FindElement(selectedElement.Path);
}
XmlSchemaAttribute FindSchemaObjectForSelectedAttribute(XmlSchemaCompletion schemaForSelectedElement, XmlSchemaElement selectedSchemaElement)
{
return schemaForSelectedElement.FindAttribute(selectedSchemaElement, selectedElement.SelectedAttribute);
}
/// <summary>
/// If the attribute value found references another item in the schema
/// return this instead of the attribute schema object. For example, if the
/// user can select the attribute value and the code will work out the schema object pointed to by the ref
/// or type attribute:
///
/// xs:element ref="ref-name"
/// xs:attribute type="type-name"
/// </summary>
/// <returns>
/// The <paramref name="attribute"/> if no schema object was referenced.
/// </returns>
XmlSchemaObject FindSchemaObjectReferencedByAttributeValue(XmlSchemaElement element, XmlSchemaAttribute attribute)
{
if ((currentSchema != null) && IsXmlSchemaNamespaceElement(element)) {
return GetSchemaObjectReferencedByAttributeValue(element.Name, attribute.Name);
}
return null;
}
XmlSchemaObject GetSchemaObjectReferencedByAttributeValue(string elementName, string attributeName)
{
if (attributeName == "ref") {
return FindSchemaObjectReference(selectedElement.SelectedAttributeValue, elementName);
} else if (attributeName == "type") {
return FindSchemaObjectType(selectedElement.SelectedAttributeValue, elementName);
}
return null;
}
/// <summary>
/// Attempts to locate the reference name in the specified schema.
/// </summary>
/// <param name="name">The reference to look up.</param>
/// <param name="schemaCompletionData">The schema completion data to use to
/// find the reference.</param>
/// <param name="elementName">The element to determine what sort of reference it is
/// (e.g. group, attribute, element).</param>
/// <returns><see langword="null"/> if no match can be found.</returns>
XmlSchemaObject FindSchemaObjectReference(string name, string elementName)
{
QualifiedName qualifiedName = currentSchema.CreateQualifiedName(name);
XmlSchemaCompletion schema = GetSchemaForQualifiedName(qualifiedName);
return FindSchemaObjectReference(qualifiedName, elementName, schema);
}
XmlSchemaObject FindSchemaObjectReference(QualifiedName qualifiedName, string elementName, XmlSchemaCompletion schema)
{
switch (elementName) {
case "element":
return schema.FindRootElement(qualifiedName);
case "attribute":
return schema.FindAttribute(qualifiedName.Name);
case "group":
return schema.FindGroup(qualifiedName.Name);
case "attributeGroup":
return schema.FindAttributeGroup(qualifiedName.Name);
}
return null;
}
XmlSchemaCompletion GetSchemaForQualifiedName(QualifiedName name)
{
XmlSchemaCompletion schema = schemas[name.Namespace];
if (schema != null) {
return schema;
}
return currentSchema;
}
/// <summary>
/// Attempts to locate the type name in the specified schema.
/// </summary>
/// <param name="name">The type to look up.</param>
/// <param name="elementName">The element to determine what sort of type it is
/// (e.g. group, attribute, element).</param>
/// <returns><see langword="null"/> if no match can be found.</returns>
XmlSchemaObject FindSchemaObjectType(string name, string elementName)
{
QualifiedName qualifiedName = currentSchema.CreateQualifiedName(name);
XmlSchemaCompletion schema = GetSchemaForQualifiedName(qualifiedName);
return FindSchemaObjectType(qualifiedName, elementName, schema);
}
XmlSchemaObject FindSchemaObjectType(QualifiedName qualifiedName, string elementName, XmlSchemaCompletion schema)
{
switch (elementName) {
case "element":
return schema.FindComplexType(qualifiedName);
case "attribute":
return schema.FindSimpleType(qualifiedName.Name);
}
return null;
}
/// <summary>
/// Checks whether the element belongs to the XSD namespace.
/// </summary>
static bool IsXmlSchemaNamespaceElement(XmlSchemaElement element)
{
XmlQualifiedName qualifiedName = element.QualifiedName;
if (qualifiedName != null) {
return IsXmlSchemaNamespace(qualifiedName.Namespace);
}
return false;
}
}
}

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

@ -0,0 +1,60 @@ @@ -0,0 +1,60 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
// <version>$Revision$</version>
// </file>
using System;
using ICSharpCode.SharpDevelop;
using System.Xml.Schema;
namespace ICSharpCode.XmlEditor
{
public class XmlSchemaObjectLocation
{
string fileName = String.Empty;
int lineNumber = -1;
int linePosition = -1;
public XmlSchemaObjectLocation(XmlSchemaObject schemaObject)
{
if (schemaObject != null) {
ReadLocation(schemaObject);
}
}
void ReadLocation(XmlSchemaObject schemaObject)
{
if (schemaObject.SourceUri != null) {
fileName = schemaObject.SourceUri.Replace("file:///", String.Empty);
}
lineNumber = schemaObject.LineNumber;
linePosition = schemaObject.LinePosition;
}
public string FileName {
get { return fileName; }
}
public int LineNumber {
get { return lineNumber; }
}
public int LinePosition {
get { return linePosition; }
}
public void JumpToFilePosition()
{
if (!String.IsNullOrEmpty(fileName)) {
JumpToFilePosition(fileName, lineNumber, linePosition);
}
}
protected virtual void JumpToFilePosition(string fileName, int line, int column)
{
FileService.JumpToFilePosition(fileName, line, column);
}
}
}

220
src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlView.cs

@ -32,6 +32,7 @@ namespace ICSharpCode.XmlEditor @@ -32,6 +32,7 @@ namespace ICSharpCode.XmlEditor
{
schemas = XmlEditorService.RegisteredXmlSchemas.Schemas;
}
/// <summary>
/// Retrieves additional data for a XML file.
/// </summary>
@ -39,13 +40,14 @@ namespace ICSharpCode.XmlEditor @@ -39,13 +40,14 @@ namespace ICSharpCode.XmlEditor
/// <returns>null if the file is not a valid XML file, otherwise a XmlView instance with additional data used by the XML editor.</returns>
public static XmlView ForFile(OpenedFile file)
{
if (file == null)
if (file == null) {
return null;
if (!XmlDisplayBinding.IsFileNameHandled(file.FileName))
}
if (!XmlDisplayBinding.IsFileNameHandled(file.FileName)) {
return null;
}
XmlView instance;
if (!mapping.TryGetValue(file, out instance)) {
file.FileClosed += new EventHandler(FileClosedHandler);
instance = new XmlView() { File = file };
@ -112,55 +114,6 @@ namespace ICSharpCode.XmlEditor @@ -112,55 +114,6 @@ namespace ICSharpCode.XmlEditor
get { return XmlView.ForViewContent(WorkbenchSingleton.Workbench.ActiveViewContent); }
}
/// <summary>
/// Finds the xml nodes that match the specified xpath.
/// </summary>
/// <returns>An array of XPathNodeMatch items. These include line number
/// and line position information aswell as the node found.</returns>
public static XPathNodeMatch[] SelectNodes(string xml, string xpath, ReadOnlyCollection<XmlNamespace> namespaces)
{
XmlTextReader xmlReader = new XmlTextReader(new StringReader(xml));
xmlReader.XmlResolver = null;
XPathDocument doc = new XPathDocument(xmlReader);
XPathNavigator navigator = doc.CreateNavigator();
// Add namespaces.
XmlNamespaceManager namespaceManager = new XmlNamespaceManager(navigator.NameTable);
foreach (XmlNamespace xmlNamespace in namespaces) {
namespaceManager.AddNamespace(xmlNamespace.Prefix, xmlNamespace.Name);
}
// Run the xpath query.
XPathNodeIterator iterator = navigator.Select(xpath, namespaceManager);
List<XPathNodeMatch> nodes = new List<XPathNodeMatch>();
while (iterator.MoveNext()) {
nodes.Add(new XPathNodeMatch(iterator.Current));
}
return nodes.ToArray();
}
/// <summary>
/// Finds the xml nodes that match the specified xpath.
/// </summary>
/// <returns>An array of XPathNodeMatch items. These include line number
/// and line position information aswell as the node found.</returns>
public static XPathNodeMatch[] SelectNodes(string xml, string xpath)
{
List<XmlNamespace> list = new List<XmlNamespace>();
return SelectNodes(xml, xpath, new ReadOnlyCollection<XmlNamespace>(list));
}
/// <summary>
/// Finds the xml nodes in the current document that match the specified xpath.
/// </summary>
/// <returns>An array of XPathNodeMatch items. These include line number
/// and line position information aswell as the node found.</returns>
public XPathNodeMatch[] SelectNodes(string xpath, ReadOnlyCollection<XmlNamespace> namespaces)
{
return SelectNodes(TextEditor.Document.Text, xpath, namespaces);
}
public void GoToSchemaDefinition()
{
// Find schema object for selected xml element or attribute.
@ -171,13 +124,9 @@ namespace ICSharpCode.XmlEditor @@ -171,13 +124,9 @@ namespace ICSharpCode.XmlEditor
return;
}
XmlSchemaObject schemaObject = GetSchemaObjectSelected(editor.Document.Text, editor.Caret.Offset, schemas, currentSchemaCompletion);
// Open schema.
if ((schemaObject != null) && (schemaObject.SourceUri != null) && (schemaObject.SourceUri.Length > 0)) {
string fileName = schemaObject.SourceUri.Replace("file:///", String.Empty);
FileService.JumpToFilePosition(fileName, schemaObject.LineNumber, schemaObject.LinePosition);
}
XmlSchemaDefinition schemaDefinition = new XmlSchemaDefinition(schemas, currentSchemaCompletion);
XmlSchemaObjectLocation schemaObjectLocation = schemaDefinition.GetSelectedSchemaObjectLocation(editor.Document.Text, editor.Caret.Offset);
schemaObjectLocation.JumpToFilePosition();
}
/// <summary>
@ -213,155 +162,6 @@ namespace ICSharpCode.XmlEditor @@ -213,155 +162,6 @@ namespace ICSharpCode.XmlEditor
}
#region XmlView methods
/// <summary>
/// If the attribute value found references another item in the schema
/// return this instead of the attribute schema object. For example, if the
/// user can select the attribute value and the code will work out the schema object pointed to by the ref
/// or type attribute:
///
/// xs:element ref="ref-name"
/// xs:attribute type="type-name"
/// </summary>
/// <returns>
/// The <paramref name="attribute"/> if no schema object was referenced.
/// </returns>
static XmlSchemaObject GetSchemaObjectReferenced(string xml, int index, XmlSchemaCompletionCollection schemas, XmlSchemaCompletion currentSchemaCompletionData, XmlSchemaElement element, XmlSchemaAttribute attribute)
{
XmlSchemaObject schemaObject = null;
if (IsXmlSchemaNamespace(element)) {
// Find attribute value.
string attributeValue = XmlParser.GetAttributeValueAtIndex(xml, index);
if (attributeValue.Length == 0) {
return attribute;
}
if (attribute.Name == "ref") {
schemaObject = FindSchemaObjectReference(attributeValue, schemas, currentSchemaCompletionData, element.Name);
} else if (attribute.Name == "type") {
schemaObject = FindSchemaObjectType(attributeValue, schemas, currentSchemaCompletionData, element.Name);
}
}
if (schemaObject != null) {
return schemaObject;
}
return attribute;
}
/// <summary>
/// Attempts to locate the reference name in the specified schema.
/// </summary>
/// <param name="name">The reference to look up.</param>
/// <param name="schemaCompletionData">The schema completion data to use to
/// find the reference.</param>
/// <param name="elementName">The element to determine what sort of reference it is
/// (e.g. group, attribute, element).</param>
/// <returns><see langword="null"/> if no match can be found.</returns>
static XmlSchemaObject FindSchemaObjectReference(string name, XmlSchemaCompletionCollection schemas, XmlSchemaCompletion schemaCompletion, string elementName)
{
QualifiedName qualifiedName = schemaCompletion.CreateQualifiedName(name);
XmlSchemaCompletion qualifiedNameSchema = schemas[qualifiedName.Namespace];
if (qualifiedNameSchema != null) {
schemaCompletion = qualifiedNameSchema;
}
switch (elementName) {
case "element":
return schemaCompletion.FindRootElement(qualifiedName);
case "attribute":
return schemaCompletion.FindAttribute(qualifiedName.Name);
case "group":
return schemaCompletion.FindGroup(qualifiedName.Name);
case "attributeGroup":
return schemaCompletion.FindAttributeGroup(qualifiedName.Name);
}
return null;
}
/// <summary>
/// Attempts to locate the type name in the specified schema.
/// </summary>
/// <param name="name">The type to look up.</param>
/// <param name="schemaCompletionData">The schema completion data to use to
/// find the type.</param>
/// <param name="elementName">The element to determine what sort of type it is
/// (e.g. group, attribute, element).</param>
/// <returns><see langword="null"/> if no match can be found.</returns>
static XmlSchemaObject FindSchemaObjectType(string name, XmlSchemaCompletionCollection schemas, XmlSchemaCompletion schemaCompletion, string elementName)
{
QualifiedName qualifiedName = schemaCompletion.CreateQualifiedName(name);
XmlSchemaCompletion qualifiedNameSchema = schemas[qualifiedName.Namespace];
if (qualifiedNameSchema != null) {
schemaCompletion = qualifiedNameSchema;
}
switch (elementName) {
case "element":
return schemaCompletion.FindComplexType(qualifiedName);
case "attribute":
return schemaCompletion.FindSimpleType(qualifiedName.Name);
}
return null;
}
/// <summary>
/// Checks whether the element belongs to the XSD namespace.
/// </summary>
static bool IsXmlSchemaNamespace(XmlSchemaElement element)
{
XmlQualifiedName qualifiedName = element.QualifiedName;
if (qualifiedName != null) {
return RegisteredXmlSchemas.IsXmlSchemaNamespace(qualifiedName.Namespace);
}
return false;
}
/// <summary>
/// Gets the XmlSchemaObject that defines the currently selected xml element or
/// attribute.
/// </summary>
/// <param name="text">The complete xml text.</param>
/// <param name="index">The current cursor index.</param>
public static XmlSchemaObject GetSchemaObjectSelected(string xml, int index, XmlSchemaCompletionCollection schemas)
{
return GetSchemaObjectSelected(xml, index, schemas, null);
}
/// <summary>
/// Gets the XmlSchemaObject that defines the currently selected xml element or
/// attribute.
/// </summary>
/// <param name="text">The complete xml text.</param>
/// <param name="index">The current cursor index.</param>
/// <param name="currentSchemaCompletionData">This is the schema completion data for the
/// schema currently being displayed. This can be null if the document is
/// not a schema.</param>
public static XmlSchemaObject GetSchemaObjectSelected(string xml, int index, XmlSchemaCompletionCollection schemas, XmlSchemaCompletion currentSchemaCompletion)
{
// Find element under cursor.
XmlElementPath path = XmlParser.GetActiveElementStartPathAtIndex(xml, index);
string attributeName = XmlParser.GetAttributeNameAtIndex(xml, index);
// Find schema definition object.
XmlSchemaCompletion schemaCompletion = schemas[path.GetRootNamespace()];
XmlSchemaObject schemaObject = null;
if (schemaCompletion != null) {
XmlSchemaElement element = schemaCompletion.FindElement(path);
schemaObject = element;
if (element != null) {
if (attributeName.Length > 0) {
XmlSchemaAttribute attribute = schemaCompletion.FindAttribute(element, attributeName);
if (attribute != null) {
if (currentSchemaCompletion != null) {
schemaObject = GetSchemaObjectReferenced(xml, index, schemas, currentSchemaCompletion, element, attribute);
} else {
schemaObject = attribute;
}
}
}
return schemaObject;
}
}
return null;
}
static void ShowErrorList()
{
@ -790,8 +590,8 @@ namespace ICSharpCode.XmlEditor @@ -790,8 +590,8 @@ namespace ICSharpCode.XmlEditor
{
XmlException innerException = ex.InnerException as XmlException;
if (innerException != null) {
string fileName = innerException.SourceUri.Replace("file:///", string.Empty);
if (!string.IsNullOrEmpty(fileName)) {
string fileName = innerException.SourceUri.Replace("file:///", String.Empty);
if (!String.IsNullOrEmpty(fileName)) {
return fileName;
}
}

6
src/AddIns/DisplayBindings/XmlEditor/Project/XmlEditor.addin

@ -97,6 +97,9 @@ @@ -97,6 +97,9 @@
label="${res:ICSharpCode.XmlEditor.ValidateXmlMenuLabel}"
class="ICSharpCode.XmlEditor.ValidateXmlCommand"
shortcut="Control|Shift|V"/>
<MenuItem id="GoToDefinition"
label="${res:ICSharpCode.NAntAddIn.GotoDefinitionMenuLabel}"
class="ICSharpCode.XmlEditor.GoToSchemaDefinitionCommand"/>
<MenuItem id="Separator1" type="Separator"/>
<ComplexCondition action="Disable">
<Not>
@ -121,6 +124,9 @@ @@ -121,6 +124,9 @@
shortcut="Control|Shift|T"/>
</ComplexCondition>
<MenuItem id="Separator2" type="Separator"/>
<MenuItem id="HideXPathResults"
label="${res:ICSharpCode.XmlEditor.HideXPathResults}"
class="ICSharpCode.XmlEditor.RemoveXPathHighlightingCommand"/>
<MenuItem id="Format"
label="${res:XML.MainMenu.EditMenu.FormatMenu}"
class="ICSharpCode.XmlEditor.FormatXmlCommand"/>

4
src/AddIns/DisplayBindings/XmlEditor/Project/XmlEditor.csproj

@ -112,6 +112,7 @@ @@ -112,6 +112,7 @@
<Compile Include="Src\RemoveXPathHighlightingCommand.cs" />
<Compile Include="Src\RunXslTransformCommand.cs" />
<Compile Include="Src\SchemaDocumentation.cs" />
<Compile Include="Src\SelectedXmlElement.cs" />
<Compile Include="Src\SelectXmlSchemaWindow.xaml.cs">
<DependentUpon>SelectXmlSchemaWindow.xaml</DependentUpon>
<SubType>Code</SubType>
@ -145,6 +146,7 @@ @@ -145,6 +146,7 @@
<Compile Include="Src\XmlNamespace.cs" />
<Compile Include="Src\XmlNamespaceCollection.cs" />
<Compile Include="Src\XmlParser.cs" />
<Compile Include="Src\XmlSchemaDefinition.cs" />
<Compile Include="Src\XmlSchemaFileAssociation.cs" />
<Compile Include="Src\XmlSchemaFileAssociationListItem.cs" />
<Compile Include="Src\XmlSchemaCompletion.cs" />
@ -152,6 +154,7 @@ @@ -152,6 +154,7 @@
<Compile Include="Src\XmlSchemaFileAssociations.cs" />
<Compile Include="Src\XmlSchemaListBoxItem.cs" />
<Compile Include="Src\RegisteredXmlSchemas.cs" />
<Compile Include="Src\XmlSchemaObjectLocation.cs" />
<Compile Include="Src\XmlSchemaPicker.cs" />
<Compile Include="Src\XmlSchemasPanel.xaml.cs">
<DependentUpon>XmlSchemasPanel.xaml</DependentUpon>
@ -167,6 +170,7 @@ @@ -167,6 +170,7 @@
<Compile Include="Src\XmlView.cs" />
<Compile Include="Src\XPathNodeMatch.cs" />
<Compile Include="Src\XPathNodeTextMarker.cs" />
<Compile Include="Src\XPathQuery.cs" />
<Compile Include="Src\XPathQueryControl.cs">
<SubType>UserControl</SubType>
</Compile>

5
src/AddIns/DisplayBindings/XmlEditor/Test/FindSchemaObject/AttributeGroupReferenceSelectedTestFixture.cs

@ -32,10 +32,11 @@ namespace XmlEditor.Tests.FindSchemaObject @@ -32,10 +32,11 @@ namespace XmlEditor.Tests.FindSchemaObject
XmlSchemaCompletion xsdSchemaCompletionData = new XmlSchemaCompletion(ResourceManager.ReadXsdSchema());
schemas.Add(xsdSchemaCompletionData);
string xml = GetSchema();
string xml = GetSchema();
int index = xml.IndexOf("ref=\"coreattrs\"");
index = xml.IndexOf("coreattrs", index);
schemaAttributeGroup = (XmlSchemaAttributeGroup)XmlView.GetSchemaObjectSelected(xml, index, schemas, SchemaCompletion);
XmlSchemaDefinition schemaDefinition = new XmlSchemaDefinition(schemas, SchemaCompletion);
schemaAttributeGroup = (XmlSchemaAttributeGroup)schemaDefinition.GetSelectedSchemaObject(xml, index);
}
[Test]

3
src/AddIns/DisplayBindings/XmlEditor/Test/FindSchemaObject/AttributeReferenceSelectedTestFixture.cs

@ -34,7 +34,8 @@ namespace XmlEditor.Tests.FindSchemaObject @@ -34,7 +34,8 @@ namespace XmlEditor.Tests.FindSchemaObject
string xml = GetSchema();
int index = xml.IndexOf("ref=\"dir\"");
index = xml.IndexOf("dir", index);
schemaAttribute = (XmlSchemaAttribute)XmlView.GetSchemaObjectSelected(xml, index, schemas, SchemaCompletion);
XmlSchemaDefinition schemaDefinition = new XmlSchemaDefinition(schemas, SchemaCompletion);
schemaAttribute = (XmlSchemaAttribute)schemaDefinition.GetSelectedSchemaObject(xml, index);
}
[Test]

5
src/AddIns/DisplayBindings/XmlEditor/Test/FindSchemaObject/AttributeSelectedTestFixture.cs

@ -25,7 +25,8 @@ namespace XmlEditor.Tests.FindSchemaObject @@ -25,7 +25,8 @@ namespace XmlEditor.Tests.FindSchemaObject
XmlSchemaCompletionCollection schemas = new XmlSchemaCompletionCollection();
schemas.Add(SchemaCompletion);
string xml = "<note xmlns='http://www.w3schools.com' name=''></note>";
schemaAttribute = (XmlSchemaAttribute)XmlView.GetSchemaObjectSelected(xml, xml.IndexOf("name"), schemas);
XmlSchemaDefinition schemaDefinition = new XmlSchemaDefinition(schemas, null);
schemaAttribute = (XmlSchemaAttribute)schemaDefinition.GetSelectedSchemaObject(xml, xml.IndexOf("name"));
}
[Test]
@ -39,7 +40,7 @@ namespace XmlEditor.Tests.FindSchemaObject @@ -39,7 +40,7 @@ namespace XmlEditor.Tests.FindSchemaObject
return "<xs:schema xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" targetNamespace=\"http://www.w3schools.com\" xmlns=\"http://www.w3schools.com\" elementFormDefault=\"qualified\">\r\n" +
" <xs:element name=\"note\">\r\n" +
" <xs:complexType>\r\n" +
"\t<xs:attribute name=\"name\" type=\"xs:string\"/>\r\n" +
" <xs:attribute name=\"name\" type=\"xs:string\"/>\r\n" +
" </xs:complexType>\r\n" +
" </xs:element>\r\n" +
"</xs:schema>";

3
src/AddIns/DisplayBindings/XmlEditor/Test/FindSchemaObject/AttributeTypeSelectedTestFixture.cs

@ -34,7 +34,8 @@ namespace XmlEditor.Tests.FindSchemaObject @@ -34,7 +34,8 @@ namespace XmlEditor.Tests.FindSchemaObject
string xml = GetSchema();
int index = xml.IndexOf("type=\"dir\"/>");
index = xml.IndexOf("dir", index);
schemaSimpleType = (XmlSchemaSimpleType)XmlView.GetSchemaObjectSelected(xml, index, schemas, SchemaCompletion);
XmlSchemaDefinition schemaDefinition = new XmlSchemaDefinition(schemas, SchemaCompletion);
schemaSimpleType = (XmlSchemaSimpleType)schemaDefinition.GetSelectedSchemaObject(xml, index);
}
[Test]

7
src/AddIns/DisplayBindings/XmlEditor/Test/FindSchemaObject/ElementReferenceSelectedTestFixture.cs

@ -33,18 +33,19 @@ namespace XmlEditor.Tests.FindSchemaObject @@ -33,18 +33,19 @@ namespace XmlEditor.Tests.FindSchemaObject
schemas.Add(xsdSchemaCompletionData);
string xml = GetSchema();
schemaAttribute = (XmlSchemaAttribute)XmlView.GetSchemaObjectSelected(xml, xml.IndexOf("ref=\"name"), schemas, SchemaCompletion);
XmlSchemaDefinition schemaDefinition = new XmlSchemaDefinition(schemas, SchemaCompletion);
schemaAttribute = (XmlSchemaAttribute)schemaDefinition.GetSelectedSchemaObject(xml, xml.IndexOf("ref=\"name"));
int index = xml.IndexOf("ref=\"name");
index = xml.IndexOf('n', index);
referencedSchemaElement = (XmlSchemaElement)XmlView.GetSchemaObjectSelected(xml, index, schemas, SchemaCompletion);
referencedSchemaElement = (XmlSchemaElement)schemaDefinition.GetSelectedSchemaObject(xml, index);
}
[Test]
public void AttributeName()
{
Assert.AreEqual("ref", schemaAttribute.QualifiedName.Name);
}
}
[Test]
public void ReferencedElementName()

3
src/AddIns/DisplayBindings/XmlEditor/Test/FindSchemaObject/ElementReferenceWithPrefixSelectedTestFixture.cs

@ -35,7 +35,8 @@ namespace XmlEditor.Tests.FindSchemaObject @@ -35,7 +35,8 @@ namespace XmlEditor.Tests.FindSchemaObject
int index = xml.IndexOf("ref=\"xs:list");
index = xml.IndexOf("xs", index);
referencedSchemaElement = (XmlSchemaElement)XmlView.GetSchemaObjectSelected(xml, index, schemas, SchemaCompletion);
XmlSchemaDefinition schemaDefinition = new XmlSchemaDefinition(schemas, SchemaCompletion);
referencedSchemaElement = (XmlSchemaElement)schemaDefinition.GetSelectedSchemaObject(xml, index);
}
[Test]

20
src/AddIns/DisplayBindings/XmlEditor/Test/FindSchemaObject/ElementSelectedTestFixture.cs

@ -19,13 +19,19 @@ namespace XmlEditor.Tests.FindSchemaObject @@ -19,13 +19,19 @@ namespace XmlEditor.Tests.FindSchemaObject
public class ElementSelectedTestFixture : SchemaTestFixtureBase
{
XmlSchemaElement schemaElement;
XmlSchemaObjectLocation location;
public override void FixtureInit()
{
XmlSchemaCompletionCollection schemas = new XmlSchemaCompletionCollection();
schemas.Add(SchemaCompletion);
string xml = "<note xmlns='http://www.w3schools.com'></note>";
schemaElement = (XmlSchemaElement)XmlView.GetSchemaObjectSelected(xml, xml.IndexOf("note xmlns"), schemas);
int index = xml.IndexOf("note xmlns");
XmlSchemaDefinition schemaDefinition = new XmlSchemaDefinition(schemas, null);
schemaElement = (XmlSchemaElement)schemaDefinition.GetSelectedSchemaObject(xml, index);
location = schemaDefinition.GetSelectedSchemaObjectLocation(xml, index);
}
[Test]
@ -53,5 +59,17 @@ namespace XmlEditor.Tests.FindSchemaObject @@ -53,5 +59,17 @@ namespace XmlEditor.Tests.FindSchemaObject
"</xs:element>\r\n" +
"</xs:schema>";
}
[Test]
public void SchemaObjectLocationLinePositionMatchesSchemaElement()
{
Assert.AreEqual(schemaElement.LinePosition, location.LinePosition);
}
[Test]
public void SchemaObjectLocationLineNumberMatchesSchemaElement()
{
Assert.AreEqual(schemaElement.LineNumber, location.LineNumber);
}
}
}

3
src/AddIns/DisplayBindings/XmlEditor/Test/FindSchemaObject/ElementTypeSelectedTestFixture.cs

@ -34,7 +34,8 @@ namespace XmlEditor.Tests.FindSchemaObject @@ -34,7 +34,8 @@ namespace XmlEditor.Tests.FindSchemaObject
string xml = GetSchema();
int index = xml.IndexOf("type=\"text-type\"");
index = xml.IndexOf("text-type", index);
schemaComplexType = (XmlSchemaComplexType)XmlView.GetSchemaObjectSelected(xml, index, schemas, SchemaCompletion);
XmlSchemaDefinition schemaDefinition = new XmlSchemaDefinition(schemas, SchemaCompletion);
schemaComplexType = (XmlSchemaComplexType)schemaDefinition.GetSelectedSchemaObject(xml, index);
}
[Test]

3
src/AddIns/DisplayBindings/XmlEditor/Test/FindSchemaObject/ElementTypeWithPrefixSelectedTestFixture.cs

@ -34,7 +34,8 @@ namespace XmlEditor.Tests.FindSchemaObject @@ -34,7 +34,8 @@ namespace XmlEditor.Tests.FindSchemaObject
string xml = GetSchema();
int index = xml.IndexOf("type=\"xs:complexType\"");
index = xml.IndexOf("xs:complexType", index);
schemaComplexType = (XmlSchemaComplexType)XmlView.GetSchemaObjectSelected(xml, index, schemas, SchemaCompletion);
XmlSchemaDefinition schemaDefinition = new XmlSchemaDefinition(schemas, SchemaCompletion);
schemaComplexType = (XmlSchemaComplexType)schemaDefinition.GetSelectedSchemaObject(xml, index);
}
[Test]

66
src/AddIns/DisplayBindings/XmlEditor/Test/FindSchemaObject/FindSelectedAttributeInTextEditorTestFixture.cs

@ -0,0 +1,66 @@ @@ -0,0 +1,66 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
// <version>$Revision$</version>
// </file>
using System;
using ICSharpCode.XmlEditor;
using NUnit.Framework;
using XmlEditor.Tests.Utils;
namespace XmlEditor.Tests.FindSchemaObject
{
[TestFixture]
public class FindSelectedAttributeInTextEditorTestFixture
{
SelectedXmlElement selectedElement;
[SetUp]
public void Init()
{
string xml = "<root attribute1=''></root>";
int index = 10;
MockTextEditor textEditor = new MockTextEditor();
textEditor.Document.Text = xml;
textEditor.Caret.Offset = index;
selectedElement = new SelectedXmlElement(textEditor);
}
[Test]
public void ElementPathContainsSingleRootElement()
{
XmlElementPath path = new XmlElementPath();
path.AddElement(new QualifiedName("root", String.Empty));
Assert.AreEqual(path, selectedElement.Path);
}
[Test]
public void HasSelectedAttribute()
{
Assert.IsTrue(selectedElement.HasSelectedAttribute);
}
[Test]
public void HasNoSelectedAttributeValue()
{
Assert.IsFalse(selectedElement.HasSelectedAttributeValue);
}
[Test]
public void SelectedAttributeIsFirstAttribute()
{
Assert.AreEqual("attribute1", selectedElement.SelectedAttribute);
}
[Test]
public void SelectedAttributeValueIsEmptyString()
{
Assert.AreEqual(String.Empty, selectedElement.SelectedAttributeValue);
}
}
}

66
src/AddIns/DisplayBindings/XmlEditor/Test/FindSchemaObject/FindSelectedAttributeValueInTextEditorTestFixture.cs

@ -0,0 +1,66 @@ @@ -0,0 +1,66 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
// <version>$Revision$</version>
// </file>
using System;
using ICSharpCode.XmlEditor;
using NUnit.Framework;
using XmlEditor.Tests.Utils;
namespace XmlEditor.Tests.FindSchemaObject
{
[TestFixture]
public class FindSelectedAttributeValueInTextEditorTestFixture
{
SelectedXmlElement selectedElement;
[SetUp]
public void Init()
{
string xml = "<parent a='attributeValue'></parent>";
int index = 15;
MockTextEditor textEditor = new MockTextEditor();
textEditor.Document.Text = xml;
textEditor.Caret.Offset = index;
selectedElement = new SelectedXmlElement(textEditor);
}
[Test]
public void ElementPathContainsSingleRootElement()
{
XmlElementPath path = new XmlElementPath();
path.AddElement(new QualifiedName("parent", String.Empty));
Assert.AreEqual(path, selectedElement.Path);
}
[Test]
public void HasSelectedAttribute()
{
Assert.IsTrue(selectedElement.HasSelectedAttribute);
}
[Test]
public void HasSelectedAttributeValue()
{
Assert.IsTrue(selectedElement.HasSelectedAttributeValue);
}
[Test]
public void SelectedAttributeIsFirstAttribute()
{
Assert.AreEqual("a", selectedElement.SelectedAttribute);
}
[Test]
public void SelectedAttributeValueIsFirstAttributeValue()
{
Assert.AreEqual("attributeValue", selectedElement.SelectedAttributeValue);
}
}
}

66
src/AddIns/DisplayBindings/XmlEditor/Test/FindSchemaObject/FindSelectedElementInTextEditorTestFixture.cs

@ -0,0 +1,66 @@ @@ -0,0 +1,66 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
// <version>$Revision$</version>
// </file>
using System;
using ICSharpCode.XmlEditor;
using NUnit.Framework;
using XmlEditor.Tests.Utils;
namespace XmlEditor.Tests.FindSchemaObject
{
[TestFixture]
public class FindSelectedElementInTextEditorTestFixture
{
SelectedXmlElement selectedElement;
[SetUp]
public void Init()
{
string xml = "<abc></abc>";
int index = 2;
MockTextEditor textEditor = new MockTextEditor();
textEditor.Document.Text = xml;
textEditor.Caret.Offset = index;
selectedElement = new SelectedXmlElement(textEditor);
}
[Test]
public void ElementPathContainsSingleRootElement()
{
XmlElementPath path = new XmlElementPath();
path.AddElement(new QualifiedName("abc", String.Empty));
Assert.AreEqual(path, selectedElement.Path);
}
[Test]
public void HasNoSelectedAttribute()
{
Assert.IsFalse(selectedElement.HasSelectedAttribute);
}
[Test]
public void HasNoSelectedAttributeValue()
{
Assert.IsFalse(selectedElement.HasSelectedAttributeValue);
}
[Test]
public void SelectedAttributeIsEmptyString()
{
Assert.AreEqual(String.Empty, selectedElement.SelectedAttribute);
}
[Test]
public void SelectedAttributeValueIsEmptyString()
{
Assert.AreEqual(String.Empty, selectedElement.SelectedAttributeValue);
}
}
}

3
src/AddIns/DisplayBindings/XmlEditor/Test/FindSchemaObject/GroupReferenceSelectedTestFixture.cs

@ -34,7 +34,8 @@ namespace XmlEditor.Tests.FindSchemaObject @@ -34,7 +34,8 @@ namespace XmlEditor.Tests.FindSchemaObject
string xml = GetSchema();
int index = xml.IndexOf("ref=\"block\"");
index = xml.IndexOf("block", index);
schemaGroup = (XmlSchemaGroup)XmlView.GetSchemaObjectSelected(xml, index, schemas, SchemaCompletion);
XmlSchemaDefinition schemaDefinition = new XmlSchemaDefinition(schemas, SchemaCompletion);
schemaGroup = (XmlSchemaGroup)schemaDefinition.GetSelectedSchemaObject(xml, index);
}
[Test]

54
src/AddIns/DisplayBindings/XmlEditor/Test/FindSchemaObject/NullSchemaObjectPassedToSchemaObjectLocationTestFixture.cs

@ -0,0 +1,54 @@ @@ -0,0 +1,54 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
// <version>$Revision$</version>
// </file>
using System;
using System.Xml.Schema;
using ICSharpCode.XmlEditor;
using NUnit.Framework;
using XmlEditor.Tests.Utils;
namespace XmlEditor.Tests.FindSchemaObject
{
[TestFixture]
public class NullSchemaObjectPassedToSchemaObjectLocationTestFixture
{
DerivedXmlSchemaObjectLocation location;
[SetUp]
public void Init()
{
XmlSchemaObject schemaObject = null;
location = new DerivedXmlSchemaObjectLocation(schemaObject);
location.JumpToFilePosition();
}
[Test]
public void FileNameIsEmptyString()
{
Assert.AreEqual(String.Empty, location.FileName);
}
[Test]
public void LineNumberIsMinusOne()
{
Assert.AreEqual(-1, location.LineNumber);
}
[Test]
public void LinePositionIsMinusOne()
{
Assert.AreEqual(-1, location.LinePosition);
}
[Test]
public void JumpToFilePositionMethodDoesNothing()
{
location.JumpToFilePosition();
Assert.IsFalse(location.IsDerivedJumpToFilePositionMethodCalled);
}
}
}

38
src/AddIns/DisplayBindings/XmlEditor/Test/FindSchemaObject/SchemaObjectLocationFileNameTests.cs

@ -0,0 +1,38 @@ @@ -0,0 +1,38 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
// <version>$Revision$</version>
// </file>
using System;
using System.Xml.Schema;
using ICSharpCode.XmlEditor;
using NUnit.Framework;
namespace XmlEditor.Tests.FindSchemaObject
{
[TestFixture]
public class SchemaObjectLocationFileNameTests
{
[Test]
public void FileColonTripleSlashUrlRemovedFromSchemaObjectFileName()
{
XmlSchema schemaObject = new XmlSchema();
schemaObject.SourceUri = @"file:///d:\schemas\test.xsd";
XmlSchemaObjectLocation location = new XmlSchemaObjectLocation(schemaObject);
Assert.AreEqual(@"d:\schemas\test.xsd", location.FileName);
}
[Test]
public void SchemaLocationFileNameIsEmptyStringIfSchemaObjectFileNameIsNull()
{
XmlSchema schemaObject = new XmlSchema();
schemaObject.SourceUri = null;
XmlSchemaObjectLocation location = new XmlSchemaObjectLocation(schemaObject);
Assert.AreEqual(String.Empty, location.FileName);
}
}
}

59
src/AddIns/DisplayBindings/XmlEditor/Test/FindSchemaObject/SchemaObjectLocationJumpToTests.cs

@ -0,0 +1,59 @@ @@ -0,0 +1,59 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
// <version>$Revision$</version>
// </file>
using System;
using System.Xml.Schema;
using ICSharpCode.XmlEditor;
using NUnit.Framework;
using XmlEditor.Tests.Utils;
namespace XmlEditor.Tests.FindSchemaObject
{
[TestFixture]
public class SchemaObjectLocationJumpToTests
{
DerivedXmlSchemaObjectLocation location;
[SetUp]
public void Init()
{
XmlSchema schemaObject = new XmlSchema();
schemaObject.SourceUri = @"d:\test\a.xsd";
schemaObject.LineNumber = 2;
schemaObject.LinePosition = 4;
location = new DerivedXmlSchemaObjectLocation(schemaObject);
location.JumpToFilePosition();
}
[Test]
public void FileNameJumpedTo()
{
Assert.AreEqual(@"d:\test\a.xsd", location.JumpToFilePositionMethodFileNameParameter);
}
[Test]
public void LineNumberJumpedTo()
{
Assert.AreEqual(2, location.JumpToFilePositionMethodLineParameter);
}
[Test]
public void LinePositionJumpedTo()
{
Assert.AreEqual(4, location.JumpToFilePositionMethodColumnParameter);
}
[Test]
public void JumpToDoesNothingWhenFileNameIsEmptyString()
{
XmlSchema schemaObject = new XmlSchema();
schemaObject.SourceUri = String.Empty;
DerivedXmlSchemaObjectLocation location = new DerivedXmlSchemaObjectLocation(schemaObject);
Assert.IsFalse(location.IsDerivedJumpToFilePositionMethodCalled);
}
}
}

6
src/AddIns/DisplayBindings/XmlEditor/Test/Schema/XmlSchemaNamespaceTests.cs

@ -20,19 +20,19 @@ namespace XmlEditor.Tests.Schema @@ -20,19 +20,19 @@ namespace XmlEditor.Tests.Schema
[Test]
public void IsXmlSchemaNamespace()
{
Assert.IsTrue(RegisteredXmlSchemas.IsXmlSchemaNamespace("http://www.w3.org/2001/XMLSchema"));
Assert.IsTrue(XmlSchemaDefinition.IsXmlSchemaNamespace("http://www.w3.org/2001/XMLSchema"));
}
[Test]
public void IsNotXmlSchemaNamespace()
{
Assert.IsFalse(RegisteredXmlSchemas.IsXmlSchemaNamespace("http://foo.com"));
Assert.IsFalse(XmlSchemaDefinition.IsXmlSchemaNamespace("http://foo.com"));
}
[Test]
public void EmptyString()
{
Assert.IsFalse(RegisteredXmlSchemas.IsXmlSchemaNamespace(String.Empty));
Assert.IsFalse(XmlSchemaDefinition.IsXmlSchemaNamespace(String.Empty));
}
}
}

55
src/AddIns/DisplayBindings/XmlEditor/Test/Utils/DerivedXmlSchemaObjectLocation.cs

@ -0,0 +1,55 @@ @@ -0,0 +1,55 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
// <version>$Revision$</version>
// </file>
using System;
using System.Xml.Schema;
using ICSharpCode.XmlEditor;
namespace XmlEditor.Tests.Utils
{
public class DerivedXmlSchemaObjectLocation : XmlSchemaObjectLocation
{
bool jumpToFilePositionCalled;
string jumpToFilePositionMethodFileNameParameter;
int jumpToFilePositionMethodLineParameter = -1;
int jumpToFilePositionMethodColumnParameter = -1;
public DerivedXmlSchemaObjectLocation(XmlSchemaObject schemaObject)
: base(schemaObject)
{
}
public bool IsDerivedJumpToFilePositionMethodCalled {
get { return jumpToFilePositionCalled; }
}
public string JumpToFilePositionMethodFileNameParameter {
get { return jumpToFilePositionMethodFileNameParameter; }
}
public int JumpToFilePositionMethodLineParameter {
get { return jumpToFilePositionMethodLineParameter; }
}
public int JumpToFilePositionMethodColumnParameter {
get { return jumpToFilePositionMethodColumnParameter; }
}
public void CallJumpToFilePosition(string fileName, int line, int column)
{
JumpToFilePosition(fileName, line, column);
}
protected override void JumpToFilePosition(string fileName, int line, int column)
{
jumpToFilePositionCalled = true;
jumpToFilePositionMethodFileNameParameter = fileName;
jumpToFilePositionMethodLineParameter = line;
jumpToFilePositionMethodColumnParameter = column;
}
}
}

31
src/AddIns/DisplayBindings/XmlEditor/Test/Utils/MockTextEditorProviderViewContent.cs

@ -0,0 +1,31 @@ @@ -0,0 +1,31 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
// <version>$Revision$</version>
// </file>
using System;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Editor;
namespace XmlEditor.Tests.Utils
{
public class MockTextEditorProviderViewContent : MockViewContent, ITextEditorProvider
{
MockTextEditor textEditor = new MockTextEditor();
public ITextEditor TextEditor {
get { return textEditor; }
}
public MockTextEditor MockTextEditor {
get { return textEditor; }
}
public IDocument GetDocumentForFile(OpenedFile file)
{
throw new NotImplementedException();
}
}
}

166
src/AddIns/DisplayBindings/XmlEditor/Test/Utils/MockViewContent.cs

@ -0,0 +1,166 @@ @@ -0,0 +1,166 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
// <version>$Revision$</version>
// </file>
using System;
using ICSharpCode.SharpDevelop.Gui;
namespace XmlEditor.Tests.Utils
{
public class MockViewContent : IViewContent
{
public event EventHandler TabPageTextChanged;
protected virtual void OnTabPageTextChanged(EventArgs e)
{
if (TabPageTextChanged != null) {
TabPageTextChanged(this, e);
}
}
public event EventHandler TitleNameChanged;
protected virtual void OnTitleNameChanged(EventArgs e)
{
if (TitleNameChanged != null) {
TitleNameChanged(this, e);
}
}
public event EventHandler Disposed;
protected virtual void OnDisposed(EventArgs e)
{
if (Disposed != null) {
Disposed(this, e);
}
}
public event EventHandler IsDirtyChanged;
protected virtual void OnIsDirtyChanged(EventArgs e)
{
if (IsDirtyChanged != null) {
IsDirtyChanged(this, e);
}
}
public object Control {
get {
throw new NotImplementedException();
}
}
public IWorkbenchWindow WorkbenchWindow {
get {
throw new NotImplementedException();
}
set {
throw new NotImplementedException();
}
}
public string TabPageText {
get {
throw new NotImplementedException();
}
}
public string TitleName {
get {
throw new NotImplementedException();
}
}
public System.Collections.Generic.IList<ICSharpCode.SharpDevelop.OpenedFile> Files {
get {
throw new NotImplementedException();
}
}
public ICSharpCode.SharpDevelop.OpenedFile PrimaryFile {
get {
throw new NotImplementedException();
}
}
public ICSharpCode.Core.FileName PrimaryFileName {
get {
throw new NotImplementedException();
}
}
public bool IsDisposed {
get {
throw new NotImplementedException();
}
}
public bool IsReadOnly {
get {
throw new NotImplementedException();
}
}
public bool IsViewOnly {
get {
throw new NotImplementedException();
}
}
public System.Collections.Generic.ICollection<IViewContent> SecondaryViewContents {
get {
throw new NotImplementedException();
}
}
public bool IsDirty {
get {
throw new NotImplementedException();
}
}
public void Save(ICSharpCode.SharpDevelop.OpenedFile file, System.IO.Stream stream)
{
throw new NotImplementedException();
}
public void Load(ICSharpCode.SharpDevelop.OpenedFile file, System.IO.Stream stream)
{
throw new NotImplementedException();
}
public ICSharpCode.SharpDevelop.INavigationPoint BuildNavPoint()
{
throw new NotImplementedException();
}
public bool SupportsSwitchFromThisWithoutSaveLoad(ICSharpCode.SharpDevelop.OpenedFile file, IViewContent newView)
{
throw new NotImplementedException();
}
public bool SupportsSwitchToThisWithoutSaveLoad(ICSharpCode.SharpDevelop.OpenedFile file, IViewContent oldView)
{
throw new NotImplementedException();
}
public void SwitchFromThisWithoutSaveLoad(ICSharpCode.SharpDevelop.OpenedFile file, IViewContent newView)
{
throw new NotImplementedException();
}
public void SwitchToThisWithoutSaveLoad(ICSharpCode.SharpDevelop.OpenedFile file, IViewContent oldView)
{
throw new NotImplementedException();
}
public void Dispose()
{
throw new NotImplementedException();
}
}
}

194
src/AddIns/DisplayBindings/XmlEditor/Test/Utils/MockWorkbench.cs

@ -0,0 +1,194 @@ @@ -0,0 +1,194 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
// <version>$Revision$</version>
// </file>
using System;
using System.Collections.Generic;
using ICSharpCode.SharpDevelop.Gui;
namespace XmlEditor.Tests.Utils
{
public class MockWorkbench : IWorkbench
{
List<IViewContent> viewContentCollection = new List<IViewContent>();
public MockWorkbench()
{
}
public event EventHandler ActiveWorkbenchWindowChanged;
protected virtual void OnActiveWorkbenchWindowChanged(EventArgs e)
{
if (ActiveWorkbenchWindowChanged != null) {
ActiveWorkbenchWindowChanged(this, e);
}
}
public event EventHandler ActiveViewContentChanged;
protected virtual void OnActiveViewContentChanged(EventArgs e)
{
if (ActiveViewContentChanged != null) {
ActiveViewContentChanged(this, e);
}
}
public event EventHandler ActiveContentChanged;
protected virtual void OnActiveContentChanged(EventArgs e)
{
if (ActiveContentChanged != null) {
ActiveContentChanged(this, e);
}
}
public event ViewContentEventHandler ViewOpened;
protected virtual void OnViewOpened(ViewContentEventArgs e)
{
if (ViewOpened != null) {
ViewOpened(this, e);
}
}
public event ViewContentEventHandler ViewClosed;
protected virtual void OnViewClosed(ViewContentEventArgs e)
{
if (ViewClosed != null) {
ViewClosed(this, e);
}
}
public System.Windows.Forms.IWin32Window MainWin32Window {
get {
throw new NotImplementedException();
}
}
public System.ComponentModel.ISynchronizeInvoke SynchronizingObject {
get {
throw new NotImplementedException();
}
}
public System.Windows.Window MainWindow {
get {
throw new NotImplementedException();
}
}
public string Title {
get {
throw new NotImplementedException();
}
set {
throw new NotImplementedException();
}
}
public ICollection<IViewContent> ViewContentCollection {
get { return viewContentCollection; }
}
public ICollection<IViewContent> PrimaryViewContents {
get {
throw new NotImplementedException();
}
}
public IList<IWorkbenchWindow> WorkbenchWindowCollection {
get {
throw new NotImplementedException();
}
}
public IList<ICSharpCode.SharpDevelop.PadDescriptor> PadContentCollection {
get {
throw new NotImplementedException();
}
}
public IWorkbenchWindow ActiveWorkbenchWindow {
get {
throw new NotImplementedException();
}
}
public IViewContent ActiveViewContent {
get {
throw new NotImplementedException();
}
}
public object ActiveContent {
get {
throw new NotImplementedException();
}
}
public IWorkbenchLayout WorkbenchLayout {
get {
throw new NotImplementedException();
}
set {
throw new NotImplementedException();
}
}
public bool IsActiveWindow {
get {
throw new NotImplementedException();
}
}
public void Initialize()
{
throw new NotImplementedException();
}
public void ShowView(IViewContent content)
{
throw new NotImplementedException();
}
public void ShowView(IViewContent content, bool switchToOpenedView)
{
throw new NotImplementedException();
}
public void ShowPad(ICSharpCode.SharpDevelop.PadDescriptor content)
{
throw new NotImplementedException();
}
public void UnloadPad(ICSharpCode.SharpDevelop.PadDescriptor content)
{
throw new NotImplementedException();
}
public ICSharpCode.SharpDevelop.PadDescriptor GetPad(Type type)
{
throw new NotImplementedException();
}
public void CloseAllViews()
{
throw new NotImplementedException();
}
public ICSharpCode.Core.Properties CreateMemento()
{
throw new NotImplementedException();
}
public void SetMemento(ICSharpCode.Core.Properties memento)
{
throw new NotImplementedException();
}
}
}

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

@ -1,7 +1,7 @@ @@ -1,7 +1,7 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Siegfried Pammer" email="sie_pam@gmx.at"/>
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
// <version>$Revision$</version>
// </file>
@ -13,9 +13,6 @@ using ICSharpCode.SharpDevelop.Gui; @@ -13,9 +13,6 @@ using ICSharpCode.SharpDevelop.Gui;
namespace XmlEditor.Tests.Utils
{
/// <summary>
/// Description of MockXmlViewContent.
/// </summary>
public class MockXmlViewContent : AbstractViewContent, IFileDocumentProvider
{
OpenedFile file;

80
src/AddIns/DisplayBindings/XmlEditor/Test/Utils/Tests/DerivedXmlSchemaObjectLocationTests.cs

@ -0,0 +1,80 @@ @@ -0,0 +1,80 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
// <version>$Revision$</version>
// </file>
using System;
using System.Xml.Schema;
using NUnit.Framework;
using XmlEditor.Tests.Utils;
namespace XmlEditor.Tests.Utils.Tests
{
[TestFixture]
public class DerivedXmlSchemaObjectLocationTests
{
DerivedXmlSchemaObjectLocation location;
[Test]
public void DefaultIsDerivedJumpToFilePositionMethodCalledIsFalse()
{
DerivedXmlSchemaObjectLocation location = new DerivedXmlSchemaObjectLocation(null);
Assert.IsFalse(location.IsDerivedJumpToFilePositionMethodCalled);
}
[Test]
public void DefaultJumpToFilePositionMethodFileNameParameter()
{
DerivedXmlSchemaObjectLocation location = new DerivedXmlSchemaObjectLocation(null);
Assert.IsNull(location.JumpToFilePositionMethodFileNameParameter);
}
[Test]
public void DefaultJumpToFilePositionMethodLineParameter()
{
DerivedXmlSchemaObjectLocation location = new DerivedXmlSchemaObjectLocation(null);
Assert.AreEqual(-1, location.JumpToFilePositionMethodLineParameter);
}
[Test]
public void DefaultJumpToFilePositionMethodColumnParameter()
{
DerivedXmlSchemaObjectLocation location = new DerivedXmlSchemaObjectLocation(null);
Assert.AreEqual(-1, location.JumpToFilePositionMethodColumnParameter);
}
[Test]
public void JumpToFilePositionMethodCallIsRecorded()
{
int line = 2;
int column = 3;
location = new DerivedXmlSchemaObjectLocation(null);
location.CallJumpToFilePosition("test.xml", line, column);
Assert.IsTrue(location.IsDerivedJumpToFilePositionMethodCalled);
}
[Test]
public void JumpToFilePositionMethodCallRecordsLineParameter()
{
JumpToFilePositionMethodCallIsRecorded();
Assert.AreEqual(2, location.JumpToFilePositionMethodLineParameter);
}
[Test]
public void JumpToFilePositionMethodCallRecordsColumnParameter()
{
JumpToFilePositionMethodCallIsRecorded();
Assert.AreEqual(3, location.JumpToFilePositionMethodColumnParameter);
}
[Test]
public void JumpToFilePositionMethodCallRecordsFileNameParameter()
{
JumpToFilePositionMethodCallIsRecorded();
Assert.AreEqual("test.xml", location.JumpToFilePositionMethodFileNameParameter);
}
}
}

55
src/AddIns/DisplayBindings/XmlEditor/Test/Utils/Tests/XPathNodeMatchComparisonResultTests.cs

@ -0,0 +1,55 @@ @@ -0,0 +1,55 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
// <version>$Revision$</version>
// </file>
using System;
using XmlEditor.Tests.Utils;
using NUnit.Framework;
namespace XmlEditor.Tests.Utils.Tests
{
[TestFixture]
public class XPathNodeMatchComparisonResultTests
{
[Test]
public void ComparisonResultsAreEqualWhenResultAndMessageAreSame()
{
XPathNodeMatchComparisonResult lhs = new XPathNodeMatchComparisonResult(true, "abc");
XPathNodeMatchComparisonResult rhs = new XPathNodeMatchComparisonResult(true, "abc");
Assert.AreEqual(lhs, rhs);
}
[Test]
public void ComparisonResultsAreNotEqualWhenResultIsDifferent()
{
XPathNodeMatchComparisonResult lhs = new XPathNodeMatchComparisonResult(false, "abc");
XPathNodeMatchComparisonResult rhs = new XPathNodeMatchComparisonResult(true, "abc");
Assert.AreNotEqual(lhs, rhs);
}
[Test]
public void ComparisonResultsAreNotEqualWhenMessageIsDifferent()
{
XPathNodeMatchComparisonResult lhs = new XPathNodeMatchComparisonResult(false, "aaa");
XPathNodeMatchComparisonResult rhs = new XPathNodeMatchComparisonResult(false, "bbb");
Assert.AreNotEqual(lhs, rhs);
}
[Test]
public void ComparisonResultToString()
{
XPathNodeMatchComparisonResult lhs = new XPathNodeMatchComparisonResult(true, "message");
Assert.AreEqual("Result: True, Message: 'message'", lhs.ToString());
}
[Test]
public void ComparisonResultEqualsReturnsFalseForNull()
{
XPathNodeMatchComparisonResult result = new XPathNodeMatchComparisonResult();
Assert.IsFalse(result.Equals(null));
}
}
}

131
src/AddIns/DisplayBindings/XmlEditor/Test/Utils/Tests/XPathNodeMatchComparisonTests.cs

@ -0,0 +1,131 @@ @@ -0,0 +1,131 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
// <version>$Revision$</version>
// </file>
using System;
using System.Xml.XPath;
using ICSharpCode.XmlEditor;
using NUnit.Framework;
using XmlEditor.Tests.Utils;
namespace XmlEditor.Tests.Utils.Tests
{
[TestFixture]
public class XPathNodeMatchComparisonTests
{
[Test]
public void ResultEqualsReturnsTrueWhenXPathNodesAreSame()
{
XPathNodeMatch lhs = new XPathNodeMatch("nodeValue", "DisplayValue", 1, 2, XPathNodeType.Text);
XPathNodeMatch rhs = new XPathNodeMatch("nodeValue", "DisplayValue", 1, 2, XPathNodeType.Text);
XPathNodeMatchComparison comparison = new XPathNodeMatchComparison();
XPathNodeMatchComparisonResult result = new XPathNodeMatchComparisonResult();
result.Result = comparison.AreEqual(lhs, rhs);
result.Message = comparison.GetReasonForNotMatching();
XPathNodeMatchComparisonResult expectedResult = new XPathNodeMatchComparisonResult(true, String.Empty);
Assert.AreEqual(expectedResult, result);
}
[Test]
public void ResultEqualsReturnsFalseWhenXPathNodeDisplayValueAreDifferent()
{
XPathNodeMatch lhs = new XPathNodeMatch("nodeValue", "DisplayValue1", 1, 2, XPathNodeType.Text);
XPathNodeMatch rhs = new XPathNodeMatch("nodeValue", "DisplayValue2", 1, 2, XPathNodeType.Text);
XPathNodeMatchComparison comparison = new XPathNodeMatchComparison();
XPathNodeMatchComparisonResult result = new XPathNodeMatchComparisonResult();
result.Result = comparison.AreEqual(lhs, rhs);
result.Message = comparison.GetReasonForNotMatching();
string expectedReason = "DisplayValues do not match. Expected 'DisplayValue1' but was 'DisplayValue2'.";
XPathNodeMatchComparisonResult expectedResult = new XPathNodeMatchComparisonResult(false, expectedReason);
Assert.AreEqual(expectedResult, result);
}
[Test]
public void ResultEqualsReturnsFalseWhenXPathNodeLineNumbersAreDifferent()
{
XPathNodeMatch lhs = new XPathNodeMatch("nodeValue", "DisplayValue", 1, 2, XPathNodeType.Text);
XPathNodeMatch rhs = new XPathNodeMatch("nodeValue", "DisplayValue", 3, 2, XPathNodeType.Text);
XPathNodeMatchComparison comparison = new XPathNodeMatchComparison();
XPathNodeMatchComparisonResult result = new XPathNodeMatchComparisonResult();
result.Result = comparison.AreEqual(lhs, rhs);
result.Message = comparison.GetReasonForNotMatching();
string expectedReason = "LineNumbers do not match. Expected '1' but was '3'.";
XPathNodeMatchComparisonResult expectedResult = new XPathNodeMatchComparisonResult(false, expectedReason);
Assert.AreEqual(expectedResult, result);
}
[Test]
public void ResultEqualsReturnsFalseWhenXPathNodeValuesAreDifferent()
{
XPathNodeMatch lhs = new XPathNodeMatch("nodeValue1", "DisplayValue", 1, 2, XPathNodeType.Text);
XPathNodeMatch rhs = new XPathNodeMatch("nodeValue2", "DisplayValue", 1, 2, XPathNodeType.Text);
XPathNodeMatchComparison comparison = new XPathNodeMatchComparison();
XPathNodeMatchComparisonResult result = new XPathNodeMatchComparisonResult();
result.Result = comparison.AreEqual(lhs, rhs);
result.Message = comparison.GetReasonForNotMatching();
string expectedReason = "Values do not match. Expected 'nodeValue1' but was 'nodeValue2'.";
XPathNodeMatchComparisonResult expectedResult = new XPathNodeMatchComparisonResult(false, expectedReason);
Assert.AreEqual(expectedResult, result);
}
[Test]
public void ResultEqualsReturnsFalseWhenXPathNodeLinePositionsAreDifferent()
{
XPathNodeMatch lhs = new XPathNodeMatch("nodeValue", "DisplayValue", 1, 2, XPathNodeType.Text);
XPathNodeMatch rhs = new XPathNodeMatch("nodeValue", "DisplayValue", 1, 3, XPathNodeType.Text);
XPathNodeMatchComparison comparison = new XPathNodeMatchComparison();
XPathNodeMatchComparisonResult result = new XPathNodeMatchComparisonResult();
result.Result = comparison.AreEqual(lhs, rhs);
result.Message = comparison.GetReasonForNotMatching();
string expectedReason = "LinePositions do not match. Expected '2' but was '3'.";
XPathNodeMatchComparisonResult expectedResult = new XPathNodeMatchComparisonResult(false, expectedReason);
Assert.AreEqual(expectedResult, result);
}
[Test]
public void ResultEqualsReturnsFalseWhenXPathNodeNodeTypesAreDifferent()
{
XPathNodeMatch lhs = new XPathNodeMatch("nodeValue", "DisplayValue", 1, 2, XPathNodeType.Text);
XPathNodeMatch rhs = new XPathNodeMatch("nodeValue", "DisplayValue", 1, 2, XPathNodeType.Element);
XPathNodeMatchComparison comparison = new XPathNodeMatchComparison();
XPathNodeMatchComparisonResult result = new XPathNodeMatchComparisonResult();
result.Result = comparison.AreEqual(lhs, rhs);
result.Message = comparison.GetReasonForNotMatching();
string expectedReason = "NodeTypes do not match. Expected 'Text' but was 'Element'.";
XPathNodeMatchComparisonResult expectedResult = new XPathNodeMatchComparisonResult(false, expectedReason);
Assert.AreEqual(expectedResult, result);
}
[Test]
public void ResultEqualsReturnsFalseWhenOneXPathNodeLineNumberIsNull()
{
int? lineNumber = null;
XPathNodeMatch lhs = new XPathNodeMatch("nodeValue", "DisplayValue", lineNumber, 2, XPathNodeType.Text);
XPathNodeMatch rhs = new XPathNodeMatch("nodeValue", "DisplayValue", 0, 2, XPathNodeType.Text);
XPathNodeMatchComparison comparison = new XPathNodeMatchComparison();
XPathNodeMatchComparisonResult result = new XPathNodeMatchComparisonResult();
result.Result = comparison.AreEqual(lhs, rhs);
result.Message = comparison.GetReasonForNotMatching();
string expectedReason = "LineNumbers do not match. Expected 'null' but was '0'.";
XPathNodeMatchComparisonResult expectedResult = new XPathNodeMatchComparisonResult(false, expectedReason);
Assert.AreEqual(expectedResult, result);
}
}
}

72
src/AddIns/DisplayBindings/XmlEditor/Test/Utils/XPathNodeMatchComparison.cs

@ -0,0 +1,72 @@ @@ -0,0 +1,72 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
// <version>$Revision$</version>
// </file>
using System;
using System.Reflection;
using System.Text;
using ICSharpCode.XmlEditor;
namespace XmlEditor.Tests.Utils
{
public class XPathNodeMatchComparison
{
StringBuilder reason = new StringBuilder();
public XPathNodeMatchComparison()
{
}
public bool AreEqual(XPathNodeMatch lhs, XPathNodeMatch rhs)
{
reason.Clear();
foreach (PropertyInfo property in typeof(XPathNodeMatch).GetProperties()) {
ComparePropertyValues(property, lhs, rhs);
}
if (lhs.HasLineInfo() != rhs.HasLineInfo()) {
AppendPropertyDoesNotMatchMessage("LineNumber", GetLineNumberIfHasLineInfo(lhs), GetLineNumberIfHasLineInfo(rhs));
}
return !HasReasonForNotMatching;
}
void ComparePropertyValues(PropertyInfo property, XPathNodeMatch lhs, XPathNodeMatch rhs)
{
string lhsPropertyValue = GetPropertyValue(property, lhs);
string rhsPropertyValue = GetPropertyValue(property, rhs);
if (lhsPropertyValue != rhsPropertyValue) {
AppendPropertyDoesNotMatchMessage(property.Name, lhsPropertyValue, rhsPropertyValue);
}
}
bool HasReasonForNotMatching {
get { return reason.Length > 0; }
}
string GetPropertyValue(PropertyInfo property, XPathNodeMatch nodeMatch)
{
return property.GetValue(nodeMatch, new object[0]).ToString();
}
void AppendPropertyDoesNotMatchMessage(string name, string lhs, string rhs)
{
reason.AppendFormat("{0}s do not match. Expected '{1}' but was '{2}'.\r\n", name, lhs, rhs);
}
string GetLineNumberIfHasLineInfo(XPathNodeMatch nodeMatch)
{
if (nodeMatch.HasLineInfo()) {
return nodeMatch.LineNumber.ToString();
}
return "null";
}
public string GetReasonForNotMatching()
{
return reason.ToString().Trim();
}
}
}

46
src/AddIns/DisplayBindings/XmlEditor/Test/Utils/XPathNodeMatchComparisonResult.cs

@ -0,0 +1,46 @@ @@ -0,0 +1,46 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
// <version>$Revision$</version>
// </file>
using System;
namespace XmlEditor.Tests.Utils
{
public class XPathNodeMatchComparisonResult
{
public XPathNodeMatchComparisonResult(bool result, string message)
{
this.Result = result;
this.Message = message;
}
public XPathNodeMatchComparisonResult()
{
}
public bool Result { get; set; }
public string Message { get; set; }
public override string ToString()
{
return String.Format("Result: {0}, Message: '{1}'", Result, Message);
}
public override int GetHashCode()
{
return base.GetHashCode();
}
public override bool Equals(object obj)
{
XPathNodeMatchComparisonResult rhs = obj as XPathNodeMatchComparisonResult;
if (rhs != null) {
return (rhs.Result == Result) && (rhs.Message == Message);
}
return false;
}
}
}

2
src/AddIns/DisplayBindings/XmlEditor/Test/XPathQuery/EncodeXPathParameterTests.cs → src/AddIns/DisplayBindings/XmlEditor/Test/XPath/EncodeXPathParameterTests.cs

@ -9,7 +9,7 @@ using ICSharpCode.XmlEditor; @@ -9,7 +9,7 @@ using ICSharpCode.XmlEditor;
using NUnit.Framework;
using System;
namespace XmlEditor.Tests.XPathQuery
namespace XmlEditor.Tests.XPath
{
/// <summary>
/// Tests the XmlEncoder class's Encode method which

4
src/AddIns/DisplayBindings/XmlEditor/Test/XPathQuery/GetNamespacesFromListViewTestFixture.cs → src/AddIns/DisplayBindings/XmlEditor/Test/XPath/GetNamespacesFromListViewTestFixture.cs

@ -12,7 +12,7 @@ using System.Collections.Generic; @@ -12,7 +12,7 @@ using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Windows.Forms;
namespace XmlEditor.Tests.XPathQuery
namespace XmlEditor.Tests.XPath
{
/// <summary>
/// Adds a set of namespaces to the XPathQueryControl and gets them back.
@ -21,7 +21,7 @@ namespace XmlEditor.Tests.XPathQuery @@ -21,7 +21,7 @@ namespace XmlEditor.Tests.XPathQuery
public class GetNamespacesFromListViewTestFixture
{
List<XmlNamespace> expectedNamespaces;
ReadOnlyCollection<XmlNamespace> namespaces;
XmlNamespaceCollection namespaces;
List<XmlNamespace> namespacesAddedToGrid;
[SetUp]

2
src/AddIns/DisplayBindings/XmlEditor/Test/XPathQuery/NamespaceGridColumnWidthsLoadedTestFixture.cs → src/AddIns/DisplayBindings/XmlEditor/Test/XPath/NamespaceGridColumnWidthsLoadedTestFixture.cs

@ -13,7 +13,7 @@ using System.Collections.Generic; @@ -13,7 +13,7 @@ using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Windows.Forms;
namespace XmlEditor.Tests.XPathQuery
namespace XmlEditor.Tests.XPath
{
/// <summary>
/// Tests that the grid column widths are remembered by the query control.

4
src/AddIns/DisplayBindings/XmlEditor/Test/XPathQuery/NamespacePropertiesLoaded.cs → src/AddIns/DisplayBindings/XmlEditor/Test/XPath/NamespacePropertiesLoaded.cs

@ -13,13 +13,13 @@ using System.Collections.Generic; @@ -13,13 +13,13 @@ using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Windows.Forms;
namespace XmlEditor.Tests.XPathQuery
namespace XmlEditor.Tests.XPath
{
[TestFixture]
public class NamespacePropertiesLoaded
{
List<XmlNamespace> expectedNamespaces;
ReadOnlyCollection<XmlNamespace> actualNamespaces;
XmlNamespaceCollection actualNamespaces;
[TestFixtureSetUp]
public void SetUpFixture()

2
src/AddIns/DisplayBindings/XmlEditor/Test/XPathQuery/NamespacePropertiesSaved.cs → src/AddIns/DisplayBindings/XmlEditor/Test/XPath/NamespacePropertiesSaved.cs

@ -13,7 +13,7 @@ using System.Collections.Generic; @@ -13,7 +13,7 @@ using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Windows.Forms;
namespace XmlEditor.Tests.XPathQuery
namespace XmlEditor.Tests.XPath
{
[TestFixture]
public class NamespacePropertiesSaved

68
src/AddIns/DisplayBindings/XmlEditor/Test/XPath/NamespaceXPathQueryTestFixture.cs

@ -0,0 +1,68 @@ @@ -0,0 +1,68 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
// <version>$Revision$</version>
// </file>
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Xml;
using System.Xml.XPath;
using ICSharpCode.XmlEditor;
using NUnit.Framework;
using XmlEditor.Tests.Utils;
namespace XmlEditor.Tests.XPath
{
[TestFixture]
public class NamespaceXPathQueryTestFixture
{
XPathNodeMatch node;
XPathNodeMatch xmlNamespaceNode;
XPathNodeMatch[] nodes;
[SetUp]
public void Init()
{
string xml = "<root xmlns='http://foo.com'/>";
XPathQuery query = new XPathQuery(xml);
nodes = query.FindNodes("//namespace::*");
node = nodes[0];
xmlNamespaceNode = nodes[1];
}
[Test]
public void TwoNamespaceNodesFoundByXPath()
{
Assert.AreEqual(2, nodes.Length);
}
[Test]
public void FooNamespaceNodeFoundByXPath()
{
string nodeValue = "xmlns=\"http://foo.com\"";
string displayValue = "xmlns=\"http://foo.com\"";
int lineNumber = 0;
int linePosition = 6;
XPathNodeType nodeType = XPathNodeType.Namespace;
XPathNodeMatch expectedMatch = new XPathNodeMatch(nodeValue, displayValue, lineNumber, linePosition, nodeType);
XPathNodeMatchComparison comparison = new XPathNodeMatchComparison();
Assert.IsTrue(comparison.AreEqual(expectedMatch, node), comparison.GetReasonForNotMatching());
}
[Test]
public void XmlNamespaceNodeFoundByXPathHasNoLineInfo()
{
Assert.IsFalse(xmlNamespaceNode.HasLineInfo());
}
[Test]
public void XmlNamespaceNodeFoundByXPathHasW3OrgSchemaNamespace()
{
Assert.AreEqual("xmlns:xml=\"http://www.w3.org/XML/1998/namespace\"", xmlNamespaceNode.Value);
}
}
}

84
src/AddIns/DisplayBindings/XmlEditor/Test/XPath/RemoveXPathHighlightingCommandTestFixture.cs

@ -0,0 +1,84 @@ @@ -0,0 +1,84 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
// <version>$Revision$</version>
// </file>
using System;
using System.Collections.Generic;
using System.ComponentModel.Design;
using System.Xml.XPath;
using ICSharpCode.SharpDevelop.Editor;
using ICSharpCode.SharpDevelop.Editor.AvalonEdit;
using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.SharpDevelop.Tests.Utils;
using ICSharpCode.XmlEditor;
using NUnit.Framework;
using XmlEditor.Tests.Utils;
namespace XmlEditor.Tests.XPath
{
[TestFixture]
public class RemoveXPathHighlightingCommandTestFixture
{
MockWorkbench workbench;
ITextMarkerService markerService;
RemoveXPathHighlightingCommand command;
MockViewContent nonTextEditorProviderView;
MockTextEditorProviderViewContent textEditorView;
[SetUp]
public void Init()
{
ServiceContainer container = new ServiceContainer();
markerService = new MockTextMarkerService();
container.AddService(typeof(ITextMarkerService), markerService);
// Add xpath marker to document.
AvalonEditDocumentAdapter doc = new AvalonEditDocumentAdapter(container);
doc.Text = "<Test/>";
XPathNodeTextMarker xpathNodeMarker = new XPathNodeTextMarker(doc);
XPathNodeMatch nodeMatch = new XPathNodeMatch("Test", "<Test/>", 0, 1, XPathNodeType.Element);
xpathNodeMarker.AddMarker(nodeMatch);
// Add non text editor provider view to workbench.
workbench = new MockWorkbench();
nonTextEditorProviderView = new MockViewContent();
workbench.ViewContentCollection.Add(nonTextEditorProviderView);
// Add document to view content.
textEditorView = new MockTextEditorProviderViewContent();
textEditorView.MockTextEditor.SetDocument(doc);
workbench.ViewContentCollection.Add(textEditorView);
command = new RemoveXPathHighlightingCommand(workbench);
}
[Test]
public void CommandRunRemovesAllXPathNodeTextMarkersRemovedFromAllTextEditorWindows()
{
command.Run();
Assert.AreEqual(0, GetAllXPathTextMarkers().Count);
}
List<ITextMarker> GetAllXPathTextMarkers()
{
return new List<ITextMarker>(markerService.TextMarkers);
}
[Test]
public void WorkbenchTextEditorsHaveAtLeastOneTextMarker()
{
Assert.IsTrue(GetAllXPathTextMarkers().Count > 0);
}
[Test]
public void MockViewContentDoesNotImplementITextEditorProviderInterface()
{
Assert.IsNull(nonTextEditorProviderView as ITextEditorProvider);
}
}
}

209
src/AddIns/DisplayBindings/XmlEditor/Test/XPath/RunXPathQueryTests.cs

@ -0,0 +1,209 @@ @@ -0,0 +1,209 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
// <version>$Revision$</version>
// </file>
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Xml;
using System.Xml.XPath;
using ICSharpCode.XmlEditor;
using NUnit.Framework;
using XmlEditor.Tests.Utils;
namespace XmlEditor.Tests.XPath
{
[TestFixture]
public class RunXPathQueryTests
{
[Test]
public void SingleEmptyElementNodeFoundByXPath()
{
string xml =
"<root>\r\n" +
"\t<foo/>\r\n" +
"</root>";
XPathQuery query = new XPathQuery(xml);
XPathNodeMatch[] nodes = query.FindNodes("//foo");
XPathNodeMatch node = nodes[0];
string nodeValue = "foo";
string displayValue = "<foo/>";
int lineNumber = 1;
int linePosition = 2;
XPathNodeType nodeType = XPathNodeType.Element;
XPathNodeMatch expectedNode = new XPathNodeMatch(nodeValue, displayValue, lineNumber, linePosition, nodeType);
XPathNodeMatchComparison comparison = new XPathNodeMatchComparison();
Assert.IsTrue(comparison.AreEqual(expectedNode, node), comparison.GetReasonForNotMatching());
Assert.AreEqual(1, nodes.Length);
}
[Test]
public void XPathNodeMatchImplementsIXmlLineInfoInterface()
{
XPathNodeMatch node = new XPathNodeMatch(String.Empty, String.Empty, 1, 1, XPathNodeType.Text);
Assert.IsNotNull(node as IXmlLineInfo);
}
[Test]
public void OneElementNodeWithNamespaceFoundByXPath()
{
string xml =
"<root xmlns='http://foo.com'>\r\n" +
"\t<foo></foo>\r\n" +
"</root>";
XmlNamespaceCollection namespaces = new XmlNamespaceCollection();
namespaces.Add(new XmlNamespace("f", "http://foo.com"));
XPathQuery query = new XPathQuery(xml, namespaces);
XPathNodeMatch[] nodes = query.FindNodes("//f:foo");
XPathNodeMatch node = nodes[0];
string nodeValue = "foo";
string displayValue = "<foo>";
int lineNumber = 1;
int linePosition = 2;
XPathNodeType nodeType = XPathNodeType.Element;
XPathNodeMatch expectedNode = new XPathNodeMatch(nodeValue, displayValue, lineNumber, linePosition, nodeType);
XPathNodeMatchComparison comparison = new XPathNodeMatchComparison();
Assert.IsTrue(comparison.AreEqual(expectedNode, node), comparison.GetReasonForNotMatching());
Assert.AreEqual(1, nodes.Length);
}
[Test]
public void SingleElementWithNamespacePrefixFoundByXPath()
{
string xml =
"<f:root xmlns:f='http://foo.com'>\r\n" +
"\t<f:foo></f:foo>\r\n" +
"</f:root>";
XmlNamespaceCollection namespaces = new XmlNamespaceCollection();
namespaces.Add(new XmlNamespace("fo", "http://foo.com"));
XPathQuery query = new XPathQuery(xml, namespaces);
XPathNodeMatch[] nodes = query.FindNodes("//fo:foo");
XPathNodeMatch node = nodes[0];
string nodeValue = "f:foo";
string displayValue = "<f:foo>";
int lineNumber = 1;
int linePosition = 2;
XPathNodeType nodeType = XPathNodeType.Element;
XPathNodeMatch expectedNode = new XPathNodeMatch(nodeValue, displayValue, lineNumber, linePosition, nodeType);
XPathNodeMatchComparison comparison = new XPathNodeMatchComparison();
Assert.IsTrue(comparison.AreEqual(expectedNode, node), comparison.GetReasonForNotMatching());
Assert.AreEqual(1, nodes.Length);
}
[Test]
public void NoXPathNodeFoundForUnknownElementInXPathQuery()
{
string xml =
"<root>\r\n" +
"\t<foo/>\r\n" +
"</root>";
XPathQuery query = new XPathQuery(xml);
XPathNodeMatch[] nodes = query.FindNodes("//bar");
Assert.AreEqual(0, nodes.Length);
}
[Test]
public void TextNodeMatchedWithXPath()
{
string xml =
"<root>\r\n" +
"\t<foo>test</foo>\r\n" +
"</root>";
XPathQuery query = new XPathQuery(xml);
XPathNodeMatch[] nodes = query.FindNodes("//foo/text()");
XPathNodeMatch node = nodes[0];
string nodeValue = "test";
string displayValue = "test";
int lineNumber = 1;
int linePosition = 6;
XPathNodeType nodeType = XPathNodeType.Text;
XPathNodeMatch expectedNode = new XPathNodeMatch(nodeValue, displayValue, lineNumber, linePosition, nodeType);
XPathNodeMatchComparison comparison = new XPathNodeMatchComparison();
Assert.IsTrue(comparison.AreEqual(expectedNode, node), comparison.GetReasonForNotMatching());
Assert.AreEqual(1, nodes.Length);
}
[Test]
public void CommentNodeFoundByXPath()
{
string xml = "<!-- Test --><root/>";
XPathQuery query = new XPathQuery(xml);
XPathNodeMatch[] nodes = query.FindNodes("//comment()");
XPathNodeMatch node = nodes[0];
string nodeValue = " Test ";
string displayValue = "<!-- Test -->";
int lineNumber = 0;
int linePosition = 4;
XPathNodeType nodeType = XPathNodeType.Comment;
XPathNodeMatch expectedNode = new XPathNodeMatch(nodeValue, displayValue, lineNumber, linePosition, nodeType);
XPathNodeMatchComparison comparison = new XPathNodeMatchComparison();
Assert.IsTrue(comparison.AreEqual(expectedNode, node), comparison.GetReasonForNotMatching());
}
[Test]
public void EmptyCommentNodeFoundByXPath()
{
string xml = "<!----><root/>";
XPathQuery query = new XPathQuery(xml);
XPathNodeMatch[] nodes = query.FindNodes("//comment()");
XPathNodeMatch node = nodes[0];
string nodeValue = String.Empty;
string displayValue = "<!---->";
int lineNumber = 0;
int linePosition = 4;
XPathNodeType nodeType = XPathNodeType.Comment;
XPathNodeMatch expectedNode = new XPathNodeMatch(nodeValue, displayValue, lineNumber, linePosition, nodeType);
XPathNodeMatchComparison comparison = new XPathNodeMatchComparison();
Assert.IsTrue(comparison.AreEqual(expectedNode, node), comparison.GetReasonForNotMatching());
Assert.AreEqual(1, nodes.Length);
}
[Test]
public void ProcessingInstructionNodeFoundByXPath()
{
string xml = "<root><?test processinstruction='1.0'?></root>";
XPathQuery query = new XPathQuery(xml);
XPathNodeMatch[] nodes = query.FindNodes("//processing-instruction()");
XPathNodeMatch node = nodes[0];
string nodeValue = "test";
string displayValue = "<?test processinstruction='1.0'?>";
int lineNumber = 0;
int linePosition = 8;
XPathNodeType nodeType = XPathNodeType.ProcessingInstruction;
XPathNodeMatch expectedNode = new XPathNodeMatch(nodeValue, displayValue, lineNumber, linePosition, nodeType);
XPathNodeMatchComparison comparison = new XPathNodeMatchComparison();
Assert.IsTrue(comparison.AreEqual(expectedNode, node), comparison.GetReasonForNotMatching());
}
[Test]
public void AttributeNodeFoundByXPath()
{
string xml = "<root>\r\n" +
"\t<foo Id='ab'></foo>\r\n" +
"</root>";
XPathQuery query = new XPathQuery(xml);
XPathNodeMatch[] nodes = query.FindNodes("//foo/@Id");
XPathNodeMatch node = nodes[0];
string nodeValue = "Id";
string displayValue = "@Id";
int lineNumber = 1;
int linePosition = 6;
XPathNodeType nodeType = XPathNodeType.Attribute;
XPathNodeMatch expectedNode = new XPathNodeMatch(nodeValue, displayValue, lineNumber, linePosition, nodeType);
XPathNodeMatchComparison comparison = new XPathNodeMatchComparison();
Assert.IsTrue(comparison.AreEqual(expectedNode, node), comparison.GetReasonForNotMatching());
}
}
}

73
src/AddIns/DisplayBindings/XmlEditor/Test/XPath/SingleXPathQueryElementMarkedTestFixture.cs

@ -0,0 +1,73 @@ @@ -0,0 +1,73 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
// <version>$Revision$</version>
// </file>
using System;
using System.Collections.Generic;
using System.ComponentModel.Design;
using ICSharpCode.SharpDevelop.Editor;
using ICSharpCode.SharpDevelop.Editor.AvalonEdit;
using ICSharpCode.SharpDevelop.Tests.Utils;
using ICSharpCode.XmlEditor;
using NUnit.Framework;
namespace XmlEditor.Tests.XPath
{
[TestFixture]
public class SingleXPathQueryElementMarkedTestFixture
{
ITextMarker xpathNodeTextMarker;
List<ITextMarker> markers;
List<ITextMarker> markersAfterRemove;
[SetUp]
public void Init()
{
string xml = "<root><foo/></root>";
XPathQuery query = new XPathQuery(xml);
XPathNodeMatch[] nodes = query.FindNodes("//root");
IDocument doc = MockTextMarkerService.CreateDocumentWithMockService();
doc.Text = xml;
XPathNodeTextMarker xpathNodeMarker = new XPathNodeTextMarker(doc);
xpathNodeMarker.AddMarkers(nodes);
ITextMarkerService service = doc.GetService(typeof(ITextMarkerService)) as ITextMarkerService;
markers = new List<ITextMarker>(service.TextMarkers);
// Remove markers.
xpathNodeMarker.RemoveMarkers();
markersAfterRemove = new List<ITextMarker>(service.TextMarkers);
xpathNodeTextMarker = markers[0];
}
[Test]
public void OneTextMarkerAddedForXPathMatch()
{
Assert.AreEqual(1, markers.Count);
}
[Test]
public void StartOffsetForXPathNodeMarkerIsOne()
{
Assert.AreEqual(1, xpathNodeTextMarker.StartOffset);
}
[Test]
public void LengthForXpathNodeMarkerIsFour()
{
Assert.AreEqual(4, xpathNodeTextMarker.Length);
}
[Test]
public void NoTextMarkersAfterXPathNodeMarkerRemoveMarkersCalled()
{
Assert.AreEqual(0, markersAfterRemove.Count);
}
}
}

61
src/AddIns/DisplayBindings/XmlEditor/Test/XPathQuery/XPathNodeTextMarkerTests.cs → src/AddIns/DisplayBindings/XmlEditor/Test/XPath/XPathNodeTextMarkerTests.cs

@ -15,65 +15,32 @@ using ICSharpCode.SharpDevelop.Tests.Utils; @@ -15,65 +15,32 @@ using ICSharpCode.SharpDevelop.Tests.Utils;
using ICSharpCode.XmlEditor;
using NUnit.Framework;
namespace XmlEditor.Tests.XPathQuery
namespace XmlEditor.Tests.XPath
{
[TestFixture]
public class XPathNodeTextMarkerTests
{
[Test]
public void OneNodeMarked()
{
string xml = "<root><foo/></root>";
XPathNodeMatch[] nodes = XmlView.SelectNodes(xml, "//root");
IDocument doc = MockTextMarkerService.CreateDocumentWithMockService();
doc.Text = xml;
XPathNodeTextMarker.AddMarkers(doc, nodes);
ITextMarkerService service = doc.GetService(typeof(ITextMarkerService)) as ITextMarkerService;
List<ITextMarker> markers = new List<ITextMarker>();
foreach (ITextMarker marker in service.TextMarkers) {
markers.Add(marker);
}
// Remove markers.
XPathNodeTextMarker.RemoveMarkers(doc);
List<ITextMarker> markersAfterRemove = new List<ITextMarker>();
foreach (ITextMarker markerAfterRemove in service.TextMarkers) {
markersAfterRemove.Add(markerAfterRemove);
}
ITextMarker xpathNodeTextMarker = markers[0];
Assert.AreEqual(1, markers.Count, "markers.Count");
Assert.AreEqual(1, xpathNodeTextMarker.StartOffset, "startoffset");
Assert.AreEqual(4, xpathNodeTextMarker.Length, "length");
Assert.AreEqual(0, markersAfterRemove.Count, "afterremove.count");
}
/// <summary>
/// Tests that XPathNodeMatch with an empty string value are not marked since
/// Tests that XPathNodeMatch with an empty string value is not marked since
/// the MarkerStrategy cannot use a TextMarker with a length of 0.
/// </summary>
[Test]
public void EmptyCommentNode()
{
string xml = "<!----><root/>";
XPathNodeMatch[] nodes = XmlView.SelectNodes(xml, "//comment()");
XPathQuery query = new XPathQuery(xml);
XPathNodeMatch[] nodes = query.FindNodes("//comment()");
ServiceContainer container = new ServiceContainer();
container.AddService(typeof(MockTextMarkerService), new MockTextMarkerService());
AvalonEditDocumentAdapter doc = new AvalonEditDocumentAdapter(container);
doc.Text = xml;
XPathNodeTextMarker.AddMarkers(doc, nodes);
XPathNodeTextMarker xpathNodeMarker = new XPathNodeTextMarker(doc);
xpathNodeMarker.AddMarkers(nodes);
ITextMarkerService service = doc.GetService(typeof(MockTextMarkerService)) as ITextMarkerService;
List<ITextMarker> markers = new List<ITextMarker>();
foreach (ITextMarker marker in service.TextMarkers) {
markers.Add(marker);
}
List<ITextMarker> markers = new List<ITextMarker>(service.TextMarkers);
Assert.AreEqual(0, markers.Count);
Assert.AreEqual(1, nodes.Length);
@ -88,23 +55,23 @@ namespace XmlEditor.Tests.XPathQuery @@ -88,23 +55,23 @@ namespace XmlEditor.Tests.XPathQuery
[Test]
public void NamespaceQuery()
{
string xml = "<?xml version='1.0'?>\r\n" +
string xml =
"<?xml version='1.0'?>\r\n" +
"<Xml1></Xml1>";
XPathNodeMatch[] nodes = XmlView.SelectNodes(xml, "//namespace::*");
XPathQuery query = new XPathQuery(xml);
XPathNodeMatch[] nodes = query.FindNodes("//namespace::*");
ServiceContainer container = new ServiceContainer();
container.AddService(typeof(MockTextMarkerService), new MockTextMarkerService());
AvalonEditDocumentAdapter doc = new AvalonEditDocumentAdapter(container);
doc.Text = xml;
XPathNodeTextMarker.AddMarkers(doc, nodes);
XPathNodeTextMarker xpathNodeMarker = new XPathNodeTextMarker(doc);
xpathNodeMarker.AddMarkers(nodes);
ITextMarkerService service = doc.GetService(typeof(MockTextMarkerService)) as ITextMarkerService;
List<ITextMarker> markers = new List<ITextMarker>(service.TextMarkers);
List<ITextMarker> markers = new List<ITextMarker>();
foreach (ITextMarker marker in service.TextMarkers) {
markers.Add(marker);
}
Assert.AreEqual(0, markers.Count);
Assert.AreEqual(1, nodes.Length);
}

2
src/AddIns/DisplayBindings/XmlEditor/Test/XPathQuery/XPathQueryHistoryTestFixture.cs → src/AddIns/DisplayBindings/XmlEditor/Test/XPath/XPathQueryHistoryTestFixture.cs

@ -13,7 +13,7 @@ using System.Collections.Generic; @@ -13,7 +13,7 @@ using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Windows.Forms;
namespace XmlEditor.Tests.XPathQuery
namespace XmlEditor.Tests.XPath
{
/// <summary>
/// Tests that the XPath queries are remembered.

2
src/AddIns/DisplayBindings/XmlEditor/Test/XPathQuery/XPathResultsListViewColumnWidthsTestFixture.cs → src/AddIns/DisplayBindings/XmlEditor/Test/XPath/XPathResultsListViewColumnWidthsTestFixture.cs

@ -13,7 +13,7 @@ using System.Collections.Generic; @@ -13,7 +13,7 @@ using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Windows.Forms;
namespace XmlEditor.Tests.XPathQuery
namespace XmlEditor.Tests.XPath
{
/// <summary>
/// Tests that the XPath results list view column widths are remembered.

2
src/AddIns/DisplayBindings/XmlEditor/Test/XPathQuery/XmlNamespaceTests.cs → src/AddIns/DisplayBindings/XmlEditor/Test/XPath/XmlNamespaceTests.cs

@ -9,7 +9,7 @@ using ICSharpCode.XmlEditor; @@ -9,7 +9,7 @@ using ICSharpCode.XmlEditor;
using NUnit.Framework;
using System;
namespace XmlEditor.Tests.XPathQuery
namespace XmlEditor.Tests.XPath
{
[TestFixture]
public class XmlNamespaceTests

2
src/AddIns/DisplayBindings/XmlEditor/Test/XPathQuery/XmlNamespaceToStringTests.cs → src/AddIns/DisplayBindings/XmlEditor/Test/XPath/XmlNamespaceToStringTests.cs

@ -9,7 +9,7 @@ using ICSharpCode.XmlEditor; @@ -9,7 +9,7 @@ using ICSharpCode.XmlEditor;
using NUnit.Framework;
using System;
namespace XmlEditor.Tests.XPathQuery
namespace XmlEditor.Tests.XPath
{
[TestFixture]
public class XmlNamespaceToStringTests

175
src/AddIns/DisplayBindings/XmlEditor/Test/XPathQuery/RunXPathQueryTests.cs

@ -1,175 +0,0 @@ @@ -1,175 +0,0 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
// <version>$Revision$</version>
// </file>
using ICSharpCode.XmlEditor;
using NUnit.Framework;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Xml;
using System.Xml.XPath;
namespace XmlEditor.Tests.XPathQuery
{
[TestFixture]
public class RunXPathQueryTests
{
[Test]
public void OneElementNode()
{
string xml = "<root>\r\n" +
"\t<foo/>\r\n" +
"</root>";
XPathNodeMatch[] nodes = XmlView.SelectNodes(xml, "//foo");
XPathNodeMatch node = nodes[0];
IXmlLineInfo lineInfo = node as IXmlLineInfo;
Assert.AreEqual(1, nodes.Length);
Assert.AreEqual(1, node.LineNumber);
Assert.AreEqual(2, node.LinePosition);
Assert.AreEqual("foo", node.Value);
Assert.AreEqual("<foo/>", node.DisplayValue);
Assert.AreEqual(XPathNodeType.Element, node.NodeType);
Assert.IsNotNull(lineInfo);
}
[Test]
public void OneElementNodeWithNamespace()
{
string xml = "<root xmlns='http://foo.com'>\r\n" +
"\t<foo></foo>\r\n" +
"</root>";
List<XmlNamespace> namespaces = new List<XmlNamespace>();
namespaces.Add(new XmlNamespace("f", "http://foo.com"));
ReadOnlyCollection<XmlNamespace> readOnlyNamespaces = new ReadOnlyCollection<XmlNamespace>(namespaces);
XPathNodeMatch[] nodes = XmlView.SelectNodes(xml, "//f:foo", readOnlyNamespaces);
XPathNodeMatch node = nodes[0];
IXmlLineInfo lineInfo = node as IXmlLineInfo;
Assert.AreEqual(1, nodes.Length);
Assert.AreEqual(1, node.LineNumber);
Assert.AreEqual(2, node.LinePosition);
Assert.AreEqual("foo", node.Value);
Assert.AreEqual("<foo>", node.DisplayValue);
Assert.AreEqual(XPathNodeType.Element, node.NodeType);
Assert.IsNotNull(lineInfo);
}
[Test]
public void ElementWithNamespacePrefix()
{
string xml = "<f:root xmlns:f='http://foo.com'>\r\n" +
"\t<f:foo></f:foo>\r\n" +
"</f:root>";
List<XmlNamespace> namespaces = new List<XmlNamespace>();
namespaces.Add(new XmlNamespace("fo", "http://foo.com"));
ReadOnlyCollection<XmlNamespace> readOnlyNamespaces = new ReadOnlyCollection<XmlNamespace>(namespaces);
XPathNodeMatch[] nodes = XmlView.SelectNodes(xml, "//fo:foo", readOnlyNamespaces);
XPathNodeMatch node = nodes[0];
IXmlLineInfo lineInfo = node as IXmlLineInfo;
Assert.AreEqual(1, nodes.Length);
Assert.AreEqual(1, node.LineNumber);
Assert.AreEqual(2, node.LinePosition);
Assert.AreEqual("f:foo", node.Value);
Assert.AreEqual("<f:foo>", node.DisplayValue);
Assert.AreEqual(XPathNodeType.Element, node.NodeType);
Assert.IsNotNull(lineInfo);
}
[Test]
public void NoNodeFound()
{
string xml = "<root>\r\n" +
"\t<foo/>\r\n" +
"</root>";
XPathNodeMatch[] nodes = XmlView.SelectNodes(xml, "//bar");
Assert.AreEqual(0, nodes.Length);
}
[Test]
public void TextNode()
{
string xml = "<root>\r\n" +
"\t<foo>test</foo>\r\n" +
"</root>";
XPathNodeMatch[] nodes = XmlView.SelectNodes(xml, "//foo/text()");
XPathNodeMatch node = nodes[0];
Assert.AreEqual(1, nodes.Length);
Assert.AreEqual(1, node.LineNumber);
Assert.AreEqual(6, node.LinePosition);
Assert.AreEqual("test", node.Value);
Assert.AreEqual("test", node.DisplayValue);
}
[Test]
public void CommentNode()
{
string xml = "<!-- Test --><root/>";
XPathNodeMatch[] nodes = XmlView.SelectNodes(xml, "//comment()");
XPathNodeMatch node = nodes[0];
Assert.AreEqual(1, nodes.Length);
Assert.AreEqual(0, node.LineNumber);
Assert.AreEqual(4, node.LinePosition);
Assert.AreEqual(" Test ", node.Value);
Assert.AreEqual("<!-- Test -->", node.DisplayValue);
}
[Test]
public void EmptyCommentNode()
{
string xml = "<!----><root/>";
XPathNodeMatch[] nodes = XmlView.SelectNodes(xml, "//comment()");
XPathNodeMatch node = nodes[0];
Assert.AreEqual(1, nodes.Length);
Assert.AreEqual(0, node.LineNumber);
Assert.AreEqual(4, node.LinePosition);
Assert.AreEqual(String.Empty, node.Value);
Assert.AreEqual("<!---->", node.DisplayValue);
}
[Test]
public void NamespaceNode()
{
string xml = "<root xmlns='http://foo.com'/>";
XPathNodeMatch[] nodes = XmlView.SelectNodes(xml, "//namespace::*");
XPathNodeMatch node = nodes[0];
XPathNodeMatch xmlNamespaceNode = nodes[1];
Assert.AreEqual(2, nodes.Length);
Assert.AreEqual(0, node.LineNumber);
Assert.AreEqual(6, node.LinePosition);
Assert.AreEqual("xmlns=\"http://foo.com\"", node.Value);
Assert.AreEqual("xmlns=\"http://foo.com\"", node.DisplayValue);
Assert.IsFalse(xmlNamespaceNode.HasLineInfo());
Assert.AreEqual("xmlns:xml=\"http://www.w3.org/XML/1998/namespace\"", xmlNamespaceNode.Value);
}
[Test]
public void ProcessingInstructionNode()
{
string xml = "<root><?test processinstruction='1.0'?></root>";
XPathNodeMatch[] nodes = XmlView.SelectNodes(xml, "//processing-instruction()");
XPathNodeMatch node = nodes[0];
Assert.AreEqual("test", node.Value);
Assert.AreEqual("<?test processinstruction='1.0'?>", node.DisplayValue);
Assert.AreEqual(0, node.LineNumber);
Assert.AreEqual(8, node.LinePosition);
}
[Test]
public void AttributeNode()
{
string xml = "<root>\r\n" +
"\t<foo Id='ab'></foo>\r\n" +
"</root>";
XPathNodeMatch[] nodes = XmlView.SelectNodes(xml, "//foo/@Id");
XPathNodeMatch node = nodes[0];
Assert.AreEqual(1, nodes.Length);
Assert.AreEqual(1, node.LineNumber);
Assert.AreEqual(6, node.LinePosition);
Assert.AreEqual("Id", node.Value);
Assert.AreEqual("@Id", node.DisplayValue);
}
}
}

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

@ -125,6 +125,12 @@ @@ -125,6 +125,12 @@
<Compile Include="Editor\XmlEditorFileExtensionsTestFixture.cs" />
<Compile Include="Editor\XmlSchemaPickerTestFixture.cs" />
<Compile Include="Editor\XmlSchemasPanelTestFixture.cs" />
<Compile Include="FindSchemaObject\FindSelectedAttributeInTextEditorTestFixture.cs" />
<Compile Include="FindSchemaObject\FindSelectedAttributeValueInTextEditorTestFixture.cs" />
<Compile Include="FindSchemaObject\FindSelectedElementInTextEditorTestFixture.cs" />
<Compile Include="FindSchemaObject\NullSchemaObjectPassedToSchemaObjectLocationTestFixture.cs" />
<Compile Include="FindSchemaObject\SchemaObjectLocationFileNameTests.cs" />
<Compile Include="FindSchemaObject\SchemaObjectLocationJumpToTests.cs" />
<Compile Include="Folding\AttributeTextInFoldIsXmlEncodedTestFixture.cs" />
<Compile Include="Folding\EmptyCommentDoesNotCreateFoldTestFixture.cs" />
<Compile Include="Folding\FoldParserParsesInvalidXmlTestFixture.cs" />
@ -226,6 +232,13 @@ @@ -226,6 +232,13 @@
<Compile Include="Schema\MissingSchemaElementTestFixture.cs" />
<Compile Include="Schema\AllElementTestFixture.cs" />
<Compile Include="Parser\InsideAttributeValueTestFixture.cs" />
<Compile Include="Utils\DerivedXmlSchemaObjectLocation.cs" />
<Compile Include="Utils\MockTextEditorProviderViewContent.cs" />
<Compile Include="Utils\MockViewContent.cs" />
<Compile Include="Utils\MockWorkbench.cs" />
<Compile Include="Utils\Tests\DerivedXmlSchemaObjectLocationTests.cs" />
<Compile Include="Utils\Tests\XPathNodeMatchComparisonResultTests.cs" />
<Compile Include="Utils\XPathNodeMatchComparisonResult.cs" />
<Compile Include="Utils\DerivedAddXmlNodeDialog.cs" />
<Compile Include="Utils\DerivedXmlTreeView.cs" />
<Compile Include="Utils\DerivedXmlTreeViewContainerControl.cs" />
@ -262,18 +275,23 @@ @@ -262,18 +275,23 @@
<Compile Include="Utils\Tests\MockXmlSchemaCompletionDataFactoryTests.cs" />
<Compile Include="Utils\Tests\MockXmlSchemasPanelTests.cs" />
<Compile Include="Utils\Tests\XmlSchemaCompletionCollectionFileNamesTests.cs" />
<Compile Include="Utils\Tests\XPathNodeMatchComparisonTests.cs" />
<Compile Include="Utils\TextSection.cs" />
<Compile Include="Utils\XmlSchemaCompletionCollectionFileNames.cs" />
<Compile Include="XPathQuery\XmlNamespaceTests.cs" />
<Compile Include="XPathQuery\GetNamespacesFromListViewTestFixture.cs" />
<Compile Include="XPathQuery\RunXPathQueryTests.cs" />
<Compile Include="XPathQuery\NamespacePropertiesLoaded.cs" />
<Compile Include="XPathQuery\XmlNamespaceToStringTests.cs" />
<Compile Include="XPathQuery\NamespacePropertiesSaved.cs" />
<Compile Include="XPathQuery\NamespaceGridColumnWidthsLoadedTestFixture.cs" />
<Compile Include="XPathQuery\XPathResultsListViewColumnWidthsTestFixture.cs" />
<Compile Include="XPathQuery\XPathQueryHistoryTestFixture.cs" />
<Compile Include="XPathQuery\XPathNodeTextMarkerTests.cs" />
<Compile Include="Utils\XPathNodeMatchComparison.cs" />
<Compile Include="XPath\NamespaceXPathQueryTestFixture.cs" />
<Compile Include="XPath\RemoveXPathHighlightingCommandTestFixture.cs" />
<Compile Include="XPath\SingleXPathQueryElementMarkedTestFixture.cs" />
<Compile Include="XPath\XmlNamespaceTests.cs" />
<Compile Include="XPath\GetNamespacesFromListViewTestFixture.cs" />
<Compile Include="XPath\RunXPathQueryTests.cs" />
<Compile Include="XPath\NamespacePropertiesLoaded.cs" />
<Compile Include="XPath\XmlNamespaceToStringTests.cs" />
<Compile Include="XPath\NamespacePropertiesSaved.cs" />
<Compile Include="XPath\NamespaceGridColumnWidthsLoadedTestFixture.cs" />
<Compile Include="XPath\XPathResultsListViewColumnWidthsTestFixture.cs" />
<Compile Include="XPath\XPathQueryHistoryTestFixture.cs" />
<Compile Include="XPath\XPathNodeTextMarkerTests.cs" />
<Compile Include="Parser\ActiveElementUnderCursorTests.cs" />
<Compile Include="Parser\AttributeNameUnderCursorTests.cs" />
<Compile Include="Schema\FindAttributeFromComplexTypeTestFixture.cs" />
@ -304,7 +322,7 @@ @@ -304,7 +322,7 @@
<Compile Include="Tree\TreeControlViewStateTestFixture.cs" />
<Compile Include="Tree\AttributeChangedTestFixture.cs" />
<Compile Include="Tree\TextNodeTextChangedTestFixture.cs" />
<Compile Include="XPathQuery\EncodeXPathParameterTests.cs" />
<Compile Include="XPath\EncodeXPathParameterTests.cs" />
<Compile Include="Tree\AddAttributeTestFixture.cs" />
<Compile Include="Tree\NoMatchingSchemaTestFixture.cs" />
<Compile Include="Tree\RemoveAttributeTestFixture.cs" />
@ -356,7 +374,7 @@ @@ -356,7 +374,7 @@
</ProjectReference>
<Folder Include="Utils" />
<Folder Include="Utils\Tests" />
<Folder Include="XPathQuery" />
<Folder Include="XPath" />
<ProjectReference Include="..\..\..\..\Main\Base\Project\ICSharpCode.SharpDevelop.csproj">
<Project>{2748AD25-9C63-4E12-877B-4DCE96FBED54}</Project>
<Name>ICSharpCode.SharpDevelop</Name>

10
src/AddIns/DisplayBindings/XmlEditor/XmlEditor.sln

@ -22,6 +22,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.TextEditor", ". @@ -22,6 +22,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.TextEditor", ".
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NRefactory", "..\..\..\Libraries\NRefactory\Project\NRefactory.csproj", "{3A9AE6AA-BC07-4A2F-972C-581E3AE2F195}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.SharpDevelop.Tests", "..\..\..\Main\Base\Test\ICSharpCode.SharpDevelop.Tests.csproj", "{4980B743-B32F-4aba-AABD-45E2CAD3568D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -68,5 +70,13 @@ Global @@ -68,5 +70,13 @@ Global
{3A9AE6AA-BC07-4A2F-972C-581E3AE2F195}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3A9AE6AA-BC07-4A2F-972C-581E3AE2F195}.Release|Any CPU.Build.0 = Release|Any CPU
{3A9AE6AA-BC07-4A2F-972C-581E3AE2F195}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4980B743-B32F-4aba-AABD-45E2CAD3568D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4980B743-B32F-4aba-AABD-45E2CAD3568D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4980B743-B32F-4aba-AABD-45E2CAD3568D}.Release|Any CPU.Build.0 = Release|Any CPU
{4980B743-B32F-4aba-AABD-45E2CAD3568D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4980B743-B32F-4ABA-AABD-45E2CAD3568D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4980B743-B32F-4ABA-AABD-45E2CAD3568D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4980B743-B32F-4ABA-AABD-45E2CAD3568D}.Release|Any CPU.Build.0 = Release|Any CPU
{4980B743-B32F-4ABA-AABD-45E2CAD3568D}.Release|Any CPU.ActiveCfg = Release|Any CPU
EndGlobalSection
EndGlobal

Loading…
Cancel
Save