From 69fb7891deb9d9a8971e38e45b7307960a35a57e Mon Sep 17 00:00:00 2001 From: David Barbet Date: Tue, 7 May 2019 11:36:58 -0700 Subject: [PATCH] Update license comments, fixup classifications. --- .../RoslynClassificationService.Exports.cs | 31 ++++++------ .../RoslynClassificationService.cs | 47 ++++++++++--------- .../RoslynCodeActionProvider.Exports.cs | 4 +- .../CodeActions/RoslynCodeActionProvider.cs | 4 +- .../CodeActions/RoslynRemoteCodeAction.cs | 4 +- .../RoslynRemoteCodeActionOperation.cs | 4 +- .../RoslynCompletionProvider.Exports.cs | 4 +- .../Completion/RoslynCompletionProvider.cs | 4 +- .../RoslynCompletionService.Exports.cs | 4 +- .../Completion/RoslynCompletionService.cs | 4 +- .../Diagnostics/IRemoteDiagnosticsService.cs | 5 +- .../RoslynDocumentDiagnosticAnalyzer.cs | 4 +- .../RoslynRemoteDiagnosticsService.Exports.cs | 4 +- .../RoslynRemoteDiagnosticsService.cs | 4 +- .../RoslynGotoDefinitionService.Exports.cs | 4 +- .../RoslynGotoDefinitionService.cs | 4 +- ...RoslynDocumentHighlightsService.Exports.cs | 4 +- .../RoslynDocumentHighlightsService.cs | 4 +- .../Client/HostLanguageServicesExtensions.cs | 31 ++++++++++++ .../RoslynNavigationBarItemService.Exports.cs | 4 +- .../RoslynNavigationBarItemService.cs | 4 +- .../RoslynFindUsagesService.Exports..cs | 4 +- .../References/RoslynFindUsagesService.cs | 4 +- .../Rename/RoslynRenameService.Exports.cs | 4 +- .../RoslynRenameService.FailureRenameInfo.cs | 4 +- .../Impl/Client/Rename/RoslynRenameService.cs | 4 +- .../RoslynSignatureHelpProvider.Exports.cs | 27 +++-------- .../RoslynSignatureHelpProvider.cs | 10 +--- 28 files changed, 107 insertions(+), 132 deletions(-) create mode 100644 src/VisualStudio/LiveShare/Impl/Client/HostLanguageServicesExtensions.cs diff --git a/src/VisualStudio/LiveShare/Impl/Client/Classification/RoslynClassificationService.Exports.cs b/src/VisualStudio/LiveShare/Impl/Client/Classification/RoslynClassificationService.Exports.cs index ae6fb40a2ec..8c0e912a48f 100644 --- a/src/VisualStudio/LiveShare/Impl/Client/Classification/RoslynClassificationService.Exports.cs +++ b/src/VisualStudio/LiveShare/Impl/Client/Classification/RoslynClassificationService.Exports.cs @@ -1,6 +1,4 @@ -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// +// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; using System.Composition; @@ -32,38 +30,41 @@ public ILanguageService CreateLanguageService(HostLanguageServices languageServi [ExportLanguageServiceFactory(typeof(ISyntaxClassificationService), StringConstants.CSharpLspLanguageName), Shared] internal class CSharpLspEditorClassificationFactoryService : ILanguageServiceFactory { - private readonly RoslynLSPClientServiceFactory roslynLSPClientServiceFactory; - private readonly ClassificationTypeMap classificationTypeMap; + private readonly RoslynLSPClientServiceFactory _roslynLSPClientServiceFactory; + private readonly ClassificationTypeMap _classificationTypeMap; + private readonly ThreadingContext _threadingContext; [ImportingConstructor] - public CSharpLspEditorClassificationFactoryService(RoslynLSPClientServiceFactory roslynLSPClientServiceFactory, ClassificationTypeMap classificationTypeMap) + public CSharpLspEditorClassificationFactoryService(RoslynLSPClientServiceFactory roslynLSPClientServiceFactory, ClassificationTypeMap classificationTypeMap, IThreadingContext threadingContext) { - this.roslynLSPClientServiceFactory = roslynLSPClientServiceFactory ?? throw new ArgumentNullException(nameof(roslynLSPClientServiceFactory)); - this.classificationTypeMap = classificationTypeMap ?? throw new ArgumentNullException(nameof(classificationTypeMap)); + _roslynLSPClientServiceFactory = roslynLSPClientServiceFactory ?? throw new ArgumentNullException(nameof(roslynLSPClientServiceFactory)); + _classificationTypeMap = classificationTypeMap ?? throw new ArgumentNullException(nameof(classificationTypeMap)); } public ILanguageService CreateLanguageService(HostLanguageServices languageServices) { - return new RoslynClassificationService(this.roslynLSPClientServiceFactory, languageServices.GetOriginalLanguageService(), this.classificationTypeMap); + return new RoslynClassificationService(_roslynLSPClientServiceFactory, languageServices.GetOriginalLanguageService(), _classificationTypeMap, _threadingContext); } } [ExportLanguageServiceFactory(typeof(ISyntaxClassificationService), StringConstants.VBLspLanguageName), Shared] internal class VBLspEditorClassificationFactoryService : ILanguageServiceFactory { - private readonly RoslynLSPClientServiceFactory roslynLSPClientServiceFactory; - private readonly ClassificationTypeMap classificationTypeMap; + private readonly RoslynLSPClientServiceFactory _roslynLSPClientServiceFactory; + private readonly ClassificationTypeMap _classificationTypeMap; + private readonly IThreadingContext _threadingContext; [ImportingConstructor] - public VBLspEditorClassificationFactoryService(RoslynLSPClientServiceFactory roslynLSPClientServiceFactory, ClassificationTypeMap classificationTypeMap) + public VBLspEditorClassificationFactoryService(RoslynLSPClientServiceFactory roslynLSPClientServiceFactory, ClassificationTypeMap classificationTypeMap, IThreadingContext threadingContext) { - this.roslynLSPClientServiceFactory = roslynLSPClientServiceFactory ?? throw new ArgumentNullException(nameof(roslynLSPClientServiceFactory)); - this.classificationTypeMap = classificationTypeMap ?? throw new ArgumentNullException(nameof(classificationTypeMap)); + _roslynLSPClientServiceFactory = roslynLSPClientServiceFactory ?? throw new ArgumentNullException(nameof(roslynLSPClientServiceFactory)); + _classificationTypeMap = classificationTypeMap ?? throw new ArgumentNullException(nameof(classificationTypeMap)); + _threadingContext = threadingContext; } public ILanguageService CreateLanguageService(HostLanguageServices languageServices) { - return new RoslynClassificationService(this.roslynLSPClientServiceFactory, languageServices.GetOriginalLanguageService(), this.classificationTypeMap); + return new RoslynClassificationService(_roslynLSPClientServiceFactory, languageServices.GetOriginalLanguageService(), _classificationTypeMap, _threadingContext); } } } diff --git a/src/VisualStudio/LiveShare/Impl/Client/Classification/RoslynClassificationService.cs b/src/VisualStudio/LiveShare/Impl/Client/Classification/RoslynClassificationService.cs index a152614ddf3..ed7e562d8ce 100644 --- a/src/VisualStudio/LiveShare/Impl/Client/Classification/RoslynClassificationService.cs +++ b/src/VisualStudio/LiveShare/Impl/Client/Classification/RoslynClassificationService.cs @@ -1,6 +1,4 @@ -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// +// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; using System.Collections.Immutable; @@ -9,36 +7,40 @@ using Microsoft.CodeAnalysis.Classification; using Microsoft.CodeAnalysis.Classification.Classifiers; using Microsoft.CodeAnalysis.Editor.Shared.Utilities; +using Microsoft.CodeAnalysis.LanguageServer; +using Microsoft.CodeAnalysis.LanguageServer.CustomProtocol; using Microsoft.CodeAnalysis.PooledObjects; using Microsoft.CodeAnalysis.Text; using Microsoft.VisualStudio.LanguageServer.Protocol; -using Microsoft.VisualStudio.LanguageServices.Remote.Shared.CustomProtocol; -using Microsoft.VisualStudio.Shell; +using Microsoft.VisualStudio.LanguageServices.LiveShare.CustomProtocol; using Task = System.Threading.Tasks.Task; namespace Microsoft.VisualStudio.LanguageServices.LiveShare.Client { internal class RoslynClassificationService : ISyntaxClassificationService { - private readonly RoslynLSPClientServiceFactory roslynLSPClientServiceFactory; - private readonly ISyntaxClassificationService originalService; - private readonly ClassificationTypeMap classificationTypeMap; + private readonly RoslynLSPClientServiceFactory _roslynLSPClientServiceFactory; + private readonly ISyntaxClassificationService _originalService; + private readonly ClassificationTypeMap _classificationTypeMap; + private readonly IThreadingContext _threadingContext; - public RoslynClassificationService(RoslynLSPClientServiceFactory roslynLSPClientServiceFactory, ISyntaxClassificationService originalService, ClassificationTypeMap classificationTypeMap) + public RoslynClassificationService(RoslynLSPClientServiceFactory roslynLSPClientServiceFactory, ISyntaxClassificationService originalService, + ClassificationTypeMap classificationTypeMap, IThreadingContext threadingContext) { - this.roslynLSPClientServiceFactory = roslynLSPClientServiceFactory ?? throw new ArgumentNullException(nameof(roslynLSPClientServiceFactory)); - this.originalService = originalService ?? throw new ArgumentNullException(nameof(originalService)); - this.classificationTypeMap = classificationTypeMap ?? throw new ArgumentNullException(nameof(classificationTypeMap)); + _roslynLSPClientServiceFactory = roslynLSPClientServiceFactory ?? throw new ArgumentNullException(nameof(roslynLSPClientServiceFactory)); + _originalService = originalService ?? throw new ArgumentNullException(nameof(originalService)); + _classificationTypeMap = classificationTypeMap ?? throw new ArgumentNullException(nameof(classificationTypeMap)); + _threadingContext = threadingContext; } public void AddLexicalClassifications(SourceText text, TextSpan textSpan, ArrayBuilder result, CancellationToken cancellationToken) { - this.originalService.AddLexicalClassifications(text, textSpan, result, cancellationToken); + _originalService.AddLexicalClassifications(text, textSpan, result, cancellationToken); } public void AddSemanticClassifications(SemanticModel semanticModel, TextSpan textSpan, Workspace workspace, Func> getNodeClassifiers, Func> getTokenClassifiers, ArrayBuilder result, CancellationToken cancellationToken) { - ThreadHelper.JoinableTaskFactory.Run(async () => + _threadingContext.JoinableTaskFactory.Run(async () => { var sourceText = await semanticModel.SyntaxTree.GetTextAsync(cancellationToken).ConfigureAwait(false); await AddRemoteSemanticClassificationsAsync(sourceText, semanticModel.SyntaxTree.FilePath, textSpan, result, cancellationToken).ConfigureAwait(false); @@ -60,7 +62,7 @@ public async Task AddSemanticClassificationsAsync(Document document, TextSpan te private async Task AddRemoteSemanticClassificationsAsync(SourceText text, string filePath, TextSpan textSpan, ArrayBuilder result, CancellationToken cancellationToken) { - var lspClient = this.roslynLSPClientServiceFactory.ActiveLanguageServerClient; + var lspClient = _roslynLSPClientServiceFactory.ActiveLanguageServerClient; if (lspClient == null) { return; @@ -69,10 +71,11 @@ private async Task AddRemoteSemanticClassificationsAsync(SourceText text, string var classificationParams = new ClassificationParams { TextDocument = new TextDocumentIdentifier { Uri = lspClient.ProtocolConverter.ToProtocolUri(new Uri(filePath)) }, - Range = textSpan.ToRange(text) + Range = ProtocolConversions.TextSpanToRange(textSpan, text) }; - ClassificationSpan[] classificationSpans = await lspClient.RequestAsync(RoslynMethods.Classifications, classificationParams, cancellationToken).ConfigureAwait(false); + var request = new LspRequest(RoslynMethods.ClassificationsName); + var classificationSpans = await lspClient.RequestAsync(request, classificationParams, cancellationToken).ConfigureAwait(false); if (classificationSpans == null) { return; @@ -83,12 +86,12 @@ private async Task AddRemoteSemanticClassificationsAsync(SourceText text, string // The host may return more classifications than are supported by the guest. As an example, 15.7 added classifications for type members which wouldnt be understood by a 15.6 guest. // Check with the classificationTypeMap to see if this is a known classification. var classification = classificationSpan.Classification; - if (this.classificationTypeMap.GetClassificationType(classification) == null) + if (_classificationTypeMap.GetClassificationType(classification) == null) { classification = ClassificationTypeNames.Identifier; } - var span = classificationSpan.Range.ToTextSpan(text); + var span = ProtocolConversions.RangeToTextSpan(classificationSpan.Range, text); if (span.End <= text.Length) { result.Add(new ClassifiedSpan(classification, span)); @@ -98,17 +101,17 @@ private async Task AddRemoteSemanticClassificationsAsync(SourceText text, string public void AddSyntacticClassifications(SyntaxTree syntaxTree, TextSpan textSpan, ArrayBuilder result, CancellationToken cancellationToken) { - this.originalService.AddSyntacticClassifications(syntaxTree, textSpan, result, cancellationToken); + _originalService.AddSyntacticClassifications(syntaxTree, textSpan, result, cancellationToken); } public ClassifiedSpan FixClassification(SourceText text, ClassifiedSpan classifiedSpan) { - return this.originalService.FixClassification(text, classifiedSpan); + return _originalService.FixClassification(text, classifiedSpan); } public ImmutableArray GetDefaultSyntaxClassifiers() { - return this.originalService.GetDefaultSyntaxClassifiers(); + return _originalService.GetDefaultSyntaxClassifiers(); } } } diff --git a/src/VisualStudio/LiveShare/Impl/Client/CodeActions/RoslynCodeActionProvider.Exports.cs b/src/VisualStudio/LiveShare/Impl/Client/CodeActions/RoslynCodeActionProvider.Exports.cs index cb550c31f33..2d61e25d690 100644 --- a/src/VisualStudio/LiveShare/Impl/Client/CodeActions/RoslynCodeActionProvider.Exports.cs +++ b/src/VisualStudio/LiveShare/Impl/Client/CodeActions/RoslynCodeActionProvider.Exports.cs @@ -1,6 +1,4 @@ -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// +// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System.Composition; using Microsoft.Cascade.Common; diff --git a/src/VisualStudio/LiveShare/Impl/Client/CodeActions/RoslynCodeActionProvider.cs b/src/VisualStudio/LiveShare/Impl/Client/CodeActions/RoslynCodeActionProvider.cs index 5ab3e0d7df0..ca8263a3b06 100644 --- a/src/VisualStudio/LiveShare/Impl/Client/CodeActions/RoslynCodeActionProvider.cs +++ b/src/VisualStudio/LiveShare/Impl/Client/CodeActions/RoslynCodeActionProvider.cs @@ -1,6 +1,4 @@ -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// +// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; using System.Linq; diff --git a/src/VisualStudio/LiveShare/Impl/Client/CodeActions/RoslynRemoteCodeAction.cs b/src/VisualStudio/LiveShare/Impl/Client/CodeActions/RoslynRemoteCodeAction.cs index d1a45fd147d..db2c87063f0 100644 --- a/src/VisualStudio/LiveShare/Impl/Client/CodeActions/RoslynRemoteCodeAction.cs +++ b/src/VisualStudio/LiveShare/Impl/Client/CodeActions/RoslynRemoteCodeAction.cs @@ -1,6 +1,4 @@ -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// +// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; using System.Collections.Generic; diff --git a/src/VisualStudio/LiveShare/Impl/Client/CodeActions/RoslynRemoteCodeActionOperation.cs b/src/VisualStudio/LiveShare/Impl/Client/CodeActions/RoslynRemoteCodeActionOperation.cs index 83e771d04ea..92a651db65a 100644 --- a/src/VisualStudio/LiveShare/Impl/Client/CodeActions/RoslynRemoteCodeActionOperation.cs +++ b/src/VisualStudio/LiveShare/Impl/Client/CodeActions/RoslynRemoteCodeActionOperation.cs @@ -1,6 +1,4 @@ -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// +// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; using System.Threading; diff --git a/src/VisualStudio/LiveShare/Impl/Client/Completion/RoslynCompletionProvider.Exports.cs b/src/VisualStudio/LiveShare/Impl/Client/Completion/RoslynCompletionProvider.Exports.cs index d35f362edda..3b3ecbc8f85 100644 --- a/src/VisualStudio/LiveShare/Impl/Client/Completion/RoslynCompletionProvider.Exports.cs +++ b/src/VisualStudio/LiveShare/Impl/Client/Completion/RoslynCompletionProvider.Exports.cs @@ -1,6 +1,4 @@ -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// +// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System.Composition; using Microsoft.Cascade.Common; diff --git a/src/VisualStudio/LiveShare/Impl/Client/Completion/RoslynCompletionProvider.cs b/src/VisualStudio/LiveShare/Impl/Client/Completion/RoslynCompletionProvider.cs index 24684eb3227..cf41469782f 100644 --- a/src/VisualStudio/LiveShare/Impl/Client/Completion/RoslynCompletionProvider.cs +++ b/src/VisualStudio/LiveShare/Impl/Client/Completion/RoslynCompletionProvider.cs @@ -1,6 +1,4 @@ -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// +// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; using System.Collections.Immutable; diff --git a/src/VisualStudio/LiveShare/Impl/Client/Completion/RoslynCompletionService.Exports.cs b/src/VisualStudio/LiveShare/Impl/Client/Completion/RoslynCompletionService.Exports.cs index 70ef611dfb9..a81fcd0caed 100644 --- a/src/VisualStudio/LiveShare/Impl/Client/Completion/RoslynCompletionService.Exports.cs +++ b/src/VisualStudio/LiveShare/Impl/Client/Completion/RoslynCompletionService.Exports.cs @@ -1,4 +1,6 @@ -using System; +// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; using System.Composition; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.Completion; diff --git a/src/VisualStudio/LiveShare/Impl/Client/Completion/RoslynCompletionService.cs b/src/VisualStudio/LiveShare/Impl/Client/Completion/RoslynCompletionService.cs index 187989cf283..4febe11bd7a 100644 --- a/src/VisualStudio/LiveShare/Impl/Client/Completion/RoslynCompletionService.cs +++ b/src/VisualStudio/LiveShare/Impl/Client/Completion/RoslynCompletionService.cs @@ -1,6 +1,4 @@ -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// +// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; using System.Collections.Immutable; diff --git a/src/VisualStudio/LiveShare/Impl/Client/Diagnostics/IRemoteDiagnosticsService.cs b/src/VisualStudio/LiveShare/Impl/Client/Diagnostics/IRemoteDiagnosticsService.cs index 0ffd97aca87..a060e1ebbfc 100644 --- a/src/VisualStudio/LiveShare/Impl/Client/Diagnostics/IRemoteDiagnosticsService.cs +++ b/src/VisualStudio/LiveShare/Impl/Client/Diagnostics/IRemoteDiagnosticsService.cs @@ -1,6 +1,5 @@ -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// +// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + using System.Collections.Immutable; using System.Threading; using System.Threading.Tasks; diff --git a/src/VisualStudio/LiveShare/Impl/Client/Diagnostics/RoslynDocumentDiagnosticAnalyzer.cs b/src/VisualStudio/LiveShare/Impl/Client/Diagnostics/RoslynDocumentDiagnosticAnalyzer.cs index bded4903197..8281d7b777b 100644 --- a/src/VisualStudio/LiveShare/Impl/Client/Diagnostics/RoslynDocumentDiagnosticAnalyzer.cs +++ b/src/VisualStudio/LiveShare/Impl/Client/Diagnostics/RoslynDocumentDiagnosticAnalyzer.cs @@ -1,6 +1,4 @@ -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// +// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System.Collections.Immutable; using System.Threading; diff --git a/src/VisualStudio/LiveShare/Impl/Client/Diagnostics/RoslynRemoteDiagnosticsService.Exports.cs b/src/VisualStudio/LiveShare/Impl/Client/Diagnostics/RoslynRemoteDiagnosticsService.Exports.cs index 761c8f28a61..207241c4c1b 100644 --- a/src/VisualStudio/LiveShare/Impl/Client/Diagnostics/RoslynRemoteDiagnosticsService.Exports.cs +++ b/src/VisualStudio/LiveShare/Impl/Client/Diagnostics/RoslynRemoteDiagnosticsService.Exports.cs @@ -1,6 +1,4 @@ -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// +// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System.Composition; using Microsoft.CodeAnalysis; diff --git a/src/VisualStudio/LiveShare/Impl/Client/Diagnostics/RoslynRemoteDiagnosticsService.cs b/src/VisualStudio/LiveShare/Impl/Client/Diagnostics/RoslynRemoteDiagnosticsService.cs index 458059d89a6..ccd31926434 100644 --- a/src/VisualStudio/LiveShare/Impl/Client/Diagnostics/RoslynRemoteDiagnosticsService.cs +++ b/src/VisualStudio/LiveShare/Impl/Client/Diagnostics/RoslynRemoteDiagnosticsService.cs @@ -1,6 +1,4 @@ -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// +// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; using System.Collections.Immutable; diff --git a/src/VisualStudio/LiveShare/Impl/Client/GotoDefinition/RoslynGotoDefinitionService.Exports.cs b/src/VisualStudio/LiveShare/Impl/Client/GotoDefinition/RoslynGotoDefinitionService.Exports.cs index a18c375cf92..2ad002866de 100644 --- a/src/VisualStudio/LiveShare/Impl/Client/GotoDefinition/RoslynGotoDefinitionService.Exports.cs +++ b/src/VisualStudio/LiveShare/Impl/Client/GotoDefinition/RoslynGotoDefinitionService.Exports.cs @@ -1,6 +1,4 @@ -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// +// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System.Composition; using Microsoft.CodeAnalysis; diff --git a/src/VisualStudio/LiveShare/Impl/Client/GotoDefinition/RoslynGotoDefinitionService.cs b/src/VisualStudio/LiveShare/Impl/Client/GotoDefinition/RoslynGotoDefinitionService.cs index c41aa7f8cf9..8c20d8125d7 100644 --- a/src/VisualStudio/LiveShare/Impl/Client/GotoDefinition/RoslynGotoDefinitionService.cs +++ b/src/VisualStudio/LiveShare/Impl/Client/GotoDefinition/RoslynGotoDefinitionService.cs @@ -1,6 +1,4 @@ -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// +// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; using System.Collections.Generic; diff --git a/src/VisualStudio/LiveShare/Impl/Client/Highlights/RoslynDocumentHighlightsService.Exports.cs b/src/VisualStudio/LiveShare/Impl/Client/Highlights/RoslynDocumentHighlightsService.Exports.cs index 7fabebce4ab..3350136a22a 100644 --- a/src/VisualStudio/LiveShare/Impl/Client/Highlights/RoslynDocumentHighlightsService.Exports.cs +++ b/src/VisualStudio/LiveShare/Impl/Client/Highlights/RoslynDocumentHighlightsService.Exports.cs @@ -1,6 +1,4 @@ -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// +// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System.Composition; using Microsoft.Cascade.Common; diff --git a/src/VisualStudio/LiveShare/Impl/Client/Highlights/RoslynDocumentHighlightsService.cs b/src/VisualStudio/LiveShare/Impl/Client/Highlights/RoslynDocumentHighlightsService.cs index b0ab0135648..387bab1edb3 100644 --- a/src/VisualStudio/LiveShare/Impl/Client/Highlights/RoslynDocumentHighlightsService.cs +++ b/src/VisualStudio/LiveShare/Impl/Client/Highlights/RoslynDocumentHighlightsService.cs @@ -1,6 +1,4 @@ -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// +// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; using System.Collections.Immutable; diff --git a/src/VisualStudio/LiveShare/Impl/Client/HostLanguageServicesExtensions.cs b/src/VisualStudio/LiveShare/Impl/Client/HostLanguageServicesExtensions.cs new file mode 100644 index 00000000000..8a4fb2dd1a2 --- /dev/null +++ b/src/VisualStudio/LiveShare/Impl/Client/HostLanguageServicesExtensions.cs @@ -0,0 +1,31 @@ +// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.Host; + +namespace Microsoft.VisualStudio.LanguageServices.LiveShare.Client +{ + internal static class HostLanguageServicesExtensions + { + public static TLanguageService GetOriginalLanguageService(this HostLanguageServices languageServices) where TLanguageService : class, ILanguageService + { + var language = languageServices.Language; + var originalLanguage = language; + + switch (language) + { + case StringConstants.CSharpLspLanguageName: + originalLanguage = LanguageNames.CSharp; + break; + case StringConstants.VBLspLanguageName: + originalLanguage = LanguageNames.VisualBasic; + break; + default: + // Unknown language. + return null; + } + + return languageServices.WorkspaceServices.GetLanguageServices(originalLanguage).GetService(); + } + } +} diff --git a/src/VisualStudio/LiveShare/Impl/Client/Navigation/RoslynNavigationBarItemService.Exports.cs b/src/VisualStudio/LiveShare/Impl/Client/Navigation/RoslynNavigationBarItemService.Exports.cs index 475332f880c..78a5519476a 100644 --- a/src/VisualStudio/LiveShare/Impl/Client/Navigation/RoslynNavigationBarItemService.Exports.cs +++ b/src/VisualStudio/LiveShare/Impl/Client/Navigation/RoslynNavigationBarItemService.Exports.cs @@ -1,6 +1,4 @@ -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// +// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System.Composition; using Microsoft.CodeAnalysis; diff --git a/src/VisualStudio/LiveShare/Impl/Client/Navigation/RoslynNavigationBarItemService.cs b/src/VisualStudio/LiveShare/Impl/Client/Navigation/RoslynNavigationBarItemService.cs index 9283b7cc091..c753c7cb9d8 100644 --- a/src/VisualStudio/LiveShare/Impl/Client/Navigation/RoslynNavigationBarItemService.cs +++ b/src/VisualStudio/LiveShare/Impl/Client/Navigation/RoslynNavigationBarItemService.cs @@ -1,6 +1,4 @@ -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// +// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; using System.Collections.Generic; diff --git a/src/VisualStudio/LiveShare/Impl/Client/References/RoslynFindUsagesService.Exports..cs b/src/VisualStudio/LiveShare/Impl/Client/References/RoslynFindUsagesService.Exports..cs index 64eebe52a8f..d1f0814f790 100644 --- a/src/VisualStudio/LiveShare/Impl/Client/References/RoslynFindUsagesService.Exports..cs +++ b/src/VisualStudio/LiveShare/Impl/Client/References/RoslynFindUsagesService.Exports..cs @@ -1,6 +1,4 @@ -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// +// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System.Composition; using Microsoft.Cascade.Common; diff --git a/src/VisualStudio/LiveShare/Impl/Client/References/RoslynFindUsagesService.cs b/src/VisualStudio/LiveShare/Impl/Client/References/RoslynFindUsagesService.cs index 94b516c8831..20f7d80dc90 100644 --- a/src/VisualStudio/LiveShare/Impl/Client/References/RoslynFindUsagesService.cs +++ b/src/VisualStudio/LiveShare/Impl/Client/References/RoslynFindUsagesService.cs @@ -1,6 +1,4 @@ -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// +// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; using System.Collections.Immutable; diff --git a/src/VisualStudio/LiveShare/Impl/Client/Rename/RoslynRenameService.Exports.cs b/src/VisualStudio/LiveShare/Impl/Client/Rename/RoslynRenameService.Exports.cs index f87ad077ee3..c96cfc1cc4a 100644 --- a/src/VisualStudio/LiveShare/Impl/Client/Rename/RoslynRenameService.Exports.cs +++ b/src/VisualStudio/LiveShare/Impl/Client/Rename/RoslynRenameService.Exports.cs @@ -1,6 +1,4 @@ -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// +// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System.Composition; using Microsoft.CodeAnalysis; diff --git a/src/VisualStudio/LiveShare/Impl/Client/Rename/RoslynRenameService.FailureRenameInfo.cs b/src/VisualStudio/LiveShare/Impl/Client/Rename/RoslynRenameService.FailureRenameInfo.cs index c98a62e8ea0..e417c3bd0a7 100644 --- a/src/VisualStudio/LiveShare/Impl/Client/Rename/RoslynRenameService.FailureRenameInfo.cs +++ b/src/VisualStudio/LiveShare/Impl/Client/Rename/RoslynRenameService.FailureRenameInfo.cs @@ -1,6 +1,4 @@ -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// +// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System.Collections.Generic; using System.Threading; diff --git a/src/VisualStudio/LiveShare/Impl/Client/Rename/RoslynRenameService.cs b/src/VisualStudio/LiveShare/Impl/Client/Rename/RoslynRenameService.cs index fd1177f010b..d4e7564ebfe 100644 --- a/src/VisualStudio/LiveShare/Impl/Client/Rename/RoslynRenameService.cs +++ b/src/VisualStudio/LiveShare/Impl/Client/Rename/RoslynRenameService.cs @@ -1,6 +1,4 @@ -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// +// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System.Threading; using System.Threading.Tasks; diff --git a/src/VisualStudio/LiveShare/Impl/Client/SignatureHelp/RoslynSignatureHelpProvider.Exports.cs b/src/VisualStudio/LiveShare/Impl/Client/SignatureHelp/RoslynSignatureHelpProvider.Exports.cs index 3be32e584f0..3c0063803e2 100644 --- a/src/VisualStudio/LiveShare/Impl/Client/SignatureHelp/RoslynSignatureHelpProvider.Exports.cs +++ b/src/VisualStudio/LiveShare/Impl/Client/SignatureHelp/RoslynSignatureHelpProvider.Exports.cs @@ -1,42 +1,29 @@ -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// +// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System.Composition; -using Microsoft.Cascade.Common; using Microsoft.CodeAnalysis.SignatureHelp; namespace Microsoft.VisualStudio.LanguageServices.LiveShare.Client { + [Shared] [ExportSignatureHelpProvider("CSharpLspSignatureHelpProvider", StringConstants.CSharpLspLanguageName)] internal class CSharpLspSignatureHelpProvider : RoslynSignatureHelpProvider { [ImportingConstructor] - public CSharpLspSignatureHelpProvider(RoslynLSPClientServiceFactory roslynLSPClientServiceFactory, IVsConfigurationSettings configurationSettings) - : base(roslynLSPClientServiceFactory, configurationSettings ) + public CSharpLspSignatureHelpProvider(RoslynLSPClientServiceFactory roslynLSPClientServiceFactory) + : base(roslynLSPClientServiceFactory) { } } + [Shared] [ExportSignatureHelpProvider("VBLspSignatureHelpProvider", StringConstants.VBLspLanguageName)] internal class VBLspSignatureHelpProvider : RoslynSignatureHelpProvider { [ImportingConstructor] - public VBLspSignatureHelpProvider(RoslynLSPClientServiceFactory roslynLSPClientServiceFactory, IVsConfigurationSettings configurationSettings) - : base(roslynLSPClientServiceFactory, configurationSettings) + public VBLspSignatureHelpProvider(RoslynLSPClientServiceFactory roslynLSPClientServiceFactory) + : base(roslynLSPClientServiceFactory) { } } - -#if !VS_16_0 - [ExportSignatureHelpProvider("TypeScriptLspSignatureHelpProvider", StringConstants.TypeScriptLanguageName)] - internal class TypeScriptLspSignatureHelpProvider : RoslynSignatureHelpProvider - { - [ImportingConstructor] - public TypeScriptLspSignatureHelpProvider(RoslynLSPClientServiceFactory roslynLSPClientServiceFactory, IVsConfigurationSettings configurationSettings) - : base(roslynLSPClientServiceFactory, configurationSettings) - { - } - } -#endif } diff --git a/src/VisualStudio/LiveShare/Impl/Client/SignatureHelp/RoslynSignatureHelpProvider.cs b/src/VisualStudio/LiveShare/Impl/Client/SignatureHelp/RoslynSignatureHelpProvider.cs index 32d4ea2a8b2..edc7b09eda3 100644 --- a/src/VisualStudio/LiveShare/Impl/Client/SignatureHelp/RoslynSignatureHelpProvider.cs +++ b/src/VisualStudio/LiveShare/Impl/Client/SignatureHelp/RoslynSignatureHelpProvider.cs @@ -1,6 +1,4 @@ -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// +// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; using System.Collections.Generic; @@ -8,7 +6,6 @@ using System.Linq; using System.Threading; using System.Threading.Tasks; -using Microsoft.Cascade.Common; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.SignatureHelp; using Microsoft.VisualStudio.LanguageServer.Protocol; @@ -18,13 +15,10 @@ namespace Microsoft.VisualStudio.LanguageServices.LiveShare.Client class RoslynSignatureHelpProvider : ISignatureHelpProvider { private readonly RoslynLSPClientServiceFactory roslynLSPClientServiceFactory; - private readonly IVsConfigurationSettings configurationSettings; - public RoslynSignatureHelpProvider(RoslynLSPClientServiceFactory roslynLSPClientServiceFactory, - IVsConfigurationSettings configurationSettings) + public RoslynSignatureHelpProvider(RoslynLSPClientServiceFactory roslynLSPClientServiceFactory) { this.roslynLSPClientServiceFactory = roslynLSPClientServiceFactory ?? throw new ArgumentNullException(nameof(roslynLSPClientServiceFactory)); - this.configurationSettings = configurationSettings ?? throw new ArgumentNullException(nameof(configurationSettings)); } public bool IsTriggerCharacter(char ch) { -- GitLab