1
1
// Copyright (c) Microsoft Corporation.
2
2
// Licensed under the MIT License.
3
3
4
+ using System . Collections . Immutable ;
4
5
using System . Xml . Linq ;
5
6
6
7
using Microsoft . CodeAnalysis ;
7
8
8
9
namespace Microsoft . Azure . ApiManagement . PolicyToolkit . Compiling ;
9
10
10
- public class DocumentCompilationContext ( Compilation compilation , SyntaxNode syntaxRoot , XElement rootElement )
11
+ public class DocumentCompilationContext ( Compilation compilation , SyntaxNode syntaxRoot , XElement currentElement )
11
12
: IDocumentCompilationContext , IDocumentCompilationResult
12
13
{
13
- private readonly IList < Diagnostic > _diagnostics = new List < Diagnostic > ( ) ;
14
-
15
- public DocumentCompilationContext ( DocumentCompilationContext parent , XElement rootElement ) : this (
16
- parent . Compilation , parent . SyntaxRoot , rootElement )
14
+ public DocumentCompilationContext ( IDocumentCompilationContext parent , XElement currentElement )
15
+ : this ( parent . Compilation , parent . SyntaxRoot , currentElement )
17
16
{
18
- _diagnostics = parent . _diagnostics ;
17
+ RootElement = parent . RootElement ;
18
+ Diagnostics = parent . Diagnostics ;
19
19
}
20
20
21
- public void AddPolicy ( XNode element ) => rootElement . Add ( element ) ;
22
- public void Report ( Diagnostic diagnostic ) => _diagnostics . Add ( diagnostic ) ;
21
+ public void AddPolicy ( XNode element ) => CurrentElement . Add ( element ) ;
22
+ public void Report ( Diagnostic diagnostic ) => Diagnostics . Add ( diagnostic ) ;
23
23
24
24
public Compilation Compilation { get ; } = compilation ;
25
25
public SyntaxNode SyntaxRoot { get ; } = syntaxRoot ;
26
+ public XElement RootElement { get ; } = currentElement ;
27
+ public XElement CurrentElement { get ; } = currentElement ;
28
+ public IList < Diagnostic > Diagnostics { get ; } = new List < Diagnostic > ( ) ;
26
29
27
- public XElement Document => rootElement ;
28
- public IReadOnlyList < Diagnostic > Diagnostics => _diagnostics . AsReadOnly ( ) ;
30
+ public XElement Document => CurrentElement ;
31
+ public ImmutableArray < Diagnostic > Errors => [ .. Diagnostics ] ;
29
32
}
0 commit comments