Skip to content

Commit

Permalink
Merge branch 'liveshare' of https://github.com/srivatsn/PTVS into liv…
Browse files Browse the repository at this point in the history
…eshare
  • Loading branch information
zooba committed Sep 6, 2018
2 parents e3daf08 + db34cef commit e75a80d
Show file tree
Hide file tree
Showing 7 changed files with 298 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Build/15.0/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
<package id="Microsoft.VSSDK.BuildTools" version="15.7.109" />
<package id="Newtonsoft.Json" version="9.0.1" targetFramework="net45" />
<package id="MicroBuild.Core" version="0.2.0" />
<package id="Microsoft.Cascade.LanguageServices.Common" version="0.3.536" />
<package id="Microsoft.Cascade.Common" version="0.3.536" />
<package id="Microsoft.Cascade.Client" version="0.3.536" />
<package id="Microsoft.VisualStudio.Cascade.Contracts" version="0.3.536" />
<package id="Microsoft.VisualStudio.Debugger.InteropA" version="9.0.21022" targetFramework="net46" />
<package id="Microsoft.VisualStudio.Debugger.Interop.10.0" version="10.0.30320" />
<package id="Microsoft.VisualStudio.Debugger.Interop.11.0" version="11.0.50728" />
Expand Down
116 changes: 116 additions & 0 deletions Python/Product/LiveShare/LiveShare.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Choose>
<When Condition=" '$(VisualStudioVersion)'=='15.0' Or '$(TargetVisualStudioVersion)'=='VS150' ">
<PropertyGroup>
<MinimumVisualStudioVersion>15.0</MinimumVisualStudioVersion>
<FileUpgradeFlags>
</FileUpgradeFlags>
<UpgradeBackupLocation>
</UpgradeBackupLocation>
<OldToolsVersion>14.0</OldToolsVersion>
</PropertyGroup>
</When>
<When Condition=" '$(VisualStudioVersion)'=='16.0' Or '$(TargetVisualStudioVersion)'=='VS160' ">
<PropertyGroup>
<MinimumVisualStudioVersion>16.0</MinimumVisualStudioVersion>
<FileUpgradeFlags>
</FileUpgradeFlags>
<UpgradeBackupLocation>
</UpgradeBackupLocation>
<OldToolsVersion>16.0</OldToolsVersion>
</PropertyGroup>
</When>
</Choose>
<Import Project="..\ProjectBefore.settings" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<SchemaVersion>2.0</SchemaVersion>
<ProjectTypeGuids>{82b43b9b-a64c-4715-b499-d71e9ca2bd60};{60DC8134-EBA5-43B8-BCC9-BB4BC16C2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Microsoft</RootNamespace>
<AssemblyName>Microsoft.PythonTools.LiveShare</AssemblyName>
<ProjectGuid>{4065A3C8-0E5E-42AC-9D94-509AA90C90E9}</ProjectGuid>
<UseVSSDK>true</UseVSSDK>
<CreateVsixContainer>true</CreateVsixContainer>
<GeneratePkgDefFile>false</GeneratePkgDefFile>
<CopyVsixManifestToOutput>true</CopyVsixManifestToOutput>
<DeployExtension>true</DeployExtension>
<DefineConstants>$(DefineConstants);$(SignedSym)</DefineConstants>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<PropertyGroup Condition=" '$(Platform)' == 'AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.VisualStudio.LanguageServer.Protocol, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<Reference Include="System" />
<Reference Include="System.Collections.Immutable" />
<Reference Include="System.ComponentModel.Composition" />
<Reference Include="System.Core" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Analysis\Analysis.csproj">
<Project>{a85d479d-67a9-4bdb-904a-7d86daf68a6f}</Project>
<Name>Analysis</Name>
</ProjectReference>
<ProjectReference Include="..\PythonTools\PythonTools.csproj">
<Project>{fa7be5f5-e04f-4613-b7ac-70ce10d1bb68}</Project>
<Name>PythonTools</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Reference Include="Microsoft.Cascade.LanguageServices.Common">
<HintPath>$(PackagesPath)\Microsoft.Cascade.LanguageServices.Common.0.3.536\lib\net461\Microsoft.Cascade.LanguageServices.Common.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Cascade.Common">
<HintPath>$(PackagesPath)\Microsoft.Cascade.Common.0.3.536\lib\net461\Microsoft.Cascade.Common.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Cascade.Client">
<HintPath>$(PackagesPath)\Microsoft.Cascade.Client.0.3.536\lib\net461\Microsoft.Cascade.Client.dll</HintPath>
</Reference>
<Reference Include="Microsoft.VisualStudio.Cascade.Contracts">
<HintPath>$(PackagesPath)\Microsoft.VisualStudio.Cascade.Contracts.0.3.536\lib\net461\Microsoft.VisualStudio.Cascade.Contracts.dll</HintPath>
</Reference>
<Reference Include="Microsoft.VisualStudio.Threading" />
<Reference Include="Microsoft.VisualStudio.Shell.Framework" />
<!-- <Reference Include="Microsoft.VisualStudio.Text.UI" /> -->
<Reference Include="Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed">
<HintPath>$(PackagesPath)\Newtonsoft.Json\lib\net45\Newtonsoft.Json.dll</HintPath>
<Private>True</Private>
<IncludeInVSIX>True</IncludeInVSIX>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="PythonLanguageClient.cs" />
<Compile Include="PythonLanguageClientFactory.cs" />
<Compile Include="PythonLanguageServiceProviderCallback.cs" />
</ItemGroup>
<ItemGroup>
<None Include="source.extension.vsixmanifest">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<Import Project="..\ProjectAfter.settings" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
<!-- We build these assemblies into separate folders to avoid incremental cleaning issues,
but then CreatePkgDef can't find them for the ProvideCodeBase attributes. So we copy
into the PythonTools output folder temporarily to generate the pkgdef file. -->
<!--<Target Name="_CopyForCreatePkgDef" BeforeTargets="GeneratePkgDef">
<Copy SourceFiles="$(OutputPath)..\Analysis\Microsoft.PythonTools.Analysis.dll;$(OutputPath)..\EnvironmentsList\Microsoft.PythonTools.EnvironmentsList.dll;$(OutputPath)..\VSInterpreters\Microsoft.PythonTools.VSInterpreters.dll" DestinationFolder="$(OutputPath)">
<Output TaskParameter="CopiedFiles" ItemName="_CopiedForCreatePkgdef" />
</Copy>
</Target>
<Target Name="_DeleteAfterCreatePkgDef" AfterTargets="GeneratePkgDef">
<Delete Files="@(_CopiedForCreatePkgdef)" />
</Target>-->
<!--<Target Name="DetokenizeVsixManifestFile" />-->
</Project>
56 changes: 56 additions & 0 deletions Python/Product/LiveShare/PythonLanguageClient.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// <copyright>
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>

using System;
using System.Threading.Tasks;
using Microsoft.Cascade.Extensibility;
using Microsoft.Cascade.LanguageServices.Common;
using Microsoft.Cascade.LanguageServices.Contracts;
using Microsoft.VisualStudio.Shell;
using Microsoft.VisualStudio.Threading;
using Task = System.Threading.Tasks.Task;

namespace Microsoft
{
internal class PythonLanguageClient : ICollaborationService, IAsyncDisposable
{
private static string[] PythonContentTypes = new string[] { "python" };
private static DocumentFilter[] PythonDocumentFilters = new DocumentFilter[]
{
new DocumentFilter() { Language = "python" }
};
private IAsyncDisposable languageServiceProviderService;
private SVsServiceProvider serviceProvider;

public PythonLanguageClient(SVsServiceProvider serviceProvider)
{
this.serviceProvider = serviceProvider ?? throw new ArgumentNullException(nameof(serviceProvider));
}

internal async Task InitializeAsync(ILanguageServerHostService languageServerHostService)
{
if (languageServerHostService == null)
{
throw new ArgumentNullException(nameof(languageServerHostService));
}

var pythonLanguageServiceProviderCallback = new PythonLanguageServiceProviderCallback(this.serviceProvider);
this.languageServiceProviderService = await languageServerHostService.CreateCustomLanguageServerProviderAsync(
"languageServerProvider-python",
new LanguageServerProviderMetadata
{
IsLanguageClientProvider = false,
ContentTypes = PythonContentTypes,
DocumentFilters = PythonDocumentFilters
},
pythonLanguageServiceProviderCallback,
null);
}

public async Task DisposeAsync()
{
await this.languageServiceProviderService?.DisposeAsync();
}
}
}
43 changes: 43 additions & 0 deletions Python/Product/LiveShare/PythonLanguageClientFactory.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// <copyright>
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>

using System;
using System.ComponentModel.Composition;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Cascade.Client;
using Microsoft.Cascade.Extensibility;
using Microsoft.Cascade.LanguageServices.Common;
using Microsoft.VisualStudio.Shell;

namespace Microsoft
{
[ExportCollaborationService(
typeof(PythonLanguageClient),
Scope = SessionScope.Host,
Features = WellKnownFeatures.LspServices)]
internal class PythonLanguageClientFactory : ICollaborationServiceFactory
{
private readonly SVsServiceProvider serviceProvider;

[ImportingConstructor]
public PythonLanguageClientFactory(SVsServiceProvider serviceProvider)
{
this.serviceProvider = serviceProvider ?? throw new ArgumentNullException(nameof(serviceProvider));
}

public async Task<ICollaborationService> CreateServiceAsync(SessionContext sessionContext, CancellationToken cancellationToken)
{
var languageServerHostService = sessionContext.ServiceProvider.GetService<ILanguageServerHostService>();
if (languageServerHostService == null)
{
return null;
}

var pythonClient = new PythonLanguageClient(this.serviceProvider);
await pythonClient.InitializeAsync(languageServerHostService);
return pythonClient;
}
}
}
55 changes: 55 additions & 0 deletions Python/Product/LiveShare/PythonLanguageServiceProviderCallback.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// <copyright>
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>

using System;
using System.Threading;
using System.Threading.Tasks;
using System.Linq;
using Microsoft.Cascade.LanguageServices.Common;
using Microsoft.VisualStudio.LanguageServer.Protocol;
using Microsoft.VisualStudio.Shell;
using Microsoft.VisualStudio.Threading;
using Microsoft.PythonTools.Editor;
using Microsoft.PythonTools.Intellisense;
using LS = Microsoft.PythonTools.Analysis.LanguageServer;
using Newtonsoft.Json.Linq;

namespace Microsoft
{
internal class PythonLanguageServiceProviderCallback : ILanguageServiceProviderCallback
{
private SVsServiceProvider serviceProvider;

public PythonLanguageServiceProviderCallback(SVsServiceProvider serviceProvider)
{
this.serviceProvider = serviceProvider ?? throw new ArgumentNullException(nameof(serviceProvider));
}

#pragma warning disable 0067
public event AsyncEventHandler<LanguageServiceNotifyEventArgs> NotifyAsync;
#pragma warning restore 0067

public async Task<TOut> RequestAsync<TIn, TOut>(LspRequest<TIn, TOut> method, TIn param, CancellationToken cancellationToken)
{
if (method.Name == Methods.Initialize.Name)
{
var capabilities = new ServerCapabilities { CompletionProvider = new VisualStudio.LanguageServer.Protocol.CompletionOptions { TriggerCharacters = new[] { "." } } };
object result = new InitializeResult { Capabilities = capabilities };
return (TOut)(result);
}
if (method.Name == Methods.TextDocumentCompletion.Name)
{
var completionParams = param as CompletionParams;
var filePath = completionParams.TextDocument.Uri.LocalPath;
VsProjectAnalyzer analyzer = (await serviceProvider.FindAllAnalyzersForFile(filePath)).FirstOrDefault() as VsProjectAnalyzer;

var lsCompletionParams = JObject.FromObject(completionParams).ToObject<LS.CompletionParams>();
object list = await analyzer.SendLanguageServerRequestAsync<LS.CompletionParams, LS.CompletionList>(method.Name, lsCompletionParams);
return (TOut)list;
}

return default(TOut);
}
}
}
23 changes: 23 additions & 0 deletions Python/Product/LiveShare/source.extension.vsixmanifest
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<PackageManifest Version="2.0.0" xmlns="http://schemas.microsoft.com/developer/vsx-schema/2011" xmlns:d="http://schemas.microsoft.com/developer/vsx-schema-design/2011">
<Metadata>
<Identity Id="2cd11de7-1df1-4d50-8a29-9c0e9a6a548d" Version="15.8.0" Language="en-US" Publisher="Microsoft Corporation" />
<DisplayName>Python - LiveShare</DisplayName>
<Description xml:space="preserve">Provides LiveShare integration for Python projects</Description>
<MoreInfo>http://aka.ms/ptvs</MoreInfo>
<GettingStartedGuide>http://aka.ms/ptvstutorial</GettingStartedGuide>
</Metadata>
<Installation SystemComponent="true" AllUsers="true" InstalledByMsi="true">
<InstallationTarget Id="Microsoft.VisualStudio.Community" Version="[15.0,16.0)" />
</Installation>
<Dependencies>
<Dependency Id="Microsoft.Framework.NDP" DisplayName="Microsoft .NET Framework" Version="4.6" />
<Dependency Id="96492FC7-7BC6-46F7-8559-66BB4E09FD1E" DisplayName="Python" Version="[15.0,16.0)" />
</Dependencies>
<Prerequisites>
<Prerequisite Id="Microsoft.VisualStudio.Component.CoreEditor" Version="[15.0,16.0)" DisplayName="Visual Studio core editor" />
</Prerequisites>
<Assets>
<Asset Type="Microsoft.VisualStudio.Assembly" Path="|%CurrentProject%;_GetTargetPath|" AssemblyName="|%CurrentProject%;_GetAssemblyName|" />
<Asset Type="Microsoft.VisualStudio.MefComponent" Path="|%CurrentProject%;_GetTargetPath|" />
</Assets>
</PackageManifest>
1 change: 1 addition & 0 deletions Python/Product/PythonTools/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
[assembly: InternalsVisibleTo("Microsoft.PythonTools.Uwp, PublicKey=002400000480000094000000060200000024000052534131000400000100010007d1fa57c4aed9f0a32e84aa0faefd0de9e8fd6aec8f87fb03766c834c99921eb23be79ad9d5dcc1dd9ad236132102900b723cf980957fc4e177108fc607774f29e8320e92ea05ece4e821c0a5efe8f1645c4c0c93c1ab99285d622caa652c1dfad63d745d6f2de5f17e5eaf0fc4963d261c8a12436518206dc093344d5ad293")]
[assembly: InternalsVisibleTo("Microsoft.PythonTools.Workspace, PublicKey=002400000480000094000000060200000024000052534131000400000100010007d1fa57c4aed9f0a32e84aa0faefd0de9e8fd6aec8f87fb03766c834c99921eb23be79ad9d5dcc1dd9ad236132102900b723cf980957fc4e177108fc607774f29e8320e92ea05ece4e821c0a5efe8f1645c4c0c93c1ab99285d622caa652c1dfad63d745d6f2de5f17e5eaf0fc4963d261c8a12436518206dc093344d5ad293")]
[assembly: InternalsVisibleTo("Microsoft.PythonTools.Wsl, PublicKey=002400000480000094000000060200000024000052534131000400000100010007d1fa57c4aed9f0a32e84aa0faefd0de9e8fd6aec8f87fb03766c834c99921eb23be79ad9d5dcc1dd9ad236132102900b723cf980957fc4e177108fc607774f29e8320e92ea05ece4e821c0a5efe8f1645c4c0c93c1ab99285d622caa652c1dfad63d745d6f2de5f17e5eaf0fc4963d261c8a12436518206dc093344d5ad293")]
[assembly: InternalsVisibleTo("Microsoft.PythonTools.LiveShare, PublicKey=002400000480000094000000060200000024000052534131000400000100010007d1fa57c4aed9f0a32e84aa0faefd0de9e8fd6aec8f87fb03766c834c99921eb23be79ad9d5dcc1dd9ad236132102900b723cf980957fc4e177108fc607774f29e8320e92ea05ece4e821c0a5efe8f1645c4c0c93c1ab99285d622caa652c1dfad63d745d6f2de5f17e5eaf0fc4963d261c8a12436518206dc093344d5ad293")]

[assembly: InternalsVisibleTo("PythonToolsMockTests, PublicKey=002400000480000094000000060200000024000052534131000400000100010007d1fa57c4aed9f0a32e84aa0faefd0de9e8fd6aec8f87fb03766c834c99921eb23be79ad9d5dcc1dd9ad236132102900b723cf980957fc4e177108fc607774f29e8320e92ea05ece4e821c0a5efe8f1645c4c0c93c1ab99285d622caa652c1dfad63d745d6f2de5f17e5eaf0fc4963d261c8a12436518206dc093344d5ad293")]
[assembly: InternalsVisibleTo("DebuggerUITests, PublicKey=002400000480000094000000060200000024000052534131000400000100010007d1fa57c4aed9f0a32e84aa0faefd0de9e8fd6aec8f87fb03766c834c99921eb23be79ad9d5dcc1dd9ad236132102900b723cf980957fc4e177108fc607774f29e8320e92ea05ece4e821c0a5efe8f1645c4c0c93c1ab99285d622caa652c1dfad63d745d6f2de5f17e5eaf0fc4963d261c8a12436518206dc093344d5ad293")]
Expand Down

0 comments on commit e75a80d

Please sign in to comment.