Exemplo n.º 1
0
        public override System.Threading.Tasks.Task <ParsedDocument> Parse(ParseOptions parseOptions, System.Threading.CancellationToken cancellationToken)
        {
            var doc = new XmlParsedDocument(parseOptions.FileName);

            doc.Flags |= ParsedDocumentFlags.NonSerializable;
            try {
                var xmlParser = new XmlParser(new XmlRootState(), true);
                xmlParser.Parse(parseOptions.Content.CreateReader());
                doc.XDocument = xmlParser.Nodes.GetRoot();
                // TODO error conversion!
                //doc.Add (xmlParser.Errors);

                if (doc.XDocument != null && doc.XDocument.RootElement != null)
                {
                    if (!doc.XDocument.RootElement.IsEnded)
                    {
                        doc.XDocument.RootElement.End(xmlParser.Location);
                    }
                }
            }
            catch (Exception ex) {
                MonoDevelop.Core.LoggingService.LogError("Unhandled error parsing xml document", ex);
            }
            return(System.Threading.Tasks.Task.FromResult((ParsedDocument)doc));
        }
Exemplo n.º 2
0
        ParsedDocument ParseInternal(ParseOptions options, CancellationToken cancellationToken)
        {
            var doc = new XmlParsedDocument(options.FileName);

            doc.Flags |= ParsedDocumentFlags.NonSerializable;
            var xmlParser = new XmlParser(new XmlRootState(), true);

            try {
                xmlParser.Parse(options.Content.CreateReader());
            } catch (Exception ex) {
                Core.LoggingService.LogError("Unhandled error parsing xml document", ex);
            }

            doc.XDocument = xmlParser.Nodes.GetRoot();
            doc.AddRange(xmlParser.Errors);

            if (doc.XDocument != null && doc.XDocument.RootElement != null)
            {
                if (!doc.XDocument.RootElement.IsEnded)
                {
                    doc.XDocument.RootElement.End(xmlParser.Location);
                }
            }

            return(doc);
        }
		public static MSBuildResolveContext Create (XmlParsedDocument doc, MSBuildResolveContext previous)
		{
			var ctx = new MSBuildResolveContext ();
			ctx.Populate (doc.XDocument);
			if (doc.Errors.Count > 0)
				ctx.Merge (previous);
			return ctx;
		}
Exemplo n.º 4
0
		public override ParsedDocument Parse (bool storeAst, string fileName, TextReader content, MonoDevelop.Projects.Project project = null)
		{
			var doc = new XmlParsedDocument (fileName);
			doc.Flags |= ParsedDocumentFlags.NonSerializable;
			try {
				var xmlParser = new XmlParser (new XmlRootState (), true);
				xmlParser.Parse (content);
				doc.XDocument = xmlParser.Nodes.GetRoot ();
				doc.Add (xmlParser.Errors);
				
				if (doc.XDocument != null && doc.XDocument.RootElement != null) {
					if (!doc.XDocument.RootElement.IsEnded)
						doc.XDocument.RootElement.End (xmlParser.Location);
				}
			}
			catch (Exception ex) {
				MonoDevelop.Core.LoggingService.LogError ("Unhandled error parsing xml document", ex);
			}
			return doc;
		}
Exemplo n.º 5
0
		public override System.Threading.Tasks.Task<ParsedDocument> Parse (ParseOptions parseOptions, System.Threading.CancellationToken cancellationToken)
		{
			var doc = new XmlParsedDocument (parseOptions.FileName);
			doc.Flags |= ParsedDocumentFlags.NonSerializable;
			try {
				var xmlParser = new XmlParser (new XmlRootState (), true);
				xmlParser.Parse (parseOptions.Content.CreateReader ());
				doc.XDocument = xmlParser.Nodes.GetRoot ();
				// TODO error conversion!
				//doc.Add (xmlParser.Errors);
				
				if (doc.XDocument != null && doc.XDocument.RootElement != null) {
					if (!doc.XDocument.RootElement.IsEnded)
						doc.XDocument.RootElement.End (xmlParser.Location);
				}
			}
			catch (Exception ex) {
				MonoDevelop.Core.LoggingService.LogError ("Unhandled error parsing xml document", ex);
			}
			return System.Threading.Tasks.Task.FromResult((ParsedDocument)doc);
		}
		ParsedDocument ParseInternal (ParseOptions options, CancellationToken cancellationToken)
		{
			var doc = new XmlParsedDocument (options.FileName);
			doc.Flags |= ParsedDocumentFlags.NonSerializable;
			var xmlParser = new XmlParser (new XmlRootState (), true);

			try {
				xmlParser.Parse (options.Content.CreateReader ());
			} catch (Exception ex) {
				Core.LoggingService.LogError ("Unhandled error parsing xml document", ex);
			}

			doc.XDocument = xmlParser.Nodes.GetRoot ();
			doc.AddRange (xmlParser.Errors);

			if (doc.XDocument != null && doc.XDocument.RootElement != null) {
				if (!doc.XDocument.RootElement.IsEnded)
					doc.XDocument.RootElement.End (xmlParser.Location);
			}

			return doc;
		}
Exemplo n.º 7
0
        public override ParsedDocument Parse(bool storeAst, string fileName, TextReader content, MonoDevelop.Projects.Project project = null)
        {
            var doc = new XmlParsedDocument(fileName);

            doc.Flags |= ParsedDocumentFlags.NonSerializable;
            try {
                var xmlParser = new XmlParser(new XmlRootState(), true);
                xmlParser.Parse(content);
                doc.XDocument = xmlParser.Nodes.GetRoot();
                doc.Add(xmlParser.Errors);

                if (doc.XDocument != null && doc.XDocument.RootElement != null)
                {
                    if (!doc.XDocument.RootElement.IsEnded)
                    {
                        doc.XDocument.RootElement.End(xmlParser.Location);
                    }
                }
            }
            catch (Exception ex) {
                MonoDevelop.Core.LoggingService.LogError("Unhandled error parsing xml document", ex);
            }
            return(doc);
        }