// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System.Collections.Generic; using System.Linq; using Microsoft.AspNet.Razor.Parser.SyntaxTree; using Microsoft.AspNet.Razor.TagHelpers; using Microsoft.Framework.Internal; namespace Microsoft.AspNet.Razor { /// /// Represents the results of parsing a Razor document /// public class ParserResults { /// /// Instantiates a new instance. /// /// The for the syntax tree. /// /// The s that apply to the current Razor document. /// /// /// The used to collect s encountered when parsing the /// current Razor document. /// public ParserResults([NotNull] Block document, [NotNull] IEnumerable tagHelperDescriptors, [NotNull] ErrorSink errorSink) : this(!errorSink.Errors.Any(), document, tagHelperDescriptors, errorSink) { } /// /// Instantiates a new instance. /// /// true if parsing was successful, false otherwise. /// The for the syntax tree. /// /// The s that apply to the current Razor document. /// /// /// The used to collect s encountered when parsing the /// current Razor document. /// protected ParserResults(bool success, [NotNull] Block document, [NotNull] IEnumerable tagHelperDescriptors, [NotNull] ErrorSink errorSink) { Success = success; Document = document; TagHelperDescriptors = tagHelperDescriptors; ErrorSink = errorSink; ParserErrors = errorSink.Errors; Prefix = tagHelperDescriptors.FirstOrDefault()?.Prefix; } /// /// Indicates if parsing was successful (no errors). /// /// true if parsing was successful, false otherwise. public bool Success { get; } /// /// The root node in the document's syntax tree. /// public Block Document { get; } /// /// Used to aggregate s. /// public ErrorSink ErrorSink { get; } /// /// The list of errors which occurred during parsing. /// public IEnumerable ParserErrors { get; } /// /// The s found for the current Razor document. /// public IEnumerable TagHelperDescriptors { get; } /// /// Text used as a required prefix when matching HTML. /// public string Prefix { get; } } }