diff options
author | Lluis Sanchez Gual <lluis@xamarin.com> | 2015-04-20 19:07:51 +0300 |
---|---|---|
committer | Lluis Sanchez Gual <lluis@xamarin.com> | 2015-04-20 19:07:51 +0300 |
commit | 95408b1a41b31b645f3a8c3323ab7d3ca4bff26b (patch) | |
tree | f8f137cddcb9a40499d303be95722fd2c6081bce /main/src/addins/Xml/Parser/XmlTagState.cs | |
parent | b70e4e04b4e41b8ec28d7e4b220b401ecf467e7a (diff) | |
parent | de043d330a8bf5855d4d983c804cd36727cb2406 (diff) |
Merge remote-tracking branch 'origin/roslyn' into new-project-model
Diffstat (limited to 'main/src/addins/Xml/Parser/XmlTagState.cs')
-rw-r--r-- | main/src/addins/Xml/Parser/XmlTagState.cs | 84 |
1 files changed, 42 insertions, 42 deletions
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? |