This repository was archived by the owner on Apr 14, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 134
Multiple fixes and additional tests for persistence #1372
Merged
Merged
Changes from 168 commits
Commits
Show all changes
187 commits
Select commit
Hold shift + click to select a range
b605b76
Remove old qualified name
5471ce4
Node storage
8a8d847
Class and scope to use AST map
89ce2ca
Library analysis
7a93bf7
Fix SO
2a2bdf8
Keep small AST with imports
3edaa73
AST reduction
73371e1
Final field
7d60edc
Initial
02475f4
Reload
835eeac
Merge master
6b6e928
Ignore post-final requests
9692397
Drop AST
080beab
Remove local variables
93a6915
Test fixes
cadd7ce
Fix overload match
f61b1a7
Tests
1b20326
Add locks
d7efdac
Remove local variables
98934d4
Drop file content to save memory
417ae03
Cache PEP hints
ec5605f
Recreate AST
713d87f
Fix specialization
50e63e6
Fix locations
fcd0c06
usings
f6a992b
Test fixes
acad202
Add options to keep data in memory
f176b2f
Merge branch 'master' of https://github.com/microsoft/python-language…
4225337
Merge master
86e36a6
Fix test
ba97e9f
Fix lambda parameters
ffed87e
Fix argument set
186a9c6
Fix overload doc
4196699
Fix stub merge errors
93249d4
Fix async issues
5e61392
Undo some changes
130b95d
Fix test
a6676f1
Fix race condition
18b61ad
Merge master
0850544
Merge master
7d0bf5b
Merge branch 'proxymod' into db
663dc8f
Partial
86544a6
Models and views
67b06c2
Merge branch 'master' of https://github.com/microsoft/python-language…
9daf4a9
Merge master
90318e9
Restore log null checks
b79d918
Merge master
a02c6f3
Fix merge conflict
8a6b055
Merge master
57358eb
Fix merge issue
41ef00f
Merge branch 'master' of https://github.com/microsoft/python-language…
814cd64
Merge master
6ceb9b8
Null check
74bb061
Merge branch 'noast5' into db
478ce37
Partial
cb46e68
Partial
ef2981c
Partial
2164ad5
Fix test
1a48790
Merge branch 'noast5' into db
319c416
Partial
86b0ee6
Partial
1670c9d
First test
ab69cfd
Baseline comparison
e00c197
Builtins
4e1657c
Partial
ade00f4
Type fixes
e2fc221
Fix type names, part I
aaf40bb
Qualified name
a5b3b20
Properly write variables
f23a487
Partial
e6373a7
Construct module from model
6f6737d
Test
081f475
Variable creations
42fa4dc
Factories
2f03cb9
Factories
1dc3339
Split construction
9535bad
Restore
bec2a82
Save builtins
80c9b1c
Test passes
5b372f7
Qualified name
3066554
Better export detection
91491d4
Test fixes
bc4f587
More consistent qualified names
af69880
Sys test
5c1a0c3
Demo
4146690
Complete sys write/read
48763aa
Partial
93bece3
Partial
55b6a3f
Test staility
5e9bf8e
Perf bug
c152e67
Merge master
eadd622
Baseline, remove debug code, deactivate db
ba87581
Test fixes
a797593
Test fix
db6c7fc
Simplify a bit
f73fed0
Baselines and use : separator
4054d5a
Baselines
4ef96d8
PR feedback
c7436ed
Merge branch 'master' of https://github.com/microsoft/python-language…
f3860e6
Merge master
cab0fce
Remove registry reference
b9c1e14
PR feedback
4fbdcb9
Merge master
c7b1a5d
Merge db
90d1429
PR feedback
10289c3
Merge branch 'master' of https://github.com/microsoft/python-language…
facb062
Restore persistence + update test
d80604a
Better handle persistent module in dependencies
0705812
Merge master
96a5b82
Merge master
360f922
Undo
1015c1b
Add location converter abstraction
2ab07d6
Store member location
57c24c5
Fix merge issue
4779813
Basic locations test
7e6fb63
Navigation
9ee9bfe
Add test
fc66756
Update baselines
3b0fb23
Type restore - initial
8192ff2
Remove debug code
e27218f
Partial
ae4e178
Fix stub merge
2209ec1
Various model fixes
73498eb
Improve module handling
fcfb2bb
Qualified name improvements
54fa335
Fix unbound case
bb0b415
Improve stub merge
3b213bc
Fix qualified names of typing
eaa9e37
Handle stub-only modules
05eb692
Merge branch 'db' of https://github.com/microsoft/python-language-ser…
5193858
Merge branch 'dbloc' into dbtype
b888b2a
Add tests for io, re and sys
40554b0
Better handle named tuple
fcd2bd5
Handle module circular references
28f5b6c
Handle else in platform and version clauses + handle it in symbol col…
8fdf769
Formatting
08b5971
Fix walk of multi-level if statement
67fed10
Unify package search in imports
247a8c3
Fix tests
2bd4749
Undo change
5ead9ec
Port changes from dbtype
4090ca0
Merge fixes from upstream
97f1716
Merge master
59f4b83
Partial
91a0bb5
Named tuple support
362800c
Baseline updates
32e8bfc
Debug code
0d65468
Support types
f42d453
Merge branch 'master' into dbtype
3a1fd40
Merge upstream
9e3011d
Properly compare class member declaring type
eba1f45
Nested classes and functions persistence
12b0269
Undo debug
234390d
Fix numpy restore
263eabf
Baselines
f065110
Fix tests
b2b0501
Update AnyStr test reflecting changes to AnyStr behavior
28fa723
Exclude baselines from git diff
b58e893
Fix gitattr
f110a53
Move git setting to root
21c1660
Try no path
754a668
Add RDT count to the analysis_complete event (#1396)
jakebailey 96d38b2
Test fixes
7ee6322
Undo change
db4aab1
Additional stub merge fixes
f72818e
Baseline updates
ed1a728
Fix goto def
8ee1fd0
Protect specific type creation
0ce7bad
Track documentaton source
f9aff94
Merge
088ce1b
More reliable tests + simplification
b423ed8
Prevent crashes when the AST happens to be null (#1405)
jakebailey 352fecc
Remove all references to dropped modules and force GC on reload (#1402)
jakebailey c1b93d8
Typo
62ac1c2
Cleanup
b719956
Basic classification
14671ae
Merge #1340
7983c75
Merge master
6b207ae
Merge master
a9b7ff0
Fix merge error
ac9d1cb
Module unique id fixes
23a9b81
Stricted check to save analysis
1d86086
Revert "Fix tests"
67350e3
Revert "Unify package search in imports"
01d7f2f
Merge branch '1376' into dbtype
f687dc8
Don't clear scope variables with inner classes
68b479b
Fix typo
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| *.json -diff |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -40,10 +40,16 @@ public bool HandleFromImport(FromImportStatement node) { | |
| } | ||
| } | ||
|
|
||
| var imports = ModuleResolution.CurrentPathResolver.FindImports(Module.FilePath, node); | ||
| if (HandleImportSearchResult(imports, null, null, node.Root, out var variableModule)) { | ||
| AssignVariables(node, imports, variableModule); | ||
| if(node.Root is RelativeModuleName) { | ||
|
||
| var imports = ModuleResolution.CurrentPathResolver.FindImports(Module.FilePath, node); | ||
| if (HandleImportSearchResult(imports, null, null, node.Root, out var variableModule)) { | ||
| AssignVariables(node, imports, variableModule); | ||
| } | ||
| } else { | ||
| FindModuleByAbsoluteName(node.Root, null, node.ForceAbsolute, out _, out var module, out _, out var imports); | ||
| AssignVariables(node, imports, module); | ||
| } | ||
|
|
||
| return false; | ||
| } | ||
|
|
||
|
|
@@ -82,7 +88,7 @@ private void HandleModuleImportStar(PythonVariableModule variableModule, bool is | |
| } | ||
|
|
||
| // If __all__ is present, take it, otherwise declare all members from the module that do not begin with an underscore. | ||
| var memberNames = isImplicitPackage | ||
| var memberNames = isImplicitPackage | ||
| ? variableModule.GetMemberNames() | ||
| : variableModule.Analysis.StarImportMemberNames ?? variableModule.GetMemberNames().Where(s => !s.StartsWithOrdinal("_")); | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -50,16 +50,30 @@ public bool HandleImport(ImportStatement node) { | |
| } | ||
|
|
||
| private void HandleImport(ModuleName moduleImportExpression, NameExpression asNameExpression, bool forceAbsolute) { | ||
|
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. |
||
| FindModuleByAbsoluteName(moduleImportExpression, asNameExpression, forceAbsolute, out var firstModule, out var lastModule, out var importNames, out _); | ||
| // "import fob.oar.baz as baz" is handled as baz = import_module('fob.oar.baz') | ||
| // "import fob.oar.baz" is handled as fob = import_module('fob') | ||
| if (!string.IsNullOrEmpty(asNameExpression?.Name) && lastModule != default) { | ||
| Eval.DeclareVariable(asNameExpression.Name, lastModule, VariableSource.Import, asNameExpression); | ||
| } else if (firstModule != default && !string.IsNullOrEmpty(importNames[0])) { | ||
| var firstName = moduleImportExpression.Names[0]; | ||
| Eval.DeclareVariable(importNames[0], firstModule, VariableSource.Import, firstName); | ||
| } | ||
| } | ||
|
|
||
| private void FindModuleByAbsoluteName(ModuleName moduleImportExpression, NameExpression asNameExpression, bool forceAbsolute, | ||
| out PythonVariableModule firstModule, out PythonVariableModule lastModule, out ImmutableArray<string> importNames, out IImportSearchResult imports) { | ||
| // "import fob.oar.baz" means | ||
| // import_module('fob') | ||
| // import_module('fob.oar') | ||
| // import_module('fob.oar.baz') | ||
| var importNames = ImmutableArray<string>.Empty; | ||
| var lastModule = default(PythonVariableModule); | ||
| var firstModule = default(PythonVariableModule); | ||
| importNames = ImmutableArray<string>.Empty; | ||
| lastModule = default; | ||
| firstModule = default; | ||
| imports = null; | ||
| foreach (var nameExpression in moduleImportExpression.Names) { | ||
| importNames = importNames.Add(nameExpression.Name); | ||
| var imports = ModuleResolution.CurrentPathResolver.GetImportsFromAbsoluteName(Module.FilePath, importNames, forceAbsolute); | ||
| imports = ModuleResolution.CurrentPathResolver.GetImportsFromAbsoluteName(Module.FilePath, importNames, forceAbsolute); | ||
| if (!HandleImportSearchResult(imports, lastModule, asNameExpression, moduleImportExpression, out lastModule)) { | ||
| lastModule = default; | ||
| break; | ||
|
|
@@ -69,15 +83,6 @@ private void HandleImport(ModuleName moduleImportExpression, NameExpression asNa | |
| firstModule = lastModule; | ||
| } | ||
| } | ||
|
|
||
| // "import fob.oar.baz as baz" is handled as baz = import_module('fob.oar.baz') | ||
| // "import fob.oar.baz" is handled as fob = import_module('fob') | ||
| if (!string.IsNullOrEmpty(asNameExpression?.Name) && lastModule != default) { | ||
| Eval.DeclareVariable(asNameExpression.Name, lastModule, VariableSource.Import, asNameExpression); | ||
| } else if (firstModule != default && !string.IsNullOrEmpty(importNames[0])) { | ||
| var firstName = moduleImportExpression.Names[0]; | ||
| Eval.DeclareVariable(importNames[0], firstModule, VariableSource.Import, firstName); | ||
| } | ||
| } | ||
|
|
||
| private bool HandleImportSearchResult(in IImportSearchResult imports, in PythonVariableModule parent, in NameExpression asNameExpression, in Node location, out PythonVariableModule variableModule) { | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change to fix the issue when standalone function could become an unbound method with declaring type of null. Does not really affect completions, but present problems when restoring function from the database.