Skip to content
This repository was archived by the owner on Apr 14, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 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
38ede80
Support oddli named files
Mar 28, 2019
cb7f966
Support untitled files
Mar 28, 2019
f4e3aae
Merge branch 'master' of https://github.com/Microsoft/python-language…
Mar 28, 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
10 changes: 8 additions & 2 deletions src/Analysis/Ast/Impl/Documents/RunningDocumentTable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,13 @@ public IDocument OpenDocument(Uri uri, string content, string filePath = null) {
entry = FindDocument(null, uri);
if (entry == null) {
var resolver = _services.GetService<IPythonInterpreter>().ModuleResolution.CurrentPathResolver;
var moduleType = resolver.IsLibraryFile(uri.ToAbsolutePath()) ? ModuleType.Library : ModuleType.User;

var moduleType = ModuleType.User;
var path = uri.ToAbsolutePath();
if (Path.IsPathRooted(path)) {
moduleType = resolver.IsLibraryFile(uri.ToAbsolutePath()) ? ModuleType.Library : ModuleType.User;
}

var mco = new ModuleCreationOptions {
ModuleName = Path.GetFileNameWithoutExtension(uri.LocalPath),
Content = content,
Expand Down Expand Up @@ -205,7 +211,7 @@ private DocumentEntry CreateDocument(ModuleCreationOptions mco) {
case ModuleType.CompiledBuiltin:
document = new CompiledBuiltinPythonModule(mco.ModuleName, mco.Stub, _services);
break;
case ModuleType.User when TryAddModulePath(mco):
case ModuleType.User:
case ModuleType.Library when TryAddModulePath(mco):
document = new PythonModule(mco, _services);
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -694,8 +694,11 @@ private static Node UpdateNodesFromEnd(Edge lastEdge, Node newEnd) {
}

private bool TryFindModule(string modulePath, out Edge lastEdge, out StringSpan unmatchedPathSpan) {
lastEdge = default;
unmatchedPathSpan = default;

if (!Path.IsPathRooted(modulePath)) {
throw new InvalidOperationException("Module path should be rooted");
return false;
}

var normalizedPath = PathUtils.NormalizePath(modulePath);
Expand Down
5 changes: 3 additions & 2 deletions src/LanguageServer/Impl/Implementation/Server.Editor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,11 @@ public async Task<CompletionList> Completion(CompletionParams @params, Cancellat
if(analysis != null) {
var result = _completionSource.GetCompletions(analysis, @params.position);
res.items = result.Completions.ToArray();

await InvokeExtensionsAsync((ext, token)
=> (ext as ICompletionExtension)?.HandleCompletionAsync(analysis, @params.position, res.items.OfType<CompletionItemEx>().ToArray(), cancellationToken), cancellationToken);
}

await InvokeExtensionsAsync((ext, token)
=> (ext as ICompletionExtension)?.HandleCompletionAsync(analysis, @params.position, res.items.OfType<CompletionItemEx>().ToArray(), cancellationToken), cancellationToken);
return res;
}

Expand Down
21 changes: 21 additions & 0 deletions src/LanguageServer/Test/CompletionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
using System;
using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using FluentAssertions;
using Microsoft.Python.Analysis;
Expand Down Expand Up @@ -1114,9 +1115,29 @@ public async Task NoCompletionForCurrentModuleName(bool empty) {
var modulePath = TestData.GetNextModulePath();
var code = empty ? string.Empty : $"{Path.GetFileNameWithoutExtension(modulePath)}.";
var analysis = await GetAnalysisAsync(code, PythonVersions.LatestAvailable3X, null, modulePath);

var cs = new CompletionSource(new PlainTextDocumentationSource(), ServerSettings.completion);
var result = cs.GetCompletions(analysis, new SourceLocation(1, code.Length + 1));
result.Should().NotContainLabels(analysis.Document.Name);
}

[TestMethod, Priority(0)]
[Ignore]
public async Task OddNamedFile() {
const string code = @"
import sys
sys.
";
var uri = await TestData.CreateTestSpecificFileAsync("a.b.py", code);
await CreateServicesAsync(PythonVersions.LatestAvailable3X, uri.AbsolutePath);
var rdt = Services.GetService<IRunningDocumentTable>();
var doc = rdt.OpenDocument(uri, null, uri.AbsolutePath);

var analysis = await doc.GetAnalysisAsync(Timeout.Infinite);
var cs = new CompletionSource(new PlainTextDocumentationSource(), ServerSettings.completion);

var completions = cs.GetCompletions(analysis, new SourceLocation(3, 5));
completions.Should().HaveLabels("argv", "path", "exit");
}
}
}
11 changes: 11 additions & 0 deletions src/LanguageServer/Test/RdtTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,17 @@ public async Task OpenCloseAnalysis() {
ds.Diagnostics[docLc3.Uri].Should().BeEmpty();
}

[DataRow("a.b.py")]
[DataRow("a-b.py")]
[DataRow("01.py")]
[DataTestMethod, Priority(0)]
public async Task OpenOddNames(string fileName) {
var uri = await TestData.CreateTestSpecificFileAsync(fileName, "x = 1");

await CreateServicesAsync(PythonVersions.LatestAvailable3X, uri.AbsolutePath);
var rdt = Services.GetService<IRunningDocumentTable>();
rdt.OpenDocument(uri, null, uri.AbsolutePath);
}

private void VerifyLockCount(IRunningDocumentTable rdt, Uri uri, int expected) {
rdt.LockDocument(uri).Should().Be(expected + 1);
Expand Down