Skip to content
This repository was archived by the owner on Apr 14, 2022. It is now read-only.
Merged
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
8bca56b
Fix #668 (partial)
Mar 1, 2019
a731c2a
Merge branch 'master' of https://github.com/Microsoft/python-language…
Mar 1, 2019
069910b
Merge branch 'master' of https://github.com/Microsoft/python-language…
Mar 5, 2019
7ffc9db
Tests
Mar 5, 2019
6303c45
Revert "Tests"
Mar 5, 2019
945451c
Merge branch 'master' of https://github.com/Microsoft/python-language…
Mar 5, 2019
034e437
Merge branch 'master' of https://github.com/Microsoft/python-language…
Mar 5, 2019
f997d68
Merge branch 'master' of https://github.com/Microsoft/python-language…
Mar 6, 2019
0e4ff95
Merge branch 'master' of https://github.com/Microsoft/python-language…
Mar 11, 2019
878c8c5
Merge branch 'master' of https://github.com/Microsoft/python-language…
Mar 13, 2019
35e1033
Merge branch 'master' of https://github.com/Microsoft/python-language…
Mar 13, 2019
1073711
Merge branch 'master' of https://github.com/Microsoft/python-language…
Mar 14, 2019
86028da
Merge branch 'master' of https://github.com/Microsoft/python-language…
Mar 14, 2019
4d4bca7
Merge branch 'master' of https://github.com/Microsoft/python-language…
Mar 18, 2019
ac04f76
Merge branch 'master' of https://github.com/Microsoft/python-language…
Mar 18, 2019
bab03da
Merge branch 'master' of https://github.com/Microsoft/python-language…
Mar 20, 2019
85ec685
Merge branch 'master' of https://github.com/Microsoft/python-language…
Mar 27, 2019
be7466d
Merge branch 'master' of https://github.com/Microsoft/python-language…
Mar 28, 2019
01781c0
Exp
Mar 27, 2019
f544f8a
Limit concurrency
Mar 28, 2019
01bd719
Concurrency limit
Mar 28, 2019
2f8e564
Drop cache after analysis
Mar 28, 2019
9a933bd
Merge branch 'master' of https://github.com/Microsoft/python-language…
Mar 28, 2019
4ad56bb
Fix regression
Mar 28, 2019
c280c55
Merge branch 'master' of https://github.com/Microsoft/python-language…
Apr 3, 2019
b21b8b8
Merge branch 'master' of https://github.com/Microsoft/python-language…
Apr 7, 2019
babaee4
Merge branch 'master' of https://github.com/Microsoft/python-language…
Apr 8, 2019
092efd6
Merge branch 'master' of https://github.com/Microsoft/python-language…
Apr 8, 2019
b97594d
Merge branch 'master' of https://github.com/Microsoft/python-language…
Apr 10, 2019
2a50eb9
Fix test
Apr 10, 2019
9c7f58d
Merge branch 'master' of https://github.com/Microsoft/python-language…
Apr 10, 2019
00faa5f
Merge branch 'master' of https://github.com/Microsoft/python-language…
Apr 12, 2019
4c8aa92
Merge branch 'master' of https://github.com/Microsoft/python-language…
Apr 12, 2019
1a67bc8
Merge branch 'master' of https://github.com/Microsoft/python-language…
Apr 12, 2019
7a13215
Merge branch 'master' of https://github.com/Microsoft/python-language…
Apr 16, 2019
3d907d8
Merge branch 'master' of https://github.com/Microsoft/python-language…
Apr 16, 2019
96a1924
Exclude empty names
Apr 17, 2019
4620786
PR feedback
Apr 17, 2019
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
28 changes: 8 additions & 20 deletions src/LanguageServer/Impl/Completion/ImportCompletion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,11 @@ public static CompletionResult GetCompletionsInFromImport(FromImportStatement fr

private static IEnumerable<CompletionItem> GetAllImportableModules(CompletionContext context) {
var mres = context.Analysis.Document.Interpreter.ModuleResolution;
var modules = mres.CurrentPathResolver.GetAllModuleNames().Distinct();
return modules.Select(n => CompletionItemSource.CreateCompletionItem(n, CompletionItemKind.Module));
var modules = mres.CurrentPathResolver.GetAllModuleNames();
return modules
.Where(n => !string.IsNullOrEmpty(n))
Comment thread
jakebailey marked this conversation as resolved.
.Distinct()
.Select(n => CompletionItemSource.CreateCompletionItem(n, CompletionItemKind.Module));
}

private static CompletionResult GetResultFromImportSearch(IImportSearchResult importSearchResult, CompletionContext context, bool prependStar, SourceSpan? applicableSpan = null) {
Expand Down Expand Up @@ -164,7 +167,9 @@ private static CompletionResult GetResultFromImportSearch(IImportSearchResult im
}

if (module != null) {
completions.AddRange(module.GetMemberNames().Select(n => context.ItemSource.CreateCompletionItem(n, module?.GetMember(n))));
completions.AddRange(module.GetMemberNames()
.Where(n => !string.IsNullOrEmpty(n))
.Select(n => context.ItemSource.CreateCompletionItem(n, module.GetMember(n))));
}

if (importSearchResult is IImportChildrenSource children) {
Expand All @@ -187,23 +192,6 @@ private static CompletionResult GetResultFromImportSearch(IImportSearchResult im
return new CompletionResult(completions, applicableSpan);
}

private static IReadOnlyList<CompletionItem> GetChildModules(string[] names, CompletionContext context) {
if (!names.Any()) {
return Array.Empty<CompletionItem>();
}

var mres = context.Analysis.Document.Interpreter.ModuleResolution;
var fullName = string.Join(".", names.Take(names.Length - 1));

var import = mres.CurrentPathResolver.GetModuleImportFromModuleName(fullName);
if (string.IsNullOrEmpty(import?.ModulePath)) {
return Array.Empty<CompletionItem>();
}

var packages = mres.GetPackagesFromDirectory(Path.GetDirectoryName(import.ModulePath));
return packages.Select(n => CompletionItemSource.CreateCompletionItem(n, CompletionItemKind.Module)).ToArray();
}

private static IEnumerable<(T1, T2)> ZipLongest<T1, T2>(IEnumerable<T1> src1, IEnumerable<T2> src2) {
using (var e1 = src1?.GetEnumerator())
using (var e2 = src2?.GetEnumerator()) {
Expand Down