From d691f33a44358fa4103b563fe80bf51d3e93d538 Mon Sep 17 00:00:00 2001 From: Gen Lu Date: Mon, 25 Nov 2019 17:03:18 -0800 Subject: [PATCH] Fix typos --- .../MoveToNamespace/AbstractMoveToNamespaceTests.cs | 1 - .../SyncNamespace/CSharpChangeNamespaceService.cs | 11 ++++++++--- .../SyncNamespace/AbstractChangeNamespaceService.cs | 8 ++++---- .../AbstractSyncNamespaceCodeRefactoringProvider.cs | 4 ++-- .../MoveToNamespace/AbstractMoveToNamespaceService.cs | 2 +- .../CoreTestUtilities/MEF/ExportProviderCache.cs | 2 +- 6 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/EditorFeatures/TestUtilities/MoveToNamespace/AbstractMoveToNamespaceTests.cs b/src/EditorFeatures/TestUtilities/MoveToNamespace/AbstractMoveToNamespaceTests.cs index 8f5f6207a26..4dc07e0e776 100644 --- a/src/EditorFeatures/TestUtilities/MoveToNamespace/AbstractMoveToNamespaceTests.cs +++ b/src/EditorFeatures/TestUtilities/MoveToNamespace/AbstractMoveToNamespaceTests.cs @@ -83,7 +83,6 @@ protected override CodeRefactoringProvider CreateCodeRefactoringProvider(Workspa checkedCodeActions.Add(codeAction); } } - } if (!optionCancelled && !string.IsNullOrEmpty(targetNamespace)) diff --git a/src/Features/CSharp/Portable/CodeRefactorings/SyncNamespace/CSharpChangeNamespaceService.cs b/src/Features/CSharp/Portable/CodeRefactorings/SyncNamespace/CSharpChangeNamespaceService.cs index 4219c01e644..1262750d56b 100644 --- a/src/Features/CSharp/Portable/CodeRefactorings/SyncNamespace/CSharpChangeNamespaceService.cs +++ b/src/Features/CSharp/Portable/CodeRefactorings/SyncNamespace/CSharpChangeNamespaceService.cs @@ -99,11 +99,11 @@ protected override SyntaxList GetMemberDeclarationsInCo } /// - /// Try to get a new node to replace given node, which is a reference to a top-level type declared inside the namespce to be changed. + /// Try to get a new node to replace given node, which is a reference to a top-level type declared inside the namespace to be changed. /// If this reference is the right side of a qualified name, the new node returned would be the entire qualified name. Depends on /// whether is provided, the name in the new node might be qualified with this new namespace instead. /// - /// A reference to a type declared inside the namespce to be changed, which is calculated based on results from + /// A reference to a type declared inside the namespace to be changed, which is calculated based on results from /// `SymbolFinder.FindReferencesAsync`. /// If specified, and the reference is qualified with namespace, the namespace part of original reference /// will be replaced with given namespace in the new node. @@ -275,7 +275,7 @@ private static CompilationUnitSyntax MoveMembersFromNamespaceToGlobal(Compilatio var eofToken = root.EndOfFileToken .WithAdditionalAnnotations(WarningAnnotation); - // Try to preserve trivia from original namesapce declaration. + // Try to preserve trivia from original namespace declaration. // If there's any member inside the declaration, we attach them to the // first and last member, otherwise, simply attach all to the EOF token. if (members.Count > 0) @@ -362,6 +362,11 @@ private static CompilationUnitSyntax MoveMembersFromGlobalToNamespace(Compilatio { // Otherwise, the span should contain a namespace declaration node, which must be the only one // in the entire syntax spine to enable the change namespace operation. + if (!compilationUnit.Span.Contains(span)) + { + return null; + } + var node = compilationUnit.FindNode(span, getInnermostNodeForTie: true); var namespaceDecl = node.AncestorsAndSelf().OfType().SingleOrDefault(); diff --git a/src/Features/Core/Portable/CodeRefactorings/SyncNamespace/AbstractChangeNamespaceService.cs b/src/Features/Core/Portable/CodeRefactorings/SyncNamespace/AbstractChangeNamespaceService.cs index 4d34329f265..166b67ba508 100644 --- a/src/Features/Core/Portable/CodeRefactorings/SyncNamespace/AbstractChangeNamespaceService.cs +++ b/src/Features/Core/Portable/CodeRefactorings/SyncNamespace/AbstractChangeNamespaceService.cs @@ -33,11 +33,11 @@ internal abstract class AbstractChangeNamespaceService : IChangeNamespaceService /// /// Try to get a new node to replace given node, which is a reference to a top-level type declared inside the - /// namespce to be changed. If this reference is the right side of a qualified name, the new node returned would + /// namespace to be changed. If this reference is the right side of a qualified name, the new node returned would /// be the entire qualified name. Depends on whether is provided, the name /// in the new node might be qualified with this new namespace instead. /// - /// A reference to a type declared inside the namespce to be changed, which is calculated + /// A reference to a type declared inside the namespace to be changed, which is calculated /// based on results from `SymbolFinder.FindReferencesAsync`. /// If specified, the namespace of original reference will be replaced with given /// namespace in the replacement node. @@ -164,7 +164,7 @@ await ChangeNamespaceInSingleDocumentAsync(solutionAfterNamespaceChange, documen // After changing documents, we still need to remove unnecessary imports related to our change. // We don't try to remove all imports that might become unnecessary/invalid after the namespace change, - // just ones that fully matche the old/new namespace. Because it's hard to get it right and will almost + // just ones that fully match the old/new namespace. Because it's hard to get it right and will almost // certainly cause perf issue. // For example, if we are changing namespace `Foo.Bar` (which is the only namespace declaration with such name) // to `A.B`, the using of name `Bar` in a different file below would remain untouched, even it's no longer valid: @@ -287,7 +287,7 @@ protected static bool IsSupportedLinkedDocument(Document document, out Immutable // TODO: figure out how to properly determine if and how a document is linked using project system. - // If we found a linked document which is part of a project with differenct project file, + // If we found a linked document which is part of a project with different project file, // then it's an actual linked file (i.e. not a multi-targeting project). We don't support that for now. if (linkedDocumentIds.Any(id => !PathUtilities.PathsEqual(solution.GetDocument(id).Project.FilePath, document.Project.FilePath))) diff --git a/src/Features/Core/Portable/CodeRefactorings/SyncNamespace/AbstractSyncNamespaceCodeRefactoringProvider.cs b/src/Features/Core/Portable/CodeRefactorings/SyncNamespace/AbstractSyncNamespaceCodeRefactoringProvider.cs index 6f3d01cf489..e4e11acdbe6 100644 --- a/src/Features/Core/Portable/CodeRefactorings/SyncNamespace/AbstractSyncNamespaceCodeRefactoringProvider.cs +++ b/src/Features/Core/Portable/CodeRefactorings/SyncNamespace/AbstractSyncNamespaceCodeRefactoringProvider.cs @@ -36,7 +36,7 @@ public override async Task ComputeRefactoringsAsync(CodeRefactoringContext conte { // These code actions try to move file to a new location based on declared namespace // and the default namespace of the project. The new location is a list of folders - // determined by the relateive part of the declared namespace compare to the default namespace. + // determined by the relative part of the declared namespace compare to the default namespace. // // For example, if he default namespace is `A.B.C`, file path is // "[project root dir]\Class1.cs" and declared namespace in the file is @@ -81,7 +81,7 @@ public override async Task ComputeRefactoringsAsync(CodeRefactoringContext conte /// Try to get the node that can be used to trigger the refactoring based on current cursor position. /// /// - /// (1) a node of type node, if curosr in the name and it's the + /// (1) a node of type node, if cursor in the name and it's the /// only namespace declaration in the document. /// (2) a node of type node, if the cursor is in the name of first /// declaration in global namespace and there's no namespace declaration in this document. diff --git a/src/Features/Core/Portable/MoveToNamespace/AbstractMoveToNamespaceService.cs b/src/Features/Core/Portable/MoveToNamespace/AbstractMoveToNamespaceService.cs index e37f5debcef..901f5c62647 100644 --- a/src/Features/Core/Portable/MoveToNamespace/AbstractMoveToNamespaceService.cs +++ b/src/Features/Core/Portable/MoveToNamespace/AbstractMoveToNamespaceService.cs @@ -93,7 +93,7 @@ protected AbstractMoveToNamespaceService(IMoveToNamespaceOptionsService moveToNa return null; } - // The underlying ChangeNamespace service doesn't support nested namespace decalration. + // The underlying ChangeNamespace service doesn't support nested namespace declaration. if (GetNamespaceInSpineCount(declarationSyntax) == 1) { var changeNamespaceService = document.GetLanguageService(); diff --git a/src/Workspaces/CoreTestUtilities/MEF/ExportProviderCache.cs b/src/Workspaces/CoreTestUtilities/MEF/ExportProviderCache.cs index 59a0e2ddbc7..15dfbecd0fe 100644 --- a/src/Workspaces/CoreTestUtilities/MEF/ExportProviderCache.cs +++ b/src/Workspaces/CoreTestUtilities/MEF/ExportProviderCache.cs @@ -275,7 +275,7 @@ private static void RequireForSingleExportProvider(bool condition) // method attempting to create a default ExportProvider which did not match the one assigned to // the test. // * A test attempted to perform multiple test sequences in the context of a single test method, - // rather than break up the test into distict tests for each case. + // rather than break up the test into distinct tests for each case. // * A test referenced different predefined ExportProvider instances within the context of a test. // Each test is expected to use the same ExportProvider throughout the test. throw new InvalidOperationException($"Only one {nameof(ExportProvider)} can be created in the context of a single test."); -- GitLab