diff --git a/src/Compilers/CSharp/Portable/CSharpCodeAnalysis.csproj b/src/Compilers/CSharp/Portable/CSharpCodeAnalysis.csproj
index fe324f4bc29f98fd4e20b0f308c5a19bc0bc4a0a..044354d882e3109b73b10340f66a1e8076771dbc 100644
--- a/src/Compilers/CSharp/Portable/CSharpCodeAnalysis.csproj
+++ b/src/Compilers/CSharp/Portable/CSharpCodeAnalysis.csproj
@@ -843,7 +843,6 @@
-
@@ -925,4 +924,4 @@
-
+
\ No newline at end of file
diff --git a/src/Compilers/CSharp/Portable/Syntax/CSharpSyntaxNode.cs b/src/Compilers/CSharp/Portable/Syntax/CSharpSyntaxNode.cs
index 0f0f9af4df424204a6a3abfc38605f3c3e17633b..358a3367503f2b16c2d0d53e7caa433c8ac11f27 100644
--- a/src/Compilers/CSharp/Portable/Syntax/CSharpSyntaxNode.cs
+++ b/src/Compilers/CSharp/Portable/Syntax/CSharpSyntaxNode.cs
@@ -37,14 +37,6 @@ internal CSharpSyntaxNode(GreenNode green, int position, SyntaxTree syntaxTree)
{
}
- internal override AbstractSyntaxNavigator Navigator
- {
- get
- {
- return SyntaxNavigator.Instance;
- }
- }
-
//TODO: move to common
///
/// Creates a clone of a red node that can be used as a root of given syntaxTree.
diff --git a/src/Compilers/CSharp/Portable/Syntax/InternalSyntax/SyntaxNode.cs b/src/Compilers/CSharp/Portable/Syntax/InternalSyntax/SyntaxNode.cs
index 8ca6c0321be49404c3531f118f941b225d86f929..3a7aa2fcd20b91c9903c9b98da74bcf878394014 100644
--- a/src/Compilers/CSharp/Portable/Syntax/InternalSyntax/SyntaxNode.cs
+++ b/src/Compilers/CSharp/Portable/Syntax/InternalSyntax/SyntaxNode.cs
@@ -95,6 +95,9 @@ public override bool IsDirective
}
}
+ public override bool IsSkippedTokensTrivia => this.Kind == SyntaxKind.SkippedTokensTrivia;
+ public override bool IsDocumentationCommentTrivia => SyntaxFacts.IsDocumentationCommentTrivia(this.Kind);
+
public override int GetSlotOffset(int index)
{
// This implementation should not support arbitrary
@@ -298,14 +301,6 @@ internal static NodeFlags SetFactoryContext(NodeFlags flags, SyntaxFactoryContex
return flags;
}
- public override AbstractSyntaxNavigator Navigator
- {
- get
- {
- return SyntaxNavigator.Instance;
- }
- }
-
public override GreenNode CreateList(IEnumerable nodes, bool alwaysCreateListNode)
{
if (nodes == null)
diff --git a/src/Compilers/CSharp/Portable/Syntax/SyntaxNavigator.cs b/src/Compilers/CSharp/Portable/Syntax/SyntaxNavigator.cs
deleted file mode 100644
index 31ef190bf9f9a14f1026ea7b181354e77c4fbaf2..0000000000000000000000000000000000000000
--- a/src/Compilers/CSharp/Portable/Syntax/SyntaxNavigator.cs
+++ /dev/null
@@ -1,39 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System;
-
-namespace Microsoft.CodeAnalysis.CSharp.Syntax
-{
- internal sealed class SyntaxNavigator : AbstractSyntaxNavigator
- {
- public static readonly AbstractSyntaxNavigator Instance = new SyntaxNavigator();
-
- [Flags]
- private enum SyntaxKinds
- {
- DocComments = 1,
- Directives = 2,
- SkippedTokens = 4,
- }
-
- private static readonly Func[] s_stepIntoFunctions = new Func[]
- {
- /* 000 */ null,
- /* 001 */ t => SyntaxFacts.IsDocumentationCommentTrivia((SyntaxKind)t.RawKind),
- /* 010 */ t => t.IsDirective ,
- /* 011 */ t => t.IsDirective || SyntaxFacts.IsDocumentationCommentTrivia((SyntaxKind)t.RawKind),
- /* 100 */ t => t.RawKind == (int)SyntaxKind.SkippedTokensTrivia ,
- /* 101 */ t => t.RawKind == (int)SyntaxKind.SkippedTokensTrivia || SyntaxFacts.IsDocumentationCommentTrivia((SyntaxKind)t.RawKind),
- /* 110 */ t => t.RawKind == (int)SyntaxKind.SkippedTokensTrivia || t.IsDirective ,
- /* 111 */ t => t.RawKind == (int)SyntaxKind.SkippedTokensTrivia || t.IsDirective || SyntaxFacts.IsDocumentationCommentTrivia((SyntaxKind)t.RawKind),
- };
-
- protected override Func GetStepIntoFunction(bool skipped, bool directives, bool docComments)
- {
- var index = (skipped ? SyntaxKinds.SkippedTokens : 0) |
- (directives ? SyntaxKinds.Directives : 0) |
- (docComments ? SyntaxKinds.DocComments : 0);
- return s_stepIntoFunctions[(int)index];
- }
- }
-}
diff --git a/src/Compilers/Core/Portable/CodeAnalysis.csproj b/src/Compilers/Core/Portable/CodeAnalysis.csproj
index 324c47776bd754c5561cec2b9bab8eacd5cd0c81..ca85427ae6cebd14c1723264fd845ae7dd9f8429 100644
--- a/src/Compilers/Core/Portable/CodeAnalysis.csproj
+++ b/src/Compilers/Core/Portable/CodeAnalysis.csproj
@@ -644,7 +644,7 @@
-
+
diff --git a/src/Compilers/Core/Portable/Syntax/GreenNode.cs b/src/Compilers/Core/Portable/Syntax/GreenNode.cs
index 1e57b2f26016e9ff4a20c574d42508a64007c9f8..5a1525e12d79f9051d93077b8f8f176ae3bc2c8b 100644
--- a/src/Compilers/Core/Portable/Syntax/GreenNode.cs
+++ b/src/Compilers/Core/Portable/Syntax/GreenNode.cs
@@ -120,9 +120,12 @@ public bool IsList
}
public abstract string KindText { get; }
- public virtual bool IsStructuredTrivia { get { return false; } }
- public virtual bool IsDirective { get { return false; } }
- public virtual bool IsToken { get { return false; } }
+
+ public virtual bool IsStructuredTrivia => false;
+ public virtual bool IsDirective => false;
+ public virtual bool IsToken => false;
+ public virtual bool IsSkippedTokensTrivia => false;
+ public virtual bool IsDocumentationCommentTrivia => false;
#endregion
@@ -598,12 +601,12 @@ protected internal virtual void WriteTo(System.IO.TextWriter writer, bool leadin
#endregion
#region Tokens
+
public virtual int RawContextualKind { get { return this.RawKind; } }
public virtual object GetValue() { return null; }
public virtual string GetValueText() { return string.Empty; }
public virtual GreenNode GetLeadingTriviaCore() { return null; }
public virtual GreenNode GetTrailingTriviaCore() { return null; }
- public abstract AbstractSyntaxNavigator Navigator { get; }
public virtual GreenNode WithLeadingTrivia(GreenNode trivia)
{
diff --git a/src/Compilers/Core/Portable/Syntax/AbstractSyntaxNavigator.cs b/src/Compilers/Core/Portable/Syntax/SyntaxNavigator.cs
similarity index 93%
rename from src/Compilers/Core/Portable/Syntax/AbstractSyntaxNavigator.cs
rename to src/Compilers/Core/Portable/Syntax/SyntaxNavigator.cs
index e2801988977953047a1592c2b206860420661511..bc8181537bea99f8aa054271bc79f48b10bd8383 100644
--- a/src/Compilers/Core/Portable/Syntax/AbstractSyntaxNavigator.cs
+++ b/src/Compilers/Core/Portable/Syntax/SyntaxNavigator.cs
@@ -7,11 +7,39 @@
namespace Microsoft.CodeAnalysis
{
- internal abstract class AbstractSyntaxNavigator
+ internal class SyntaxNavigator
{
private const int None = 0;
- protected abstract Func GetStepIntoFunction(bool skipped, bool directives, bool docComments);
+ public static readonly SyntaxNavigator Instance = new SyntaxNavigator();
+
+ [Flags]
+ private enum SyntaxKinds
+ {
+ DocComments = 1,
+ Directives = 2,
+ SkippedTokens = 4,
+ }
+
+ private static readonly Func[] s_stepIntoFunctions = new Func[]
+ {
+ /* 000 */ null,
+ /* 001 */ t => t.IsDocumentationCommentTrivia,
+ /* 010 */ t => t.IsDirective,
+ /* 011 */ t => t.IsDirective || t.IsDocumentationCommentTrivia,
+ /* 100 */ t => t.IsSkippedTokensTrivia,
+ /* 101 */ t => t.IsSkippedTokensTrivia || t.IsDocumentationCommentTrivia,
+ /* 110 */ t => t.IsSkippedTokensTrivia || t.IsDirective,
+ /* 111 */ t => t.IsSkippedTokensTrivia || t.IsDirective || t.IsDocumentationCommentTrivia,
+ };
+
+ private Func GetStepIntoFunction(bool skipped, bool directives, bool docComments)
+ {
+ var index = (skipped ? SyntaxKinds.SkippedTokens : 0) |
+ (directives ? SyntaxKinds.Directives : 0) |
+ (docComments ? SyntaxKinds.DocComments : 0);
+ return s_stepIntoFunctions[(int)index];
+ }
private static Func GetPredicateFunction(bool includeZeroWidth)
{
@@ -594,4 +622,4 @@ internal SyntaxToken GetNextToken(SyntaxToken current, Func p
return default(SyntaxToken);
}
}
-}
+}
\ No newline at end of file
diff --git a/src/Compilers/Core/Portable/Syntax/SyntaxNode.cs b/src/Compilers/Core/Portable/Syntax/SyntaxNode.cs
index fe398f804d4b4cc21c9311e3e05bad3347c008dd..3d2dda0da32023221bc2f97cb82419320197075e 100644
--- a/src/Compilers/Core/Portable/Syntax/SyntaxNode.cs
+++ b/src/Compilers/Core/Portable/Syntax/SyntaxNode.cs
@@ -44,8 +44,6 @@ internal SyntaxNode(GreenNode green, int position, SyntaxTree syntaxTree)
this._syntaxTree = syntaxTree;
}
- internal abstract AbstractSyntaxNavigator Navigator { get; }
-
private string GetDebuggerDisplay()
{
return GetType().Name + " " + KindText + " " + ToString();
@@ -822,7 +820,7 @@ public SyntaxToken FindToken(int position, bool findInsideTrivia = false)
/// The first token or default(SyntaxToken) if it doesn't exist.
public SyntaxToken GetFirstToken(bool includeZeroWidth = false, bool includeSkipped = false, bool includeDirectives = false, bool includeDocumentationComments = false)
{
- return this.Navigator.GetFirstToken(this, includeZeroWidth, includeSkipped, includeDirectives, includeDocumentationComments);
+ return SyntaxNavigator.Instance.GetFirstToken(this, includeZeroWidth, includeSkipped, includeDirectives, includeDocumentationComments);
}
///
@@ -831,7 +829,7 @@ public SyntaxToken GetFirstToken(bool includeZeroWidth = false, bool includeSkip
/// The last token or default(SyntaxToken) if it doesn't exist.
public SyntaxToken GetLastToken(bool includeZeroWidth = false, bool includeSkipped = false, bool includeDirectives = false, bool includeDocumentationComments = false)
{
- return this.Navigator.GetLastToken(this, includeZeroWidth, includeSkipped, includeDirectives, includeDocumentationComments);
+ return SyntaxNavigator.Instance.GetLastToken(this, includeZeroWidth, includeSkipped, includeDirectives, includeDocumentationComments);
}
///
diff --git a/src/Compilers/Core/Portable/Syntax/SyntaxToken.cs b/src/Compilers/Core/Portable/Syntax/SyntaxToken.cs
index 138fcc172abc0f4563f53a527ea0cdd2087fd2db..4c0f547902a994d9709e8e306e036ebffd2a4e38 100644
--- a/src/Compilers/Core/Portable/Syntax/SyntaxToken.cs
+++ b/src/Compilers/Core/Portable/Syntax/SyntaxToken.cs
@@ -578,7 +578,7 @@ public SyntaxToken GetNextToken(bool includeZeroWidth = false, bool includeSkipp
return default(SyntaxToken);
}
- return Node.Navigator.GetNextToken(this, includeZeroWidth, includeSkipped, includeDirectives, includeDocumentationComments);
+ return SyntaxNavigator.Instance.GetNextToken(this, includeZeroWidth, includeSkipped, includeDirectives, includeDocumentationComments);
}
///
@@ -595,7 +595,7 @@ internal SyntaxToken GetNextToken(Func predicate, Func
@@ -609,7 +609,7 @@ public SyntaxToken GetPreviousToken(bool includeZeroWidth = false, bool includeS
return default(SyntaxToken);
}
- return Node.Navigator.GetPreviousToken(this, includeZeroWidth, includeSkipped, includeDirectives, includeDocumentationComments);
+ return SyntaxNavigator.Instance.GetPreviousToken(this, includeZeroWidth, includeSkipped, includeDirectives, includeDocumentationComments);
}
///
@@ -621,7 +621,7 @@ public SyntaxToken GetPreviousToken(bool includeZeroWidth = false, bool includeS
/// included in the search.
internal SyntaxToken GetPreviousToken(Func predicate, Func stepInto = null)
{
- return Node.Navigator.GetPreviousToken(this, predicate, stepInto);
+ return SyntaxNavigator.Instance.GetPreviousToken(this, predicate, stepInto);
}
///
diff --git a/src/Compilers/Core/Portable/Syntax/SyntaxTrivia.cs b/src/Compilers/Core/Portable/Syntax/SyntaxTrivia.cs
index 1d4f2250030e813574e739a3d147fd8dac6c414f..2635df4fc4f5a901f48344e7a130cf64d6edb097 100644
--- a/src/Compilers/Core/Portable/Syntax/SyntaxTrivia.cs
+++ b/src/Compilers/Core/Portable/Syntax/SyntaxTrivia.cs
@@ -184,6 +184,9 @@ public IEnumerable GetAnnotations(params string[] annotationKi
///
public bool IsDirective => UnderlyingNode?.IsDirective ?? false;
+ internal bool IsSkippedTokensTrivia => UnderlyingNode?.IsSkippedTokensTrivia ?? false;
+ internal bool IsDocumentationCommentTrivia => UnderlyingNode?.IsDocumentationCommentTrivia ?? false;
+
///
/// Returns the child non-terminal node representing the syntax tree structure under this structured trivia.
///
diff --git a/src/Compilers/VisualBasic/Portable/BasicCodeAnalysis.vbproj b/src/Compilers/VisualBasic/Portable/BasicCodeAnalysis.vbproj
index 734b8d6b1386c54f9cd300f126d8e14b373cfe31..ef61c8adadb4c7274ce3e78ebe9a1a9dca1a0d16 100644
--- a/src/Compilers/VisualBasic/Portable/BasicCodeAnalysis.vbproj
+++ b/src/Compilers/VisualBasic/Portable/BasicCodeAnalysis.vbproj
@@ -902,7 +902,6 @@
-
@@ -1016,4 +1015,4 @@
-
+
\ No newline at end of file
diff --git a/src/Compilers/VisualBasic/Portable/Syntax/InternalSyntax/SyntaxNode.vb b/src/Compilers/VisualBasic/Portable/Syntax/InternalSyntax/SyntaxNode.vb
index 25f73c2a9fee5d7973a91368416e4de8aab1c8fd..83abe87ca361034436d21f6cc4e98bfbc70bf5df 100644
--- a/src/Compilers/VisualBasic/Portable/Syntax/InternalSyntax/SyntaxNode.vb
+++ b/src/Compilers/VisualBasic/Portable/Syntax/InternalSyntax/SyntaxNode.vb
@@ -180,6 +180,18 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Syntax.InternalSyntax
End Get
End Property
+ Public Overrides ReadOnly Property IsSkippedTokensTrivia As Boolean
+ Get
+ Return Me.Kind = SyntaxKind.SkippedTokensTrivia
+ End Get
+ End Property
+
+ Public Overrides ReadOnly Property IsDocumentationCommentTrivia As Boolean
+ Get
+ Return Me.Kind = SyntaxKind.DocumentationCommentTrivia
+ End Get
+ End Property
+
Protected Overrides Function GetSlotCount() As Integer
Throw ExceptionUtilities.Unreachable
End Function
@@ -439,12 +451,6 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Syntax.InternalSyntax
Return [structure]
End Function
- Public Overrides ReadOnly Property Navigator As AbstractSyntaxNavigator
- Get
- Return SyntaxNavigator.Instance
- End Get
- End Property
-
Public Overrides Function CreateList(nodes As IEnumerable(Of GreenNode), Optional alwaysCreateListNode As Boolean = False) As GreenNode
If nodes Is Nothing Then
Return Nothing
diff --git a/src/Compilers/VisualBasic/Portable/Syntax/SyntaxNavigator.vb b/src/Compilers/VisualBasic/Portable/Syntax/SyntaxNavigator.vb
deleted file mode 100644
index 55e858763602e2168af56eea636721d11e703a67..0000000000000000000000000000000000000000
--- a/src/Compilers/VisualBasic/Portable/Syntax/SyntaxNavigator.vb
+++ /dev/null
@@ -1,33 +0,0 @@
-' Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-Namespace Microsoft.CodeAnalysis.VisualBasic.Syntax
- Friend Class SyntaxNavigator
- Inherits AbstractSyntaxNavigator
-
-
- Private Enum SyntaxKinds
- DocComments = 1
- Directives = 2
- SkippedTokens = 4
- End Enum
-
- Public Shared ReadOnly Instance As AbstractSyntaxNavigator = New SyntaxNavigator()
-
- Private ReadOnly _stepIntoFunctions As Func(Of SyntaxTrivia, Boolean)() = New Func(Of SyntaxTrivia, Boolean)() {
- Nothing,
- Function(t) t.RawKind = SyntaxKind.DocumentationCommentTrivia,
- Function(t) t.IsDirective,
- Function(t) t.IsDirective OrElse t.RawKind = SyntaxKind.DocumentationCommentTrivia,
- Function(t) t.RawKind = SyntaxKind.SkippedTokensTrivia,
- Function(t) t.RawKind = SyntaxKind.SkippedTokensTrivia OrElse t.RawKind = SyntaxKind.DocumentationCommentTrivia,
- Function(t) t.RawKind = SyntaxKind.SkippedTokensTrivia OrElse t.IsDirective,
- Function(t) t.RawKind = SyntaxKind.SkippedTokensTrivia OrElse t.IsDirective OrElse t.RawKind = SyntaxKind.DocumentationCommentTrivia
- }
-
- Protected Overrides Function GetStepIntoFunction(skipped As Boolean, directives As Boolean, docComments As Boolean) As Func(Of SyntaxTrivia, Boolean)
- Dim index = If(skipped, SyntaxKinds.SkippedTokens, 0) Or If(directives, SyntaxKinds.Directives, 0) Or If(docComments, SyntaxKinds.DocComments, 0)
- Return _stepIntoFunctions(index)
- End Function
-
- End Class
-End Namespace
diff --git a/src/Compilers/VisualBasic/Portable/Syntax/VisualBasicSyntaxNode.vb b/src/Compilers/VisualBasic/Portable/Syntax/VisualBasicSyntaxNode.vb
index ed2fd830f40bc5258a8f19de0f23f85b6b515856..eb4afb4111981f4b3d5dce04c50f2c66d898cd24 100644
--- a/src/Compilers/VisualBasic/Portable/Syntax/VisualBasicSyntaxNode.vb
+++ b/src/Compilers/VisualBasic/Portable/Syntax/VisualBasicSyntaxNode.vb
@@ -31,12 +31,6 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
_syntaxTree = syntaxTree
End Sub
- Friend Overrides ReadOnly Property Navigator As AbstractSyntaxNavigator
- Get
- Return SyntaxNavigator.Instance
- End Get
- End Property
-
'TODO: may be eventually not needed
Friend ReadOnly Property VbGreen As InternalSyntax.VisualBasicSyntaxNode
Get
diff --git a/src/Dependencies/PooledObjects/Microsoft.CodeAnalysis.PooledObjects.shproj b/src/Dependencies/PooledObjects/Microsoft.CodeAnalysis.PooledObjects.shproj
index d00c5194a1adbca593f0fbd86cac1a950d8497c0..6274cf7f1762a8cc395aea3c07a627d183db3dc6 100644
--- a/src/Dependencies/PooledObjects/Microsoft.CodeAnalysis.PooledObjects.shproj
+++ b/src/Dependencies/PooledObjects/Microsoft.CodeAnalysis.PooledObjects.shproj
@@ -1,7 +1,7 @@
- cd77a8cc-2885-47a7-b99c-fbf13353400b
+ c1930979-c824-496b-a630-70f5369a636f
14.0