@@ -18,8 +18,7 @@ Imports Microsoft.CodeAnalysis.VisualBasic.Syntax
1818Imports Microsoft.CodeAnalysis.VisualBasic.Utilities
1919
2020Namespace Microsoft.CodeAnalysis.VisualBasic.Rename
21-
22- Friend Class VisualBasicRenameRewriterLanguageService
21+ Friend NotInheritable Class VisualBasicRenameRewriterLanguageService
2322 Inherits AbstractRenameRewriterLanguageService
2423
2524 Public Shared ReadOnly Instance As New VisualBasicRenameRewriterLanguageService()
@@ -680,15 +679,14 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Rename
680679 End Function
681680
682681 Public Overrides Async Function ComputeDeclarationConflictsAsync(
683- replacementText As String ,
684- renamedSymbol As ISymbol,
685- renameSymbol As ISymbol,
686- referencedSymbols As IEnumerable( Of ISymbol),
687- baseSolution As Solution,
688- newSolution As Solution,
689- reverseMappedLocations As IDictionary( Of Location, Location),
690- cancellationToken As CancellationToken
691- ) As Task( Of ImmutableArray( Of Location))
682+ replacementText As String ,
683+ renamedSymbol As ISymbol,
684+ renameSymbol As ISymbol,
685+ referencedSymbols As IEnumerable( Of ISymbol),
686+ baseSolution As Solution,
687+ newSolution As Solution,
688+ reverseMappedLocations As IDictionary( Of Location, Location),
689+ cancellationToken As CancellationToken) As Task( Of ImmutableArray( Of Location))
692690
693691 Dim conflicts = ArrayBuilder( Of Location).GetInstance()
694692
@@ -700,17 +698,19 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Rename
700698
701699 ' Find the method block or field declaration that we're in. Note the LastOrDefault
702700 ' so we find the uppermost one, since VariableDeclarators live in methods too.
703- Dim methodBase = token.Parent.AncestorsAndSelf.Where( Function (s) TypeOf s Is MethodBlockBaseSyntax OrElse TypeOf s Is VariableDeclaratorSyntax) _
704- .LastOrDefault()
705-
706- Dim semanticModel = Await newSolution.
707- GetRequiredDocument(methodBase.SyntaxTree).
708- GetSemanticModelAsync(cancellationToken).ConfigureAwait( False )
709- Dim visitor As New LocalConflictVisitor(token, semanticModel, cancellationToken)
710- visitor.Visit(methodBase)
711-
712- conflicts.AddRange(visitor.ConflictingTokens.Select( Function (t) t.GetLocation()) _
713- .Select( Function (loc) reverseMappedLocations(loc)))
701+ Dim methodBase = token.Parent.
702+ AncestorsAndSelf().
703+ Where ( Function (s) TypeOf s Is MethodBlockBaseSyntax OrElse TypeOf s Is VariableDeclaratorSyntax).
704+ LastOrDefault()
705+
706+ If methodBase IsNot Nothing Then
707+ Dim semanticModel = Await newSolution.
708+ GetRequiredDocument(methodBase.SyntaxTree).
709+ GetSemanticModelAsync(cancellationToken).ConfigureAwait( False )
710+ Dim visitor As New LocalConflictVisitor(token, semanticModel, cancellationToken)
711+ visitor.Visit(methodBase)
712+ conflicts.AddRange(visitor.ConflictingTokens.Select( Function (t) t.GetLocation()).Select( Function (loc) reverseMappedLocations(loc)))
713+ End If
714714
715715 ' If this is a parameter symbol for a partial method definition, be sure we visited
716716 ' the implementation part's body.
@@ -723,14 +723,15 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Rename
723723 token = matchingParameterSymbol.Locations.Single().FindToken(cancellationToken)
724724 methodBase = token.GetAncestor( Of MethodBlockSyntax)
725725
726- semanticModel = Await newSolution.
727- GetRequiredDocument(methodBase.SyntaxTree).
728- GetSemanticModelAsync(cancellationToken).ConfigureAwait( False )
729- visitor = New LocalConflictVisitor(token, semanticModel, cancellationToken)
730- visitor.Visit(methodBase)
726+ If methodBase IsNot Nothing Then
727+ Dim semanticModel = Await newSolution.
728+ GetRequiredDocument(methodBase.SyntaxTree).
729+ GetSemanticModelAsync(cancellationToken).ConfigureAwait( False )
730+ Dim visitor = New LocalConflictVisitor(token, semanticModel, cancellationToken)
731+ visitor.Visit(methodBase)
731732
732- conflicts.AddRange(visitor.ConflictingTokens.Select( Function (t) t.GetLocation()) _
733- .Select( Function (loc) reverseMappedLocations(loc)))
733+ conflicts.AddRange(visitor.ConflictingTokens.Select( Function (t) t.GetLocation()).Select( Function (loc) reverseMappedLocations(loc)))
734+ End If
734735 End If
735736 End If
736737
0 commit comments