- Notifications
You must be signed in to change notification settings - Fork 133
Use PathResolverSnapshot to find modules.#361
Use PathResolverSnapshot to find modules. #361
Uh oh!
There was an error while loading. Please reload this page.
Conversation
src/Analysis/Engine/Impl/DependencyResolution/AvailablePackageImports.cs Outdated Show resolvedHide resolved
Uh oh!
There was an error while loading. Please reload this page.
src/Analysis/Engine/Impl/DependencyResolution/IAvailableImports.cs Outdated Show resolvedHide resolved
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
src/Analysis/Engine/Impl/DependencyResolution/PathResolverSnapshot.Node.cs Outdated Show resolvedHide resolved
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
| var rootNodes = searchPaths.Where(Path.IsPathRooted).Select(Node.CreateRoot).Prepend(_roots[0]).ToArray(); | ||
| return new PathResolverSnapshot(_pythonLanguageVersion, rootNodes, Version + 1); | ||
| public PathResolverSnapshot SetUserSearchPaths(in IEnumerable<string> searchPaths){ | ||
| var userSearchPaths = searchPaths.ToArray(); |
MikhailArkhipovNov 8, 2018 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
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.
User search paths can contain anything, like . for example. VSC passed . as one of the paths normally. Also, since we pass them down verbatim from user settings, I'd try/catch IOException since they can contain random characters and may be malformed.
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.
PathResolver never accesses file system, so there can't be any IOExceptions. Search paths are preserved in their form cause when _rootDirectory is changed, we can try to convert relative path to absolute.
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.
I think Path.Combine(rootDirectory, p) etc also throw when path parts are invalid, but that is ArgumentException
src/Analysis/Engine/Impl/DependencyResolution/PathResolverSnapshot.cs Outdated Show resolvedHide resolved
Uh oh!
There was an error while loading. Please reload this page.
src/Analysis/Engine/Impl/DependencyResolution/PathResolverSnapshot.cs Outdated Show resolvedHide resolved
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
MikhailArkhipov commented Nov 9, 2018 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
BTW, how does it work with |
| return null; | ||
| } | ||
| public static bool IsNormalizedPath(string path){ |
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.
I wonder if we can just PathUtil.NormalizePath(path) == path?
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.
PathUtil.NormalizePath(path) produces enormous amount of garbage. During initial load, some of that garbage even ends up in Gen2. So the goal was the opposite - don't create new path if the original one is normalized already.
AlexanderSher commented Nov 12, 2018
Unfortunately,
So the only thing I can share is |
- Fixed namespace package resolution in completions (microsoft#12) - Fixed support for sys.modules (microsoft#363) - Added several tests (microsoft#365) - Fixed support for implicit relative module names (microsoft#366) - Added support for multiple matching rules in PathResolver (microsoft#367) Not yet implemented: - Fix imports of binary modules (microsoft#362) - Fix stubs handling - AstAnalysisWalker - More tests - Code cleanup
| // permissions and limitations under the License. | ||
| using Microsoft.PythonTools.Analysis.Infrastructure; | ||
| using Microsoft.PythonTools.Parsing; |
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.
Sorting
Uh oh!
There was an error while loading. Please reload this page.
MikhailArkhipov commented Nov 20, 2018
This needs tons of tests :-) |
MikhailArkhipov commented Nov 23, 2018
I assume we merge it post Nov release? |
- Use PathResolverSnapshot in AstAnalysisWalker - More cleanup Bug to fix: PathResolverSnapshot.AddModulePath should add path to all roots where it matches, not just the first one.
… is created - Added support for native module file names with versions
AlexanderSher commented Dec 3, 2018
Ok, I've removed the WIP prefix. There are some known bugs, but they can be fixed separately. |
# Conflicts: # src/Analysis/Engine/Impl/PythonAnalyzer.cs
…-server into NamespacePackages # Conflicts: # src/Analysis/Engine/Impl/Interpreter/Ast/AstBuiltinsPythonModule.cs
jakebailey commented Dec 3, 2018
Given that this dependency resolver is independent from the analyzer and really only makes use of the AST, would it make more sense to move this into one of the new assemblies Mikhail is planning on creating in a future PR? The only |
MikhailArkhipov commented Dec 4, 2018
@jakebailey - I will move the resolver to the proper assembly with my PR so new code can access it. Currently there is no separate assembly yet. |
Use PathResolverSnapshot to find modules.
No description provided.