提交 98ccb40e 编写于 作者: M Manish Vasani

Move ISyntaxKindsService language service in shared layer

Split `ISyntaxKindsService` into two parts:

1. `ISyntaxKinds`: Pure data query interface, which already exists in CompilerExtensions shared project and can be used by analyzers.
2. `ISyntaxKindsService`: The `ILangaugeService` implementation of `ISyntaxKinds`

Above split ensures that we can move the `ISyntaxKindsService` language service implementation down to the WorkspaceExtensions project, which in turn ensures that `GetLanguageService<ISyntaxKindsService>` will always succeed in our entire code base. This is currently not true in CodeStyle fixes layer due to the fact that the language service implementation is defined in Workspaces.csproj
上级 916b15db
......@@ -7,7 +7,6 @@
using System.Composition;
using Microsoft.CodeAnalysis.CodeFixes;
using Microsoft.CodeAnalysis.ConflictMarkerResolution;
using Microsoft.CodeAnalysis.CSharp.LanguageServices;
namespace Microsoft.CodeAnalysis.CSharp.ConflictMarkerResolution
{
......@@ -18,7 +17,7 @@ internal class CSharpResolveConflictMarkerCodeFixProvider : AbstractResolveConfl
[ImportingConstructor]
public CSharpResolveConflictMarkerCodeFixProvider()
: base(CSharpSyntaxKindsService.Instance, CS8300)
: base(CSharpSyntaxKinds.Instance, CS8300)
{
}
}
......
......@@ -5,7 +5,6 @@
#nullable enable
using Microsoft.CodeAnalysis.ConvertAnonymousTypeToTuple;
using Microsoft.CodeAnalysis.CSharp.LanguageServices;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Diagnostics;
......@@ -18,7 +17,7 @@ internal class CSharpConvertAnonymousTypeToTupleDiagnosticAnalyzer
AnonymousObjectCreationExpressionSyntax>
{
public CSharpConvertAnonymousTypeToTupleDiagnosticAnalyzer()
: base(CSharpSyntaxKindsService.Instance)
: base(CSharpSyntaxKinds.Instance)
{
}
......
......@@ -20,10 +20,10 @@ internal abstract class AbstractResolveConflictMarkerCodeFixProvider : CodeFixPr
{
private static readonly int s_mergeConflictLength = "<<<<<<<".Length;
private readonly ISyntaxKindsService _syntaxKinds;
private readonly ISyntaxKinds _syntaxKinds;
protected AbstractResolveConflictMarkerCodeFixProvider(
ISyntaxKindsService syntaxKinds, string diagnosticId)
ISyntaxKinds syntaxKinds, string diagnosticId)
{
FixableDiagnosticIds = ImmutableArray.Create(diagnosticId);
_syntaxKinds = syntaxKinds;
......
......@@ -17,9 +17,9 @@ internal abstract class AbstractConvertAnonymousTypeToTupleDiagnosticAnalyzer<
where TSyntaxKind : struct
where TAnonymousObjectCreationExpressionSyntax : SyntaxNode
{
private readonly ISyntaxKindsService _syntaxKinds;
private readonly ISyntaxKinds _syntaxKinds;
protected AbstractConvertAnonymousTypeToTupleDiagnosticAnalyzer(ISyntaxKindsService syntaxKinds)
protected AbstractConvertAnonymousTypeToTupleDiagnosticAnalyzer(ISyntaxKinds syntaxKinds)
: base(IDEDiagnosticIds.ConvertAnonymousTypeToTupleDiagnosticId,
option: null,
new LocalizableResourceString(nameof(FeaturesResources.Convert_to_tuple), FeaturesResources.ResourceManager, typeof(FeaturesResources)),
......
......@@ -5,7 +5,6 @@
Imports System.Composition
Imports Microsoft.CodeAnalysis.CodeFixes
Imports Microsoft.CodeAnalysis.ConflictMarkerResolution
Imports Microsoft.CodeAnalysis.VisualBasic.LanguageServices
Namespace Microsoft.CodeAnalysis.VisualBasic.ConflictMarkerResolution
<ExportCodeFixProvider(LanguageNames.VisualBasic), [Shared]>
......@@ -16,7 +15,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.ConflictMarkerResolution
<ImportingConstructor>
Public Sub New()
MyBase.New(VisualBasicSyntaxKindsService.Instance, BC37284)
MyBase.New(VisualBasicSyntaxKinds.Instance, BC37284)
End Sub
End Class
End Namespace
......@@ -5,7 +5,6 @@
Imports Microsoft.CodeAnalysis.ConvertAnonymousTypeToTuple
Imports Microsoft.CodeAnalysis.Diagnostics
Imports Microsoft.CodeAnalysis.VisualBasic.Syntax
Imports Microsoft.CodeAnalysis.VisualBasic.LanguageServices
Namespace Microsoft.CodeAnalysis.VisualBasic.ConvertAnonymousTypeToTuple
<DiagnosticAnalyzer(LanguageNames.VisualBasic)>
......@@ -14,7 +13,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.ConvertAnonymousTypeToTuple
SyntaxKind, AnonymousObjectCreationExpressionSyntax)
Public Sub New()
MyBase.New(VisualBasicSyntaxKindsService.Instance)
MyBase.New(VisualBasicSyntaxKinds.Instance)
End Sub
Protected Overrides Function GetInitializerCount(anonymousType As AnonymousObjectCreationExpressionSyntax) As Integer
......
......@@ -61,7 +61,7 @@
<Compile Include="$(MSBuildThisFileDirectory)Formatting\Rules\TokenBasedFormattingRule.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Formatting\Rules\WrappingFormattingRule.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Helpers\RemoveUnnecessaryImports\CSharpUnnecessaryImportsProvider.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Services\SyntaxFacts\CSharpSyntaxKindsService.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Services\SyntaxFacts\CSharpSyntaxKinds.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Utilities\FormattingRangeHelper.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Utilities\TypeStyle\CSharpTypeStyleHelper.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Utilities\TypeStyle\CSharpTypeStyleHelper.State.cs" />
......
......@@ -4,15 +4,13 @@
#nullable enable
using Microsoft.CodeAnalysis.LanguageServices;
namespace Microsoft.CodeAnalysis.CSharp.LanguageServices
namespace Microsoft.CodeAnalysis.CSharp
{
internal sealed class CSharpSyntaxKindsService : ISyntaxKindsService
internal class CSharpSyntaxKinds : ISyntaxKinds
{
public static readonly CSharpSyntaxKindsService Instance = new CSharpSyntaxKindsService();
public static readonly CSharpSyntaxKinds Instance = new CSharpSyntaxKinds();
private CSharpSyntaxKindsService()
protected CSharpSyntaxKinds()
{
}
......
......@@ -270,7 +270,7 @@
<Compile Include="$(MSBuildThisFileDirectory)Log\Logger.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Log\Logger.LogBlock.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Log\LogMessage.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Services\SyntaxFacts\ISyntaxKindsService.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Services\SyntaxFacts\ISyntaxKinds.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Simplification\AliasAnnotation.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Simplification\DoNotAddImportsAnnotation.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Simplification\DoNotAllowVarAnnotation.cs" />
......
......@@ -4,13 +4,13 @@
#nullable enable
namespace Microsoft.CodeAnalysis.LanguageServices
namespace Microsoft.CodeAnalysis
{
/// <summary>
/// Provides a uniform view of SyntaxKinds over C# and VB for constructs they have
/// in common.
/// </summary>
internal partial interface ISyntaxKindsService
internal interface ISyntaxKinds
{
TSyntaxKind Convert<TSyntaxKind>(int kind) where TSyntaxKind : struct;
......
......@@ -2,87 +2,85 @@
' The .NET Foundation licenses this file to you under the MIT license.
' See the LICENSE file in the project root for more information.
Imports Microsoft.CodeAnalysis.LanguageServices
Namespace Microsoft.CodeAnalysis.VisualBasic
Friend Class VisualBasicSyntaxKinds
Implements ISyntaxKinds
Namespace Microsoft.CodeAnalysis.VisualBasic.LanguageServices
Friend NotInheritable Class VisualBasicSyntaxKindsService
Implements ISyntaxKindsService
Public Shared ReadOnly Instance As New VisualBasicSyntaxKinds()
Public Shared ReadOnly Instance As New VisualBasicSyntaxKindsService()
Private Sub New()
Protected Sub New()
End Sub
Public Function Convert(Of TSyntaxKind As Structure)(kind As Integer) As TSyntaxKind Implements ISyntaxKindsService.Convert
Public Function Convert(Of TSyntaxKind As Structure)(kind As Integer) As TSyntaxKind Implements ISyntaxKinds.Convert
' Boxing/Unboxing casts from Object to TSyntaxKind will be erased by jit.
Return CType(CType(CType(kind, SyntaxKind), Object), TSyntaxKind)
End Function
Public ReadOnly Property ConflictMarkerTrivia As Integer = SyntaxKind.ConflictMarkerTrivia Implements ISyntaxKindsService.ConflictMarkerTrivia
Public ReadOnly Property DisabledTextTrivia As Integer = SyntaxKind.DisabledTextTrivia Implements ISyntaxKindsService.DisabledTextTrivia
Public ReadOnly Property EndOfLineTrivia As Integer = SyntaxKind.EndOfLineTrivia Implements ISyntaxKindsService.EndOfLineTrivia
Public ReadOnly Property SkippedTokensTrivia As Integer = SyntaxKind.SkippedTokensTrivia Implements ISyntaxKindsService.SkippedTokensTrivia
Public ReadOnly Property WhitespaceTrivia As Integer = SyntaxKind.WhitespaceTrivia Implements ISyntaxKindsService.WhitespaceTrivia
Public ReadOnly Property CharacterLiteralToken As Integer = SyntaxKind.CharacterLiteralToken Implements ISyntaxKindsService.CharacterLiteralToken
Public ReadOnly Property DotToken As Integer = SyntaxKind.DotToken Implements ISyntaxKindsService.DotToken
Public ReadOnly Property InterpolatedStringTextToken As Integer = SyntaxKind.InterpolatedStringTextToken Implements ISyntaxKindsService.InterpolatedStringTextToken
Public ReadOnly Property QuestionToken As Integer = SyntaxKind.QuestionToken Implements ISyntaxKindsService.QuestionToken
Public ReadOnly Property StringLiteralToken As Integer = SyntaxKind.StringLiteralToken Implements ISyntaxKindsService.StringLiteralToken
Public ReadOnly Property IfKeyword As Integer = SyntaxKind.IfKeyword Implements ISyntaxKindsService.IfKeyword
Public ReadOnly Property GenericName As Integer = SyntaxKind.GenericName Implements ISyntaxKindsService.GenericName
Public ReadOnly Property IdentifierName As Integer = SyntaxKind.IdentifierName Implements ISyntaxKindsService.IdentifierName
Public ReadOnly Property QualifiedName As Integer = SyntaxKind.QualifiedName Implements ISyntaxKindsService.QualifiedName
Public ReadOnly Property TupleType As Integer = SyntaxKind.TupleType Implements ISyntaxKindsService.TupleType
Public ReadOnly Property CharacterLiteralExpression As Integer = SyntaxKind.CharacterLiteralExpression Implements ISyntaxKindsService.CharacterLiteralExpression
Public ReadOnly Property DefaultLiteralExpression As Integer = SyntaxKind.NothingLiteralExpression Implements ISyntaxKindsService.DefaultLiteralExpression
Public ReadOnly Property FalseLiteralExpression As Integer = SyntaxKind.FalseLiteralExpression Implements ISyntaxKindsService.FalseLiteralExpression
Public ReadOnly Property NullLiteralExpression As Integer = SyntaxKind.NothingLiteralExpression Implements ISyntaxKindsService.NullLiteralExpression
Public ReadOnly Property StringLiteralExpression As Integer = SyntaxKind.StringLiteralExpression Implements ISyntaxKindsService.StringLiteralExpression
Public ReadOnly Property TrueLiteralExpression As Integer = SyntaxKind.TrueLiteralExpression Implements ISyntaxKindsService.TrueLiteralExpression
Public ReadOnly Property AnonymousObjectCreationExpression As Integer = SyntaxKind.AnonymousObjectCreationExpression Implements ISyntaxKindsService.AnonymousObjectCreationExpression
Public ReadOnly Property AwaitExpression As Integer = SyntaxKind.AwaitExpression Implements ISyntaxKindsService.AwaitExpression
Public ReadOnly Property BaseExpression As Integer = SyntaxKind.MyBaseExpression Implements ISyntaxKindsService.BaseExpression
Public ReadOnly Property ConditionalAccessExpression As Integer = SyntaxKind.ConditionalAccessExpression Implements ISyntaxKindsService.ConditionalAccessExpression
Public ReadOnly Property InvocationExpression As Integer = SyntaxKind.InvocationExpression Implements ISyntaxKindsService.InvocationExpression
Public ReadOnly Property LogicalAndExpression As Integer = SyntaxKind.AndAlsoExpression Implements ISyntaxKindsService.LogicalAndExpression
Public ReadOnly Property LogicalOrExpression As Integer = SyntaxKind.OrElseExpression Implements ISyntaxKindsService.LogicalOrExpression
Public ReadOnly Property LogicalNotExpression As Integer = SyntaxKind.NotExpression Implements ISyntaxKindsService.LogicalNotExpression
Public ReadOnly Property ObjectCreationExpression As Integer = SyntaxKind.ObjectCreationExpression Implements ISyntaxKindsService.ObjectCreationExpression
Public ReadOnly Property ParenthesizedExpression As Integer = SyntaxKind.ParenthesizedExpression Implements ISyntaxKindsService.ParenthesizedExpression
Public ReadOnly Property QueryExpression As Integer = SyntaxKind.QueryExpression Implements ISyntaxKindsService.QueryExpression
Public ReadOnly Property ReferenceEqualsExpression As Integer = SyntaxKind.IsExpression Implements ISyntaxKindsService.ReferenceEqualsExpression
Public ReadOnly Property ReferenceNotEqualsExpression As Integer = SyntaxKind.IsNotExpression Implements ISyntaxKindsService.ReferenceNotEqualsExpression
Public ReadOnly Property SimpleMemberAccessExpression As Integer = SyntaxKind.SimpleMemberAccessExpression Implements ISyntaxKindsService.SimpleMemberAccessExpression
Public ReadOnly Property TernaryConditionalExpression As Integer = SyntaxKind.TernaryConditionalExpression Implements ISyntaxKindsService.TernaryConditionalExpression
Public ReadOnly Property ThisExpression As Integer = SyntaxKind.MeExpression Implements ISyntaxKindsService.ThisExpression
Public ReadOnly Property TupleExpression As Integer = SyntaxKind.TupleExpression Implements ISyntaxKindsService.TupleExpression
Public ReadOnly Property EndOfFileToken As Integer = SyntaxKind.EndOfFileToken Implements ISyntaxKindsService.EndOfFileToken
Public ReadOnly Property AwaitKeyword As Integer = SyntaxKind.AwaitKeyword Implements ISyntaxKindsService.AwaitKeyword
Public ReadOnly Property IdentifierToken As Integer = SyntaxKind.IdentifierToken Implements ISyntaxKindsService.IdentifierToken
Public ReadOnly Property GlobalKeyword As Integer = SyntaxKind.GlobalKeyword Implements ISyntaxKindsService.GlobalKeyword
Public ReadOnly Property IncompleteMember As Integer = SyntaxKind.IncompleteMember Implements ISyntaxKindsService.IncompleteMember
Public ReadOnly Property HashToken As Integer = SyntaxKind.HashToken Implements ISyntaxKindsService.HashToken
Public ReadOnly Property ExpressionStatement As Integer = SyntaxKind.ExpressionStatement Implements ISyntaxKindsService.ExpressionStatement
Public ReadOnly Property ForEachStatement As Integer = SyntaxKind.ForEachStatement Implements ISyntaxKindsService.ForEachStatement
Public ReadOnly Property LocalDeclarationStatement As Integer = SyntaxKind.LocalDeclarationStatement Implements ISyntaxKindsService.LocalDeclarationStatement
Public ReadOnly Property LockStatement As Integer = SyntaxKind.SyncLockStatement Implements ISyntaxKindsService.LockStatement
Public ReadOnly Property ReturnStatement As Integer = SyntaxKind.ReturnStatement Implements ISyntaxKindsService.ReturnStatement
Public ReadOnly Property UsingStatement As Integer = SyntaxKind.UsingStatement Implements ISyntaxKindsService.UsingStatement
Public ReadOnly Property Attribute As Integer = SyntaxKind.Attribute Implements ISyntaxKindsService.Attribute
Public ReadOnly Property Parameter As Integer = SyntaxKind.Parameter Implements ISyntaxKindsService.Parameter
Public ReadOnly Property TypeConstraint As Integer = SyntaxKind.TypeConstraint Implements ISyntaxKindsService.TypeConstraint
Public ReadOnly Property VariableDeclarator As Integer = SyntaxKind.VariableDeclarator Implements ISyntaxKindsService.VariableDeclarator
Public ReadOnly Property TypeArgumentList As Integer = SyntaxKind.TypeArgumentList Implements ISyntaxKindsService.TypeArgumentList
Public ReadOnly Property ConflictMarkerTrivia As Integer = SyntaxKind.ConflictMarkerTrivia Implements ISyntaxKinds.ConflictMarkerTrivia
Public ReadOnly Property DisabledTextTrivia As Integer = SyntaxKind.DisabledTextTrivia Implements ISyntaxKinds.DisabledTextTrivia
Public ReadOnly Property EndOfLineTrivia As Integer = SyntaxKind.EndOfLineTrivia Implements ISyntaxKinds.EndOfLineTrivia
Public ReadOnly Property SkippedTokensTrivia As Integer = SyntaxKind.SkippedTokensTrivia Implements ISyntaxKinds.SkippedTokensTrivia
Public ReadOnly Property WhitespaceTrivia As Integer = SyntaxKind.WhitespaceTrivia Implements ISyntaxKinds.WhitespaceTrivia
Public ReadOnly Property CharacterLiteralToken As Integer = SyntaxKind.CharacterLiteralToken Implements ISyntaxKinds.CharacterLiteralToken
Public ReadOnly Property DotToken As Integer = SyntaxKind.DotToken Implements ISyntaxKinds.DotToken
Public ReadOnly Property InterpolatedStringTextToken As Integer = SyntaxKind.InterpolatedStringTextToken Implements ISyntaxKinds.InterpolatedStringTextToken
Public ReadOnly Property QuestionToken As Integer = SyntaxKind.QuestionToken Implements ISyntaxKinds.QuestionToken
Public ReadOnly Property StringLiteralToken As Integer = SyntaxKind.StringLiteralToken Implements ISyntaxKinds.StringLiteralToken
Public ReadOnly Property IfKeyword As Integer = SyntaxKind.IfKeyword Implements ISyntaxKinds.IfKeyword
Public ReadOnly Property GenericName As Integer = SyntaxKind.GenericName Implements ISyntaxKinds.GenericName
Public ReadOnly Property IdentifierName As Integer = SyntaxKind.IdentifierName Implements ISyntaxKinds.IdentifierName
Public ReadOnly Property QualifiedName As Integer = SyntaxKind.QualifiedName Implements ISyntaxKinds.QualifiedName
Public ReadOnly Property TupleType As Integer = SyntaxKind.TupleType Implements ISyntaxKinds.TupleType
Public ReadOnly Property CharacterLiteralExpression As Integer = SyntaxKind.CharacterLiteralExpression Implements ISyntaxKinds.CharacterLiteralExpression
Public ReadOnly Property DefaultLiteralExpression As Integer = SyntaxKind.NothingLiteralExpression Implements ISyntaxKinds.DefaultLiteralExpression
Public ReadOnly Property FalseLiteralExpression As Integer = SyntaxKind.FalseLiteralExpression Implements ISyntaxKinds.FalseLiteralExpression
Public ReadOnly Property NullLiteralExpression As Integer = SyntaxKind.NothingLiteralExpression Implements ISyntaxKinds.NullLiteralExpression
Public ReadOnly Property StringLiteralExpression As Integer = SyntaxKind.StringLiteralExpression Implements ISyntaxKinds.StringLiteralExpression
Public ReadOnly Property TrueLiteralExpression As Integer = SyntaxKind.TrueLiteralExpression Implements ISyntaxKinds.TrueLiteralExpression
Public ReadOnly Property AnonymousObjectCreationExpression As Integer = SyntaxKind.AnonymousObjectCreationExpression Implements ISyntaxKinds.AnonymousObjectCreationExpression
Public ReadOnly Property AwaitExpression As Integer = SyntaxKind.AwaitExpression Implements ISyntaxKinds.AwaitExpression
Public ReadOnly Property BaseExpression As Integer = SyntaxKind.MyBaseExpression Implements ISyntaxKinds.BaseExpression
Public ReadOnly Property ConditionalAccessExpression As Integer = SyntaxKind.ConditionalAccessExpression Implements ISyntaxKinds.ConditionalAccessExpression
Public ReadOnly Property InvocationExpression As Integer = SyntaxKind.InvocationExpression Implements ISyntaxKinds.InvocationExpression
Public ReadOnly Property LogicalAndExpression As Integer = SyntaxKind.AndAlsoExpression Implements ISyntaxKinds.LogicalAndExpression
Public ReadOnly Property LogicalOrExpression As Integer = SyntaxKind.OrElseExpression Implements ISyntaxKinds.LogicalOrExpression
Public ReadOnly Property LogicalNotExpression As Integer = SyntaxKind.NotExpression Implements ISyntaxKinds.LogicalNotExpression
Public ReadOnly Property ObjectCreationExpression As Integer = SyntaxKind.ObjectCreationExpression Implements ISyntaxKinds.ObjectCreationExpression
Public ReadOnly Property ParenthesizedExpression As Integer = SyntaxKind.ParenthesizedExpression Implements ISyntaxKinds.ParenthesizedExpression
Public ReadOnly Property QueryExpression As Integer = SyntaxKind.QueryExpression Implements ISyntaxKinds.QueryExpression
Public ReadOnly Property ReferenceEqualsExpression As Integer = SyntaxKind.IsExpression Implements ISyntaxKinds.ReferenceEqualsExpression
Public ReadOnly Property ReferenceNotEqualsExpression As Integer = SyntaxKind.IsNotExpression Implements ISyntaxKinds.ReferenceNotEqualsExpression
Public ReadOnly Property SimpleMemberAccessExpression As Integer = SyntaxKind.SimpleMemberAccessExpression Implements ISyntaxKinds.SimpleMemberAccessExpression
Public ReadOnly Property TernaryConditionalExpression As Integer = SyntaxKind.TernaryConditionalExpression Implements ISyntaxKinds.TernaryConditionalExpression
Public ReadOnly Property ThisExpression As Integer = SyntaxKind.MeExpression Implements ISyntaxKinds.ThisExpression
Public ReadOnly Property TupleExpression As Integer = SyntaxKind.TupleExpression Implements ISyntaxKinds.TupleExpression
Public ReadOnly Property EndOfFileToken As Integer = SyntaxKind.EndOfFileToken Implements ISyntaxKinds.EndOfFileToken
Public ReadOnly Property AwaitKeyword As Integer = SyntaxKind.AwaitKeyword Implements ISyntaxKinds.AwaitKeyword
Public ReadOnly Property IdentifierToken As Integer = SyntaxKind.IdentifierToken Implements ISyntaxKinds.IdentifierToken
Public ReadOnly Property GlobalKeyword As Integer = SyntaxKind.GlobalKeyword Implements ISyntaxKinds.GlobalKeyword
Public ReadOnly Property IncompleteMember As Integer = SyntaxKind.IncompleteMember Implements ISyntaxKinds.IncompleteMember
Public ReadOnly Property HashToken As Integer = SyntaxKind.HashToken Implements ISyntaxKinds.HashToken
Public ReadOnly Property ExpressionStatement As Integer = SyntaxKind.ExpressionStatement Implements ISyntaxKinds.ExpressionStatement
Public ReadOnly Property ForEachStatement As Integer = SyntaxKind.ForEachStatement Implements ISyntaxKinds.ForEachStatement
Public ReadOnly Property LocalDeclarationStatement As Integer = SyntaxKind.LocalDeclarationStatement Implements ISyntaxKinds.LocalDeclarationStatement
Public ReadOnly Property LockStatement As Integer = SyntaxKind.SyncLockStatement Implements ISyntaxKinds.LockStatement
Public ReadOnly Property ReturnStatement As Integer = SyntaxKind.ReturnStatement Implements ISyntaxKinds.ReturnStatement
Public ReadOnly Property UsingStatement As Integer = SyntaxKind.UsingStatement Implements ISyntaxKinds.UsingStatement
Public ReadOnly Property Attribute As Integer = SyntaxKind.Attribute Implements ISyntaxKinds.Attribute
Public ReadOnly Property Parameter As Integer = SyntaxKind.Parameter Implements ISyntaxKinds.Parameter
Public ReadOnly Property TypeConstraint As Integer = SyntaxKind.TypeConstraint Implements ISyntaxKinds.TypeConstraint
Public ReadOnly Property VariableDeclarator As Integer = SyntaxKind.VariableDeclarator Implements ISyntaxKinds.VariableDeclarator
Public ReadOnly Property TypeArgumentList As Integer = SyntaxKind.TypeArgumentList Implements ISyntaxKinds.TypeArgumentList
End Class
End Namespace
......@@ -13,7 +13,7 @@
<Compile Include="$(MSBuildThisFileDirectory)Extensions\SyntaxTreeExtensions_SharedWithCodeStyle.vb" />
<Compile Include="$(MSBuildThisFileDirectory)Extensions\SyntaxTriviaExtensions.vb" />
<Compile Include="$(MSBuildThisFileDirectory)Helpers\RemoveUnnecessaryImports\VisualBasicUnnecessaryImportsProvider.vb" />
<Compile Include="$(MSBuildThisFileDirectory)Services\SyntaxFacts\VisualBasicSyntaxKindsService.vb" />
<Compile Include="$(MSBuildThisFileDirectory)Services\SyntaxFacts\VisualBasicSyntaxKinds.vb" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="$(MSBuildThisFileDirectory)VisualBasicCompilerExtensionsResources.resx" GenerateSource="true" Link="VisualBasicCompilerExtensionsResources.resx" />
......
......@@ -61,6 +61,7 @@
<Compile Include="$(MSBuildThisFileDirectory)LanguageServices\CSharpSymbolDeclarationService.cs" />
<Compile Include="$(MSBuildThisFileDirectory)LanguageServices\CSharpSyntaxFactsService.cs" />
<Compile Include="$(MSBuildThisFileDirectory)LanguageServices\CSharpSyntaxFactsServiceFactory.cs" />
<Compile Include="$(MSBuildThisFileDirectory)LanguageServices\CSharpSyntaxKindsServiceFactory.cs" />
<Compile Include="$(MSBuildThisFileDirectory)LanguageServices\CSharpTypeInferenceService.cs" />
<Compile Include="$(MSBuildThisFileDirectory)LanguageServices\CSharpTypeInferenceService.TypeInferrer.cs" />
<Compile Include="$(MSBuildThisFileDirectory)LanguageServices\CSharpGeneratedCodeRecognitionService.cs" />
......
......@@ -12,7 +12,6 @@
using System.Threading;
using Microsoft.CodeAnalysis.CSharp.Extensions;
using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
using Microsoft.CodeAnalysis.CSharp.LanguageServices;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Formatting;
using Microsoft.CodeAnalysis.LanguageServices;
......@@ -41,7 +40,7 @@ public SyntaxTrivia ElasticMarker
public SyntaxTrivia ElasticCarriageReturnLineFeed
=> SyntaxFactory.ElasticCarriageReturnLineFeed;
public override ISyntaxKindsService SyntaxKinds { get; } = CSharpSyntaxKindsService.Instance;
public override ISyntaxKinds SyntaxKinds { get; } = CSharpSyntaxKinds.Instance;
protected override IDocumentationCommentService DocumentationCommentService
=> CSharpDocumentationCommentService.Instance;
......
......@@ -3,7 +3,6 @@
// See the LICENSE file in the project root for more information.
using System.Composition;
using Microsoft.CodeAnalysis.CSharp.LanguageServices;
using Microsoft.CodeAnalysis.Host;
using Microsoft.CodeAnalysis.Host.Mef;
using Microsoft.CodeAnalysis.LanguageServices;
......@@ -15,5 +14,10 @@ internal class CSharpSyntaxKindsServiceFactory : ILanguageServiceFactory
{
public ILanguageService CreateLanguageService(HostLanguageServices languageServices)
=> CSharpSyntaxKindsService.Instance;
private sealed class CSharpSyntaxKindsService : CSharpSyntaxKinds, ILanguageService
{
public static readonly new CSharpSyntaxKindsService Instance = new CSharpSyntaxKindsService();
}
}
}
......@@ -22,7 +22,7 @@ internal abstract class AbstractSyntaxFactsService
private readonly static ObjectPool<Stack<(SyntaxNodeOrToken nodeOrToken, bool leading, bool trailing)>> s_stackPool
= SharedPools.Default<Stack<(SyntaxNodeOrToken nodeOrToken, bool leading, bool trailing)>>();
public abstract ISyntaxKindsService SyntaxKinds { get; }
public abstract ISyntaxKinds SyntaxKinds { get; }
// Matches the following:
//
......
......@@ -20,7 +20,7 @@ internal interface ISyntaxFactsService : ILanguageService
SyntaxTrivia ElasticMarker { get; }
SyntaxTrivia ElasticCarriageReturnLineFeed { get; }
ISyntaxKindsService SyntaxKinds { get; }
ISyntaxKinds SyntaxKinds { get; }
bool SupportsIndexingInitializer(ParseOptions options);
bool SupportsThrowExpression(ParseOptions options);
......
......@@ -12,7 +12,7 @@ namespace Microsoft.CodeAnalysis.LanguageServices
/// Provides a uniform view of SyntaxKinds over C# and VB for constructs they have
/// in common.
/// </summary>
internal partial interface ISyntaxKindsService : ILanguageService
internal partial interface ISyntaxKindsService : ISyntaxKinds, ILanguageService
{
}
}
......@@ -35,6 +35,7 @@
<Compile Include="$(MSBuildThisFileDirectory)LanguageServices\Precedence\PrecedenceKind.cs" />
<Compile Include="$(MSBuildThisFileDirectory)LanguageServices\RemoveUnnecessaryImports\AbstractRemoveUnnecessaryImportsService.cs" />
<Compile Include="$(MSBuildThisFileDirectory)LanguageServices\RemoveUnnecessaryImports\IRemoveUnnecessaryImportsService.cs" />
<Compile Include="$(MSBuildThisFileDirectory)LanguageServices\SyntaxFactsService\ISyntaxKindsService.cs" />
<Compile Include="$(MSBuildThisFileDirectory)LanguageServices\TypeInferenceService\AbstractTypeInferenceService.AbstractTypeInferrer.cs" />
<Compile Include="$(MSBuildThisFileDirectory)LanguageServices\TypeInferenceService\AbstractTypeInferenceService.cs" />
<Compile Include="$(MSBuildThisFileDirectory)LanguageServices\TypeInferenceService\ITypeInferenceService.cs" />
......
......@@ -11,7 +11,6 @@ Imports Microsoft.CodeAnalysis.PooledObjects
Imports Microsoft.CodeAnalysis.Text
Imports Microsoft.CodeAnalysis.VisualBasic.CodeGeneration
Imports Microsoft.CodeAnalysis.VisualBasic.Extensions.ContextQuery
Imports Microsoft.CodeAnalysis.VisualBasic.LanguageServices
Imports Microsoft.CodeAnalysis.VisualBasic.Syntax
Imports Microsoft.CodeAnalysis.VisualBasic.SyntaxFacts
......@@ -49,7 +48,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
End Get
End Property
Public Overrides ReadOnly Property SyntaxKinds As ISyntaxKindsService = VisualBasicSyntaxKindsService.Instance Implements ISyntaxFactsService.SyntaxKinds
Public Overrides ReadOnly Property SyntaxKinds As ISyntaxKinds = VisualBasicSyntaxKinds.Instance Implements ISyntaxFactsService.SyntaxKinds
Protected Overrides ReadOnly Property DocumentationCommentService As IDocumentationCommentService
Get
......
......@@ -6,7 +6,6 @@ Imports System.Composition
Imports Microsoft.CodeAnalysis.Host
Imports Microsoft.CodeAnalysis.Host.Mef
Imports Microsoft.CodeAnalysis.LanguageServices
Imports Microsoft.CodeAnalysis.VisualBasic.LanguageServices
Namespace Microsoft.CodeAnalysis.VisualBasic
<ExportLanguageServiceFactory(GetType(ISyntaxKindsService), LanguageNames.VisualBasic), [Shared]>
......@@ -16,5 +15,12 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
Public Function CreateLanguageService(languageServices As HostLanguageServices) As ILanguageService Implements ILanguageServiceFactory.CreateLanguageService
Return VisualBasicSyntaxKindsService.Instance
End Function
Private NotInheritable Class VisualBasicSyntaxKindsService
Inherits VisualBasicSyntaxKinds
Implements ILanguageService
Public Shared Shadows ReadOnly Instance As New VisualBasicSyntaxKindsService
End Class
End Class
End Namespace
......@@ -60,6 +60,7 @@
<Compile Include="$(MSBuildThisFileDirectory)LanguageServices\VisualBasicSymbolDeclarationService.vb" />
<Compile Include="$(MSBuildThisFileDirectory)LanguageServices\VisualBasicSyntaxFactsService.vb" />
<Compile Include="$(MSBuildThisFileDirectory)LanguageServices\VisualBasicSyntaxFactsServiceFactory.vb" />
<Compile Include="$(MSBuildThisFileDirectory)LanguageServices\VisualBasicSyntaxKindsServiceFactory.vb" />
<Compile Include="$(MSBuildThisFileDirectory)LanguageServices\VisualBasicTypeInferenceService.TypeInferrer.vb" />
<Compile Include="$(MSBuildThisFileDirectory)LanguageServices\VisualBasicTypeInferenceService.vb" />
<Compile Include="$(MSBuildThisFileDirectory)Utilities\DirectiveSyntaxEqualityComparer.vb" />
......
......@@ -41,7 +41,7 @@
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.EditorFeatures.Test.Utilities" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Update="VBWorkspaceResources.resx" GenerateSource="true" NAmespace="Microsoft.CodeAnalysis.VisualBasic"/>
<EmbeddedResource Update="VBWorkspaceResources.resx" GenerateSource="true" NAmespace="Microsoft.CodeAnalysis.VisualBasic" />
</ItemGroup>
<ItemGroup>
<Folder Include="Workspace\LanguageServices\" />
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册