Skip to content
This repository was archived by the owner on Apr 14, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,6 @@ private void DeclareParameters(bool declareVariables) {

// Declare parameters in scope
IMember defaultValue = null;
var meaningfuleDefautValue = false;
for (var i = skip; i < FunctionDefinition.Parameters.Length; i++) {
var isGeneric = false;
var p = FunctionDefinition.Parameters[i];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<None Remove="app.config" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.0.0" />
<PackageReference Include="Microsoft.Win32.Registry" Version="4.5.0" />
<PackageReference Include="MSTest.TestAdapter" Version="1.4.0" />
<PackageReference Include="MSTest.TestFramework" Version="1.4.0" />
Expand Down
6 changes: 3 additions & 3 deletions src/Core/Test/Microsoft.Python.Core.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@
<None Remove="app.config" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.8.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.0.0" />
<PackageReference Include="Microsoft.Win32.Registry" Version="4.5.0" />
<PackageReference Include="MSTest.TestAdapter" Version="1.3.2" />
<PackageReference Include="MSTest.TestFramework" Version="1.3.2" />
<PackageReference Include="MSTest.TestAdapter" Version="1.4.0" />
<PackageReference Include="MSTest.TestFramework" Version="1.4.0" />
<PackageReference Include="MicroBuild.Core" Version="0.3.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
Expand Down
39 changes: 30 additions & 9 deletions src/LanguageServer/Impl/Implementation/Server.cs
Original file line number Diff line number Diff line change
Expand Up @@ -154,17 +154,18 @@ public Task Shutdown() {
return Task.CompletedTask;
}

public async Task DidChangeConfiguration(DidChangeConfigurationParams @params, CancellationToken cancellationToken) {
public void DidChangeConfiguration(DidChangeConfigurationParams @params, CancellationToken cancellationToken) {
_disposableBag.ThrowIfDisposed();

var reanalyze = true;
if (@params.settings != null) {
if (@params.settings is ServerSettings settings) {
reanalyze = HandleConfigurationChanges(settings);
} else {
_log?.Log(TraceEventType.Error, "change configuration notification sent unsupported settings");
return;
switch (@params.settings) {
case ServerSettings settings: {
if (HandleConfigurationChanges(settings)) {
RestartAnalysis();
}
break;
}
default:
_log?.Log(TraceEventType.Error, "change configuration notification sent unsupported settings");
break;
}
}
#endregion
Expand Down Expand Up @@ -198,5 +199,25 @@ private bool HandleConfigurationChanges(ServerSettings newSettings) {
return false;
}
#endregion

public void NotifyPackagesChanged(CancellationToken cancellationToken) {
var interpreter = _services.GetService<IPythonInterpreter>();
_log?.Log(TraceEventType.Information, Resources.ReloadingModules);
// No need to reload typeshed resolution since it is a static storage.
// User does can add stubs while application is running, but it is
// by design at this time that the app should be restarted.
interpreter.ModuleResolution.ReloadAsync(cancellationToken).ContinueWith(t => {
_log?.Log(TraceEventType.Information, Resources.Done);
_log?.Log(TraceEventType.Information, Resources.RestartingAnalysis);
RestartAnalysis();
}, cancellationToken).DoNotWait();

}

private void RestartAnalysis() {
foreach (var doc in _rdt) {
doc.Reset(null);
}
}
}
}
20 changes: 3 additions & 17 deletions src/LanguageServer/Impl/LanguageServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,11 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Python.Analysis;
using Microsoft.Python.Analysis.Diagnostics;
using Microsoft.Python.Analysis.Documents;
using Microsoft.Python.Analysis.Modules;
using Microsoft.Python.Core;
using Microsoft.Python.Core.Disposables;
using Microsoft.Python.Core.Idle;
Expand Down Expand Up @@ -126,7 +124,7 @@ public async Task DidChangeConfiguration(JToken token, CancellationToken cancell
GetSetting(analysis, "information", Array.Empty<string>()),
GetSetting(analysis, "disabled", Array.Empty<string>()));

await _server.DidChangeConfiguration(new DidChangeConfigurationParams { settings = settings }, cancellationToken);
_server.DidChangeConfiguration(new DidChangeConfigurationParams { settings = settings }, cancellationToken);
}
}

Expand Down Expand Up @@ -383,27 +381,15 @@ private void HandlePathWatchChange(JToken section, CancellationToken cancellatio
var logger = _services.GetService<ILogger>();
_pathsWatcher = new PathsWatcher(
_initParams.initializationOptions.searchPaths,
() => {
logger.Log(TraceEventType.Information, Resources.ReloadingModules);
// No need to reload typeshed resolution since it is a static storage.
// User does can add stubs while application is running, but it is
// by design at this time that the app should be restarted.
interpreter.ModuleResolution.ReloadAsync(cancellationToken).ContinueWith(t => {
logger.Log(TraceEventType.Information, Resources.Done);
logger.Log(TraceEventType.Information, Resources.RestartingAnalysis);
var rdt = _services.GetService<IRunningDocumentTable>();
foreach (var doc in rdt) {
doc.Reset(null);
}
}, cancellationToken).DoNotWait();
},
() =>_server.NotifyPackagesChanged(cancellationToken),
_services.GetService<ILogger>()
);

_watchSearchPaths = true;
_searchPaths = _initParams.initializationOptions.searchPaths;
}
}

private static CancellationToken GetToken(CancellationToken original)
=> Debugger.IsAttached ? CancellationToken.None : original;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.FileSystemGlobbing" Version="2.2.0" />
<PackageReference Include="NewtonSoft.Json" Version="11.0.2" />
<PackageReference Include="StreamJsonRpc" Version="2.0.102-beta" />
<PackageReference Include="NewtonSoft.Json" Version="12.0.1" />
<PackageReference Include="StreamJsonRpc" Version="2.0.146" />
</ItemGroup>
<ItemGroup Condition="$(AnalysisReference) != ''">
<Reference Include="Microsoft.Python.Analysis.Engine">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<None Remove="app.config" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.0.0" />
<PackageReference Include="Microsoft.Win32.Registry" Version="4.5.0" />
<PackageReference Include="MSTest.TestAdapter" Version="1.4.0" />
<PackageReference Include="MSTest.TestFramework" Version="1.4.0" />
Expand Down
6 changes: 3 additions & 3 deletions src/Parsing/Test/Microsoft.Python.Parsing.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@
<None Remove="app.config" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.8.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.0.0" />
<PackageReference Include="Microsoft.Win32.Registry" Version="4.5.0" />
<PackageReference Include="MSTest.TestAdapter" Version="1.3.2" />
<PackageReference Include="MSTest.TestFramework" Version="1.3.2" />
<PackageReference Include="MSTest.TestAdapter" Version="1.4.0" />
<PackageReference Include="MSTest.TestFramework" Version="1.4.0" />
<PackageReference Include="MicroBuild.Core" Version="0.3.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
Expand Down
4 changes: 2 additions & 2 deletions src/UnitTests/Core/Impl/UnitTests.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
<Import Project="..\..\..\..\build\NetStandard.settings" />
<Import Project="Sdk.props" Sdk="Microsoft.NET.Sdk" />
<ItemGroup>
<PackageReference Include="FluentAssertions" Version="5.4.1" />
<PackageReference Include="MSTest.TestFramework" Version="1.3.2" />
<PackageReference Include="FluentAssertions" Version="5.4.0" />
<PackageReference Include="MSTest.TestFramework" Version="1.4.0" />
<PackageReference Include="MicroBuild.Core" Version="0.3.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
Expand Down