Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/monodevelop.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'main/src/addins/Xml')
-rw-r--r--main/src/addins/Xml/Completion/XmlCompletionData.cs21
-rw-r--r--main/src/addins/Xml/Completion/XmlTagCompletionData.cs14
-rw-r--r--main/src/addins/Xml/Dom/XAttribute.cs7
-rw-r--r--main/src/addins/Xml/Dom/XCData.cs7
-rw-r--r--main/src/addins/Xml/Dom/XClosingTag.cs6
-rw-r--r--main/src/addins/Xml/Dom/XComment.cs8
-rw-r--r--main/src/addins/Xml/Dom/XContainer.cs6
-rw-r--r--main/src/addins/Xml/Dom/XDocType.cs9
-rw-r--r--main/src/addins/Xml/Dom/XDocument.cs6
-rw-r--r--main/src/addins/Xml/Dom/XElement.cs8
-rw-r--r--main/src/addins/Xml/Dom/XNode.cs7
-rw-r--r--main/src/addins/Xml/Dom/XObject.cs19
-rw-r--r--main/src/addins/Xml/Dom/XProcessingInstruction.cs8
-rw-r--r--main/src/addins/Xml/Editor/BaseXmlEditorExtension.cs264
-rw-r--r--main/src/addins/Xml/Editor/XmlDocumentParser.cs12
-rw-r--r--main/src/addins/Xml/Editor/XmlEditorService.cs670
-rw-r--r--main/src/addins/Xml/Editor/XmlParsedDocument.cs18
-rw-r--r--main/src/addins/Xml/Editor/XmlTextEditorExtension.cs683
-rw-r--r--main/src/addins/Xml/MSBuild/MSBuildResolveContext.cs2
-rw-r--r--main/src/addins/Xml/MonoDevelop.Xml.csproj24
-rw-r--r--main/src/addins/Xml/Parser/XmlDocTypeState.cs7
-rw-r--r--main/src/addins/Xml/Parser/XmlParser.cs54
-rw-r--r--main/src/addins/Xml/Parser/XmlRootState.cs8
-rw-r--r--main/src/addins/Xml/Parser/XmlTagState.cs84
-rw-r--r--main/src/addins/Xml/Tests/MonoDevelop.Xml.Tests.csproj12
-rw-r--r--main/src/addins/Xml/Tests/Parser/ParsingTests.cs6
-rw-r--r--main/src/addins/Xml/Tests/Parser/TestXmlParser.cs6
-rw-r--r--main/src/addins/Xml/Tests/Schema/AttributeAnnotationTestFixture.cs4
-rw-r--r--main/src/addins/Xml/Tests/Schema/ElementAnnotationTestFixture.cs4
-rw-r--r--main/src/addins/Xml/Tests/Schema/SchemaTestFixtureBase.cs11
30 files changed, 1111 insertions, 884 deletions
diff --git a/main/src/addins/Xml/Completion/XmlCompletionData.cs b/main/src/addins/Xml/Completion/XmlCompletionData.cs
index c3c77f6e94..3eb5a504c9 100644
--- a/main/src/addins/Xml/Completion/XmlCompletionData.cs
+++ b/main/src/addins/Xml/Completion/XmlCompletionData.cs
@@ -22,15 +22,19 @@
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-using System;
-using Gdk;
-using Mono.TextEditor;
+using Gdk;
+using Gtk;
+using MonoDevelop.Ide.Gui;
+using MonoDevelop.Ide.CodeCompletion;
+using System;
using MonoDevelop.Core;
+using MonoDevelop.Ide.Gui.Content;
using MonoDevelop.Ide;
using MonoDevelop.Ide.CodeCompletion;
using MonoDevelop.Ide.Commands;
using MonoDevelop.Ide.Gui.Content;
using MonoDevelop.Xml.Editor;
+using MonoDevelop.Ide.Editor.Extension;
namespace MonoDevelop.Xml.Completion
{
@@ -104,18 +108,15 @@ namespace MonoDevelop.Xml.Completion
}
}
- public override void InsertCompletionText (CompletionListWindow window, ref KeyActions ka, Gdk.Key closeChar, char keyChar, ModifierType modifier)
+ public override void InsertCompletionText (CompletionListWindow window, ref KeyActions ka, KeyDescriptor descriptor)
{
if (XmlEditorOptions.AutoInsertFragments && dataType == DataType.XmlAttribute) {
- var textEditorDataProvier = window.CompletionWidget as ITextEditorDataProvider;
- var textBuffer = window.CompletionWidget as ITextBuffer;
- base.InsertCompletionText (window, ref ka, closeChar, keyChar, modifier);
- if (textEditorDataProvier != null && textBuffer != null)
- textEditorDataProvier.GetTextEditorData ().SetSkipChar (textBuffer.CursorPosition, '"');
+ base.InsertCompletionText (window, ref ka, descriptor);
+ window.CompletionWidget.AddSkipChar (window.CompletionWidget.CaretOffset, '"');
IdeApp.CommandService.DispatchCommand (TextEditorCommands.ShowCompletionWindow);
ka &= ~KeyActions.CloseWindow;
} else {
- base.InsertCompletionText (window, ref ka, closeChar, keyChar, modifier);
+ base.InsertCompletionText (window, ref ka, descriptor);
}
}
diff --git a/main/src/addins/Xml/Completion/XmlTagCompletionData.cs b/main/src/addins/Xml/Completion/XmlTagCompletionData.cs
index befc32f068..e0d08b5ef2 100644
--- a/main/src/addins/Xml/Completion/XmlTagCompletionData.cs
+++ b/main/src/addins/Xml/Completion/XmlTagCompletionData.cs
@@ -31,6 +31,7 @@ using System;
using MonoDevelop.Ide.CodeCompletion;
using MonoDevelop.Ide.Gui.Content;
using MonoDevelop.Core;
+using MonoDevelop.Ide.Editor.Extension;
namespace MonoDevelop.Xml.Completion
{
@@ -66,20 +67,17 @@ namespace MonoDevelop.Xml.Completion
get { return element; }
}
- public override void InsertCompletionText (CompletionListWindow window, ref KeyActions ka, Gdk.Key closeChar, char keyChar, Gdk.ModifierType modifier)
+ public override void InsertCompletionText (CompletionListWindow window, ref KeyActions ka, KeyDescriptor descriptor)
{
- IEditableTextBuffer buf = window.CompletionWidget as IEditableTextBuffer;
+ var buf = window.CompletionWidget;
if (buf != null) {
//completion context gets nulled from window as soon as we alter the buffer
var codeCompletionContext = window.CodeCompletionContext;
- using (var undo = buf.OpenUndoGroup ()) {
- buf.InsertText (buf.CursorPosition, element);
+ buf.Replace (buf.CaretOffset, 0, element);
- // Move caret into the middle of the tags
- buf.CursorPosition = codeCompletionContext.TriggerOffset + cursorOffset;
- buf.Select (buf.CursorPosition, buf.CursorPosition);
- }
+ // Move caret into the middle of the tags
+ buf.CaretOffset = codeCompletionContext.TriggerOffset + cursorOffset;
}
}
}
diff --git a/main/src/addins/Xml/Dom/XAttribute.cs b/main/src/addins/Xml/Dom/XAttribute.cs
index f34f456727..c82a8e7a8b 100644
--- a/main/src/addins/Xml/Dom/XAttribute.cs
+++ b/main/src/addins/Xml/Dom/XAttribute.cs
@@ -23,21 +23,20 @@
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
-
-using ICSharpCode.NRefactory;
+using MonoDevelop.Ide.Editor;
namespace MonoDevelop.Xml.Dom
{
public class XAttribute : XObject, INamedXObject
{
- public XAttribute (TextLocation start, XName name, string value) : base (start)
+ public XAttribute (DocumentLocation start, XName name, string value) : base (start)
{
this.Name = name;
this.Value = value;
}
- public XAttribute (TextLocation start) : base (start)
+ public XAttribute (DocumentLocation start) : base (start)
{
}
diff --git a/main/src/addins/Xml/Dom/XCData.cs b/main/src/addins/Xml/Dom/XCData.cs
index 001f80521b..f850d91cec 100644
--- a/main/src/addins/Xml/Dom/XCData.cs
+++ b/main/src/addins/Xml/Dom/XCData.cs
@@ -24,15 +24,14 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
-using ICSharpCode.NRefactory.TypeSystem;
-using ICSharpCode.NRefactory;
+using MonoDevelop.Ide.Editor;
namespace MonoDevelop.Xml.Dom
{
public class XCData : XNode
{
- public XCData (TextLocation start) : base (start) {}
- public XCData (DomRegion region) : base (region) {}
+ public XCData (DocumentLocation start) : base (start) {}
+ public XCData (DocumentRegion region) : base (region) {}
protected XCData () {}
protected override XObject NewInstance () { return new XCData (); }
diff --git a/main/src/addins/Xml/Dom/XClosingTag.cs b/main/src/addins/Xml/Dom/XClosingTag.cs
index c134dea6a4..3973ad2ab8 100644
--- a/main/src/addins/Xml/Dom/XClosingTag.cs
+++ b/main/src/addins/Xml/Dom/XClosingTag.cs
@@ -24,15 +24,15 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
-using ICSharpCode.NRefactory;
+using MonoDevelop.Ide.Editor;
namespace MonoDevelop.Xml.Dom
{
public class XClosingTag : XNode, INamedXObject
{
- public XClosingTag (TextLocation start) : base (start) {}
+ public XClosingTag (DocumentLocation start) : base (start) {}
- public XClosingTag (XName name, TextLocation start) : base (start)
+ public XClosingTag (XName name, DocumentLocation start) : base (start)
{
this.Name = name;
}
diff --git a/main/src/addins/Xml/Dom/XComment.cs b/main/src/addins/Xml/Dom/XComment.cs
index 57231b974f..08a7998065 100644
--- a/main/src/addins/Xml/Dom/XComment.cs
+++ b/main/src/addins/Xml/Dom/XComment.cs
@@ -23,16 +23,14 @@
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
-
-using ICSharpCode.NRefactory.TypeSystem;
-using ICSharpCode.NRefactory;
+using MonoDevelop.Ide.Editor;
namespace MonoDevelop.Xml.Dom
{
public class XComment : XNode
{
- public XComment (TextLocation start) : base (start) {}
- public XComment (DomRegion region) : base (region) {}
+ public XComment (DocumentLocation start) : base (start) {}
+ public XComment (DocumentRegion region) : base (region) {}
protected XComment () {}
protected override XObject NewInstance () { return new XComment (); }
diff --git a/main/src/addins/Xml/Dom/XContainer.cs b/main/src/addins/Xml/Dom/XContainer.cs
index 997def1ad0..dd6e0c10fd 100644
--- a/main/src/addins/Xml/Dom/XContainer.cs
+++ b/main/src/addins/Xml/Dom/XContainer.cs
@@ -25,14 +25,14 @@
// THE SOFTWARE.
using System.Collections.Generic;
-using System.Text;
-using ICSharpCode.NRefactory;
+using System.Text;
+using MonoDevelop.Ide.Editor;
namespace MonoDevelop.Xml.Dom
{
public abstract class XContainer : XNode
{
- protected XContainer (TextLocation start) : base (start) { }
+ protected XContainer (DocumentLocation start) : base (start) { }
XNode firstNode;
XNode lastChild;
diff --git a/main/src/addins/Xml/Dom/XDocType.cs b/main/src/addins/Xml/Dom/XDocType.cs
index ff29a31322..a91f85be96 100644
--- a/main/src/addins/Xml/Dom/XDocType.cs
+++ b/main/src/addins/Xml/Dom/XDocType.cs
@@ -24,15 +24,14 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
-using ICSharpCode.NRefactory.TypeSystem;
-using ICSharpCode.NRefactory;
+using MonoDevelop.Ide.Editor;
namespace MonoDevelop.Xml.Dom
{
public class XDocType : XNode, INamedXObject
{
- public XDocType (TextLocation start) : base (start) {}
- public XDocType (DomRegion region) : base (region) {}
+ public XDocType (DocumentLocation start) : base (start) {}
+ public XDocType (DocumentRegion region) : base (region) {}
protected XDocType () {}
protected override XObject NewInstance () { return new XDocType (); }
@@ -40,7 +39,7 @@ namespace MonoDevelop.Xml.Dom
public XName RootElement { get; set; }
public string PublicFpi { get; set; }
public bool IsPublic { get { return PublicFpi != null; } }
- public DomRegion InternalDeclarationRegion { get; set; }
+ public DocumentRegion InternalDeclarationRegion { get; set; }
public string Uri { get; set; }
public override string FriendlyPathRepresentation {
diff --git a/main/src/addins/Xml/Dom/XDocument.cs b/main/src/addins/Xml/Dom/XDocument.cs
index dc6cfafccc..2425c065c7 100644
--- a/main/src/addins/Xml/Dom/XDocument.cs
+++ b/main/src/addins/Xml/Dom/XDocument.cs
@@ -24,8 +24,8 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
-using System;
-using ICSharpCode.NRefactory;
+using System;
+using MonoDevelop.Ide.Editor;
namespace MonoDevelop.Xml.Dom
{
@@ -33,7 +33,7 @@ namespace MonoDevelop.Xml.Dom
{
public XElement RootElement { get; private set; }
- public XDocument () : base (new TextLocation (1, 1)) {}
+ public XDocument () : base (new DocumentLocation (1, 1)) {}
protected override XObject NewInstance () { return new XDocument (); }
public override string FriendlyPathRepresentation {
diff --git a/main/src/addins/Xml/Dom/XElement.cs b/main/src/addins/Xml/Dom/XElement.cs
index a49a2b81d4..81ff5eceba 100644
--- a/main/src/addins/Xml/Dom/XElement.cs
+++ b/main/src/addins/Xml/Dom/XElement.cs
@@ -25,8 +25,8 @@
// THE SOFTWARE.
using System.Collections.Generic;
-using System.Text;
-using ICSharpCode.NRefactory;
+using System.Text;
+using MonoDevelop.Ide.Editor;
namespace MonoDevelop.Xml.Dom
{
@@ -35,12 +35,12 @@ namespace MonoDevelop.Xml.Dom
XNode closingTag;
readonly XAttributeCollection attributes;
- public XElement (TextLocation start) : base (start)
+ public XElement (DocumentLocation start) : base (start)
{
attributes = new XAttributeCollection (this);
}
- public XElement (TextLocation start, XName name) : this (start)
+ public XElement (DocumentLocation start, XName name) : this (start)
{
this.Name = name;
}
diff --git a/main/src/addins/Xml/Dom/XNode.cs b/main/src/addins/Xml/Dom/XNode.cs
index d98b02b761..37fd74d643 100644
--- a/main/src/addins/Xml/Dom/XNode.cs
+++ b/main/src/addins/Xml/Dom/XNode.cs
@@ -24,15 +24,14 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
-using ICSharpCode.NRefactory.TypeSystem;
-using ICSharpCode.NRefactory;
+using MonoDevelop.Ide.Editor;
namespace MonoDevelop.Xml.Dom
{
public abstract class XNode : XObject
{
- protected XNode (TextLocation start) : base (start) {}
- protected XNode (DomRegion region) : base (region) {}
+ protected XNode (DocumentLocation start) : base (start) {}
+ protected XNode (DocumentRegion region) : base (region) {}
protected XNode () {}
public XNode NextSibling { get; internal protected set; }
diff --git a/main/src/addins/Xml/Dom/XObject.cs b/main/src/addins/Xml/Dom/XObject.cs
index f999256eea..c55d3e3742 100644
--- a/main/src/addins/Xml/Dom/XObject.cs
+++ b/main/src/addins/Xml/Dom/XObject.cs
@@ -25,22 +25,21 @@
// THE SOFTWARE.
using System.Collections.Generic;
-using System.Text;
-using ICSharpCode.NRefactory.TypeSystem;
-using ICSharpCode.NRefactory;
+using System.Text;
+using MonoDevelop.Ide.Editor;
namespace MonoDevelop.Xml.Dom
{
public abstract class XObject
{
- DomRegion region;
+ DocumentRegion region;
- protected XObject (TextLocation start)
+ protected XObject (DocumentLocation start)
{
- region = new DomRegion (start, TextLocation.Empty);
+ region = new DocumentRegion (start, DocumentLocation.Empty);
}
- protected XObject (DomRegion region)
+ protected XObject (DocumentRegion region)
{
this.region = region;
}
@@ -57,13 +56,13 @@ namespace MonoDevelop.Xml.Dom
}
}
- public DomRegion Region {
+ public DocumentRegion Region {
get { return region; }
}
- public void End (TextLocation endLocation)
+ public void End (DocumentLocation endLocation)
{
- region = new DomRegion (region.Begin, endLocation);
+ region = new DocumentRegion (region.Begin, endLocation);
}
public bool IsEnded {
diff --git a/main/src/addins/Xml/Dom/XProcessingInstruction.cs b/main/src/addins/Xml/Dom/XProcessingInstruction.cs
index 9089897116..03d907fe62 100644
--- a/main/src/addins/Xml/Dom/XProcessingInstruction.cs
+++ b/main/src/addins/Xml/Dom/XProcessingInstruction.cs
@@ -23,16 +23,14 @@
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
-
-using ICSharpCode.NRefactory.TypeSystem;
-using ICSharpCode.NRefactory;
+using MonoDevelop.Ide.Editor;
namespace MonoDevelop.Xml.Dom
{
public class XProcessingInstruction : XNode
{
- public XProcessingInstruction (TextLocation start) : base (start) {}
- public XProcessingInstruction (DomRegion region) : base (region) {}
+ public XProcessingInstruction (DocumentLocation start) : base (start) {}
+ public XProcessingInstruction (DocumentRegion region) : base (region) {}
protected XProcessingInstruction () {}
protected override XObject NewInstance () { return new XProcessingInstruction (); }
diff --git a/main/src/addins/Xml/Editor/BaseXmlEditorExtension.cs b/main/src/addins/Xml/Editor/BaseXmlEditorExtension.cs
index f0395d0aea..75a9fdf5de 100644
--- a/main/src/addins/Xml/Editor/BaseXmlEditorExtension.cs
+++ b/main/src/addins/Xml/Editor/BaseXmlEditorExtension.cs
@@ -34,10 +34,7 @@ using System.Linq;
using Gtk;
-using ICSharpCode.NRefactory;
-using ICSharpCode.NRefactory.TypeSystem;
-using Mono.TextEditor;
using MonoDevelop.Components;
using MonoDevelop.Core;
using MonoDevelop.DesignerSupport;
@@ -45,10 +42,14 @@ using MonoDevelop.Ide;
using MonoDevelop.Ide.CodeCompletion;
using MonoDevelop.Ide.Gui.Content;
using MonoDevelop.Ide.TypeSystem;
+using MonoDevelop.Ide.Editor;
+using MonoDevelop.Ide.Editor.Extension;
using MonoDevelop.Projects;
using MonoDevelop.Xml.Completion;
using MonoDevelop.Xml.Dom;
using MonoDevelop.Xml.Parser;
+using System.Threading.Tasks;
+using System.Threading;
namespace MonoDevelop.Xml.Editor
{
@@ -65,18 +66,17 @@ namespace MonoDevelop.Xml.Editor
#region Setup and teardown
- public override bool ExtendsEditor (MonoDevelop.Ide.Gui.Document doc, IEditableTextBuffer editor)
+ public override bool IsValidInContext (DocumentContext context)
{
//can only attach if there is not already an attached BaseXmlEditorExtension
- return doc.GetContent<BaseXmlEditorExtension> () == null;
+ return context.GetContent<BaseXmlEditorExtension> () == null;
}
protected virtual XmlRootState CreateRootState ()
{
return new XmlRootState ();
}
-
- public override void Initialize ()
+ protected override void Initialize ()
{
base.Initialize ();
@@ -89,11 +89,11 @@ namespace MonoDevelop.Xml.Editor
var parser = new XmlParser (CreateRootState (), false);
tracker = new DocumentStateTracker<XmlParser> (parser, Editor);
+ DocumentContext.DocumentParsed += UpdateParsedDocument;
+ Editor.CaretPositionChanged += HandleCaretPositionChanged;
- Document.DocumentParsed += UpdateParsedDocument;
-
- if (Document.ParsedDocument != null) {
- lastCU = Document.ParsedDocument;
+ if (DocumentContext.ParsedDocument != null) {
+ lastCU = DocumentContext.ParsedDocument;
OnParsedDocumentUpdated ();
}
@@ -105,7 +105,7 @@ namespace MonoDevelop.Xml.Editor
void HandleProjectChanged (object sender, ProjectFileEventArgs e)
{
- if (e.Any (f => f.ProjectFile.FilePath == Document.FileName))
+ if (e.Any (f => f.ProjectFile.FilePath == DocumentContext.Name))
UpdateOwnerProjects ();
}
@@ -115,37 +115,39 @@ namespace MonoDevelop.Xml.Editor
ownerProjects = new List<DotNetProject> ();
return;
}
- var projects = new HashSet<DotNetProject> (IdeApp.Workspace.GetAllItems<DotNetProject> ().Where (p => p.IsFileInProject (Document.FileName)));
+ var projects = new HashSet<DotNetProject> (IdeApp.Workspace.GetAllItems<DotNetProject> ().Where (p => p.IsFileInProject (DocumentContext.Name)));
if (ownerProjects == null || !projects.SetEquals (ownerProjects)) {
ownerProjects = projects.OrderBy (p => p.Name).ToList ();
- var dnp = Document.Project as DotNetProject;
+ var dnp = DocumentContext.Project as DotNetProject;
if (ownerProjects.Count > 0 && (dnp == null || !ownerProjects.Contains (dnp))) {
// If the project for the document is not a DotNetProject but there is a project containing this file
// in the current solution, then use that project
- var pp = Document.Project != null ? ownerProjects.FirstOrDefault (p => p.ParentSolution == Document.Project.ParentSolution) : null;
+ var pp = DocumentContext.Project != null ? ownerProjects.FirstOrDefault (p => p.ParentSolution == DocumentContext.Project.ParentSolution) : null;
if (pp != null)
- Document.AttachToProject (pp);
+ DocumentContext.AttachToProject (pp);
}
}
- if (Document.Project == null && ownerProjects.Count > 0)
- Document.AttachToProject (ownerProjects[0]);
+ if (DocumentContext.Project == null && ownerProjects.Count > 0)
+ DocumentContext.AttachToProject (ownerProjects[0]);
UpdatePath ();
}
void UpdateParsedDocument (object sender, EventArgs args)
{
- lastCU = Document.ParsedDocument;
+ lastCU = DocumentContext.ParsedDocument;
OnParsedDocumentUpdated ();
}
public override void Dispose ()
{
+ Editor.CaretPositionChanged -= HandleCaretPositionChanged;
+
if (tracker != null) {
tracker = null;
base.Dispose ();
}
- Document.DocumentParsed -= UpdateParsedDocument;
+ DocumentContext.DocumentParsed -= UpdateParsedDocument;
if (IdeApp.Workspace != null) {
IdeApp.Workspace.FileAddedToProject -= HandleProjectChanged;
@@ -183,34 +185,17 @@ namespace MonoDevelop.Xml.Editor
protected ParsedDocument CU {
get { return lastCU; }
}
-
- protected ITextBuffer Buffer {
- get {
- if (Document == null)
- throw new InvalidOperationException ("Editor extension not yet initialized");
- return Document.GetContent<ITextBuffer> ();
- }
- }
-
- protected IEditableTextBuffer EditableBuffer {
- get {
- if (Document == null)
- throw new InvalidOperationException ("Editor extension not yet initialized");
- return Document.GetContent<IEditableTextBuffer> ();
- }
- }
-
+
protected DocumentStateTracker<XmlParser> Tracker {
get { return tracker; }
}
- protected string GetBufferText (DomRegion region)
+ protected string GetBufferText (DocumentRegion region)
{
- ITextBuffer buf = Buffer;
- int start = buf.GetPositionFromLineColumn (region.BeginLine, region.BeginColumn);
- int end = buf.GetPositionFromLineColumn (region.EndLine, region.EndColumn);
+ int start = Editor.LocationToOffset (region.BeginLine, region.BeginColumn);
+ int end = Editor.LocationToOffset (region.EndLine, region.EndColumn);
if (end > start && start >= 0)
- return buf.GetText (start, end);
+ return Editor.GetTextBetween (start, end);
return null;
}
@@ -219,7 +204,12 @@ namespace MonoDevelop.Xml.Editor
public override string CompletionLanguage {
get { return "Xml"; }
}
-
+
+ protected FilePath FileName {
+ get {
+ return Editor.FileName;
+ }
+ }
protected XDocType DocType {
get { return docType; }
set {
@@ -234,29 +224,24 @@ namespace MonoDevelop.Xml.Editor
{
}
- public override bool KeyPress (Gdk.Key key, char keyChar, Gdk.ModifierType modifier)
+ public override bool KeyPress (KeyDescriptor descriptor)
{
- if (Document.Editor.Options.IndentStyle == IndentStyle.Smart) {
- var newLine = Editor.Caret.Line + 1;
- var ret = base.KeyPress (key, keyChar, modifier);
- if (key == Gdk.Key.Return && Editor.Caret.Line == newLine) {
+ if (Editor.Options.IndentStyle == IndentStyle.Smart) {
+ var newLine = Editor.CaretLine + 1;
+ var ret = base.KeyPress (descriptor);
+ if (descriptor.SpecialKey == SpecialKey.Return && Editor.CaretLine == newLine) {
string indent = GetLineIndent (newLine);
var oldIndent = Editor.GetLineIndent (newLine);
var seg = Editor.GetLine (newLine);
if (oldIndent != indent) {
- int newCaretOffset = Editor.Caret.Offset;
- if (newCaretOffset > seg.Offset) {
- newCaretOffset += (indent.Length - oldIndent.Length);
- }
using (var undo = Editor.OpenUndoGroup ()) {
- Editor.Replace (seg.Offset, oldIndent.Length, indent);
- Editor.Caret.Offset = newCaretOffset;
+ Editor.ReplaceText (seg.Offset, oldIndent.Length, indent);
}
}
}
return ret;
}
- return base.KeyPress (key, keyChar, modifier);
+ return base.KeyPress (descriptor);
}
#region Code completion
@@ -266,31 +251,29 @@ namespace MonoDevelop.Xml.Editor
int pos = completionContext.TriggerOffset;
if (pos <= 0)
return null;
- int triggerWordLength = 0;
-
tracker.UpdateEngine ();
- return HandleCodeCompletion (completionContext, true, ref triggerWordLength);
+ var task = HandleCodeCompletion (completionContext, true, default(CancellationToken));
+ return task != null ? task.Result : null;
}
- public override ICompletionDataList HandleCodeCompletion (
- CodeCompletionContext completionContext, char completionChar, ref int triggerWordLength)
+ public override Task<ICompletionDataList> HandleCodeCompletionAsync (CodeCompletionContext completionContext, char completionChar, CancellationToken token = default(CancellationToken))
{
int pos = completionContext.TriggerOffset;
char ch = CompletionWidget != null ? CompletionWidget.GetChar (pos - 1) : Editor.GetCharAt (pos - 1);
if (pos > 0 && ch == completionChar) {
tracker.UpdateEngine ();
- return HandleCodeCompletion (completionContext, false, ref triggerWordLength);
+ return HandleCodeCompletion (completionContext, false, token);
}
return null;
}
- protected virtual ICompletionDataList HandleCodeCompletion (
- CodeCompletionContext completionContext, bool forced, ref int triggerWordLength)
+ protected virtual Task<ICompletionDataList> HandleCodeCompletion (
+ CodeCompletionContext completionContext, bool forced, CancellationToken token)
{
- IEditableTextBuffer buf = EditableBuffer;
+ var buf = this.Editor;
// completionChar may be a space even if the current char isn't, when ctrl-space is fired t
- var currentLocation = new TextLocation (completionContext.TriggerLine, completionContext.TriggerLineOffset);
+ var currentLocation = new DocumentLocation (completionContext.TriggerLine, completionContext.TriggerLineOffset);
char currentChar = completionContext.TriggerOffset < 1? ' ' : buf.GetCharAt (completionContext.TriggerOffset - 1);
char previousChar = completionContext.TriggerOffset < 2? ' ' : buf.GetCharAt (completionContext.TriggerOffset - 2);
@@ -299,13 +282,13 @@ namespace MonoDevelop.Xml.Editor
tracker.Engine.CurrentStateLength, previousChar, currentChar, forced);
//closing tag completion
- if (tracker.Engine.CurrentState is XmlRootState && currentChar == '>')
- return ClosingTagCompletion (buf, currentLocation);
+ if (tracker.Engine.CurrentState is XmlRootState && currentChar == '>')
+ return Task.FromResult (ClosingTagCompletion (buf, currentLocation));
// Auto insert '>' when '/' is typed inside tag state (for quick tag closing)
//FIXME: avoid doing this when the next non-whitespace char is ">" or ignore the next ">" typed
if (XmlEditorOptions.AutoInsertFragments && tracker.Engine.CurrentState is XmlTagState && currentChar == '/') {
- buf.InsertText (buf.CursorPosition, ">");
+ buf.InsertAtCaret (">");
return null;
}
@@ -331,7 +314,7 @@ namespace MonoDevelop.Xml.Editor
list.Add ("&").CompletionText = "amp;";
GetEntityCompletions (list);
- return list;
+ return Task.FromResult ((ICompletionDataList)list);
}
//doctype completion
@@ -339,7 +322,7 @@ namespace MonoDevelop.Xml.Editor
if (tracker.Engine.CurrentStateLength == 1) {
CompletionDataList list = GetDocTypeCompletions ();
if (list != null && list.Count > 0)
- return list;
+ return Task.FromResult ((ICompletionDataList)list);
}
return null;
}
@@ -359,9 +342,13 @@ namespace MonoDevelop.Xml.Editor
return null;
//if triggered by first letter of value or forced, grab those letters
- triggerWordLength = Tracker.Engine.CurrentStateLength - 1;
- return GetAttributeValueCompletions (attributedOb, att);
+ var result = GetAttributeValueCompletions (attributedOb, att);
+ if (result != null) {
+ result.TriggerWordLength = Tracker.Engine.CurrentStateLength - 1;
+ return Task.FromResult ((ICompletionDataList)result);
+ }
+ return null;
}
}
@@ -380,17 +367,18 @@ namespace MonoDevelop.Xml.Editor
if (attributedOb.Name.IsValid && (forced ||
(char.IsWhiteSpace (previousChar) && char.IsLetter (currentChar))))
{
-
- if (!forced)
- triggerWordLength = 1;
-
var existingAtts = new Dictionary<string,string> (StringComparer.OrdinalIgnoreCase);
foreach (XAttribute att in attributedOb.Attributes) {
existingAtts [att.Name.FullName] = att.Value ?? string.Empty;
}
-
- return GetAttributeCompletions (attributedOb, existingAtts);
+ var result = GetAttributeCompletions (attributedOb, existingAtts);
+ if (result != null) {
+ if (!forced)
+ result.TriggerWordLength = 1;
+ return Task.FromResult ((ICompletionDataList)result);
+ }
+ return null;
}
}
@@ -405,48 +393,79 @@ namespace MonoDevelop.Xml.Editor
var list = new CompletionDataList ();
GetElementCompletions (list);
AddCloseTag (list, Tracker.Engine.Nodes);
- return list.Count > 0? list : null;
+ return Task.FromResult ((ICompletionDataList)(list.Count > 0? list : null));
}
if (forced && Tracker.Engine.CurrentState is XmlRootState) {
var list = new CompletionDataList ();
- MonoDevelop.Ide.CodeTemplates.CodeTemplateService.AddCompletionDataForFileName (Document.Name, list);
- return list.Count > 0? list : null;
+ MonoDevelop.Ide.CodeTemplates.CodeTemplateService.AddCompletionDataForFileName (DocumentContext.Name, list);
+ return Task.FromResult ((ICompletionDataList)(list.Count > 0? list : null));
}
return null;
- }
-
- protected virtual ICompletionDataList ClosingTagCompletion (IEditableTextBuffer buf, TextLocation currentLocation)
- {
- //get name of current node in document that's being ended
- var el = tracker.Engine.Nodes.Peek () as XElement;
- if (el != null && el.Region.End >= currentLocation && !el.IsClosed && el.IsNamed) {
- string tag = String.Concat ("</", el.Name.FullName, ">");
- if (XmlEditorOptions.AutoCompleteElements) {
-
- // //make sure we have a clean atomic undo so the user can undo the tag insertion
- // //independently of the >
- // bool wasInAtomicUndo = this.Editor.Document.IsInAtomicUndo;
- // if (wasInAtomicUndo)
- // this.Editor.Document.EndAtomicUndo ();
-
- using (var undo = buf.OpenUndoGroup ()) {
- buf.InsertText (buf.CursorPosition, tag);
- buf.CursorPosition -= tag.Length;
- }
-
- // if (wasInAtomicUndo)
- // this.Editor.Document.BeginAtomicUndo ();
-
- return null;
- } else {
- var cp = new CompletionDataList ();
- cp.Add (new XmlTagCompletionData (tag, 0, true));
- return cp;
- }
- }
- return null;
+ }
+
+
+
+ protected virtual ICompletionDataList ClosingTagCompletion (TextEditor buf, DocumentLocation currentLocation)
+
+ {
+
+ //get name of current node in document that's being ended
+
+ var el = tracker.Engine.Nodes.Peek () as XElement;
+
+ if (el != null && el.Region.End >= currentLocation && !el.IsClosed && el.IsNamed) {
+
+ string tag = String.Concat ("</", el.Name.FullName, ">");
+
+ if (XmlEditorOptions.AutoCompleteElements) {
+
+
+
+ // //make sure we have a clean atomic undo so the user can undo the tag insertion
+
+ // //independently of the >
+
+ // bool wasInAtomicUndo = this.Editor.Document.IsInAtomicUndo;
+
+ // if (wasInAtomicUndo)
+
+ // this.Editor.Document.EndAtomicUndo ();
+
+
+
+ using (var undo = buf.OpenUndoGroup ()) {
+
+ buf.InsertText (buf.CaretOffset, tag);
+
+ buf.CaretOffset -= tag.Length;
+
+ }
+
+
+
+ // if (wasInAtomicUndo)
+
+ // this.Editor.Document.BeginAtomicUndo ();
+
+
+
+ return null;
+
+ } else {
+
+ var cp = new CompletionDataList ();
+
+ cp.Add (new XmlTagCompletionData (tag, 0, true));
+
+ return cp;
+
+ }
+
+ }
+
+ return null;
}
protected virtual void GetElementCompletions (CompletionDataList list)
@@ -475,7 +494,7 @@ namespace MonoDevelop.Xml.Editor
protected string GetLineIndent (int line)
{
- var seg = Editor.Document.GetLine (line);
+ var seg = Editor.GetLine (line);
//reset the tracker to the beginning of the line
Tracker.UpdateEngine (seg.Offset);
@@ -592,7 +611,7 @@ namespace MonoDevelop.Xml.Editor
PathEntry[] currentPath;
bool pathUpdateQueued;
- public override void CursorPositionChanged ()
+ void HandleCaretPositionChanged (object sender, EventArgs e)
{
if (pathUpdateQueued)
return;
@@ -602,7 +621,6 @@ namespace MonoDevelop.Xml.Editor
UpdatePath ();
return false;
});
-
}
public void SelectPath (int depth)
@@ -662,16 +680,16 @@ namespace MonoDevelop.Xml.Editor
//pick out the locations, with some offsets to account for the parsing model
var s = contents? el.Region.End : el.Region.Begin;
var e = contents? el.ClosingTag.Region.Begin : el.ClosingTag.Region.End;
- EditorSelect (new DomRegion (s, e));
+ EditorSelect (new DocumentRegion (s, e));
} else {
LoggingService.LogDebug ("No end tag found for selection");
}
}
- protected void EditorSelect (DomRegion region)
+ protected void EditorSelect (DocumentRegion region)
{
- int s = Editor.Document.LocationToOffset (region.BeginLine, region.BeginColumn);
- int e = Editor.Document.LocationToOffset (region.EndLine, region.EndColumn);
+ int s = Editor.LocationToOffset (region.BeginLine, region.BeginColumn);
+ int e = Editor.LocationToOffset (region.EndLine, region.EndColumn);
if (s > -1 && e > s) {
Editor.SetSelection (s, e);
Editor.ScrollTo (s);
@@ -743,7 +761,7 @@ namespace MonoDevelop.Xml.Editor
public void ActivateItem (int n)
{
- ext.Document.AttachToProject (ext.ownerProjects [n]);
+ ext.DocumentContext.AttachToProject (ext.ownerProjects [n]);
}
public int IconCount {
@@ -842,7 +860,7 @@ namespace MonoDevelop.Xml.Editor
var path = new List<PathEntry> ();
if (ownerProjects.Count > 1) {
// Current project if there is more than one
- path.Add (new PathEntry (ImageService.GetIcon (Document.Project.StockIcon), GLib.Markup.EscapeText (Document.Project.Name)) { Tag = Document.Project });
+ path.Add (new PathEntry (ImageService.GetIcon (DocumentContext.Project.StockIcon), GLib.Markup.EscapeText (DocumentContext.Project.Name)) { Tag = DocumentContext.Project });
}
if (l != null) {
for (int i = 0; i < l.Count; i++) {
@@ -999,7 +1017,7 @@ namespace MonoDevelop.Xml.Editor
var el = n as XElement;
if (el != null && el.IsClosed && el.ClosingTag.Region.End > region.End) {
- region = new DomRegion (region.Begin, el.ClosingTag.Region.End);
+ region = new DocumentRegion (region.Begin, el.ClosingTag.Region.End);
}
EditorSelect (region);
}
diff --git a/main/src/addins/Xml/Editor/XmlDocumentParser.cs b/main/src/addins/Xml/Editor/XmlDocumentParser.cs
index 5f17fead35..d97ef44b69 100644
--- a/main/src/addins/Xml/Editor/XmlDocumentParser.cs
+++ b/main/src/addins/Xml/Editor/XmlDocumentParser.cs
@@ -31,20 +31,22 @@ using System.IO;
using MonoDevelop.Ide.TypeSystem;
using MonoDevelop.Xml.Parser;
+using MonoDevelop.Core.Text;
namespace MonoDevelop.Xml.Editor
{
class XmlDocumentParser : TypeSystemParser
{
- public override ParsedDocument Parse (bool storeAst, string fileName, TextReader content, MonoDevelop.Projects.Project project = null)
+ public override System.Threading.Tasks.Task<ParsedDocument> Parse (ParseOptions parseOptions, System.Threading.CancellationToken cancellationToken)
{
- var doc = new XmlParsedDocument (fileName);
+ var doc = new XmlParsedDocument (parseOptions.FileName);
doc.Flags |= ParsedDocumentFlags.NonSerializable;
try {
var xmlParser = new XmlParser (new XmlRootState (), true);
- xmlParser.Parse (content);
+ xmlParser.Parse (parseOptions.Content.CreateReader ());
doc.XDocument = xmlParser.Nodes.GetRoot ();
- doc.Add (xmlParser.Errors);
+ // TODO error conversion!
+ //doc.Add (xmlParser.Errors);
if (doc.XDocument != null && doc.XDocument.RootElement != null) {
if (!doc.XDocument.RootElement.IsEnded)
@@ -54,7 +56,7 @@ namespace MonoDevelop.Xml.Editor
catch (Exception ex) {
MonoDevelop.Core.LoggingService.LogError ("Unhandled error parsing xml document", ex);
}
- return doc;
+ return System.Threading.Tasks.Task.FromResult((ParsedDocument)doc);
}
}
}
diff --git a/main/src/addins/Xml/Editor/XmlEditorService.cs b/main/src/addins/Xml/Editor/XmlEditorService.cs
index 7e0201ef57..4b388eb528 100644
--- a/main/src/addins/Xml/Editor/XmlEditorService.cs
+++ b/main/src/addins/Xml/Editor/XmlEditorService.cs
@@ -1,42 +1,48 @@
-//
-// MonoDevelop XML Editor
-//
-// Copyright (C) 2006-2007 Matthew Ward
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+//
+// MonoDevelop XML Editor
+//
+// Copyright (C) 2006-2007 Matthew Ward
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
-using System.Text;
-using System.Xml;
-using System.Xml.Schema;
+using System.Text;
+using System.Xml;
+using System.Xml.Schema;
+using System.Xml.XPath;
+using System.Xml.Xsl;
+using MonoDevelop.Components;
+using Gtk;
+using MonoDevelop.Components.Extensions;
+using MonoDevelop.Ide.Editor;
using System.Xml.XPath;
using System.Xml.Xsl;
using MonoDevelop.Components;
using MonoDevelop.Components.Extensions;
-using MonoDevelop.Core;
-using MonoDevelop.Ide;
-using MonoDevelop.Ide.Gui;
-using MonoDevelop.Ide.Tasks;
-using MonoDevelop.Projects;
+using MonoDevelop.Core;
+using MonoDevelop.Ide;
+using MonoDevelop.Ide.Gui;
+using MonoDevelop.Ide.Tasks;
+using MonoDevelop.Projects;
using MonoDevelop.Xml.Completion;
namespace MonoDevelop.Xml.Editor
@@ -44,7 +50,7 @@ namespace MonoDevelop.Xml.Editor
static class XmlEditorService
{
#region Task management
- public static void AddTask(string fileName, string message, int column, int line, TaskSeverity taskType)
+ public static void AddTask(string fileName, string message, int column, int line, TaskSeverity taskType)
{
// HACK: Use a compiler error since we cannot add an error
// task otherwise (task type property is read-only and
@@ -55,23 +61,23 @@ namespace MonoDevelop.Xml.Editor
error.ErrorText = message;
error.FileName = fileName;
error.IsWarning = false;
-
+
//Task task = new Task(fileName, message, column, line);
TaskListEntry task = new TaskListEntry (error);
- TaskService.Errors.Add(task);
- }
- #endregion
-
+ TaskService.Errors.Add(task);
+ }
+ #endregion
+
#region View tracking
-
- public static XmlTextEditorExtension ActiveEditor {
- get {
- Document doc = IdeApp.Workbench.ActiveDocument;
- if (doc != null)
- return doc.GetContent<XmlTextEditorExtension>();
- return null;
- }
- }
+
+ public static XmlTextEditorExtension ActiveEditor {
+ get {
+ Document doc = IdeApp.Workbench.ActiveDocument;
+ if (doc != null)
+ return doc.GetContent<XmlTextEditorExtension>();
+ return null;
+ }
+ }
public static ReadOnlyCollection<XmlTextEditorExtension> OpenXmlEditorViews {
get {
@@ -89,8 +95,8 @@ namespace MonoDevelop.Xml.Editor
get {
return ActiveEditor != null;
}
- }
- #endregion
+ }
+ #endregion
/*
public static bool IsXslOutputViewContentActive {
@@ -103,339 +109,339 @@ namespace MonoDevelop.Xml.Editor
public static ProgressMonitor GetMonitor ()
{
return IdeApp.Workbench.ProgressMonitors.GetOutputProgressMonitor ("XML", "md-xml-file-icon", true, true);
- }
-
+ }
+
#region Formatting utilities
/// <summary>
/// Creates a XmlTextWriter using the current text editor
/// properties for indentation.
/// </summary>
- public static XmlTextWriter CreateXmlTextWriter (Document doc, TextWriter textWriter)
+ public static XmlTextWriter CreateXmlTextWriter (TextEditor doc, TextWriter textWriter)
{
- XmlTextWriter xmlWriter = new XmlTextWriter(textWriter);
- xmlWriter.Formatting = System.Xml.Formatting.Indented;
- if (doc.Editor.TabsToSpaces) {
- xmlWriter.Indentation = doc.Editor.Options.TabSize;
- xmlWriter.IndentChar = ' ';
- } else {
- xmlWriter.Indentation = 1;
- xmlWriter.IndentChar = '\t';
- }
+ XmlTextWriter xmlWriter = new XmlTextWriter(textWriter);
+ xmlWriter.Formatting = System.Xml.Formatting.Indented;
+ if (doc.Options.TabsToSpaces) {
+ xmlWriter.Indentation = doc.Options.TabSize;
+ xmlWriter.IndentChar = ' ';
+ } else {
+ xmlWriter.Indentation = 1;
+ xmlWriter.IndentChar = '\t';
+ }
return xmlWriter;
- }
-
- public static XmlTextWriter CreateXmlTextWriter (Document doc)
- {
- return CreateXmlTextWriter (doc, new EncodedStringWriter (Encoding.UTF8));
- }
-
+ }
+
+ public static XmlTextWriter CreateXmlTextWriter (TextEditor doc)
+ {
+ return CreateXmlTextWriter (doc, new EncodedStringWriter (Encoding.UTF8));
+ }
+
#endregion
- /// <summary>
- /// Runs an XSL transform on the input xml.
- /// </summary>
- /// <param name="input">The input xml to transform.</param>
- /// <param name="transform">The transform xml.</param>
- /// <returns>The output of the transform.</returns>
- public static string Transform (string input, string transform)
- {
- StringReader inputString = new StringReader (input);
- XPathDocument sourceDocument = new XPathDocument (inputString);
-
- StringReader transformString = new StringReader (transform);
- XPathDocument transformDocument = new XPathDocument (transformString);
-
- XslCompiledTransform xslTransform = new XslCompiledTransform ();
+ /// <summary>
+ /// Runs an XSL transform on the input xml.
+ /// </summary>
+ /// <param name="input">The input xml to transform.</param>
+ /// <param name="transform">The transform xml.</param>
+ /// <returns>The output of the transform.</returns>
+ public static string Transform (string input, string transform)
+ {
+ StringReader inputString = new StringReader (input);
+ XPathDocument sourceDocument = new XPathDocument (inputString);
+
+ StringReader transformString = new StringReader (transform);
+ XPathDocument transformDocument = new XPathDocument (transformString);
+
+ XslCompiledTransform xslTransform = new XslCompiledTransform ();
xslTransform.Load (transformDocument, null, new XmlUrlResolver ());
-
- MemoryStream outputStream = new MemoryStream ();
- XmlTextWriter writer = new XmlTextWriter (outputStream, Encoding.UTF8);
-
- xslTransform.Transform (sourceDocument, writer);
-
- int preambleLength = Encoding.UTF8.GetPreamble ().Length;
- byte[] outputBytes = outputStream.ToArray ();
- return UTF8Encoding.UTF8.GetString (outputBytes, preambleLength, outputBytes.Length - preambleLength);
- }
-
- public static string CreateSchema (Document doc, string xml)
- {
- using (System.Data.DataSet dataSet = new System.Data.DataSet()) {
- dataSet.ReadXml(new StringReader (xml), System.Data.XmlReadMode.InferSchema);
- using (EncodedStringWriter writer = new EncodedStringWriter (Encoding.UTF8)) {
- using (XmlTextWriter xmlWriter = XmlEditorService.CreateXmlTextWriter (doc, writer)) {
- dataSet.WriteXmlSchema(xmlWriter);
- return writer.ToString();
+
+ MemoryStream outputStream = new MemoryStream ();
+ XmlTextWriter writer = new XmlTextWriter (outputStream, Encoding.UTF8);
+
+ xslTransform.Transform (sourceDocument, writer);
+
+ int preambleLength = Encoding.UTF8.GetPreamble ().Length;
+ byte[] outputBytes = outputStream.ToArray ();
+ return UTF8Encoding.UTF8.GetString (outputBytes, preambleLength, outputBytes.Length - preambleLength);
+ }
+
+ public static string CreateSchema (TextEditor doc, string xml)
+ {
+ using (System.Data.DataSet dataSet = new System.Data.DataSet()) {
+ dataSet.ReadXml(new StringReader (xml), System.Data.XmlReadMode.InferSchema);
+ using (EncodedStringWriter writer = new EncodedStringWriter (Encoding.UTF8)) {
+ using (XmlTextWriter xmlWriter = XmlEditorService.CreateXmlTextWriter (doc, writer)) {
+ dataSet.WriteXmlSchema(xmlWriter);
+ return writer.ToString();
}
- }
- }
- }
-
- public static string GenerateFileName (string sourceName, string extensionFormat)
- {
- return GenerateFileName (
- Path.Combine (Path.GetDirectoryName (sourceName), Path.GetFileNameWithoutExtension (sourceName)) +
- extensionFormat);
- }
-
- // newNameFormat should be a string format for the new filename such as
- // "/some/path/oldname{0}.xsd", where {0} is the index that will be incremented until a
- // non-existing file is found.
- public static string GenerateFileName (string newNameFormat)
- {
- string generatedFilename = string.Format (newNameFormat, "");
+ }
+ }
+ }
+
+ public static string GenerateFileName (string sourceName, string extensionFormat)
+ {
+ return GenerateFileName (
+ Path.Combine (Path.GetDirectoryName (sourceName), Path.GetFileNameWithoutExtension (sourceName)) +
+ extensionFormat);
+ }
+
+ // newNameFormat should be a string format for the new filename such as
+ // "/some/path/oldname{0}.xsd", where {0} is the index that will be incremented until a
+ // non-existing file is found.
+ public static string GenerateFileName (string newNameFormat)
+ {
+ string generatedFilename = string.Format (newNameFormat, "");
int count = 1;
while (File.Exists (generatedFilename)) {
- generatedFilename = string.Format (newNameFormat, count);
- ++count;
- }
- return generatedFilename;
- }
-
- #region Validation
-
- /// <summary>
- /// Checks that the xml in this view is well-formed.
- /// </summary>
+ generatedFilename = string.Format (newNameFormat, count);
+ ++count;
+ }
+ return generatedFilename;
+ }
+
+ #region Validation
+
+ /// <summary>
+ /// Checks that the xml in this view is well-formed.
+ /// </summary>
public static XmlDocument ValidateWellFormedness (ProgressMonitor monitor, string xml, string fileName)
- {
+ {
monitor.BeginTask (GettextCatalog.GetString ("Validating XML..."), 1);
- bool error = false;
- XmlDocument doc = null;
+ bool error = false;
+ XmlDocument doc = null;
try {
- doc = new XmlDocument ();
- doc.LoadXml (xml);
- } catch (XmlException ex) {
- monitor.ReportError (ex.Message, ex);
- AddTask (fileName, ex.Message, ex.LinePosition, ex.LineNumber, TaskSeverity.Error);
- error = true;
- }
+ doc = new XmlDocument ();
+ doc.LoadXml (xml);
+ } catch (XmlException ex) {
+ monitor.ReportError (ex.Message, ex);
+ AddTask (fileName, ex.Message, ex.LinePosition, ex.LineNumber, TaskSeverity.Error);
+ error = true;
+ }
- if (error) {
+ if (error) {
monitor.Log.WriteLine (GettextCatalog.GetString ("Validation failed."));
TaskService.ShowErrors ();
- } else {
- monitor.Log.WriteLine (GettextCatalog.GetString ("XML is valid."));
- }
-
- monitor.EndTask ();
+ } else {
+ monitor.Log.WriteLine (GettextCatalog.GetString ("XML is valid."));
+ }
+
+ monitor.EndTask ();
return error? null: doc;
- }
-
- /// <summary>
- /// Validates the xml against known schemas.
+ }
+
+ /// <summary>
+ /// Validates the xml against known schemas.
/// </summary>
public static XmlDocument ValidateXml (ProgressMonitor monitor, string xml, string fileName)
{
monitor.BeginTask (GettextCatalog.GetString ("Validating XML..."), 1);
- bool error = false;
- XmlDocument doc = null;
- StringReader stringReader = new StringReader (xml);
-
- XmlReaderSettings settings = new XmlReaderSettings ();
- settings.ValidationFlags = XmlSchemaValidationFlags.ProcessIdentityConstraints
- | XmlSchemaValidationFlags.ProcessInlineSchema
- | XmlSchemaValidationFlags.ProcessSchemaLocation
- | XmlSchemaValidationFlags.ReportValidationWarnings;
- settings.ValidationType = ValidationType.Schema;
- settings.DtdProcessing = DtdProcessing.Parse;
-
- ValidationEventHandler validationHandler = delegate (object sender, System.Xml.Schema.ValidationEventArgs args) {
- if (args.Severity == XmlSeverityType.Warning) {
- monitor.Log.WriteLine (args.Message);
- AddTask (fileName, args.Exception.Message, args.Exception.LinePosition, args.Exception.LineNumber,TaskSeverity.Warning);
- } else {
- AddTask (fileName, args.Exception.Message, args.Exception.LinePosition, args.Exception.LineNumber,TaskSeverity.Error);
- monitor.Log.WriteLine (args.Message);
- error = true;
- }
- };
- settings.ValidationEventHandler += validationHandler;
-
+ bool error = false;
+ XmlDocument doc = null;
+ StringReader stringReader = new StringReader (xml);
+
+ XmlReaderSettings settings = new XmlReaderSettings ();
+ settings.ValidationFlags = XmlSchemaValidationFlags.ProcessIdentityConstraints
+ | XmlSchemaValidationFlags.ProcessInlineSchema
+ | XmlSchemaValidationFlags.ProcessSchemaLocation
+ | XmlSchemaValidationFlags.ReportValidationWarnings;
+ settings.ValidationType = ValidationType.Schema;
+ settings.DtdProcessing = DtdProcessing.Parse;
+
+ ValidationEventHandler validationHandler = delegate (object sender, System.Xml.Schema.ValidationEventArgs args) {
+ if (args.Severity == XmlSeverityType.Warning) {
+ monitor.Log.WriteLine (args.Message);
+ AddTask (fileName, args.Exception.Message, args.Exception.LinePosition, args.Exception.LineNumber,TaskSeverity.Warning);
+ } else {
+ AddTask (fileName, args.Exception.Message, args.Exception.LinePosition, args.Exception.LineNumber,TaskSeverity.Error);
+ monitor.Log.WriteLine (args.Message);
+ error = true;
+ }
+ };
+ settings.ValidationEventHandler += validationHandler;
+
try {
- foreach (XmlSchemaCompletionData sd in XmlSchemaManager.SchemaCompletionDataItems)
- settings.Schemas.Add (sd.Schema);
- settings.Schemas.Compile ();
-
- XmlReader reader = XmlReader.Create (stringReader, settings);
- doc = new XmlDocument();
- doc.Load (reader);
-
- } catch (XmlSchemaException ex) {
- monitor.ReportError (ex.Message, ex);
- AddTask (fileName, ex.Message, ex.LinePosition, ex.LineNumber,TaskSeverity.Error);
- error = true;
- }
- catch (XmlException ex) {
- monitor.ReportError (ex.Message, ex);
- AddTask (fileName, ex.Message, ex.LinePosition, ex.LineNumber,TaskSeverity.Error);
- error = true;
- }
- finally {
- if (stringReader != null)
- stringReader.Dispose ();
- settings.ValidationEventHandler -= validationHandler;
+ foreach (XmlSchemaCompletionData sd in XmlSchemaManager.SchemaCompletionDataItems)
+ settings.Schemas.Add (sd.Schema);
+ settings.Schemas.Compile ();
+
+ XmlReader reader = XmlReader.Create (stringReader, settings);
+ doc = new XmlDocument();
+ doc.Load (reader);
+
+ } catch (XmlSchemaException ex) {
+ monitor.ReportError (ex.Message, ex);
+ AddTask (fileName, ex.Message, ex.LinePosition, ex.LineNumber,TaskSeverity.Error);
+ error = true;
+ }
+ catch (XmlException ex) {
+ monitor.ReportError (ex.Message, ex);
+ AddTask (fileName, ex.Message, ex.LinePosition, ex.LineNumber,TaskSeverity.Error);
+ error = true;
+ }
+ finally {
+ if (stringReader != null)
+ stringReader.Dispose ();
+ settings.ValidationEventHandler -= validationHandler;
}
- if (error) {
+ if (error) {
monitor.Log.WriteLine (GettextCatalog.GetString ("Validation failed."));
TaskService.ShowErrors ();
} else {
- monitor.Log.WriteLine (GettextCatalog.GetString ("XML is valid."));
- }
-
- monitor.EndTask ();
- return error? null: doc;
- }
-
- /// <summary>
- /// Validates the schema.
+ monitor.Log.WriteLine (GettextCatalog.GetString ("XML is valid."));
+ }
+
+ monitor.EndTask ();
+ return error? null: doc;
+ }
+
+ /// <summary>
+ /// Validates the schema.
/// </summary>
public static XmlSchema ValidateSchema (ProgressMonitor monitor, string xml, string fileName)
{
monitor.BeginTask (GettextCatalog.GetString ("Validating schema..."), 1);
- bool error = false;
- XmlSchema schema = null;
- try {
- StringReader stringReader = new StringReader (xml);
- XmlTextReader xmlReader = new XmlTextReader (stringReader);
+ bool error = false;
+ XmlSchema schema = null;
+ try {
+ StringReader stringReader = new StringReader (xml);
+ XmlTextReader xmlReader = new XmlTextReader (stringReader);
xmlReader.XmlResolver = null;
-
- ValidationEventHandler callback = delegate (object source, ValidationEventArgs args) {
- if (args.Severity == XmlSeverityType.Warning) {
- monitor.ReportWarning (args.Message);
- } else {
- monitor.ReportError (args.Message, args.Exception);
- error = true;
- }
- AddTask (fileName, args.Message, args.Exception.LinePosition, args.Exception.LineNumber,
- (args.Severity == XmlSeverityType.Warning)? TaskSeverity.Warning : TaskSeverity.Error);
+
+ ValidationEventHandler callback = delegate (object source, ValidationEventArgs args) {
+ if (args.Severity == XmlSeverityType.Warning) {
+ monitor.ReportWarning (args.Message);
+ } else {
+ monitor.ReportError (args.Message, args.Exception);
+ error = true;
+ }
+ AddTask (fileName, args.Message, args.Exception.LinePosition, args.Exception.LineNumber,
+ (args.Severity == XmlSeverityType.Warning)? TaskSeverity.Warning : TaskSeverity.Error);
};
- schema = XmlSchema.Read (xmlReader, callback);
- XmlSchemaSet sset = new XmlSchemaSet ();
- sset.Add (schema);
- sset.ValidationEventHandler += callback;
+ schema = XmlSchema.Read (xmlReader, callback);
+ XmlSchemaSet sset = new XmlSchemaSet ();
+ sset.Add (schema);
+ sset.ValidationEventHandler += callback;
sset.Compile ();
- }
- catch (XmlSchemaException ex) {
- monitor.ReportError (ex.Message, ex);
- AddTask (fileName, ex.Message, ex.LinePosition, ex.LineNumber,TaskSeverity.Error);
- error = true;
- }
- catch (XmlException ex) {
- monitor.ReportError (ex.Message, ex);
- AddTask (fileName, ex.Message, ex.LinePosition, ex.LineNumber,TaskSeverity.Error);
- error = true;
- }
+ }
+ catch (XmlSchemaException ex) {
+ monitor.ReportError (ex.Message, ex);
+ AddTask (fileName, ex.Message, ex.LinePosition, ex.LineNumber,TaskSeverity.Error);
+ error = true;
+ }
+ catch (XmlException ex) {
+ monitor.ReportError (ex.Message, ex);
+ AddTask (fileName, ex.Message, ex.LinePosition, ex.LineNumber,TaskSeverity.Error);
+ error = true;
+ }
- if (error) {
+ if (error) {
monitor.Log.WriteLine (GettextCatalog.GetString ("Validation failed."));
TaskService.ShowErrors ();
} else {
- monitor.Log.WriteLine (GettextCatalog.GetString ("Schema is valid."));
- }
-
- monitor.EndTask ();
- return error? null: schema;
- }
-
- public static XslCompiledTransform ValidateStylesheet (ProgressMonitor monitor, string xml, string fileName)
- {
+ monitor.Log.WriteLine (GettextCatalog.GetString ("Schema is valid."));
+ }
+
+ monitor.EndTask ();
+ return error? null: schema;
+ }
+
+ public static XslCompiledTransform ValidateStylesheet (ProgressMonitor monitor, string xml, string fileName)
+ {
monitor.BeginTask (GettextCatalog.GetString ("Validating stylesheet..."), 1);
- bool error = true;
- XslCompiledTransform xslt = null;
-
- try {
- StringReader reader = new StringReader (xml);
- XPathDocument doc = new XPathDocument (reader);
- xslt = new XslCompiledTransform ();
- xslt.Load (doc, null, new XmlUrlResolver ());
- error = false;
- } catch (XsltCompileException ex) {
- monitor.ReportError (ex.Message, ex);
- AddTask (fileName, ex.Message, ex.LinePosition, ex.LineNumber,TaskSeverity.Error);
- }
- catch (XsltException ex) {
- monitor.ReportError (ex.Message, ex);
- AddTask (fileName, ex.Message, ex.LinePosition, ex.LineNumber,TaskSeverity.Error);
- }
- catch (XmlException ex) {
- monitor.ReportError (ex.Message, ex);
- AddTask (fileName, ex.Message, ex.LinePosition, ex.LineNumber,TaskSeverity.Error);
- }
-
- if (error) {
+ bool error = true;
+ XslCompiledTransform xslt = null;
+
+ try {
+ StringReader reader = new StringReader (xml);
+ XPathDocument doc = new XPathDocument (reader);
+ xslt = new XslCompiledTransform ();
+ xslt.Load (doc, null, new XmlUrlResolver ());
+ error = false;
+ } catch (XsltCompileException ex) {
+ monitor.ReportError (ex.Message, ex);
+ AddTask (fileName, ex.Message, ex.LinePosition, ex.LineNumber,TaskSeverity.Error);
+ }
+ catch (XsltException ex) {
+ monitor.ReportError (ex.Message, ex);
+ AddTask (fileName, ex.Message, ex.LinePosition, ex.LineNumber,TaskSeverity.Error);
+ }
+ catch (XmlException ex) {
+ monitor.ReportError (ex.Message, ex);
+ AddTask (fileName, ex.Message, ex.LinePosition, ex.LineNumber,TaskSeverity.Error);
+ }
+
+ if (error) {
monitor.Log.WriteLine (GettextCatalog.GetString ("Validation failed."));
TaskService.ShowErrors ();
} else {
- monitor.Log.WriteLine (GettextCatalog.GetString ("Stylesheet is valid."));
- }
- return error? null: xslt;
- }
-
- #endregion
-
- #region File browsing utilities
-
- /// <summary>Allows the user to browse the file system for a stylesheet.</summary>
- /// <returns>The stylesheet filename the user selected; otherwise null.</returns>
- public static string BrowseForStylesheetFile ()
- {
- var dlg = new SelectFileDialog (GettextCatalog.GetString ("Select XSLT Stylesheet")) {
- TransientFor = IdeApp.Workbench.RootWindow,
- };
- dlg.AddFilter (new SelectFileDialogFilter (
- GettextCatalog.GetString ("XML Files"),
- new string[] { "*.xml" },
- new string[] { "text/xml", "application/xml" }
- ));
- dlg.AddFilter (new SelectFileDialogFilter(
- GettextCatalog.GetString ("XSL Files"),
- new string[] { "*.xslt", "*.xsl" },
- new string[] { "text/x-xslt" }
- ));
- dlg.AddAllFilesFilter ();
-
- if (dlg.Run ())
- return dlg.SelectedFile;
- return null;
- }
-
- /// <summary>Allows the user to browse the file system for a schema.</summary>
- /// <returns>The schema filename the user selected; otherwise null.</returns>
- public static string BrowseForSchemaFile ()
- {
- var dlg = new SelectFileDialog (GettextCatalog.GetString ("Select XML Schema"));
- dlg.AddFilter (new SelectFileDialogFilter (
- GettextCatalog.GetString ("XML Files"),
- new string[] { "*.xsd" },
- new string[] { "text/xml", "application/xml" }
- ));
- dlg.AddAllFilesFilter ();
-
- if (dlg.Run ())
- return dlg.SelectedFile;
- return null;
- }
-
- #endregion
-
- class EncodedStringWriter : StringWriter
- {
- readonly Encoding encoding;
-
- public EncodedStringWriter(Encoding encoding)
- {
- this.encoding = encoding;
- }
-
- public override Encoding Encoding {
- get {
- return encoding;
- }
- }
+ monitor.Log.WriteLine (GettextCatalog.GetString ("Stylesheet is valid."));
+ }
+ return error? null: xslt;
+ }
+
+ #endregion
+
+ #region File browsing utilities
+
+ /// <summary>Allows the user to browse the file system for a stylesheet.</summary>
+ /// <returns>The stylesheet filename the user selected; otherwise null.</returns>
+ public static string BrowseForStylesheetFile ()
+ {
+ var dlg = new SelectFileDialog (GettextCatalog.GetString ("Select XSLT Stylesheet")) {
+ TransientFor = IdeApp.Workbench.RootWindow,
+ };
+ dlg.AddFilter (new SelectFileDialogFilter (
+ GettextCatalog.GetString ("XML Files"),
+ new string[] { "*.xml" },
+ new string[] { "text/xml", "application/xml" }
+ ));
+ dlg.AddFilter (new SelectFileDialogFilter(
+ GettextCatalog.GetString ("XSL Files"),
+ new string[] { "*.xslt", "*.xsl" },
+ new string[] { "text/x-xslt" }
+ ));
+ dlg.AddAllFilesFilter ();
+
+ if (dlg.Run ())
+ return dlg.SelectedFile;
+ return null;
+ }
+
+ /// <summary>Allows the user to browse the file system for a schema.</summary>
+ /// <returns>The schema filename the user selected; otherwise null.</returns>
+ public static string BrowseForSchemaFile ()
+ {
+ var dlg = new SelectFileDialog (GettextCatalog.GetString ("Select XML Schema"));
+ dlg.AddFilter (new SelectFileDialogFilter (
+ GettextCatalog.GetString ("XML Files"),
+ new string[] { "*.xsd" },
+ new string[] { "text/xml", "application/xml" }
+ ));
+ dlg.AddAllFilesFilter ();
+
+ if (dlg.Run ())
+ return dlg.SelectedFile;
+ return null;
+ }
+
+ #endregion
+
+ class EncodedStringWriter : StringWriter
+ {
+ readonly Encoding encoding;
+
+ public EncodedStringWriter(Encoding encoding)
+ {
+ this.encoding = encoding;
+ }
+
+ public override Encoding Encoding {
+ get {
+ return encoding;
+ }
+ }
}
}
}
diff --git a/main/src/addins/Xml/Editor/XmlParsedDocument.cs b/main/src/addins/Xml/Editor/XmlParsedDocument.cs
index bd6bc32cbf..94de472070 100644
--- a/main/src/addins/Xml/Editor/XmlParsedDocument.cs
+++ b/main/src/addins/Xml/Editor/XmlParsedDocument.cs
@@ -29,8 +29,9 @@
using System;
using System.Collections.Generic;
using MonoDevelop.Ide.TypeSystem;
-using ICSharpCode.NRefactory.TypeSystem;
using MonoDevelop.Xml.Dom;
+using MonoDevelop.Ide.Editor;
+using System.Linq;
namespace MonoDevelop.Xml.Editor
{
@@ -41,19 +42,24 @@ namespace MonoDevelop.Xml.Editor
}
public XDocument XDocument { get; set; }
-
- public override IEnumerable<FoldingRegion> Foldings {
+
+ public override System.Threading.Tasks.Task<IReadOnlyList<FoldingRegion>> GetFoldingsAsync (System.Threading.CancellationToken cancellationToken)
+ {
+ return System.Threading.Tasks.Task.FromResult((IReadOnlyList<FoldingRegion>)Foldings.ToList ());
+ }
+
+ public IEnumerable<FoldingRegion> Foldings {
get {
if (XDocument == null)
yield break;
- foreach (var region in Comments.ToFolds ())
+ foreach (var region in GetCommentsAsync().Result.ToFolds ())
yield return region;
foreach (XNode node in XDocument.AllDescendentNodes) {
if (node is XCData)
{
if (node.Region.EndLine - node.Region.BeginLine > 2)
yield return new FoldingRegion ("<![CDATA[ ]]>", node.Region);
- }
+ }
else if (node is XComment)
{
if (node.Region.EndLine - node.Region.BeginLine > 2)
@@ -65,7 +71,7 @@ namespace MonoDevelop.Xml.Editor
if (el.IsClosed && el.ClosingTag.Region.EndLine - el.Region.BeginLine > 2) {
yield return new FoldingRegion
(string.Format ("<{0}...>", el.Name.FullName),
- new DomRegion (el.Region.Begin, el.ClosingTag.Region.End));
+ new DocumentRegion (el.Region.Begin, el.ClosingTag.Region.End));
}
}
else if (node is XDocType)
diff --git a/main/src/addins/Xml/Editor/XmlTextEditorExtension.cs b/main/src/addins/Xml/Editor/XmlTextEditorExtension.cs
index 58790e1276..d04db17fd2 100644
--- a/main/src/addins/Xml/Editor/XmlTextEditorExtension.cs
+++ b/main/src/addins/Xml/Editor/XmlTextEditorExtension.cs
@@ -32,17 +32,19 @@ using System.Collections.Generic;
using System.Xml;
using System.Xml.Schema;
-using Mono.TextEditor;
-
using MonoDevelop.Components.Commands;
using MonoDevelop.Core;
using MonoDevelop.Ide;
using MonoDevelop.Ide.CodeCompletion;
using MonoDevelop.Ide.Gui.Content;
using MonoDevelop.Ide.Tasks;
+using MonoDevelop.Ide;
+using MonoDevelop.Ide.CodeFormatting;
+using MonoDevelop.Ide.Editor;
using MonoDevelop.Xml.Completion;
using MonoDevelop.Xml.Dom;
using MonoDevelop.Xml.Parser;
+using MonoDevelop.Ide.Editor.Extension;
namespace MonoDevelop.Xml.Editor
{
@@ -56,12 +58,12 @@ namespace MonoDevelop.Xml.Editor
InferredXmlCompletionProvider inferredCompletionData;
bool inferenceQueued;
- public override bool ExtendsEditor (MonoDevelop.Ide.Gui.Document doc, IEditableTextBuffer editor)
+ public override bool IsValidInContext (DocumentContext context)
{
- return IsFileNameHandled (doc.Name) && base.ExtendsEditor (doc, editor);
+ return IsFileNameHandled (context.Name) && base.IsValidInContext (context);
}
- public override void Initialize ()
+ protected override void Initialize ()
{
base.Initialize ();
XmlEditorOptions.XmlFileAssociationChanged += HandleXmlFileAssociationChanged;
@@ -69,16 +71,16 @@ namespace MonoDevelop.Xml.Editor
XmlSchemaManager.UserSchemaRemoved += UserSchemaRemoved;
SetDefaultSchema ();
- var view = Document.GetContent<MonoDevelop.SourceEditor.SourceEditorView> ();
- if (view != null && string.IsNullOrEmpty (view.Document.MimeType)) {
- view.Document.MimeType = ApplicationXmlMimeType;
- Document.ReparseDocument ();
+ //var view = Document.GetContent<MonoDevelop.SourceEditor.SourceEditorView> ();
+ if (string.IsNullOrEmpty (Editor.MimeType)) {
+ Editor.MimeType = ApplicationXmlMimeType;
+ DocumentContext.ReparseDocument ();
}
}
void HandleXmlFileAssociationChanged (object sender, XmlFileAssociationChangedEventArgs e)
{
- var filename = document.FileName;
+ var filename = DocumentContext.Name;
if (filename != null && filename.ToString ().EndsWith (e.Extension, StringComparison.Ordinal))
SetDefaultSchema ();
}
@@ -89,7 +91,8 @@ namespace MonoDevelop.Xml.Editor
if (!disposed) {
disposed = false;
XmlEditorOptions.XmlFileAssociationChanged -= HandleXmlFileAssociationChanged;
- XmlSchemaManager.UserSchemaAdded -= UserSchemaAdded;
+ XmlSchemaManager.UserSchemaAdded -= UserSchemaAdded;
+
XmlSchemaManager.UserSchemaRemoved -= UserSchemaRemoved;
base.Dispose ();
}
@@ -108,18 +111,23 @@ namespace MonoDevelop.Xml.Editor
protected override void GetElementCompletions (CompletionDataList list)
{
- var path = GetElementPath ();
+ var path = GetElementPath ();
+
if (path.Elements.Count > 0) {
IXmlCompletionProvider schema = FindSchema (path);
if (schema == null)
- schema = inferredCompletionData;
- if (schema != null) {
+ schema = inferredCompletionData;
+
+ if (schema != null) {
+
var completionData = schema.GetChildElementCompletionData (path);
if (completionData != null)
list.AddRange (completionData);
- }
+ }
+
} else if (defaultSchemaCompletionData != null) {
- list.AddRange (defaultSchemaCompletionData.GetElementCompletionData (defaultNamespacePrefix));
+ list.AddRange (defaultSchemaCompletionData.GetElementCompletionData (defaultNamespacePrefix));
+
} else if (inferredCompletionData != null) {
list.AddRange (inferredCompletionData.GetElementCompletionData ());
}
@@ -129,12 +137,15 @@ namespace MonoDevelop.Xml.Editor
protected override CompletionDataList GetAttributeCompletions (IAttributedXObject attributedOb,
Dictionary<string, string> existingAtts)
{
- var path = GetElementPath ();
+ var path = GetElementPath ();
+
if (path.Elements.Count > 0) {
IXmlCompletionProvider schema = FindSchema (path);
if (schema == null)
- schema = inferredCompletionData;
- if (schema != null)
+ schema = inferredCompletionData;
+
+ if (schema != null)
+
return schema.GetAttributeCompletionData (path);
}
return null;
@@ -142,10 +153,13 @@ namespace MonoDevelop.Xml.Editor
protected override CompletionDataList GetAttributeValueCompletions (IAttributedXObject attributedOb, XAttribute att)
{
- var path = GetElementPath ();
+ var path = GetElementPath ();
+
if (path.Elements.Count > 0) {
- var schema = FindSchema (path);
- if (schema != null)
+ var schema = FindSchema (path);
+
+ if (schema != null)
+
return schema.GetAttributeValueCompletionData (path, att.Name.FullName);
}
return null;
@@ -170,47 +184,79 @@ namespace MonoDevelop.Xml.Editor
return FindSchema (XmlSchemaManager.SchemaCompletionDataItems, path);
}
- /// <summary>
- /// Finds the schema given the xml element path.
- /// </summary>
- public XmlSchemaCompletionData FindSchema (IXmlSchemaCompletionDataCollection schemaCompletionDataItems, XmlElementPath path)
- {
- if (path.Elements.Count > 0) {
- string namespaceUri = path.Elements[0].Namespace;
- if (namespaceUri.Length > 0) {
- return schemaCompletionDataItems[namespaceUri];
- } else if (defaultSchemaCompletionData != null) {
-
- // Use the default schema namespace if none
- // specified in a xml element path, otherwise
- // we will not find any attribute or element matches
- // later.
- foreach (QualifiedName name in path.Elements) {
- if (name.Namespace.Length == 0) {
- name.Namespace = defaultSchemaCompletionData.NamespaceUri;
- }
- }
- return defaultSchemaCompletionData;
- }
- }
- return null;
+ /// <summary>
+
+ /// Finds the schema given the xml element path.
+
+ /// </summary>
+
+ public XmlSchemaCompletionData FindSchema (IXmlSchemaCompletionDataCollection schemaCompletionDataItems, XmlElementPath path)
+
+ {
+
+ if (path.Elements.Count > 0) {
+
+ string namespaceUri = path.Elements[0].Namespace;
+
+ if (namespaceUri.Length > 0) {
+
+ return schemaCompletionDataItems[namespaceUri];
+
+ } else if (defaultSchemaCompletionData != null) {
+
+
+
+ // Use the default schema namespace if none
+
+ // specified in a xml element path, otherwise
+
+ // we will not find any attribute or element matches
+
+ // later.
+
+ foreach (QualifiedName name in path.Elements) {
+
+ if (name.Namespace.Length == 0) {
+
+ name.Namespace = defaultSchemaCompletionData.NamespaceUri;
+
+ }
+
+ }
+
+ return defaultSchemaCompletionData;
+
+ }
+
+ }
+
+ return null;
+
}
#endregion
#region Schema resolution
- /// <summary>
- /// Gets the XmlSchemaObject that defines the currently selected xml element or attribute.
- /// </summary>
+ /// <summary>
+
+ /// Gets the XmlSchemaObject that defines the currently selected xml element or attribute.
+
+ /// </summary>
+
/// <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 GetSchemaObjectSelected (XmlSchemaCompletionData currentSchemaCompletionData)
- {
- // Find element under cursor.
+ /// displayed. This can be null if the document is not a schema.</param>
+
+ public XmlSchemaObject GetSchemaObjectSelected (XmlSchemaCompletionData currentSchemaCompletionData)
+
+ {
+
+ // Find element under cursor.
+
XmlElementPath path = GetElementPath ();
- //attribute name under cursor, if valid
+ //attribute name under cursor, if valid
+
string attributeName = null;
XAttribute xatt = Tracker.Engine.Nodes.Peek (0) as XAttribute;
if (xatt != null) {
@@ -219,173 +265,306 @@ namespace MonoDevelop.Xml.Editor
xattName = GetCompleteName ();
}
attributeName = xattName.FullName;
- }
+ }
+
- // Find schema definition object.
- XmlSchemaCompletionData schemaCompletionData = FindSchema (path);
- XmlSchemaObject schemaObject = null;
+ // Find schema definition object.
+
+ XmlSchemaCompletionData schemaCompletionData = FindSchema (path);
+
+ XmlSchemaObject schemaObject = null;
+
if (schemaCompletionData != null) {
- XmlSchemaElement element = schemaCompletionData.FindElement(path);
- schemaObject = element;
+ XmlSchemaElement element = schemaCompletionData.FindElement(path);
+
+ schemaObject = element;
+
if (element != null) {
if (!string.IsNullOrEmpty (attributeName)) {
- XmlSchemaAttribute attribute = schemaCompletionData.FindAttribute(element, attributeName);
+ XmlSchemaAttribute attribute = schemaCompletionData.FindAttribute(element, attributeName);
+
if (attribute != null) {
- if (currentSchemaCompletionData != null) {
- schemaObject = GetSchemaObjectReferenced (currentSchemaCompletionData, element, attribute);
- } else {
- schemaObject = attribute;
- }
- }
- }
- return schemaObject;
- }
- }
- return null;
- }
-
- /// <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 GetSchemaObjectReferenced (XmlSchemaCompletionData currentSchemaCompletionData, XmlSchemaElement element, XmlSchemaAttribute attribute)
- {
- XmlSchemaObject schemaObject = null;
- if (IsXmlSchemaNamespace(element)) {
+ if (currentSchemaCompletionData != null) {
+
+ schemaObject = GetSchemaObjectReferenced (currentSchemaCompletionData, element, attribute);
+
+ } else {
+
+ schemaObject = attribute;
+
+ }
+
+ }
+
+ }
+
+ return schemaObject;
+
+ }
+
+ }
+
+ return null;
+
+ }
+
+ /// <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 GetSchemaObjectReferenced (XmlSchemaCompletionData currentSchemaCompletionData, XmlSchemaElement element, XmlSchemaAttribute attribute)
+
+ {
+
+ XmlSchemaObject schemaObject = null;
+
+ if (IsXmlSchemaNamespace(element)) {
+
// Find attribute value.
- //fixme implement
- string attributeValue = "";// XmlParser.GetAttributeValueAtIndex(xml, index);
- if (attributeValue.Length == 0) {
- return attribute;
- }
-
- if (attribute.Name == "ref") {
- schemaObject = FindSchemaObjectReference(attributeValue, currentSchemaCompletionData, element.Name);
- } else if (attribute.Name == "type") {
- schemaObject = FindSchemaObjectType(attributeValue, currentSchemaCompletionData, element.Name);
- }
- }
-
- if (schemaObject != null) {
- return schemaObject;
- }
- return attribute;
- }
-
- /// <summary>
- /// Checks whether the element belongs to the XSD namespace.
- /// </summary>
- static bool IsXmlSchemaNamespace (XmlSchemaElement element)
- {
- XmlQualifiedName qualifiedName = element.QualifiedName;
- if (qualifiedName != null) {
- return XmlSchemaManager.IsXmlSchemaNamespace (qualifiedName.Namespace);
- }
- return false;
- }
-
- /// <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, XmlSchemaCompletionData schemaCompletionData, string elementName)
- {
- QualifiedName qualifiedName = schemaCompletionData.CreateQualifiedName(name);
- XmlSchemaCompletionData qualifiedNameSchema = FindSchema(qualifiedName.Namespace);
- if (qualifiedNameSchema != null) {
- schemaCompletionData = qualifiedNameSchema;
- }
- switch (elementName) {
- case "element":
- return schemaCompletionData.FindElement(qualifiedName);
- case "attribute":
- return schemaCompletionData.FindAttribute(qualifiedName.Name);
- case "group":
- return schemaCompletionData.FindGroup(qualifiedName.Name);
- case "attributeGroup":
- return schemaCompletionData.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>
- XmlSchemaObject FindSchemaObjectType(string name, XmlSchemaCompletionData schemaCompletionData, string elementName)
- {
- QualifiedName qualifiedName = schemaCompletionData.CreateQualifiedName(name);
- XmlSchemaCompletionData qualifiedNameSchema = FindSchema(qualifiedName.Namespace);
- if (qualifiedNameSchema != null) {
- schemaCompletionData = qualifiedNameSchema;
- }
- switch (elementName) {
- case "element":
- return schemaCompletionData.FindComplexType(qualifiedName);
- case "attribute":
- return schemaCompletionData.FindSimpleType(qualifiedName.Name);
- }
- return null;
+ //fixme implement
+
+ string attributeValue = "";// XmlParser.GetAttributeValueAtIndex(xml, index);
+
+ if (attributeValue.Length == 0) {
+
+ return attribute;
+
+ }
+
+
+
+ if (attribute.Name == "ref") {
+
+ schemaObject = FindSchemaObjectReference(attributeValue, currentSchemaCompletionData, element.Name);
+
+ } else if (attribute.Name == "type") {
+
+ schemaObject = FindSchemaObjectType(attributeValue, currentSchemaCompletionData, element.Name);
+
+ }
+
+ }
+
+
+
+ if (schemaObject != null) {
+
+ return schemaObject;
+
+ }
+
+ return attribute;
+
+ }
+
+ /// <summary>
+
+ /// Checks whether the element belongs to the XSD namespace.
+
+ /// </summary>
+
+ static bool IsXmlSchemaNamespace (XmlSchemaElement element)
+
+ {
+
+ XmlQualifiedName qualifiedName = element.QualifiedName;
+
+ if (qualifiedName != null) {
+
+ return XmlSchemaManager.IsXmlSchemaNamespace (qualifiedName.Namespace);
+
+ }
+
+ return false;
+
+ }
+
+ /// <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, XmlSchemaCompletionData schemaCompletionData, string elementName)
+
+ {
+
+ QualifiedName qualifiedName = schemaCompletionData.CreateQualifiedName(name);
+
+ XmlSchemaCompletionData qualifiedNameSchema = FindSchema(qualifiedName.Namespace);
+
+ if (qualifiedNameSchema != null) {
+
+ schemaCompletionData = qualifiedNameSchema;
+
+ }
+
+ switch (elementName) {
+
+ case "element":
+
+ return schemaCompletionData.FindElement(qualifiedName);
+
+ case "attribute":
+
+ return schemaCompletionData.FindAttribute(qualifiedName.Name);
+
+ case "group":
+
+ return schemaCompletionData.FindGroup(qualifiedName.Name);
+
+ case "attributeGroup":
+
+ return schemaCompletionData.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>
+
+ XmlSchemaObject FindSchemaObjectType(string name, XmlSchemaCompletionData schemaCompletionData, string elementName)
+
+ {
+
+ QualifiedName qualifiedName = schemaCompletionData.CreateQualifiedName(name);
+
+ XmlSchemaCompletionData qualifiedNameSchema = FindSchema(qualifiedName.Namespace);
+
+ if (qualifiedNameSchema != null) {
+
+ schemaCompletionData = qualifiedNameSchema;
+
+ }
+
+ switch (elementName) {
+
+ case "element":
+
+ return schemaCompletionData.FindComplexType(qualifiedName);
+
+ case "attribute":
+
+ return schemaCompletionData.FindSimpleType(qualifiedName.Name);
+
+ }
+
+ return null;
+
}
#endregion
#region Settings handling
- void SetDefaultSchema ()
+ void SetDefaultSchema ()
+
{
- var filename = document.FileName;
+ var filename = DocumentContext.Name;
if (filename == null)
return;
-
+
+
defaultSchemaCompletionData = XmlSchemaManager.GetSchemaCompletionDataForFileName (filename);
if (defaultSchemaCompletionData != null)
inferredCompletionData = null;
else
- QueueInference ();
- defaultNamespacePrefix = XmlSchemaManager.GetNamespacePrefixForFileName (filename);
- }
-
- /// Updates the default schema association since the schema may have been added.
- void UserSchemaAdded (object source, EventArgs e)
+ QueueInference ();
+
+ defaultNamespacePrefix = XmlSchemaManager.GetNamespacePrefixForFileName (filename);
+
+ }
+
+
+
+ /// Updates the default schema association since the schema may have been added.
+
+ void UserSchemaAdded (object source, EventArgs e)
+
{
SetDefaultSchema ();
- }
-
- // Updates the default schema association since the schema may have been removed.
- void UserSchemaRemoved (object source, EventArgs e)
- {
- SetDefaultSchema ();
+ }
+
+
+
+ // Updates the default schema association since the schema may have been removed.
+
+ void UserSchemaRemoved (object source, EventArgs e)
+
+ {
+
+ SetDefaultSchema ();
+
}
#endregion
#region Stylesheet handling
- /// <summary>
- /// Gets or sets the stylesheet associated with this xml file.
- /// </summary>
- public string StylesheetFileName {
- get { return stylesheetFileName; }
- set { stylesheetFileName = value; }
+ /// <summary>
+
+ /// Gets or sets the stylesheet associated with this xml file.
+
+ /// </summary>
+
+ public string StylesheetFileName {
+
+ get { return stylesheetFileName; }
+
+ set { stylesheetFileName = value; }
+
}
#endregion
@@ -430,16 +609,17 @@ namespace MonoDevelop.Xml.Editor
#region Smart indent
- public override bool KeyPress (Gdk.Key key, char keyChar, Gdk.ModifierType modifier)
+ public override bool KeyPress (KeyDescriptor descriptor)
{
bool result;
-
- if (Document.Editor.Options.IndentStyle == IndentStyle.Smart && key == Gdk.Key.Return) {
- result = base.KeyPress (key, keyChar, modifier);
- SmartIndentLine (Editor.Caret.Line);
+
+
+ if (Editor.Options.IndentStyle == IndentStyle.Smart && descriptor.SpecialKey == SpecialKey.Return) {
+ result = base.KeyPress (descriptor);
+ SmartIndentLine (Editor.CaretLine);
return result;
}
- return base.KeyPress (key, keyChar, modifier);
+ return base.KeyPress (descriptor);
}
void SmartIndentLine (int line)
@@ -500,8 +680,10 @@ namespace MonoDevelop.Xml.Editor
[CommandHandler (XmlCommands.CreateSchema)]
public void CreateSchemaCommand ()
{
- try {
- TaskService.Errors.Clear ();
+ try {
+
+ TaskService.Errors.Clear ();
+
string xml = Editor.Text;
using (ProgressMonitor monitor = XmlEditorService.GetMonitor ()) {
XmlDocument doc = XmlEditorService.ValidateWellFormedness (monitor, xml, FileName);
@@ -509,7 +691,8 @@ namespace MonoDevelop.Xml.Editor
return;
monitor.BeginTask (GettextCatalog.GetString ("Creating schema..."), 0);
try {
- string schema = XmlEditorService.CreateSchema (Document, xml);
+ string schema = XmlEditorService.CreateSchema (Editor, xml);
+
string fileName = XmlEditorService.GenerateFileName (FileName, "{0}.xsd");
IdeApp.Workbench.NewDocument (fileName, "application/xml", schema);
monitor.ReportSuccess (GettextCatalog.GetString ("Schema created."));
@@ -518,22 +701,30 @@ namespace MonoDevelop.Xml.Editor
LoggingService.LogError (msg, ex);
monitor.ReportError (msg, ex);
}
- }
- } catch (Exception ex) {
- MessageService.ShowError (ex.Message);
+ }
+
+ } catch (Exception ex) {
+
+ MessageService.ShowError (ex.Message);
+
}
}
[CommandHandler (XmlCommands.OpenStylesheet)]
public void OpenStylesheetCommand ()
- {
- if (!string.IsNullOrEmpty (stylesheetFileName)) {
- try {
- IdeApp.Workbench.OpenDocument (stylesheetFileName, Document.Project);
+ {
+
+ if (!string.IsNullOrEmpty (stylesheetFileName)) {
+
+ try {
+
+ IdeApp.Workbench.OpenDocument (stylesheetFileName, DocumentContext.Project);
+
} catch (Exception ex) {
- MessageService.ShowError ("Could not open document.", ex);
- }
- }
+ LoggingService.LogError ("Could not open document.", ex);
+ MessageService.ShowException (ex, "Could not open document.");
+ }
+ }
}
[CommandUpdateHandler (XmlCommands.OpenStylesheet)]
@@ -546,21 +737,28 @@ namespace MonoDevelop.Xml.Editor
public void GoToSchemaDefinitionCommand ()
{
try {
- //try to resolve the schema
- XmlSchemaCompletionData currentSchemaCompletionData = FindSchemaFromFileName (FileName);
- XmlSchemaObject schemaObject = GetSchemaObjectSelected (currentSchemaCompletionData);
-
- // Open schema if resolved
- if (schemaObject != null && schemaObject.SourceUri != null && schemaObject.SourceUri.Length > 0) {
+ //try to resolve the schema
+
+ XmlSchemaCompletionData currentSchemaCompletionData = FindSchemaFromFileName (FileName);
+
+ XmlSchemaObject schemaObject = GetSchemaObjectSelected (currentSchemaCompletionData);
+
+
+
+ // Open schema if resolved
+
+ if (schemaObject != null && schemaObject.SourceUri != null && schemaObject.SourceUri.Length > 0) {
+
string schemaFileName = schemaObject.SourceUri.Replace ("file:/", String.Empty);
IdeApp.Workbench.OpenDocument (
schemaFileName,
- Document.Project,
+ DocumentContext.Project,
Math.Max (1, schemaObject.LineNumber),
Math.Max (1, schemaObject.LinePosition));
}
} catch (Exception ex) {
- MessageService.ShowError ("Could not open document.", ex);
+ MonoDevelop.Core.LoggingService.LogError ("Could not open document.", ex);
+ MessageService.ShowException (ex, "Could not open document.");
}
}
@@ -571,7 +769,8 @@ namespace MonoDevelop.Xml.Editor
using (ProgressMonitor monitor = XmlEditorService.GetMonitor()) {
if (IsSchema)
XmlEditorService.ValidateSchema (monitor, Editor.Text, FileName);
- else
+ else
+
XmlEditorService.ValidateXml (monitor, Editor.Text, FileName);
}
}
@@ -579,17 +778,22 @@ namespace MonoDevelop.Xml.Editor
[CommandHandler (XmlCommands.AssignStylesheet)]
public void AssignStylesheetCommand ()
{
- // Prompt user for filename.
- string fileName = XmlEditorService.BrowseForStylesheetFile ();
- if (!string.IsNullOrEmpty (stylesheetFileName))
+ // Prompt user for filename.
+
+ string fileName = XmlEditorService.BrowseForStylesheetFile ();
+
+ if (!string.IsNullOrEmpty (stylesheetFileName))
+
stylesheetFileName = fileName;
}
[CommandHandler (XmlCommands.RunXslTransform)]
public void RunXslTransformCommand ()
{
- if (string.IsNullOrEmpty (stylesheetFileName)) {
- stylesheetFileName = XmlEditorService.BrowseForStylesheetFile ();
+ if (string.IsNullOrEmpty (stylesheetFileName)) {
+
+ stylesheetFileName = XmlEditorService.BrowseForStylesheetFile ();
+
if (string.IsNullOrEmpty (stylesheetFileName))
return;
}
@@ -616,7 +820,7 @@ namespace MonoDevelop.Xml.Editor
string newFileName = XmlEditorService.GenerateFileName (FileName, "-transformed{0}.xml");
monitor.BeginTask (GettextCatalog.GetString ("Executing transform..."), 1);
- using (XmlTextWriter output = XmlEditorService.CreateXmlTextWriter(Document)) {
+ using (XmlTextWriter output = XmlEditorService.CreateXmlTextWriter(Editor)) {
xslt.Transform (doc, null, output);
IdeApp.Workbench.NewDocument (
newFileName, "application/xml", output.ToString ());
@@ -626,19 +830,24 @@ namespace MonoDevelop.Xml.Editor
} catch (Exception ex) {
string msg = GettextCatalog.GetString ("Could not run transform.");
monitor.ReportError (msg, ex);
- monitor.EndTask ();
+ monitor.EndTask ();
+
}
}
}
- string GetFileContent (string fileName)
+ string GetFileContent (string fileName)
+
{
- MonoDevelop.Projects.Text.IEditableTextFile tf =
- MonoDevelop.Ide.TextFileProvider.Instance.GetEditableTextFile (fileName);
+ var tf =
+ MonoDevelop.Ide.TextFileProvider.Instance.GetReadOnlyTextEditorData (fileName);
if (tf != null)
- return tf.Text;
- System.IO.StreamReader reader = new System.IO.StreamReader (fileName, true);
- return reader.ReadToEnd();
+ return tf.Text;
+
+ System.IO.StreamReader reader = new System.IO.StreamReader (fileName, true);
+
+ return reader.ReadToEnd();
+
}
#endregion
@@ -650,7 +859,7 @@ namespace MonoDevelop.Xml.Editor
return;
if (inferredCompletionData == null
|| (doc.LastWriteTimeUtc - inferredCompletionData.TimeStampUtc).TotalSeconds >= 5
- && doc.Errors.Count <= inferredCompletionData.ErrorCount)
+ && doc.GetErrorsAsync().Result.Count <= inferredCompletionData.ErrorCount)
{
inferenceQueued = true;
System.Threading.ThreadPool.QueueUserWorkItem (delegate {
@@ -658,7 +867,7 @@ namespace MonoDevelop.Xml.Editor
InferredXmlCompletionProvider newData = new InferredXmlCompletionProvider ();
newData.Populate (doc.XDocument);
newData.TimeStampUtc = DateTime.UtcNow;
- newData.ErrorCount = doc.Errors.Count;
+ newData.ErrorCount = doc.GetErrorsAsync().Result.Count;
this.inferenceQueued = false;
this.inferredCompletionData = newData;
} catch (Exception ex) {
diff --git a/main/src/addins/Xml/MSBuild/MSBuildResolveContext.cs b/main/src/addins/Xml/MSBuild/MSBuildResolveContext.cs
index bb01db9027..b9de149700 100644
--- a/main/src/addins/Xml/MSBuild/MSBuildResolveContext.cs
+++ b/main/src/addins/Xml/MSBuild/MSBuildResolveContext.cs
@@ -82,7 +82,7 @@ namespace MonoDevelop.Xml.MSBuild
{
var ctx = new MSBuildResolveContext ();
ctx.Populate (doc.XDocument);
- if (doc.Errors.Count > 0)
+ if (doc.GetErrorsAsync().Result.Count > 0)
ctx.Merge (previous);
return ctx;
}
diff --git a/main/src/addins/Xml/MonoDevelop.Xml.csproj b/main/src/addins/Xml/MonoDevelop.Xml.csproj
index 5a796abe25..8637fab210 100644
--- a/main/src/addins/Xml/MonoDevelop.Xml.csproj
+++ b/main/src/addins/Xml/MonoDevelop.Xml.csproj
@@ -66,6 +66,10 @@
<SpecificVersion>False</SpecificVersion>
</Reference>
<Reference Include="System.Core" />
+ <Reference Include="Microsoft.CodeAnalysis">
+ <HintPath>..\..\..\build\bin\Microsoft.CodeAnalysis.dll</HintPath>
+ <Private>False</Private>
+ </Reference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\core\MonoDevelop.Core\MonoDevelop.Core.csproj">
@@ -83,26 +87,11 @@
<Name>MonoDevelop.DesignerSupport</Name>
<Private>False</Private>
</ProjectReference>
- <ProjectReference Include="..\MonoDevelop.SourceEditor2\MonoDevelop.SourceEditor.csproj">
- <Project>{F8F92AA4-A376-4679-A9D4-60E7B7FBF477}</Project>
- <Name>MonoDevelop.SourceEditor</Name>
- <Private>False</Private>
- </ProjectReference>
- <ProjectReference Include="..\..\core\Mono.Texteditor\Mono.TextEditor.csproj">
- <Project>{A2329308-3751-4DBD-9A75-5F7B8B024625}</Project>
- <Name>Mono.TextEditor</Name>
- <Private>False</Private>
- </ProjectReference>
<ProjectReference Include="..\MonoDevelop.Debugger\MonoDevelop.Debugger.csproj">
<Project>{2357AABD-08C7-4808-A495-8FF2D3CDFDB0}</Project>
<Name>MonoDevelop.Debugger</Name>
<Private>False</Private>
</ProjectReference>
- <ProjectReference Include="..\..\..\external\nrefactory\ICSharpCode.NRefactory\ICSharpCode.NRefactory.csproj">
- <Project>{3B2A5653-EC97-4001-BB9B-D90F1AF2C371}</Project>
- <Name>ICSharpCode.NRefactory</Name>
- <Private>False</Private>
- </ProjectReference>
<ProjectReference Include="..\..\..\external\mono-addins\Mono.Addins\Mono.Addins.csproj">
<Project>{91DD5A2D-9FE3-4C3C-9253-876141874DAD}</Project>
<Name>Mono.Addins</Name>
@@ -118,6 +107,11 @@
<Name>Xwt</Name>
<Private>False</Private>
</ProjectReference>
+ <ProjectReference Include="..\..\..\external\NRefactory6\ICSharpCode.NRefactory.CSharp\ICSharpCode.NRefactory6.CSharp.csproj">
+ <Project>{7E891659-45F3-42B5-B940-A728780CCAE9}</Project>
+ <Name>ICSharpCode.NRefactory6.CSharp</Name>
+ <Private>False</Private>
+ </ProjectReference>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="icons\prefs-xml-16.png">
diff --git a/main/src/addins/Xml/Parser/XmlDocTypeState.cs b/main/src/addins/Xml/Parser/XmlDocTypeState.cs
index fc8103e8fd..2445422939 100644
--- a/main/src/addins/Xml/Parser/XmlDocTypeState.cs
+++ b/main/src/addins/Xml/Parser/XmlDocTypeState.cs
@@ -27,9 +27,8 @@
//
using System;
-using ICSharpCode.NRefactory.TypeSystem;
-using ICSharpCode.NRefactory;
using MonoDevelop.Xml.Dom;
+using MonoDevelop.Ide.Editor;
namespace MonoDevelop.Xml.Parser
{
@@ -132,7 +131,7 @@ namespace MonoDevelop.Xml.Parser
switch (context.StateTag) {
case 0:
if (c == '[') {
- doc.InternalDeclarationRegion = new DomRegion (context.Location, TextLocation.Empty);
+ doc.InternalDeclarationRegion = new DocumentRegion (context.Location, DocumentLocation.Empty);
context.StateTag = 1;
return null;
}
@@ -143,7 +142,7 @@ namespace MonoDevelop.Xml.Parser
return null;
} else if (c == ']') {
context.StateTag = 0;
- doc.InternalDeclarationRegion = new DomRegion (doc.InternalDeclarationRegion.Begin, context.Location);
+ doc.InternalDeclarationRegion = new DocumentRegion (doc.InternalDeclarationRegion.Begin, context.Location);
return null;
}
break;
diff --git a/main/src/addins/Xml/Parser/XmlParser.cs b/main/src/addins/Xml/Parser/XmlParser.cs
index de40145786..72d8f726e6 100644
--- a/main/src/addins/Xml/Parser/XmlParser.cs
+++ b/main/src/addins/Xml/Parser/XmlParser.cs
@@ -30,10 +30,10 @@ using System;
using System.Collections.Generic;
using System.Text;
-using ICSharpCode.NRefactory;
-using ICSharpCode.NRefactory.TypeSystem;
using MonoDevelop.Ide.Gui.Content;
-using MonoDevelop.Xml.Dom;
+using MonoDevelop.Xml.Dom;
+using MonoDevelop.Ide.Editor;
+using MonoDevelop.Ide.TypeSystem;
namespace MonoDevelop.Xml.Parser
{
@@ -45,8 +45,8 @@ namespace MonoDevelop.Xml.Parser
bool buildTree;
int position;
- TextLocation location;
- TextLocation previousLineEnd;
+ DocumentLocation location;
+ DocumentLocation previousLineEnd;
int stateTag;
StringBuilder keywordBuilder;
int currentStateLength;
@@ -94,7 +94,7 @@ namespace MonoDevelop.Xml.Parser
#region IDocumentStateEngine
public int Position { get { return position; } }
- public TextLocation Location { get { return location; } }
+ public DocumentLocation Location { get { return location; } }
public void Reset ()
{
@@ -102,8 +102,8 @@ namespace MonoDevelop.Xml.Parser
previousState = rootState;
position = 0;
stateTag = 0;
- location = new TextLocation (1, 1);
- previousLineEnd = TextLocation.Empty;
+ location = new DocumentLocation (1, 1);
+ previousLineEnd = DocumentLocation.Empty;
keywordBuilder = new StringBuilder ();
currentStateLength = 0;
nodes = new NodeStack ();
@@ -131,10 +131,10 @@ namespace MonoDevelop.Xml.Parser
//FIXME: position/location should be at current char, not after it
position++;
if (c == '\n') {
- previousLineEnd = new TextLocation (location.Line, location.Column + 1);
- location = new TextLocation (location.Line + 1, 1);
+ previousLineEnd = new DocumentLocation (location.Line, location.Column + 1);
+ location = new DocumentLocation (location.Line + 1, 1);
} else {
- location = new TextLocation (location.Line, location.Column + 1);
+ location = new DocumentLocation (location.Line, location.Column + 1);
}
for (int loopLimit = 0; loopLimit < 10; loopLimit++) {
@@ -172,7 +172,7 @@ namespace MonoDevelop.Xml.Parser
//rollback position and location so they're valid
position -= (rollback.Length + 1);
- location = new TextLocation (location.Line, location.Column - (rollback.Length + 1));
+ location = new DocumentLocation (location.Line, location.Column - (rollback.Length + 1));
if (location.Column < 0)
throw new InvalidOperationException ("Can't roll back across line boundary");
@@ -181,7 +181,7 @@ namespace MonoDevelop.Xml.Parser
//restore position and location
position++;
- location = new TextLocation (location.Line, location.Column + 1);
+ location = new DocumentLocation (location.Line, location.Column + 1);
}
throw new InvalidOperationException ("Too many state changes for char '" + c + "'. Current state is " + currentState.ToString () + ".");
} catch (Exception ex) {
@@ -253,8 +253,8 @@ namespace MonoDevelop.Xml.Parser
builder.AppendLine ("Errors=");
foreach (Error err in errors) {
builder.Append (' ', 4);
- builder.AppendFormat ("[{0}@{1}:{2}, {3}]\n", err.ErrorType, err.Region.BeginLine,
- err.Region.BeginColumn, err.Message);
+ builder.AppendFormat ("[{0}@{1}:{2}, {3}]\n", err.ErrorType, err.Region.Begin.Line,
+ err.Region.Begin.Column, err.Message);
}
}
@@ -269,7 +269,7 @@ namespace MonoDevelop.Xml.Parser
set { stateTag = value; }
}
- TextLocation IXmlParserContext.LocationMinus (int colOffset)
+ DocumentLocation IXmlParserContext.LocationMinus (int colOffset)
{
int col = Location.Column - colOffset;
int line = Location.Line;
@@ -279,7 +279,7 @@ namespace MonoDevelop.Xml.Parser
System.Diagnostics.Debug.Assert (col > 0);
}
System.Diagnostics.Debug.Assert (line > 0);
- return new TextLocation (line, col);
+ return new DocumentLocation (line, col);
}
StringBuilder IXmlParserContext.KeywordBuilder {
@@ -307,25 +307,25 @@ namespace MonoDevelop.Xml.Parser
InternalLogError (new Error (ErrorType.Warning, message, ((IXmlParserContext)this).LocationMinus (1)));
}
- void IXmlParserContext.LogError (string message, TextLocation location)
+ void IXmlParserContext.LogError (string message, DocumentLocation location)
{
if (errors != null || ErrorLogged != null)
InternalLogError (new Error (ErrorType.Error, message, ((IXmlParserContext)this).LocationMinus (1)));
}
- void IXmlParserContext.LogWarning (string message, TextLocation location)
+ void IXmlParserContext.LogWarning (string message, DocumentLocation location)
{
if (errors != null || ErrorLogged != null)
InternalLogError (new Error (ErrorType.Warning, message, location));
}
- void IXmlParserContext.LogError (string message, DomRegion region)
+ void IXmlParserContext.LogError (string message, DocumentRegion region)
{
if (errors != null || ErrorLogged != null)
InternalLogError (new Error (ErrorType.Error, message, region));
}
- void IXmlParserContext.LogWarning (string message, DomRegion region)
+ void IXmlParserContext.LogWarning (string message, DocumentRegion region)
{
if (errors != null || ErrorLogged != null)
InternalLogError (new Error (ErrorType.Warning, message, region));
@@ -382,17 +382,17 @@ namespace MonoDevelop.Xml.Parser
int StateTag { get; set; }
StringBuilder KeywordBuilder { get; }
int CurrentStateLength { get; }
- TextLocation Location { get; }
- TextLocation LocationMinus (int colOffset);
+ DocumentLocation Location { get; }
+ DocumentLocation LocationMinus (int colOffset);
XmlParserState PreviousState { get; }
NodeStack Nodes { get; }
bool BuildTree { get; }
void LogError (string message);
void LogWarning (string message);
- void LogError (string message, TextLocation location);
- void LogWarning (string message, TextLocation location);
- void LogError (string message, DomRegion region);
- void LogWarning (string message, DomRegion region);
+ void LogError (string message, DocumentLocation location);
+ void LogWarning (string message, DocumentLocation location);
+ void LogError (string message, DocumentRegion region);
+ void LogWarning (string message, DocumentRegion region);
void EndAll (bool pop);
void ConnectAll ();
}
diff --git a/main/src/addins/Xml/Parser/XmlRootState.cs b/main/src/addins/Xml/Parser/XmlRootState.cs
index d77d7e787b..bdc49a57a9 100644
--- a/main/src/addins/Xml/Parser/XmlRootState.cs
+++ b/main/src/addins/Xml/Parser/XmlRootState.cs
@@ -26,8 +26,8 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-using ICSharpCode.NRefactory.TypeSystem;
-using MonoDevelop.Xml.Dom;
+using MonoDevelop.Xml.Dom;
+using MonoDevelop.Ide.Editor;
namespace MonoDevelop.Xml.Parser
{
@@ -106,7 +106,7 @@ namespace MonoDevelop.Xml.Parser
if (c == '<') {
if (context.StateTag != FREE)
context.LogError ("Incomplete tag opening; encountered unexpected '<'.",
- new DomRegion (
+ new DocumentRegion (
context.LocationMinus (LengthFromOpenBracket (context) + 1),
context.LocationMinus (1)));
context.StateTag = BRACKET;
@@ -176,7 +176,7 @@ namespace MonoDevelop.Xml.Parser
}
context.LogError ("Incomplete tag opening; encountered unexpected character '" + c + "'.",
- new DomRegion (
+ new DocumentRegion (
context.LocationMinus (LengthFromOpenBracket (context)),
context.Location));
diff --git a/main/src/addins/Xml/Parser/XmlTagState.cs b/main/src/addins/Xml/Parser/XmlTagState.cs
index 20de1d46ec..604613a88c 100644
--- a/main/src/addins/Xml/Parser/XmlTagState.cs
+++ b/main/src/addins/Xml/Parser/XmlTagState.cs
@@ -27,19 +27,19 @@
//
using System;
-using System.Diagnostics;
-using ICSharpCode.NRefactory;
-using MonoDevelop.Xml.Dom;
-
+using System.Diagnostics;
+using MonoDevelop.Xml.Dom;
+using MonoDevelop.Ide.Editor;
+
namespace MonoDevelop.Xml.Parser
{
public class XmlTagState : XmlParserState
- {
- const int ATTEMPT_RECOVERY = 1;
- const int RECOVERY_FOUND_WHITESPACE = 2;
- const int MAYBE_SELF_CLOSING = 2;
+ {
+ const int ATTEMPT_RECOVERY = 1;
+ const int RECOVERY_FOUND_WHITESPACE = 2;
+ const int MAYBE_SELF_CLOSING = 2;
const int OK = 0;
readonly XmlAttributeState AttributeState;
@@ -49,16 +49,16 @@ namespace MonoDevelop.Xml.Parser
public XmlTagState (XmlAttributeState attributeState)
: this (attributeState, new XmlNameState ()) {}
-
- public XmlTagState (XmlAttributeState attributeState, XmlNameState nameState)
+
+ public XmlTagState (XmlAttributeState attributeState, XmlNameState nameState)
{
this.AttributeState = attributeState;
this.NameState = nameState;
Adopt (this.AttributeState);
- Adopt (this.NameState);
+ Adopt (this.NameState);
}
-
+
public override XmlParserState PushChar (char c, IXmlParserContext context, ref string rollback)
{
XElement element = context.Nodes.Peek () as XElement;
@@ -105,33 +105,33 @@ namespace MonoDevelop.Xml.Parser
Close (element, context, context.Location);
}
return Parent;
- }
-
- if (c == '/') {
- context.StateTag = MAYBE_SELF_CLOSING;
- return null;
- }
-
- if (context.StateTag == ATTEMPT_RECOVERY) {
- if (XmlChar.IsWhitespace (c)) {
- context.StateTag = RECOVERY_FOUND_WHITESPACE;
- }
- return null;
- }
-
- if (context.StateTag == RECOVERY_FOUND_WHITESPACE) {
- if (!XmlChar.IsFirstNameChar (c))
- return null;
- }
-
- context.StateTag = OK;
-
+ }
+
+ if (c == '/') {
+ context.StateTag = MAYBE_SELF_CLOSING;
+ return null;
+ }
+
+ if (context.StateTag == ATTEMPT_RECOVERY) {
+ if (XmlChar.IsWhitespace (c)) {
+ context.StateTag = RECOVERY_FOUND_WHITESPACE;
+ }
+ return null;
+ }
+
+ if (context.StateTag == RECOVERY_FOUND_WHITESPACE) {
+ if (!XmlChar.IsFirstNameChar (c))
+ return null;
+ }
+
+ context.StateTag = OK;
+
if (!element.IsNamed && XmlChar.IsFirstNameChar (c)) {
rollback = string.Empty;
- return NameState;
- }
-
- if (context.CurrentStateLength > 1 && XmlChar.IsFirstNameChar (c)) {
+ return NameState;
+ }
+
+ if (context.CurrentStateLength > 1 && XmlChar.IsFirstNameChar (c)) {
rollback = string.Empty;
return AttributeState;
}
@@ -139,17 +139,17 @@ namespace MonoDevelop.Xml.Parser
if (XmlChar.IsWhitespace (c))
return null;
- context.LogError ("Unexpected character '" + c + "' in tag.", context.LocationMinus (1));
+ context.LogError ("Unexpected character '" + c + "' in tag.", context.LocationMinus (1));
context.StateTag = ATTEMPT_RECOVERY;
- return null;
+ return null;
}
- protected virtual void Close (XElement element, IXmlParserContext context, TextLocation location)
+ protected virtual void Close (XElement element, IXmlParserContext context, DocumentLocation location)
{
//have already checked that element is not null, i.e. top of stack is our element
if (element.IsClosed)
- context.Nodes.Pop ();
-
+ context.Nodes.Pop ();
+
element.End (location);
if (context.BuildTree) {
XContainer container = element.IsClosed?
diff --git a/main/src/addins/Xml/Tests/MonoDevelop.Xml.Tests.csproj b/main/src/addins/Xml/Tests/MonoDevelop.Xml.Tests.csproj
index 19cc5c4b38..0b551fa523 100644
--- a/main/src/addins/Xml/Tests/MonoDevelop.Xml.Tests.csproj
+++ b/main/src/addins/Xml/Tests/MonoDevelop.Xml.Tests.csproj
@@ -51,10 +51,6 @@
<Name>MonoDevelop.Ide</Name>
<Private>False</Private>
</ProjectReference>
- <ProjectReference Include="..\..\..\..\external\nrefactory\ICSharpCode.NRefactory\ICSharpCode.NRefactory.csproj">
- <Project>{3B2A5653-EC97-4001-BB9B-D90F1AF2C371}</Project>
- <Name>ICSharpCode.NRefactory</Name>
- </ProjectReference>
<ProjectReference Include="..\..\..\..\external\guiunit\src\framework\GuiUnit_NET_4_5.csproj">
<Project>{D12F0F7B-8DE3-43EC-BA49-41052D065A9B}</Project>
<Name>GuiUnit_NET_4_5</Name>
@@ -64,10 +60,18 @@
<Name>MonoDevelop.Xml</Name>
<Private>False</Private>
</ProjectReference>
+ <ProjectReference Include="..\..\..\..\external\NRefactory6\ICSharpCode.NRefactory.CSharp\ICSharpCode.NRefactory6.CSharp.csproj">
+ <Project>{7E891659-45F3-42B5-B940-A728780CCAE9}</Project>
+ <Name>ICSharpCode.NRefactory6.CSharp</Name>
+ </ProjectReference>
</ItemGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Xml" />
+ <Reference Include="Microsoft.CodeAnalysis">
+ <HintPath>..\..\..\..\build\bin\Microsoft.CodeAnalysis.dll</HintPath>
+ <Private>False</Private>
+ </Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Parser\ActiveElementStartPathTestFixture.cs" />
diff --git a/main/src/addins/Xml/Tests/Parser/ParsingTests.cs b/main/src/addins/Xml/Tests/Parser/ParsingTests.cs
index 04d8f2275d..f30f8d1581 100644
--- a/main/src/addins/Xml/Tests/Parser/ParsingTests.cs
+++ b/main/src/addins/Xml/Tests/Parser/ParsingTests.cs
@@ -28,10 +28,10 @@
using System.Linq;
-using ICSharpCode.NRefactory.TypeSystem;
using MonoDevelop.Xml.Dom;
using MonoDevelop.Xml.Parser;
using NUnit.Framework;
+using MonoDevelop.Ide.TypeSystem;
namespace MonoDevelop.Xml.Tests.Parser
@@ -243,8 +243,8 @@ namespace MonoDevelop.Xml.Tests.Parser
Assert.AreEqual ("foo", el.Attributes.ElementAt (2).Name.Name);
Assert.AreEqual (3, el.Attributes.Count ());
parser.AssertErrorCount (1);
- Assert.AreEqual (1, parser.Errors [0].Region.BeginLine);
- Assert.AreEqual (26, parser.Errors [0].Region.BeginColumn);
+ Assert.AreEqual (1, parser.Errors [0].Region.Begin.Line);
+ Assert.AreEqual (26, parser.Errors [0].Region.Begin.Column);
}
[Test]
diff --git a/main/src/addins/Xml/Tests/Parser/TestXmlParser.cs b/main/src/addins/Xml/Tests/Parser/TestXmlParser.cs
index 74afe274ff..04b6c5b979 100644
--- a/main/src/addins/Xml/Tests/Parser/TestXmlParser.cs
+++ b/main/src/addins/Xml/Tests/Parser/TestXmlParser.cs
@@ -30,12 +30,12 @@ using System;
using System.Collections.Generic;
using System.Linq;
-using ICSharpCode.NRefactory;
-using ICSharpCode.NRefactory.TypeSystem;
using MonoDevelop.Xml.Completion;
using MonoDevelop.Xml.Dom;
using MonoDevelop.Xml.Parser;
using NUnit.Framework;
+using MonoDevelop.Ide.TypeSystem;
+using MonoDevelop.Ide.Editor;
namespace MonoDevelop.Xml.Tests.Parser
{
@@ -65,7 +65,7 @@ namespace MonoDevelop.Xml.Tests.Parser
var p = new TestXmlParser (new XmlRootState (), true);
//parse and capture line/col info
- var list = new List<TextLocation> ();
+ var list = new List<DocumentLocation> ();
p.Parse (txt, Array.ConvertAll (asserts, a => (Action)(() => list.Add (p.Location))));
var doc = (XDocument) p.Nodes.Last ();
diff --git a/main/src/addins/Xml/Tests/Schema/AttributeAnnotationTestFixture.cs b/main/src/addins/Xml/Tests/Schema/AttributeAnnotationTestFixture.cs
index 071f9ac510..098e18098f 100644
--- a/main/src/addins/Xml/Tests/Schema/AttributeAnnotationTestFixture.cs
+++ b/main/src/addins/Xml/Tests/Schema/AttributeAnnotationTestFixture.cs
@@ -28,13 +28,13 @@ namespace MonoDevelop.Xml.Tests.Schema
[Test]
public void FooAttributeDocumentation()
{
- Assert.AreEqual("Documentation for foo attribute.", fooAttributeCompletionData[0].Description);
+ Assert.AreEqual("Documentation for foo attribute.", ((MonoDevelop.Ide.CodeCompletion.CompletionData)fooAttributeCompletionData[0]).Description);
}
[Test]
public void BarAttributeDocumentation()
{
- Assert.AreEqual("Documentation for bar attribute.", barAttributeCompletionData[0].Description);
+ Assert.AreEqual("Documentation for bar attribute.", ((MonoDevelop.Ide.CodeCompletion.CompletionData)barAttributeCompletionData[0]).Description);
}
protected override string GetSchema()
diff --git a/main/src/addins/Xml/Tests/Schema/ElementAnnotationTestFixture.cs b/main/src/addins/Xml/Tests/Schema/ElementAnnotationTestFixture.cs
index f4f709366e..0799de7aec 100644
--- a/main/src/addins/Xml/Tests/Schema/ElementAnnotationTestFixture.cs
+++ b/main/src/addins/Xml/Tests/Schema/ElementAnnotationTestFixture.cs
@@ -27,13 +27,13 @@ namespace MonoDevelop.Xml.Tests.Schema
[Test]
public void RootElementDocumentation()
{
- Assert.AreEqual("Documentation for foo element.", rootElementCompletionData[0].Description);
+ Assert.AreEqual("Documentation for foo element.", ((MonoDevelop.Ide.CodeCompletion.CompletionData)rootElementCompletionData[0]).Description);
}
[Test]
public void FooChildElementDocumentation()
{
- Assert.AreEqual("Documentation for bar element.", fooChildElementCompletionData[0].Description);
+ Assert.AreEqual("Documentation for bar element.", ((MonoDevelop.Ide.CodeCompletion.CompletionData)fooChildElementCompletionData[0]).Description);
}
protected override string GetSchema()
diff --git a/main/src/addins/Xml/Tests/Schema/SchemaTestFixtureBase.cs b/main/src/addins/Xml/Tests/Schema/SchemaTestFixtureBase.cs
index 5997a316bd..16e56e185e 100644
--- a/main/src/addins/Xml/Tests/Schema/SchemaTestFixtureBase.cs
+++ b/main/src/addins/Xml/Tests/Schema/SchemaTestFixtureBase.cs
@@ -1,4 +1,3 @@
-using ICSharpCode.NRefactory.Completion;
using MonoDevelop.Ide.CodeCompletion;
using MonoDevelop.Xml.Completion;
using NUnit.Framework;
@@ -52,7 +51,7 @@ namespace MonoDevelop.Xml.Tests.Schema
{
bool Contains = false;
- foreach (ICompletionData data in items) {
+ foreach (var data in items) {
if (data.DisplayText == name) {
Contains = true;
break;
@@ -70,12 +69,12 @@ namespace MonoDevelop.Xml.Tests.Schema
{
bool Contains = false;
- foreach (ICompletionData data in items) {
+ foreach (var data in items) {
if (data.DisplayText == name) {
- if (data.Description == description) {
+ //if (data.DisplayText == description) {
Contains = true;
break;
- }
+ //}
}
}
@@ -90,7 +89,7 @@ namespace MonoDevelop.Xml.Tests.Schema
{
int count = 0;
- foreach (ICompletionData data in items) {
+ foreach (var data in items) {
if (data.DisplayText == name) {
++count;
}