public void Init()
		{
			ServiceContainer container = new ServiceContainer();
			markerService = new MockTextMarkerService();
			container.AddService(typeof(ITextMarkerService), markerService);
			
			// Add xpath marker to document.
			AvalonEditDocumentAdapter doc = new AvalonEditDocumentAdapter(new ICSharpCode.AvalonEdit.Document.TextDocument(), 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);
		}
        public void Init()
        {
            IDocument doc = MockTextMarkerService.CreateDocumentWithMockService();
            markerService = doc.GetRequiredService<ITextMarkerService>();

            // Add xpath marker to document.
            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 = MockRepository.GenerateStrictMock<IWorkbench>();
            workbench.Stub(w => w.ViewContentCollection).Return(new List<IViewContent>());

            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);
        }
		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();
				}
			}
		}
 public void RemoveXPathNodeTextMarkers()
 {
     foreach (IViewContent view in workbench.ViewContentCollection)
     {
         ITextEditor textEditor = view.GetService <ITextEditor>();
         if (textEditor != null)
         {
             XPathNodeTextMarker.RemoveMarkers(textEditor);
         }
     }
 }
예제 #5
0
 /// <summary>
 /// Removes all the XPath Node markers from all the open documents.
 /// </summary>
 public void RemoveXPathNodeTextMarkers()
 {
     foreach (IViewContent view in WorkbenchSingleton.Workbench.ViewContentCollection)
     {
         ITextEditorControlProvider textEditorProvider = view as ITextEditorControlProvider;
         if (textEditorProvider != null)
         {
             XPathNodeTextMarker.RemoveMarkers(textEditorProvider.TextEditorControl.Document.MarkerStrategy);
             textEditorProvider.TextEditorControl.Refresh();
         }
     }
 }
예제 #6
0
 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();
         }
     }
 }
		public void EmptyCommentNode()
		{
			string xml = "<!----><root/>";
			XPathQuery query = new XPathQuery(xml);
			XPathNodeMatch[] nodes = query.FindNodes("//comment()");
			
			ServiceContainer container = new ServiceContainer();
			container.AddService(typeof(MockTextMarkerService), new MockTextMarkerService());
			
			IDocument doc = new ICSharpCode.AvalonEdit.Document.TextDocument() { ServiceProvider = container };
			doc.Text = xml;
			XPathNodeTextMarker xpathNodeMarker = new XPathNodeTextMarker(doc);
			xpathNodeMarker.AddMarkers(nodes);
			
			ITextMarkerService service = doc.GetService(typeof(MockTextMarkerService)) as ITextMarkerService;
			List<ITextMarker> markers = new List<ITextMarker>(service.TextMarkers);
			
			Assert.AreEqual(0, markers.Count);
			Assert.AreEqual(1, nodes.Length);
		}
		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.
			XPathNodeTextMarker.RemoveMarkers(doc);
			markersAfterRemove = new List<ITextMarker>(service.TextMarkers);
			
			xpathNodeTextMarker = markers[0];
		}
		public void NamespaceQuery()
		{
			string xml = 
				"<?xml version='1.0'?>\r\n" +
				"<Xml1></Xml1>";
			XPathQuery query = new XPathQuery(xml);
			XPathNodeMatch[] nodes = query.FindNodes("//namespace::*");
			
			ServiceContainer container = new ServiceContainer();
			container.AddService(typeof(MockTextMarkerService), new MockTextMarkerService());
			
			IDocument doc = new ICSharpCode.AvalonEdit.Document.TextDocument() { ServiceProvider = container };
			doc.Text = xml;
			XPathNodeTextMarker xpathNodeMarker = new XPathNodeTextMarker(doc);
			xpathNodeMarker.AddMarkers(nodes);
			
			ITextMarkerService service = doc.GetService(typeof(MockTextMarkerService)) as ITextMarkerService;
			List<ITextMarker> markers = new List<ITextMarker>(service.TextMarkers);
			
			Assert.AreEqual(0, markers.Count);
			Assert.AreEqual(1, nodes.Length);
		}
예제 #10
0
        void RunXPathQuery()
        {
            XmlView xmlView = XmlView.ActiveXmlView;

            if (xmlView == null)
            {
                return;
            }

            try {
                fileName = xmlView.File.FileName;

                // Clear previous XPath results.
                ClearResults();
                XPathNodeTextMarker.RemoveMarkers(xmlView.TextEditor.Document);

                // Run XPath query.
                XPathQuery       query = new XPathQuery(xmlView.TextEditor, GetNamespaces());
                XPathNodeMatch[] nodes = query.FindNodes(xpathComboBox.Text);
                if (nodes.Length > 0)
                {
                    AddXPathResults(nodes);
                    XPathNodeTextMarker marker = new XPathNodeTextMarker(xmlView.TextEditor.Document);
                    marker.AddMarkers(nodes);
                }
                else
                {
                    AddNoXPathResult();
                }
                AddXPathToHistory();
            } catch (XPathException xpathEx) {
                AddErrorResult(xpathEx);
            } catch (XmlException xmlEx) {
                AddErrorResult(xmlEx);
            } finally {
                BringResultsTabToFront();
            }
        }
예제 #11
0
        void RunXPathQuery()
        {
            XmlView view = XmlView.ActiveXmlView;

            if (view == null)
            {
                return;
            }

            try {
                MarkerStrategy markerStrategy = view.TextEditorControl.Document.MarkerStrategy;
                fileName = view.PrimaryFileName;

                // Clear previous XPath results.
                ClearResults();
                XPathNodeTextMarker.RemoveMarkers(markerStrategy);

                // Run XPath query.
                XPathNodeMatch[] nodes = view.SelectNodes(xPathComboBox.Text, GetNamespaces());
                if (nodes.Length > 0)
                {
                    AddXPathResults(nodes);
                    XPathNodeTextMarker.AddMarkers(markerStrategy, nodes);
                }
                else
                {
                    AddNoXPathResult();
                }
                AddXPathToHistory();
            } catch (XPathException xpathEx) {
                AddErrorResult(xpathEx);
            } catch (XmlException xmlEx) {
                AddErrorResult(xmlEx);
            } finally {
                BringResultsTabToFront();
                view.TextEditorControl.Refresh();
            }
        }
예제 #12
0
        void RunXPathQuery()
        {
            XmlView xmlView = XmlView.ActiveXmlView;
            if (xmlView == null) {
                return;
            }

            try {
                fileName = xmlView.File.FileName;

                // Clear previous XPath results.
                ClearResults();
                XPathNodeTextMarker.RemoveMarkers(xmlView.TextEditor.Document);

                // Run XPath query.
                XPathQuery query = new XPathQuery(xmlView.TextEditor, GetNamespaces());
                XPathNodeMatch[] nodes = query.FindNodes(xpathComboBox.Text);
                if (nodes.Length > 0) {
                    AddXPathResults(nodes);
                    XPathNodeTextMarker marker = new XPathNodeTextMarker(xmlView.TextEditor.Document);
                    marker.AddMarkers(nodes);
                } else {
                    AddNoXPathResult();
                }
                AddXPathToHistory();
            } catch (XPathException xpathEx) {
                AddErrorResult(xpathEx);
            } catch (XmlException xmlEx) {
                AddErrorResult(xmlEx);
            } finally {
                BringResultsTabToFront();
            }
        }