-
Notifications
You must be signed in to change notification settings - Fork 133
Persistent analysis, part I #1224
Changes from all commits
b605b76
5471ce4
8a8d847
89ce2ca
7a93bf7
2a2bdf8
3edaa73
73371e1
7d60edc
02475f4
835eeac
6b6e928
9692397
080beab
93a6915
cadd7ce
f61b1a7
1b20326
d7efdac
98934d4
417ae03
ec5605f
713d87f
50e63e6
fcd0c06
f6a992b
acad202
f176b2f
4225337
86e36a6
ba97e9f
ffed87e
186a9c6
4196699
93249d4
5e61392
130b95d
a6676f1
18b61ad
0850544
7d0bf5b
663dc8f
86544a6
67b06c2
9daf4a9
90318e9
b79d918
a02c6f3
8a6b055
57358eb
41ef00f
814cd64
6ceb9b8
74bb061
478ce37
cb46e68
ef2981c
2164ad5
1a48790
319c416
86b0ee6
1670c9d
ab69cfd
e00c197
4e1657c
ade00f4
e2fc221
aaf40bb
a5b3b20
f23a487
e6373a7
6f6737d
081f475
42fa4dc
2f03cb9
1dc3339
9535bad
bec2a82
80c9b1c
5b372f7
3066554
91491d4
bc4f587
af69880
5c1a0c3
4146690
48763aa
93bece3
55b6a3f
5e9bf8e
c152e67
eadd622
ba87581
a797593
db6c7fc
f73fed0
4054d5a
4ef96d8
c7436ed
f3860e6
cab0fce
b9c1e14
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -107,7 +107,7 @@ private void HandleAllAppendExtend(CallExpression node) { | |
IPythonCollection values = null; | ||
switch (me.Name) { | ||
case "append": | ||
values = PythonCollectionType.CreateList(Module.Interpreter, new List<IMember> { v }, exact: true); | ||
values = PythonCollectionType.CreateList(Module, new List<IMember> { v }, exact: true); | ||
break; | ||
case "extend": | ||
values = v as IPythonCollection; | ||
|
@@ -129,7 +129,7 @@ private void ExtendAll(Node location, IPythonCollection values) { | |
} | ||
|
||
var all = scope.Variables[AllVariableName]?.Value as IPythonCollection; | ||
var list = PythonCollectionType.CreateConcatenatedList(Module.Interpreter, all, values); | ||
var list = PythonCollectionType.CreateConcatenatedList(Module, all, values); | ||
var source = list.IsGeneric() ? VariableSource.Generic : VariableSource.Declaration; | ||
|
||
Eval.DeclareVariable(AllVariableName, list, source, location); | ||
|
@@ -228,6 +228,8 @@ private void MergeStub() { | |
return; | ||
} | ||
|
||
var builtins = Module.Interpreter.ModuleResolution.BuiltinsModule; | ||
|
||
// Note that scrape can pick up more functions than the stub contains | ||
// Or the stub can have definitions that scraping had missed. Therefore | ||
// merge is the combination of the two with the documentation coming | ||
|
@@ -258,6 +260,10 @@ private void MergeStub() { | |
|
||
var memberType = member?.GetPythonType(); | ||
var stubMemberType = stubMember.GetPythonType(); | ||
|
||
if (builtins.Equals(memberType?.DeclaringModule) || builtins.Equals(stubMemberType.DeclaringModule)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually no. We have a bit of a mess with what is This specific check is if member actually belongs to the |
||
continue; // Leave builtins alone. | ||
} | ||
if (!IsStubBetterType(memberType, stubMemberType)) { | ||
continue; | ||
} | ||
|
@@ -271,7 +277,7 @@ private void MergeStub() { | |
// Re-declare variable with the data from the stub unless member is a module. | ||
// Modules members that are modules should remain as they are, i.e. os.path | ||
// should remain library with its own stub attached. | ||
if (!(stubType is IPythonModule)) { | ||
if (!(stubType is IPythonModule) && !builtins.Equals(stubType.DeclaringModule)) { | ||
sourceType.TransferDocumentationAndLocation(stubType); | ||
// TODO: choose best type between the scrape and the stub. Stub probably should always win. | ||
var source = Eval.CurrentScope.Variables[v.Name]?.Source ?? VariableSource.Declaration; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Copyright(c) Microsoft Corporation | ||
// All rights reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the License); you may not use | ||
// this file except in compliance with the License. You may obtain a copy of the | ||
// License at http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS | ||
// OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY | ||
// IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, | ||
// MERCHANTABILITY OR NON-INFRINGEMENT. | ||
// | ||
// See the Apache Version 2.0 License for specific language governing | ||
// permissions and limitations under the License. | ||
|
||
namespace Microsoft.Python.Analysis.Caching { | ||
public interface ICacheFolderService { | ||
string CacheFolder { get; } | ||
string GetFileNameFromContent(string content); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// Copyright(c) Microsoft Corporation | ||
// All rights reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the License); you may not use | ||
// this file except in compliance with the License. You may obtain a copy of the | ||
// License at http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS | ||
// OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY | ||
// IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, | ||
// MERCHANTABILITY OR NON-INFRINGEMENT. | ||
// | ||
// See the Apache Version 2.0 License for specific language governing | ||
// permissions and limitations under the License. | ||
|
||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using Microsoft.Python.Analysis.Types; | ||
|
||
namespace Microsoft.Python.Analysis.Caching { | ||
internal interface IModuleDatabaseService { | ||
/// <summary> | ||
/// Creates module representation from module persistent state. | ||
/// </summary> | ||
/// <param name="moduleName">Module name. If the name is not qualified | ||
/// the module will ge resolved against active Python version.</param> | ||
/// <param name="filePath">Module file path.</param> | ||
/// <param name="module">Python module.</param> | ||
/// <returns>Module storage state</returns> | ||
ModuleStorageState TryCreateModule(string moduleName, string filePath, out IPythonModule module); | ||
|
||
/// <summary> | ||
/// Writes module data to the database. | ||
/// </summary> | ||
Task StoreModuleAnalysisAsync(IDocumentAnalysis analysis, CancellationToken cancellationToken = default); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// Copyright(c) Microsoft Corporation | ||
// All rights reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the License); you may not use | ||
// this file except in compliance with the License. You may obtain a copy of the | ||
// License at http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS | ||
// OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY | ||
// IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, | ||
// MERCHANTABILITY OR NON-INFRINGEMENT. | ||
// | ||
// See the Apache Version 2.0 License for specific language governing | ||
// permissions and limitations under the License. | ||
|
||
namespace Microsoft.Python.Analysis.Caching { | ||
/// <summary> | ||
/// Describes module data stored in a database. | ||
/// </summary> | ||
public enum ModuleStorageState { | ||
/// <summary> | ||
/// Module does not exist in the database. | ||
/// </summary> | ||
DoesNotExist, | ||
|
||
/// <summary> | ||
/// Partial data. This means module is still being analyzed | ||
/// and the data on the module members is incomplete. | ||
/// </summary> | ||
Partial, | ||
|
||
/// <summary> | ||
/// Modules exist and the analysis is complete. | ||
/// </summary> | ||
Complete, | ||
|
||
/// <summary> | ||
/// Storage is corrupted or incompatible. | ||
/// </summary> | ||
Corrupted | ||
} | ||
} |
Uh oh!
There was an error while loading. Please reload this page.