Skip to content

Commit 1a0f2ba

Browse files
committed
Last port
1 parent d0ba35e commit 1a0f2ba

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+1215
-202
lines changed

src/Analysis/Engine/Impl/Interpreter/Definitions/PythonMemberType.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ public enum PythonMemberType {
6464
/// An instance of a namespace object that was imported from .NET.
6565
/// </summary>
6666
Namespace,
67-
6867
/// <summary>
6968
/// A constant defined in source code.
7069
/// </summary>

src/Analysis/Engine/Impl/ModuleAnalysis.cs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -857,17 +857,6 @@ private IEnumerable<IMemberResult> GetKeywordMembers(GetMemberOptions options, I
857857

858858
#endregion
859859

860-
/// <summary>
861-
/// Gets the available names at the given location. This includes
862-
/// global variables and locals, but not built-in variables.
863-
/// </summary>
864-
/// <param name="index">
865-
/// The 0-based absolute index into the file where the available members
866-
/// should be looked up.
867-
/// </param>
868-
/// <remarks>TODO: Remove; this is only used for tests</remarks>
869-
internal IEnumerable<string> GetVariablesNoBuiltinsByIndex(int index) => GetVariablesNoBuiltins(_unit.Tree.IndexToLocation(index));
870-
871860
/// <summary>
872861
/// Gets the available names at the given location. This includes
873862
/// global variables and locals, but not built-in variables.

src/Analysis/Engine/Test/AnalysisTest.cs

Lines changed: 47 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
using Microsoft.PythonTools.Analysis.Analyzer;
3030
using Microsoft.PythonTools.Analysis.FluentAssertions;
3131
using Microsoft.PythonTools.Analysis.Values;
32+
using Microsoft.PythonTools.Intellisense;
3233
using Microsoft.PythonTools.Interpreter;
3334
using Microsoft.PythonTools.Interpreter.Ast;
3435
using Microsoft.PythonTools.Parsing;
@@ -5576,6 +5577,52 @@ def f(s = 123) -> s:
55765577
.And.HaveReturnValue().OfTypes(BuiltinTypeId.Int, BuiltinTypeId.NoneType, BuiltinTypeId.Unknown);
55775578
}
55785579
}
5580+
5581+
5582+
[TestMethod, Priority(0)]
5583+
public async Task SysModulesSetSpecialization() {
5584+
var code = @"import sys
5585+
modules = sys.modules
5586+
5587+
modules['name_in_modules'] = None
5588+
";
5589+
code += string.Join(
5590+
Environment.NewLine,
5591+
Enumerable.Range(0, 100).Select(i => $"sys.modules['name{i}'] = None")
5592+
);
5593+
5594+
using (var server = await CreateServerAsync(PythonVersions.LatestAvailable2X)) {
5595+
var analysis = await server.OpenDefaultDocumentAndGetAnalysisAsync(code);
5596+
analysis.Should().HaveVariable("sys").WithValue<SysModuleInfo>()
5597+
.And.HaveVariable("modules").WithValue<SysModuleInfo.SysModulesDictionaryInfo>();
5598+
}
5599+
5600+
}
5601+
5602+
5603+
[DataRow("import abc", 7, "abc", "")]
5604+
[DataRow("import abc", 8, "abc", "")]
5605+
[DataRow("import abc", 9, "abc", "")]
5606+
[DataRow("import abc", 10, "abc", "")]
5607+
[DataRow("import deg, abc as A",12, "abc", "")]
5608+
[DataRow("from abc import A", 6, "abc", "")]
5609+
[DataRow("from .deg import A", 9, "deg", "abc")]
5610+
[DataRow("from .hij import A", 9, "abc.hij", "abc.deg")]
5611+
[DataRow("from ..hij import A", 10, "hij", "abc.deg")]
5612+
[DataRow("from ..hij import A", 10, "abc.hij", "abc.deg.HIJ")]
5613+
[DataTestMethod, Priority(0)]
5614+
public async Task ModuleNameWalker(string code, int index, string expected, string baseCode) {
5615+
using (var server = await CreateServerAsync(PythonVersions.LatestAvailable3X)) {
5616+
var analysis = await server.OpenDefaultDocumentAndGetAnalysisAsync(code);
5617+
var entry = (IPythonProjectEntry)server.GetEntry(analysis.DocumentUri);
5618+
var walker = new ImportedModuleNameWalker(baseCode, string.Empty, index, null);
5619+
entry.Tree.Walk(walker);
5620+
walker.ImportedModules.Should().NotBeEmpty()
5621+
.And.NotContainNulls()
5622+
.And.Subject.First().Name.Should().Be(expected);
5623+
}
5624+
}
5625+
55795626
/*
55805627
[TestMethod, Priority(0)]
55815628
public async Task Super() {
@@ -5842,32 +5889,6 @@ def fn(self):
58425889
);
58435890
}
58445891
5845-
[TestMethod, Priority(0)]
5846-
public async Task SysModulesSetSpecialization() {
5847-
var code = @"import sys
5848-
modules = sys.modules
5849-
5850-
modules['name_in_modules'] = None
5851-
";
5852-
code += string.Join(
5853-
Environment.NewLine,
5854-
Enumerable.Range(0, 100).Select(i => string.Format("sys.modules['name{0}'] = None", i))
5855-
);
5856-
5857-
var entry = ProcessTextV2(code);
5858-
5859-
var sys = entry.GetValue<SysModuleInfo>("sys");
5860-
5861-
var modules = entry.GetValue<SysModuleInfo.SysModulesDictionaryInfo>("modules");
5862-
Assert.IsInstanceOfType(modules, typeof(SysModuleInfo.SysModulesDictionaryInfo));
5863-
5864-
AssertUtil.ContainsExactly(
5865-
sys.Modules.Keys,
5866-
Enumerable.Range(0, 100).Select(i => string.Format("name{0}", i))
5867-
.Concat(new[] { "name_in_modules" })
5868-
);
5869-
}
5870-
58715892
[TestMethod, Priority(0)]
58725893
public async Task SysModulesGetSpecialization() {
58735894
var code = @"import sys
@@ -6030,28 +6051,6 @@ public void NullNamedArgument() {
60306051
}
60316052
}
60326053
6033-
[TestMethod, Priority(0)]
6034-
public void ModuleNameWalker() {
6035-
foreach (var item in new[] {
6036-
new { Code="import abc", Index=7, Expected="abc", Base="" },
6037-
new { Code="import abc", Index=8, Expected="abc", Base="" },
6038-
new { Code="import abc", Index=9, Expected="abc", Base="" },
6039-
new { Code="import abc", Index=10, Expected="abc", Base="" },
6040-
new { Code="import deg, abc as A", Index=12, Expected="abc", Base="" },
6041-
new { Code="from abc import A", Index=6, Expected="abc", Base="" },
6042-
new { Code="from .deg import A", Index=9, Expected="deg", Base="abc" },
6043-
new { Code="from .hij import A", Index=9, Expected="abc.hij", Base="abc.deg" },
6044-
new { Code="from ..hij import A", Index=10, Expected="hij", Base="abc.deg" },
6045-
new { Code="from ..hij import A", Index=10, Expected="abc.hij", Base="abc.deg.HIJ" },
6046-
}) {
6047-
var entry = ProcessTextV3(item.Code);
6048-
var walker = new ImportedModuleNameWalker(item.Base, string.Empty, item.Index, null);
6049-
entry.Modules[entry.DefaultModule].Tree.Walk(walker);
6050-
6051-
Assert.AreEqual(item.Expected, walker.ImportedModules.FirstOrDefault()?.Name);
6052-
}
6053-
}
6054-
60556054
[TestMethod, Priority(0)]
60566055
public void CrossModuleFunctionCallMemLeak() {
60576056
var modA = @"from B import h

src/LanguageServer/Impl/Program.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ namespace Microsoft.Python.LanguageServer.Server {
2929
internal static class Program {
3030
public static void Main(string[] args) {
3131
CheckDebugMode();
32-
Debugger.Launch();
3332
using (CoreShell.Create()) {
3433
var services = CoreShell.Current.ServiceManager;
3534

src/PLS.sln

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Python.Analysis.E
1515
EndProject
1616
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Python.Analysis.Engine.Tests", "Analysis\Engine\Test\Microsoft.Python.Analysis.Engine.Tests.csproj", "{1CFA416B-6932-432F-8C75-34B5615D7664}"
1717
EndProject
18-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.PythonTools.Analyzer", "PTVS\Microsoft.PythonTools.Analyzer\Microsoft.PythonTools.Analyzer.csproj", "{467679B2-D043-4C7D-855C-5A833B635EEE}"
18+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.PythonTools.Analyzer", "PTVS\Microsoft.PythonTools.Analyzer\Impl\Microsoft.PythonTools.Analyzer.csproj", "{467679B2-D043-4C7D-855C-5A833B635EEE}"
1919
EndProject
20-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.PythonTools.Ipc.Json", "PTVS\Microsoft.PythonTools.Ipc.Json\Microsoft.PythonTools.Ipc.Json.csproj", "{A5E04CC1-F600-45BA-B493-F7DCBA8C7E1A}"
20+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.PythonTools.Ipc.Json", "PTVS\Microsoft.PythonTools.Ipc.Json\Impl\Microsoft.PythonTools.Ipc.Json.csproj", "{A5E04CC1-F600-45BA-B493-F7DCBA8C7E1A}"
2121
EndProject
2222
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Python.LanguageServer.Core", "LanguageServer\Core\Impl\Microsoft.Python.LanguageServer.Core.csproj", "{0EA1F1C3-2733-423C-BEC5-059BD77F0A3F}"
2323
EndProject

src/PTVS/Microsoft.PythonTools.Analyzer/Analyzer.csproj

Lines changed: 0 additions & 125 deletions
This file was deleted.

src/PTVS/Microsoft.PythonTools.Analyzer/AssemblyInfo.cs renamed to src/PTVS/Microsoft.PythonTools.Analyzer/Impl/AssemblyInfo.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
using System.Reflection;
1818
using System.Runtime.InteropServices;
1919

20-
[assembly: AssemblyTitle("Visual Studio - Python background analyzer")]
2120
[assembly: AssemblyDescription("Performs analysis of the Python standard library and installed site packages.")]
2221

23-
[assembly: ComVisible(false)]
22+
[assembly: ComVisible(false)]

src/PTVS/Microsoft.PythonTools.Analyzer/Intellisense/OutOfProcProjectAnalyzer.cs renamed to src/PTVS/Microsoft.PythonTools.Analyzer/Impl/Intellisense/OutOfProcProjectAnalyzer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1558,7 +1558,7 @@ private Response SetAnalysisOptions(AP.SetAnalysisOptionsRequest request) {
15581558
Project.Limits = AnalysisLimitsConverter.FromDictionary(Options.analysisLimits);
15591559
_server.ParseQueue.InconsistentIndentation = DiagnosticsErrorSink.GetSeverity(Options.indentationInconsistencySeverity);
15601560
_server.ParseQueue.TaskCommentMap = Options.commentTokens;
1561-
_server.Analyzer.SetTypeStubPaths(Options.typeStubPaths);
1561+
_server.Analyzer.SetTypeStubPaths(Options.typeStubPaths ?? Enumerable.Empty<string>());
15621562

15631563
return new Response();
15641564
}

src/PTVS/Microsoft.PythonTools.Analyzer/Microsoft.PythonTools.Analyzer.csproj renamed to src/PTVS/Microsoft.PythonTools.Analyzer/Impl/Microsoft.PythonTools.Analyzer.csproj

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,21 @@
22
<PropertyGroup>
33
<TargetFramework>net472</TargetFramework>
44
<RootNamespace>Microsoft.PythonTools.Analysis</RootNamespace>
5+
<AssemblyTitle>Visual Studio - Python background analyzer</AssemblyTitle>
56
<AssemblyName>Microsoft.PythonTools.Analyzer</AssemblyName>
67
</PropertyGroup>
7-
<Import Project="..\..\..\build\NetStandard.settings" />
8+
<Import Project="..\..\..\..\build\NetStandard.settings" />
89
<Import Project="Sdk.props" Sdk="Microsoft.NET.Sdk" />
910
<PropertyGroup>
1011
<OutputType>Exe</OutputType>
1112
<DebugType>portable</DebugType>
1213
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
1314
</PropertyGroup>
1415
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
15-
<CodeAnalysisRuleSet>..\..\PLS.ruleset</CodeAnalysisRuleSet>
16+
<CodeAnalysisRuleSet>..\..\..\PLS.ruleset</CodeAnalysisRuleSet>
1617
</PropertyGroup>
1718
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
18-
<CodeAnalysisRuleSet>..\..\PLS.ruleset</CodeAnalysisRuleSet>
19+
<CodeAnalysisRuleSet>..\..\..\PLS.ruleset</CodeAnalysisRuleSet>
1920
</PropertyGroup>
2021
<ItemGroup>
2122
<Compile Remove="obj\**" />
@@ -61,13 +62,13 @@
6162
<None Include="App.config" />
6263
</ItemGroup>
6364
<ItemGroup>
64-
<ProjectReference Include="..\..\Analysis\Engine\Impl\Microsoft.Python.Analysis.Engine.csproj" />
65-
<ProjectReference Include="..\..\LanguageServer\Core\Impl\Microsoft.Python.LanguageServer.Core.csproj" />
66-
<ProjectReference Include="..\Microsoft.PythonTools.Ipc.Json\Microsoft.PythonTools.Ipc.Json.csproj" />
65+
<ProjectReference Include="..\..\..\Analysis\Engine\Impl\Microsoft.Python.Analysis.Engine.csproj" />
66+
<ProjectReference Include="..\..\..\LanguageServer\Core\Impl\Microsoft.Python.LanguageServer.Core.csproj" />
67+
<ProjectReference Include="..\..\Microsoft.PythonTools.Ipc.Json\Impl\Microsoft.PythonTools.Ipc.Json.csproj" />
6768
</ItemGroup>
6869
<ItemGroup>
69-
<PackageReference Include="NewtonSoft.Json" Version="11.0.2" />
70+
<PackageReference Include="NewtonSoft.Json" Version="9.0.1" />
7071
</ItemGroup>
7172
<Import Project="Sdk.targets" Sdk="Microsoft.NET.Sdk" />
72-
<Import Project="..\..\..\build\NetStandard.targets" />
73+
<Import Project="..\..\..\..\build\NetStandard.targets" />
7374
</Project>

src/PTVS/Microsoft.PythonTools.Ipc.Json/Microsoft.PythonTools.Ipc.Json.csproj renamed to src/PTVS/Microsoft.PythonTools.Ipc.Json/Impl/Microsoft.PythonTools.Ipc.Json.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
<AssemblyName>Microsoft.PythonTools.Ipc.Json</AssemblyName>
66
<AssemblyTitle></AssemblyTitle>
77
</PropertyGroup>
8-
<Import Project="..\..\..\build\NetStandard.settings" />
8+
<Import Project="..\..\..\..\build\NetStandard.settings" />
99
<Import Project="Sdk.props" Sdk="Microsoft.NET.Sdk" />
1010
<ItemGroup>
11-
<PackageReference Include="NewtonSoft.Json" Version="11.0.2" />
11+
<PackageReference Include="NewtonSoft.Json" Version="9.0.1" />
1212
</ItemGroup>
1313
<Import Project="Sdk.targets" Sdk="Microsoft.NET.Sdk" />
14-
<Import Project="..\..\..\build\NetStandard.targets" />
14+
<Import Project="..\..\..\..\build\NetStandard.targets" />
1515
</Project>

0 commit comments

Comments
 (0)