Skip to content

Commit 208da19

Browse files
NodeLocator doesn't need a CodeModelService just to get language name
1 parent f23c0f7 commit 208da19

File tree

3 files changed

+11
-20
lines changed

3 files changed

+11
-20
lines changed

src/VisualStudio/CSharp/Impl/CodeModel/CSharpCodeModelService.NodeLocator.cs

+3-9
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,14 @@ internal partial class CSharpCodeModelService
1919
{
2020
protected override AbstractNodeLocator CreateNodeLocator()
2121
{
22-
return new NodeLocator(this);
22+
return new NodeLocator();
2323
}
2424

2525
private class NodeLocator : AbstractNodeLocator
2626
{
27-
public NodeLocator(CSharpCodeModelService codeModelService)
28-
: base(codeModelService)
29-
{
30-
}
27+
protected override string LanguageName => LanguageNames.CSharp;
3128

32-
protected override EnvDTE.vsCMPart DefaultPart
33-
{
34-
get { return EnvDTE.vsCMPart.vsCMPartWholeWithAttributes; }
35-
}
29+
protected override EnvDTE.vsCMPart DefaultPart => EnvDTE.vsCMPart.vsCMPartWholeWithAttributes;
3630

3731
protected override VirtualTreePoint? GetStartPoint(SourceText text, OptionSet options, SyntaxNode node, EnvDTE.vsCMPart part)
3832
{

src/VisualStudio/Core/Impl/CodeModel/AbstractCodeModelService.AbstractNodeLocator.cs

+2-7
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,7 @@ internal partial class AbstractCodeModelService : ICodeModelService
1414

1515
protected abstract class AbstractNodeLocator
1616
{
17-
private readonly AbstractCodeModelService _codeModelService;
18-
19-
protected AbstractNodeLocator(AbstractCodeModelService codeModelService)
20-
{
21-
_codeModelService = codeModelService;
22-
}
17+
protected abstract string LanguageName { get; }
2318

2419
protected abstract EnvDTE.vsCMPart DefaultPart { get; }
2520

@@ -28,7 +23,7 @@ protected AbstractNodeLocator(AbstractCodeModelService codeModelService)
2823

2924
protected int GetTabSize(OptionSet options)
3025
{
31-
return options.GetOption(FormattingOptions.TabSize, _codeModelService.Language);
26+
return options.GetOption(FormattingOptions.TabSize, LanguageName);
3227
}
3328

3429
public VirtualTreePoint? GetStartPoint(SyntaxNode node, OptionSet options, EnvDTE.vsCMPart? part)

src/VisualStudio/VisualBasic/Impl/CodeModel/VisualBasicCodeModelService.NodeLocator.vb

+6-4
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,17 @@ Namespace Microsoft.VisualStudio.LanguageServices.VisualBasic.CodeModel
1414
Partial Friend Class VisualBasicCodeModelService
1515

1616
Protected Overrides Function CreateNodeLocator() As AbstractNodeLocator
17-
Return New NodeLocator(Me)
17+
Return New NodeLocator()
1818
End Function
1919

2020
Private Class NodeLocator
2121
Inherits AbstractNodeLocator
2222

23-
Public Sub New(codeModelService As VisualBasicCodeModelService)
24-
MyBase.New(codeModelService)
25-
End Sub
23+
Protected Overrides ReadOnly Property LanguageName As String
24+
Get
25+
Return LanguageNames.VisualBasic
26+
End Get
27+
End Property
2628

2729
Protected Overrides ReadOnly Property DefaultPart As EnvDTE.vsCMPart
2830
Get

0 commit comments

Comments
 (0)