示例#1
0
        List <InternalObject> InternalParseIncremental(
            IncrementalParserState oldParserState, ITextSource newTextSource, out IncrementalParserState newParserState,
            bool collapseProperlyNestedElements, CancellationToken cancellationToken)
        {
            var reader = new TagReader(this, newTextSource, collapseProperlyNestedElements);
            ITextSourceVersion newVersion = newTextSource.Version;
            var reuseMap = oldParserState != null?oldParserState.GetReuseMapTo(newVersion) : null;

            List <InternalObject> internalObjects;

            if (reuseMap != null)
            {
                internalObjects = reader.ReadAllObjectsIncremental(oldParserState.Objects, reuseMap, cancellationToken);
            }
            else
            {
                internalObjects = reader.ReadAllObjects(cancellationToken);
            }

            if (newVersion != null)
            {
                newParserState = new IncrementalParserState(newTextSource.TextLength, newVersion, internalObjects.ToArray());
            }
            else
            {
                newParserState = null;
            }

            return(internalObjects);
        }
示例#2
0
		/// <summary>
		/// Parses a document incrementally into a flat list of tags.
		/// </summary>
		/// <param name="oldParserState">The parser state from a previous call to ParseIncremental(). Use null for the first call.</param>
		/// <param name="newTextSource">The text source for the new document version.</param>
		/// <param name="newParserState">Out: the new parser state, pass this to the next ParseIncremental() call.</param>
		/// <param name="cancellationToken">Optional: cancellation token.</param>
		/// <returns>Parsed tag soup.</returns>
		public IList<AXmlObject> ParseTagSoupIncremental(
			IncrementalParserState oldParserState, ITextSource newTextSource, out IncrementalParserState newParserState,
			CancellationToken cancellationToken = default(CancellationToken))
		{
			if (newTextSource == null)
				throw new ArgumentNullException("newTextSource");
			var internalObjects = InternalParseIncremental(oldParserState, newTextSource, out newParserState, false, cancellationToken);
			return CreatePublic(internalObjects);
		}
示例#3
0
        /// <summary>
        /// Parses a document incrementally into a flat list of tags.
        /// </summary>
        /// <param name="oldParserState">The parser state from a previous call to ParseIncremental(). Use null for the first call.</param>
        /// <param name="newTextSource">The text source for the new document version.</param>
        /// <param name="newParserState">Out: the new parser state, pass this to the next ParseIncremental() call.</param>
        /// <param name="cancellationToken">Optional: cancellation token.</param>
        /// <returns>Parsed tag soup.</returns>
        public AXmlDocument ParseIncremental(
			IncrementalParserState oldParserState, ITextSource newTextSource, out IncrementalParserState newParserState,
			CancellationToken cancellationToken = default(CancellationToken))
        {
            if (newTextSource == null)
                throw new ArgumentNullException("newTextSource");
            var internalObjects = InternalParseIncremental(oldParserState, newTextSource, out newParserState, true, cancellationToken);
            var heuristic = new TagMatchingHeuristics(newTextSource);
            return new AXmlDocument(null, 0, heuristic.CreateDocument(internalObjects, cancellationToken));
        }
示例#4
0
        /// <summary>
        /// Parses a document incrementally into a flat list of tags.
        /// </summary>
        /// <param name="oldParserState">The parser state from a previous call to ParseIncremental(). Use null for the first call.</param>
        /// <param name="newTextSource">The text source for the new document version.</param>
        /// <param name="newParserState">Out: the new parser state, pass this to the next ParseIncremental() call.</param>
        /// <param name="cancellationToken">Optional: cancellation token.</param>
        /// <returns>Parsed tag soup.</returns>
        public IList <AXmlObject> ParseTagSoupIncremental(
            IncrementalParserState oldParserState, ITextSource newTextSource, out IncrementalParserState newParserState,
            CancellationToken cancellationToken = default(CancellationToken))
        {
            if (newTextSource == null)
            {
                throw new ArgumentNullException("newTextSource");
            }
            var internalObjects = InternalParseIncremental(oldParserState, newTextSource, out newParserState, false, cancellationToken);

            return(CreatePublic(internalObjects));
        }
示例#5
0
        /// <summary>
        /// Parses a document incrementally into a flat list of tags.
        /// </summary>
        /// <param name="oldParserState">The parser state from a previous call to ParseIncremental(). Use null for the first call.</param>
        /// <param name="newTextSource">The text source for the new document version.</param>
        /// <param name="newParserState">Out: the new parser state, pass this to the next ParseIncremental() call.</param>
        /// <param name="cancellationToken">Optional: cancellation token.</param>
        /// <returns>Parsed tag soup.</returns>
        public AXmlDocument ParseIncremental(
            IncrementalParserState oldParserState, ITextSource newTextSource, out IncrementalParserState newParserState,
            CancellationToken cancellationToken = default(CancellationToken))
        {
            if (newTextSource == null)
            {
                throw new ArgumentNullException("newTextSource");
            }
            var internalObjects = InternalParseIncremental(oldParserState, newTextSource, out newParserState, true, cancellationToken);
            var heuristic       = new TagMatchingHeuristics(newTextSource);

            return(new AXmlDocument(null, 0, heuristic.CreateDocument(internalObjects, cancellationToken)));
        }
示例#6
0
		List<InternalObject> InternalParseIncremental(
			IncrementalParserState oldParserState, ITextSource newTextSource, out IncrementalParserState newParserState,
			bool collapseProperlyNestedElements, CancellationToken cancellationToken)
		{
			var reader = new TagReader(this, newTextSource, collapseProperlyNestedElements);
			ITextSourceVersion newVersion = newTextSource.Version;
			var reuseMap = oldParserState != null ? oldParserState.GetReuseMapTo(newVersion) : null;
			
			List<InternalObject> internalObjects;
			if (reuseMap != null)
				internalObjects = reader.ReadAllObjectsIncremental(oldParserState.Objects, reuseMap, cancellationToken);
			else
				internalObjects = reader.ReadAllObjects(cancellationToken);
			
			if (newVersion != null)
				newParserState = new IncrementalParserState(newTextSource.TextLength, newVersion, internalObjects.ToArray());
			else
				newParserState = null;
			
			return internalObjects;
		}
示例#7
0
		public ParseInformation Parse(FileName fileName, ITextSource fileContent, bool fullParseInformationRequested,
		                              IProject parentProject, CancellationToken cancellationToken)
		{
			AXmlParser parser = new AXmlParser();
			AXmlDocument document;
			IncrementalParserState newParserState;
			if (fileContent.Version is OnDiskTextSourceVersion) {
				document = parser.Parse(fileContent, cancellationToken);
				newParserState = null;
			} else {
				document = parser.ParseIncremental(parserState, fileContent, out newParserState, cancellationToken);
			}
			parserState = newParserState;
			XamlUnresolvedFile unresolvedFile = XamlUnresolvedFile.Create(fileName, fileContent, document);
			ParseInformation parseInfo;
			if (fullParseInformationRequested)
				parseInfo = new XamlFullParseInformation(unresolvedFile, document, fileContent.CreateSnapshot());
			else
				parseInfo = new ParseInformation(unresolvedFile, fileContent.Version, false);
			AddTagComments(document, parseInfo, fileContent);
			return parseInfo;
		}