-
Notifications
You must be signed in to change notification settings - Fork 4k
/
SyntaxReference.cs
55 lines (49 loc) · 1.94 KB
/
SyntaxReference.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Text;
namespace Microsoft.CodeAnalysis
{
/// <summary>
/// A reference to a syntax node.
/// </summary>
public abstract class SyntaxReference
{
/// <summary>
/// The syntax tree that this references a node within.
/// </summary>
public abstract SyntaxTree SyntaxTree { get; }
/// <summary>
/// The span of the node referenced.
/// </summary>
public abstract TextSpan Span { get; }
/// <summary>
/// Retrieves the original referenced syntax node.
/// This action may cause a parse to happen to recover the syntax node.
/// </summary>
/// <returns>The original referenced syntax node.</returns>
public abstract SyntaxNode GetSyntax(CancellationToken cancellationToken = default(CancellationToken));
/// <summary>
/// Retrieves the original referenced syntax node.
/// This action may cause a parse to happen to recover the syntax node.
/// </summary>
/// <returns>The original referenced syntax node.</returns>
public virtual Task<SyntaxNode> GetSyntaxAsync(CancellationToken cancellationToken = default(CancellationToken))
{
return Task.FromResult(this.GetSyntax(cancellationToken));
}
/// <summary>
/// The location of this syntax reference.
/// </summary>
/// <returns>The location of this syntax reference.</returns>
/// <remarks>
/// More performant than GetSyntax().GetLocation().
/// </remarks>
internal Location GetLocation()
{
return this.SyntaxTree.GetLocation(this.Span);
}
}
}