8
8
using Microsoft . CodeAnalysis . CSharp . Extensions ;
9
9
using Microsoft . CodeAnalysis . CSharp . Syntax ;
10
10
using Microsoft . CodeAnalysis . Editor . Shared . Utilities ;
11
+ using Microsoft . CodeAnalysis . Options ;
11
12
using Microsoft . CodeAnalysis . Shared . Extensions ;
12
13
using Microsoft . CodeAnalysis . Text ;
13
14
using Microsoft . VisualStudio . LanguageServices . Implementation . Utilities ;
@@ -18,22 +19,16 @@ internal partial class CSharpCodeModelService
18
19
{
19
20
protected override AbstractNodeLocator CreateNodeLocator ( )
20
21
{
21
- return new NodeLocator ( this ) ;
22
+ return new NodeLocator ( ) ;
22
23
}
23
24
24
25
private class NodeLocator : AbstractNodeLocator
25
26
{
26
- public NodeLocator ( CSharpCodeModelService codeModelService )
27
- : base ( codeModelService )
28
- {
29
- }
27
+ protected override string LanguageName => LanguageNames . CSharp ;
30
28
31
- protected override EnvDTE . vsCMPart DefaultPart
32
- {
33
- get { return EnvDTE . vsCMPart . vsCMPartWholeWithAttributes ; }
34
- }
29
+ protected override EnvDTE . vsCMPart DefaultPart => EnvDTE . vsCMPart . vsCMPartWholeWithAttributes ;
35
30
36
- protected override VirtualTreePoint ? GetStartPoint ( SourceText text , SyntaxNode node , EnvDTE . vsCMPart part )
31
+ protected override VirtualTreePoint ? GetStartPoint ( SourceText text , OptionSet options , SyntaxNode node , EnvDTE . vsCMPart part )
37
32
{
38
33
switch ( node . Kind ( ) )
39
34
{
@@ -53,16 +48,16 @@ protected override EnvDTE.vsCMPart DefaultPart
53
48
case SyntaxKind . DestructorDeclaration :
54
49
case SyntaxKind . OperatorDeclaration :
55
50
case SyntaxKind . ConversionOperatorDeclaration :
56
- return GetStartPoint ( text , ( BaseMethodDeclarationSyntax ) node , part ) ;
51
+ return GetStartPoint ( text , options , ( BaseMethodDeclarationSyntax ) node , part ) ;
57
52
case SyntaxKind . PropertyDeclaration :
58
53
case SyntaxKind . IndexerDeclaration :
59
54
case SyntaxKind . EventDeclaration :
60
- return GetStartPoint ( text , ( BasePropertyDeclarationSyntax ) node , part ) ;
55
+ return GetStartPoint ( text , options , ( BasePropertyDeclarationSyntax ) node , part ) ;
61
56
case SyntaxKind . GetAccessorDeclaration :
62
57
case SyntaxKind . SetAccessorDeclaration :
63
58
case SyntaxKind . AddAccessorDeclaration :
64
59
case SyntaxKind . RemoveAccessorDeclaration :
65
- return GetStartPoint ( text , ( AccessorDeclarationSyntax ) node , part ) ;
60
+ return GetStartPoint ( text , options , ( AccessorDeclarationSyntax ) node , part ) ;
66
61
case SyntaxKind . DelegateDeclaration :
67
62
return GetStartPoint ( text , ( DelegateDeclarationSyntax ) node , part ) ;
68
63
case SyntaxKind . NamespaceDeclaration :
@@ -81,7 +76,7 @@ protected override EnvDTE.vsCMPart DefaultPart
81
76
}
82
77
}
83
78
84
- protected override VirtualTreePoint ? GetEndPoint ( SourceText text , SyntaxNode node , EnvDTE . vsCMPart part )
79
+ protected override VirtualTreePoint ? GetEndPoint ( SourceText text , OptionSet options , SyntaxNode node , EnvDTE . vsCMPart part )
85
80
{
86
81
switch ( node . Kind ( ) )
87
82
{
@@ -141,7 +136,7 @@ private VirtualTreePoint GetBodyStartPoint(SourceText text, SyntaxToken openBrac
141
136
: new VirtualTreePoint ( openBrace . SyntaxTree , text , openBrace . Span . End ) ;
142
137
}
143
138
144
- private VirtualTreePoint GetBodyStartPoint ( SourceText text , SyntaxToken openBrace , SyntaxToken closeBrace , int memberStartColumn )
139
+ private VirtualTreePoint GetBodyStartPoint ( SourceText text , OptionSet options , SyntaxToken openBrace , SyntaxToken closeBrace , int memberStartColumn )
145
140
{
146
141
Debug . Assert ( ! openBrace . IsMissing ) ;
147
142
Debug . Assert ( ! closeBrace . IsMissing ) ;
@@ -181,7 +176,7 @@ private VirtualTreePoint GetBodyStartPoint(SourceText text, SyntaxToken openBrac
181
176
182
177
// If the line is all whitespace then place the caret at the first indent after the start
183
178
// of the member.
184
- var indentSize = GetTabSize ( text ) ;
179
+ var indentSize = GetTabSize ( options ) ;
185
180
var lineText = lineAfterOpenBrace . ToString ( ) ;
186
181
187
182
var lineEndColumn = lineText . GetColumnFromLineOffset ( lineText . Length , indentSize ) ;
@@ -347,7 +342,7 @@ private VirtualTreePoint GetStartPoint(SourceText text, BaseTypeDeclarationSynta
347
342
return new VirtualTreePoint ( node . SyntaxTree , text , startPosition ) ;
348
343
}
349
344
350
- private VirtualTreePoint GetStartPoint ( SourceText text , BaseMethodDeclarationSyntax node , EnvDTE . vsCMPart part )
345
+ private VirtualTreePoint GetStartPoint ( SourceText text , OptionSet options , BaseMethodDeclarationSyntax node , EnvDTE . vsCMPart part )
351
346
{
352
347
int startPosition ;
353
348
@@ -380,9 +375,9 @@ private VirtualTreePoint GetStartPoint(SourceText text, BaseMethodDeclarationSyn
380
375
if ( node . Body != null && ! node . Body . OpenBraceToken . IsMissing )
381
376
{
382
377
var line = text . Lines . GetLineFromPosition ( node . SpanStart ) ;
383
- var indentation = line . GetColumnOfFirstNonWhitespaceCharacterOrEndOfLine ( GetTabSize ( text ) ) ;
378
+ var indentation = line . GetColumnOfFirstNonWhitespaceCharacterOrEndOfLine ( GetTabSize ( options ) ) ;
384
379
385
- return GetBodyStartPoint ( text , node . Body . OpenBraceToken , node . Body . CloseBraceToken , indentation ) ;
380
+ return GetBodyStartPoint ( text , options , node . Body . OpenBraceToken , node . Body . CloseBraceToken , indentation ) ;
386
381
}
387
382
else
388
383
{
@@ -436,7 +431,7 @@ private AccessorDeclarationSyntax FindFirstAccessorNode(BasePropertyDeclarationS
436
431
return node . AccessorList . Accessors . FirstOrDefault ( ) ;
437
432
}
438
433
439
- private VirtualTreePoint GetStartPoint ( SourceText text , BasePropertyDeclarationSyntax node , EnvDTE . vsCMPart part )
434
+ private VirtualTreePoint GetStartPoint ( SourceText text , OptionSet options , BasePropertyDeclarationSyntax node , EnvDTE . vsCMPart part )
440
435
{
441
436
int startPosition ;
442
437
@@ -467,17 +462,17 @@ private VirtualTreePoint GetStartPoint(SourceText text, BasePropertyDeclarationS
467
462
if ( firstAccessorNode != null )
468
463
{
469
464
var line = text . Lines . GetLineFromPosition ( firstAccessorNode . SpanStart ) ;
470
- var indentation = line . GetColumnOfFirstNonWhitespaceCharacterOrEndOfLine ( GetTabSize ( text ) ) ;
465
+ var indentation = line . GetColumnOfFirstNonWhitespaceCharacterOrEndOfLine ( GetTabSize ( options ) ) ;
471
466
472
467
if ( firstAccessorNode . Body != null )
473
468
{
474
- return GetBodyStartPoint ( text , firstAccessorNode . Body . OpenBraceToken , firstAccessorNode . Body . CloseBraceToken , indentation ) ;
469
+ return GetBodyStartPoint ( text , options , firstAccessorNode . Body . OpenBraceToken , firstAccessorNode . Body . CloseBraceToken , indentation ) ;
475
470
}
476
471
else if ( ! firstAccessorNode . SemicolonToken . IsMissing )
477
472
{
478
473
// This is total weirdness from the old C# code model with auto props.
479
474
// If there isn't a body, the semi-colon is used
480
- return GetBodyStartPoint ( text , firstAccessorNode . SemicolonToken , firstAccessorNode . SemicolonToken , indentation ) ;
475
+ return GetBodyStartPoint ( text , options , firstAccessorNode . SemicolonToken , firstAccessorNode . SemicolonToken , indentation ) ;
481
476
}
482
477
}
483
478
@@ -487,9 +482,9 @@ private VirtualTreePoint GetStartPoint(SourceText text, BasePropertyDeclarationS
487
482
if ( node . AccessorList != null && ! node . AccessorList . OpenBraceToken . IsMissing )
488
483
{
489
484
var line = text . Lines . GetLineFromPosition ( node . SpanStart ) ;
490
- var indentation = line . GetColumnOfFirstNonWhitespaceCharacterOrEndOfLine ( GetTabSize ( text ) ) ;
485
+ var indentation = line . GetColumnOfFirstNonWhitespaceCharacterOrEndOfLine ( GetTabSize ( options ) ) ;
491
486
492
- return GetBodyStartPoint ( text , node . AccessorList . OpenBraceToken , node . AccessorList . CloseBraceToken , indentation ) ;
487
+ return GetBodyStartPoint ( text , options , node . AccessorList . OpenBraceToken , node . AccessorList . CloseBraceToken , indentation ) ;
493
488
}
494
489
495
490
throw Exceptions . ThrowEFail ( ) ;
@@ -501,7 +496,7 @@ private VirtualTreePoint GetStartPoint(SourceText text, BasePropertyDeclarationS
501
496
return new VirtualTreePoint ( node . SyntaxTree , text , startPosition ) ;
502
497
}
503
498
504
- private VirtualTreePoint GetStartPoint ( SourceText text , AccessorDeclarationSyntax node , EnvDTE . vsCMPart part )
499
+ private VirtualTreePoint GetStartPoint ( SourceText text , OptionSet options , AccessorDeclarationSyntax node , EnvDTE . vsCMPart part )
505
500
{
506
501
int startPosition ;
507
502
@@ -526,9 +521,9 @@ private VirtualTreePoint GetStartPoint(SourceText text, AccessorDeclarationSynta
526
521
if ( node . Body != null && ! node . Body . OpenBraceToken . IsMissing )
527
522
{
528
523
var line = text . Lines . GetLineFromPosition ( node . SpanStart ) ;
529
- var indentation = line . GetColumnOfFirstNonWhitespaceCharacterOrEndOfLine ( GetTabSize ( text ) ) ;
524
+ var indentation = line . GetColumnOfFirstNonWhitespaceCharacterOrEndOfLine ( GetTabSize ( options ) ) ;
530
525
531
- return GetBodyStartPoint ( text , node . Body . OpenBraceToken , node . Body . CloseBraceToken , indentation ) ;
526
+ return GetBodyStartPoint ( text , options , node . Body . OpenBraceToken , node . Body . CloseBraceToken , indentation ) ;
532
527
}
533
528
534
529
throw Exceptions . ThrowEFail ( ) ;
0 commit comments