@zzzen/pyright-internal 1.2.0-dev.20250209 → 1.2.0-dev.20250216
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/analyzer/checker.d.ts +1 -1
- package/dist/analyzer/checker.js +30 -84
- package/dist/analyzer/checker.js.map +1 -1
- package/dist/analyzer/constraintTracker.d.ts +2 -2
- package/dist/analyzer/constraintTracker.js +11 -5
- package/dist/analyzer/constraintTracker.js.map +1 -1
- package/dist/analyzer/constructors.js +2 -2
- package/dist/analyzer/constructors.js.map +1 -1
- package/dist/analyzer/importResolver.d.ts +1 -1
- package/dist/analyzer/program.d.ts +1 -0
- package/dist/analyzer/program.js +4 -1
- package/dist/analyzer/program.js.map +1 -1
- package/dist/analyzer/protocols.js +26 -11
- package/dist/analyzer/protocols.js.map +1 -1
- package/dist/analyzer/service.d.ts +1 -0
- package/dist/analyzer/service.js +3 -1
- package/dist/analyzer/service.js.map +1 -1
- package/dist/analyzer/sourceFile.d.ts +10 -0
- package/dist/analyzer/sourceFile.js +5 -0
- package/dist/analyzer/sourceFile.js.map +1 -1
- package/dist/analyzer/sourceFileInfoUtils.d.ts +1 -0
- package/dist/analyzer/sourceFileInfoUtils.js +12 -11
- package/dist/analyzer/sourceFileInfoUtils.js.map +1 -1
- package/dist/analyzer/typeEvaluator.js +146 -42
- package/dist/analyzer/typeEvaluator.js.map +1 -1
- package/dist/analyzer/typeEvaluatorTypes.d.ts +1 -0
- package/dist/analyzer/typeGuards.js +20 -3
- package/dist/analyzer/typeGuards.js.map +1 -1
- package/dist/backgroundAnalysisBase.d.ts +2 -2
- package/dist/backgroundAnalysisBase.js +14 -13
- package/dist/backgroundAnalysisBase.js.map +1 -1
- package/dist/backgroundThreadBase.d.ts +6 -2
- package/dist/backgroundThreadBase.js +7 -1
- package/dist/backgroundThreadBase.js.map +1 -1
- package/dist/common/fileSystem.d.ts +2 -0
- package/dist/common/fileSystem.js.map +1 -1
- package/dist/common/languageServerInterface.d.ts +0 -24
- package/dist/common/languageServerInterface.js.map +1 -1
- package/dist/common/realFileSystem.d.ts +2 -0
- package/dist/common/realFileSystem.js +8 -0
- package/dist/common/realFileSystem.js.map +1 -1
- package/dist/common/serviceKeys.d.ts +1 -1
- package/dist/common/serviceProviderExtensions.d.ts +1 -1
- package/dist/common/serviceProviderExtensions.js +2 -2
- package/dist/common/serviceProviderExtensions.js.map +1 -1
- package/dist/common/uri/uriMap.d.ts +17 -0
- package/dist/common/uri/uriMap.js +76 -0
- package/dist/common/uri/uriMap.js.map +1 -0
- package/dist/languageServerBase.d.ts +2 -1
- package/dist/languageServerBase.js +2 -0
- package/dist/languageServerBase.js.map +1 -1
- package/dist/languageService/completionProvider.js +1 -1
- package/dist/languageService/completionProvider.js.map +1 -1
- package/dist/languageService/referencesProvider.js +9 -2
- package/dist/languageService/referencesProvider.js.map +1 -1
- package/dist/localization/localize.d.ts +0 -4
- package/dist/localization/localize.js +0 -1
- package/dist/localization/localize.js.map +1 -1
- package/dist/localization/package.nls.cs.json +7 -7
- package/dist/localization/package.nls.de.json +7 -7
- package/dist/localization/package.nls.en-us.json +0 -4
- package/dist/localization/package.nls.es.json +7 -7
- package/dist/localization/package.nls.fr.json +7 -7
- package/dist/localization/package.nls.it.json +7 -7
- package/dist/localization/package.nls.ja.json +7 -7
- package/dist/localization/package.nls.ko.json +7 -7
- package/dist/localization/package.nls.pl.json +7 -7
- package/dist/localization/package.nls.pt-br.json +7 -7
- package/dist/localization/package.nls.qps-ploc.json +3 -3
- package/dist/localization/package.nls.ru.json +7 -7
- package/dist/localization/package.nls.tr.json +7 -7
- package/dist/localization/package.nls.zh-cn.json +7 -7
- package/dist/localization/package.nls.zh-tw.json +7 -7
- package/dist/partialStubService.d.ts +26 -0
- package/dist/partialStubService.js +138 -0
- package/dist/partialStubService.js.map +1 -0
- package/dist/pyrightFileSystem.d.ts +1 -21
- package/dist/pyrightFileSystem.js +7 -137
- package/dist/pyrightFileSystem.js.map +1 -1
- package/dist/readonlyAugmentedFileSystem.d.ts +7 -4
- package/dist/readonlyAugmentedFileSystem.js +124 -60
- package/dist/readonlyAugmentedFileSystem.js.map +1 -1
- package/dist/server.js +3 -1
- package/dist/server.js.map +1 -1
- package/dist/tests/completions.test.js +23 -0
- package/dist/tests/completions.test.js.map +1 -1
- package/dist/tests/fourslash/rename.typeParams.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/rename.typeParams.fourslash.js +27 -0
- package/dist/tests/fourslash/rename.typeParams.fourslash.js.map +1 -0
- package/dist/tests/harness/fourslash/testState.js +3 -1
- package/dist/tests/harness/fourslash/testState.js.map +1 -1
- package/dist/tests/harness/vfs/filesystem.d.ts +2 -0
- package/dist/tests/harness/vfs/filesystem.js +5 -2
- package/dist/tests/harness/vfs/filesystem.js.map +1 -1
- package/dist/tests/importResolver.test.js +8 -2
- package/dist/tests/importResolver.test.js.map +1 -1
- package/dist/tests/pyrightFileSystem.test.js +15 -8
- package/dist/tests/pyrightFileSystem.test.js.map +1 -1
- package/dist/tests/typeEvaluator4.test.js +2 -2
- package/dist/tests/typeEvaluator6.test.js +4 -0
- package/dist/tests/typeEvaluator6.test.js.map +1 -1
- package/dist/tests/typeEvaluator7.test.js +1 -1
- package/dist/tests/typeEvaluator8.test.js +1 -1
- package/dist/tests/typeEvaluator8.test.js.map +1 -1
- package/dist/types.d.ts +26 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/package.json +1 -1
@@ -0,0 +1,138 @@
|
|
1
|
+
"use strict";
|
2
|
+
/*
|
3
|
+
* partialStubService.ts
|
4
|
+
* Copyright (c) Microsoft Corporation.
|
5
|
+
* Licensed under the MIT license.
|
6
|
+
*
|
7
|
+
* A service that maps partial stub packages into the original directory of the installed library.
|
8
|
+
*/
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
10
|
+
exports.PartialStubService = exports.SupportPartialStubs = void 0;
|
11
|
+
const pyTypedUtils_1 = require("./analyzer/pyTypedUtils");
|
12
|
+
const pathConsts_1 = require("./common/pathConsts");
|
13
|
+
const uriUtils_1 = require("./common/uri/uriUtils");
|
14
|
+
var SupportPartialStubs;
|
15
|
+
(function (SupportPartialStubs) {
|
16
|
+
function is(value) {
|
17
|
+
return (value.isPartialStubPackagesScanned &&
|
18
|
+
value.isPathScanned &&
|
19
|
+
value.processPartialStubPackages &&
|
20
|
+
value.clearPartialStubs);
|
21
|
+
}
|
22
|
+
SupportPartialStubs.is = is;
|
23
|
+
})(SupportPartialStubs || (exports.SupportPartialStubs = SupportPartialStubs = {}));
|
24
|
+
class PartialStubService {
|
25
|
+
constructor(_realFs) {
|
26
|
+
this._realFs = _realFs;
|
27
|
+
// Root paths processed
|
28
|
+
this._rootSearched = new Set();
|
29
|
+
// Partial stub package paths processed
|
30
|
+
this._partialStubPackagePaths = new Set();
|
31
|
+
// Disposables to cleanup moved directories
|
32
|
+
this._movedDirectories = [];
|
33
|
+
}
|
34
|
+
isPartialStubPackagesScanned(execEnv) {
|
35
|
+
return execEnv.root ? this.isPathScanned(execEnv.root) : false;
|
36
|
+
}
|
37
|
+
isPathScanned(uri) {
|
38
|
+
return this._rootSearched.has(uri.key);
|
39
|
+
}
|
40
|
+
processPartialStubPackages(paths, roots, bundledStubPath, allowMoving) {
|
41
|
+
const allowMovingFn = allowMoving ?? this._allowMoving.bind(this);
|
42
|
+
for (const path of paths) {
|
43
|
+
this._rootSearched.add(path.key);
|
44
|
+
if (!this._realFs.existsSync(path) || !(0, uriUtils_1.isDirectory)(this._realFs, path)) {
|
45
|
+
continue;
|
46
|
+
}
|
47
|
+
let dirEntries = [];
|
48
|
+
try {
|
49
|
+
dirEntries = this._realFs.readdirEntriesSync(path);
|
50
|
+
}
|
51
|
+
catch {
|
52
|
+
// Leave empty set of dir entries to process.
|
53
|
+
}
|
54
|
+
const isBundledStub = path.equals(bundledStubPath);
|
55
|
+
for (const entry of dirEntries) {
|
56
|
+
const partialStubPackagePath = path.combinePaths(entry.name);
|
57
|
+
const isDirectory = !entry.isSymbolicLink()
|
58
|
+
? entry.isDirectory()
|
59
|
+
: !!(0, uriUtils_1.tryStat)(this._realFs, partialStubPackagePath)?.isDirectory();
|
60
|
+
if (!isDirectory || !entry.name.endsWith(pathConsts_1.stubsSuffix)) {
|
61
|
+
continue;
|
62
|
+
}
|
63
|
+
const pyTypedInfo = (0, pyTypedUtils_1.getPyTypedInfo)(this._realFs, partialStubPackagePath);
|
64
|
+
if (!pyTypedInfo || !pyTypedInfo.isPartiallyTyped) {
|
65
|
+
// Stub-Package is fully typed.
|
66
|
+
continue;
|
67
|
+
}
|
68
|
+
// We found partially typed stub-packages.
|
69
|
+
this._partialStubPackagePaths.add(partialStubPackagePath.key);
|
70
|
+
// Search the root to see whether we have matching package installed.
|
71
|
+
const packageName = entry.name.substr(0, entry.name.length - pathConsts_1.stubsSuffix.length);
|
72
|
+
for (const root of roots) {
|
73
|
+
const packagePath = root.combinePaths(packageName);
|
74
|
+
try {
|
75
|
+
const stat = (0, uriUtils_1.tryStat)(this._realFs, packagePath);
|
76
|
+
if (!stat?.isDirectory()) {
|
77
|
+
continue;
|
78
|
+
}
|
79
|
+
// If partial stub we found is from bundled stub and library installed is marked as py.typed
|
80
|
+
// ignore bundled partial stub.
|
81
|
+
if (!allowMovingFn(isBundledStub, (0, pyTypedUtils_1.getPyTypedInfo)(this._realFs, packagePath), pyTypedInfo)) {
|
82
|
+
continue;
|
83
|
+
}
|
84
|
+
// Merge partial stub packages to the library.
|
85
|
+
this._movedDirectories.push(this._realFs.mapDirectory(packagePath, partialStubPackagePath, (u, fs) => u.hasExtension('.pyi') || (fs.existsSync(u) && fs.statSync(u).isDirectory())));
|
86
|
+
}
|
87
|
+
catch {
|
88
|
+
// ignore
|
89
|
+
}
|
90
|
+
}
|
91
|
+
}
|
92
|
+
}
|
93
|
+
}
|
94
|
+
clearPartialStubs() {
|
95
|
+
this._rootSearched.clear();
|
96
|
+
this._partialStubPackagePaths.clear();
|
97
|
+
this._movedDirectories.forEach((d) => d.dispose());
|
98
|
+
this._movedDirectories = [];
|
99
|
+
}
|
100
|
+
_allowMoving(isBundled, packagePyTyped, _stubPyTyped) {
|
101
|
+
if (!isBundled) {
|
102
|
+
return true;
|
103
|
+
}
|
104
|
+
// If partial stub we found is from bundled stub and library installed is marked as py.typed
|
105
|
+
// allow moving only if the package is marked as partially typed.
|
106
|
+
return !packagePyTyped || packagePyTyped.isPartiallyTyped;
|
107
|
+
}
|
108
|
+
_getRelativePathPartialStubs(partialStubPath) {
|
109
|
+
const relativePaths = [];
|
110
|
+
const searchAllStubs = (uri) => {
|
111
|
+
for (const entry of this._realFs.readdirEntriesSync(uri)) {
|
112
|
+
const filePath = uri.combinePaths(entry.name);
|
113
|
+
let isDirectory = entry.isDirectory();
|
114
|
+
let isFile = entry.isFile();
|
115
|
+
if (entry.isSymbolicLink()) {
|
116
|
+
const stat = (0, uriUtils_1.tryStat)(this._realFs, filePath);
|
117
|
+
if (stat) {
|
118
|
+
isDirectory = stat.isDirectory();
|
119
|
+
isFile = stat.isFile();
|
120
|
+
}
|
121
|
+
}
|
122
|
+
if (isDirectory) {
|
123
|
+
searchAllStubs(filePath);
|
124
|
+
}
|
125
|
+
if (isFile && entry.name.endsWith('.pyi')) {
|
126
|
+
const relative = partialStubPath.getRelativePathComponents(filePath).join('/');
|
127
|
+
if (relative) {
|
128
|
+
relativePaths.push(relative);
|
129
|
+
}
|
130
|
+
}
|
131
|
+
}
|
132
|
+
};
|
133
|
+
searchAllStubs(partialStubPath);
|
134
|
+
return relativePaths;
|
135
|
+
}
|
136
|
+
}
|
137
|
+
exports.PartialStubService = PartialStubService;
|
138
|
+
//# sourceMappingURL=partialStubService.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"partialStubService.js","sourceRoot":"","sources":["../../../../src/partialStubService.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAIH,0DAAsE;AAGtE,oDAAkD;AAElD,oDAA6D;AAU7D,IAAiB,mBAAmB,CAS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L,CAAC,CAAC;QAEF,cAAc,CAAC,eAAe,CAAC,CAAC;QAChC,OAAO,aAAa,CAAC;IACzB,CAAC;CACJ;AAtJD,gDAsJC"}
|
@@ -1,23 +1,10 @@
|
|
1
1
|
import type * as fs from 'fs';
|
2
|
-
import { PyTypedInfo } from './analyzer/pyTypedUtils';
|
3
|
-
import { ExecutionEnvironment } from './common/configOptions';
|
4
2
|
import { FileSystem, MkDirOptions } from './common/fileSystem';
|
5
3
|
import { Uri } from './common/uri/uri';
|
6
4
|
import { ReadOnlyAugmentedFileSystem } from './readonlyAugmentedFileSystem';
|
7
|
-
export interface
|
8
|
-
isPartialStubPackagesScanned(execEnv: ExecutionEnvironment): boolean;
|
9
|
-
isPathScanned(path: Uri): boolean;
|
10
|
-
processPartialStubPackages(paths: Uri[], roots: Uri[], bundledStubPath?: Uri): void;
|
11
|
-
clearPartialStubs(): void;
|
12
|
-
}
|
13
|
-
export declare namespace SupportPartialStubs {
|
14
|
-
function is(value: any): value is SupportPartialStubs;
|
15
|
-
}
|
16
|
-
export interface IPyrightFileSystem extends FileSystem, SupportPartialStubs {
|
5
|
+
export interface IPyrightFileSystem extends FileSystem {
|
17
6
|
}
|
18
7
|
export declare class PyrightFileSystem extends ReadOnlyAugmentedFileSystem implements IPyrightFileSystem {
|
19
|
-
private readonly _rootSearched;
|
20
|
-
private readonly _partialStubPackagePaths;
|
21
8
|
constructor(realFS: FileSystem);
|
22
9
|
mkdirSync(uri: Uri, options?: MkDirOptions): void;
|
23
10
|
chdir(uri: Uri): void;
|
@@ -26,11 +13,4 @@ export declare class PyrightFileSystem extends ReadOnlyAugmentedFileSystem imple
|
|
26
13
|
unlinkSync(uri: Uri): void;
|
27
14
|
createWriteStream(uri: Uri): fs.WriteStream;
|
28
15
|
copyFileSync(src: Uri, dst: Uri): void;
|
29
|
-
isPartialStubPackagesScanned(execEnv: ExecutionEnvironment): boolean;
|
30
|
-
isPathScanned(uri: Uri): boolean;
|
31
|
-
processPartialStubPackages(paths: Uri[], roots: Uri[], bundledStubPath?: Uri, allowMoving?: (isBundled: boolean, packagePyTyped: PyTypedInfo | undefined, _stubPyTyped: PyTypedInfo) => boolean): void;
|
32
|
-
clearPartialStubs(): void;
|
33
|
-
protected isMovedEntry(uri: Uri): boolean;
|
34
|
-
private _allowMoving;
|
35
|
-
private _getRelativePathPartialStubs;
|
36
16
|
}
|
@@ -4,34 +4,14 @@
|
|
4
4
|
* Copyright (c) Microsoft Corporation.
|
5
5
|
* Licensed under the MIT license.
|
6
6
|
*
|
7
|
-
* A file system that knows how to deal with
|
8
|
-
* Files within a partial stub package act as though they are
|
9
|
-
* copied into the associated package, and the combined set of
|
10
|
-
* files is treated as one.
|
7
|
+
* A file system that knows how to deal with remapping files from one folder to another.
|
11
8
|
*/
|
12
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
13
|
-
exports.PyrightFileSystem =
|
14
|
-
const pyTypedUtils_1 = require("./analyzer/pyTypedUtils");
|
15
|
-
const pathConsts_1 = require("./common/pathConsts");
|
16
|
-
const uriUtils_1 = require("./common/uri/uriUtils");
|
10
|
+
exports.PyrightFileSystem = void 0;
|
17
11
|
const readonlyAugmentedFileSystem_1 = require("./readonlyAugmentedFileSystem");
|
18
|
-
var SupportPartialStubs;
|
19
|
-
(function (SupportPartialStubs) {
|
20
|
-
function is(value) {
|
21
|
-
return (value.isPartialStubPackagesScanned &&
|
22
|
-
value.isPathScanned &&
|
23
|
-
value.processPartialStubPackages &&
|
24
|
-
value.clearPartialStubs);
|
25
|
-
}
|
26
|
-
SupportPartialStubs.is = is;
|
27
|
-
})(SupportPartialStubs || (exports.SupportPartialStubs = SupportPartialStubs = {}));
|
28
12
|
class PyrightFileSystem extends readonlyAugmentedFileSystem_1.ReadOnlyAugmentedFileSystem {
|
29
13
|
constructor(realFS) {
|
30
14
|
super(realFS);
|
31
|
-
// Root paths processed
|
32
|
-
this._rootSearched = new Set();
|
33
|
-
// Partial stub package paths processed
|
34
|
-
this._partialStubPackagePaths = new Set();
|
35
15
|
}
|
36
16
|
mkdirSync(uri, options) {
|
37
17
|
this.realFS.mkdirSync(uri, options);
|
@@ -40,129 +20,19 @@ class PyrightFileSystem extends readonlyAugmentedFileSystem_1.ReadOnlyAugmentedF
|
|
40
20
|
this.realFS.chdir(uri);
|
41
21
|
}
|
42
22
|
writeFileSync(uri, data, encoding) {
|
43
|
-
this.realFS.writeFileSync(this.
|
23
|
+
this.realFS.writeFileSync(this.getOriginalUri(uri), data, encoding);
|
44
24
|
}
|
45
25
|
rmdirSync(uri) {
|
46
|
-
this.realFS.rmdirSync(this.
|
26
|
+
this.realFS.rmdirSync(this.getOriginalUri(uri));
|
47
27
|
}
|
48
28
|
unlinkSync(uri) {
|
49
|
-
this.realFS.unlinkSync(this.
|
29
|
+
this.realFS.unlinkSync(this.getOriginalUri(uri));
|
50
30
|
}
|
51
31
|
createWriteStream(uri) {
|
52
|
-
return this.realFS.createWriteStream(this.
|
32
|
+
return this.realFS.createWriteStream(this.getOriginalUri(uri));
|
53
33
|
}
|
54
34
|
copyFileSync(src, dst) {
|
55
|
-
this.realFS.copyFileSync(this.
|
56
|
-
}
|
57
|
-
isPartialStubPackagesScanned(execEnv) {
|
58
|
-
return execEnv.root ? this.isPathScanned(execEnv.root) : false;
|
59
|
-
}
|
60
|
-
isPathScanned(uri) {
|
61
|
-
return this._rootSearched.has(uri.key);
|
62
|
-
}
|
63
|
-
processPartialStubPackages(paths, roots, bundledStubPath, allowMoving) {
|
64
|
-
const allowMovingFn = allowMoving ?? this._allowMoving.bind(this);
|
65
|
-
for (const path of paths) {
|
66
|
-
this._rootSearched.add(path.key);
|
67
|
-
if (!this.realFS.existsSync(path) || !(0, uriUtils_1.isDirectory)(this.realFS, path)) {
|
68
|
-
continue;
|
69
|
-
}
|
70
|
-
let dirEntries = [];
|
71
|
-
try {
|
72
|
-
dirEntries = this.realFS.readdirEntriesSync(path);
|
73
|
-
}
|
74
|
-
catch {
|
75
|
-
// Leave empty set of dir entries to process.
|
76
|
-
}
|
77
|
-
const isBundledStub = path.equals(bundledStubPath);
|
78
|
-
for (const entry of dirEntries) {
|
79
|
-
const partialStubPackagePath = path.combinePaths(entry.name);
|
80
|
-
const isDirectory = !entry.isSymbolicLink()
|
81
|
-
? entry.isDirectory()
|
82
|
-
: !!(0, uriUtils_1.tryStat)(this.realFS, partialStubPackagePath)?.isDirectory();
|
83
|
-
if (!isDirectory || !entry.name.endsWith(pathConsts_1.stubsSuffix)) {
|
84
|
-
continue;
|
85
|
-
}
|
86
|
-
const pyTypedInfo = (0, pyTypedUtils_1.getPyTypedInfo)(this.realFS, partialStubPackagePath);
|
87
|
-
if (!pyTypedInfo || !pyTypedInfo.isPartiallyTyped) {
|
88
|
-
// Stub-Package is fully typed.
|
89
|
-
continue;
|
90
|
-
}
|
91
|
-
// We found partially typed stub-packages.
|
92
|
-
this._partialStubPackagePaths.add(partialStubPackagePath.key);
|
93
|
-
// Search the root to see whether we have matching package installed.
|
94
|
-
let partialStubs;
|
95
|
-
const packageName = entry.name.substr(0, entry.name.length - pathConsts_1.stubsSuffix.length);
|
96
|
-
for (const root of roots) {
|
97
|
-
const packagePath = root.combinePaths(packageName);
|
98
|
-
try {
|
99
|
-
const stat = (0, uriUtils_1.tryStat)(this.realFS, packagePath);
|
100
|
-
if (!stat?.isDirectory()) {
|
101
|
-
continue;
|
102
|
-
}
|
103
|
-
// If partial stub we found is from bundled stub and library installed is marked as py.typed
|
104
|
-
// ignore bundled partial stub.
|
105
|
-
if (!allowMovingFn(isBundledStub, (0, pyTypedUtils_1.getPyTypedInfo)(this.realFS, packagePath), pyTypedInfo)) {
|
106
|
-
continue;
|
107
|
-
}
|
108
|
-
// Merge partial stub packages to the library.
|
109
|
-
partialStubs = partialStubs ?? this._getRelativePathPartialStubs(partialStubPackagePath);
|
110
|
-
for (const partialStub of partialStubs) {
|
111
|
-
const originalPyiFile = partialStubPackagePath.resolvePaths(partialStub);
|
112
|
-
const mappedPyiFile = packagePath.resolvePaths(partialStub);
|
113
|
-
this.recordMovedEntry(mappedPyiFile, originalPyiFile, packagePath);
|
114
|
-
}
|
115
|
-
}
|
116
|
-
catch {
|
117
|
-
// ignore
|
118
|
-
}
|
119
|
-
}
|
120
|
-
}
|
121
|
-
}
|
122
|
-
}
|
123
|
-
clearPartialStubs() {
|
124
|
-
super.clear();
|
125
|
-
this._rootSearched.clear();
|
126
|
-
this._partialStubPackagePaths.clear();
|
127
|
-
}
|
128
|
-
isMovedEntry(uri) {
|
129
|
-
return this._partialStubPackagePaths.has(uri.key) || super.isMovedEntry(uri);
|
130
|
-
}
|
131
|
-
_allowMoving(isBundled, packagePyTyped, _stubPyTyped) {
|
132
|
-
if (!isBundled) {
|
133
|
-
return true;
|
134
|
-
}
|
135
|
-
// If partial stub we found is from bundled stub and library installed is marked as py.typed
|
136
|
-
// allow moving only if the package is marked as partially typed.
|
137
|
-
return !packagePyTyped || packagePyTyped.isPartiallyTyped;
|
138
|
-
}
|
139
|
-
_getRelativePathPartialStubs(partialStubPath) {
|
140
|
-
const relativePaths = [];
|
141
|
-
const searchAllStubs = (uri) => {
|
142
|
-
for (const entry of this.realFS.readdirEntriesSync(uri)) {
|
143
|
-
const filePath = uri.combinePaths(entry.name);
|
144
|
-
let isDirectory = entry.isDirectory();
|
145
|
-
let isFile = entry.isFile();
|
146
|
-
if (entry.isSymbolicLink()) {
|
147
|
-
const stat = (0, uriUtils_1.tryStat)(this.realFS, filePath);
|
148
|
-
if (stat) {
|
149
|
-
isDirectory = stat.isDirectory();
|
150
|
-
isFile = stat.isFile();
|
151
|
-
}
|
152
|
-
}
|
153
|
-
if (isDirectory) {
|
154
|
-
searchAllStubs(filePath);
|
155
|
-
}
|
156
|
-
if (isFile && entry.name.endsWith('.pyi')) {
|
157
|
-
const relative = partialStubPath.getRelativePathComponents(filePath).join('/');
|
158
|
-
if (relative) {
|
159
|
-
relativePaths.push(relative);
|
160
|
-
}
|
161
|
-
}
|
162
|
-
}
|
163
|
-
};
|
164
|
-
searchAllStubs(partialStubPath);
|
165
|
-
return relativePaths;
|
35
|
+
this.realFS.copyFileSync(this.getOriginalUri(src), this.getOriginalUri(dst));
|
166
36
|
}
|
167
37
|
}
|
168
38
|
exports.PyrightFileSystem = PyrightFileSystem;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"pyrightFileSystem.js","sourceRoot":"","sources":["../../../../src/pyrightFileSystem.ts"],"names":[],"mappings":";AAAA
|
1
|
+
{"version":3,"file":"pyrightFileSystem.js","sourceRoot":"","sources":["../../../../src/pyrightFileSystem.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAMH,+EAA4E;AAI5E,MAAa,iBAAkB,SAAQ,yDAA2B;IAC9D,YAAY,MAAkB;QAC1B,KAAK,CAAC,MAAM,CAAC,CAAC;IAClB,CAAC;IAEQ,SAAS,CAAC,GAAQ,EAAE,OAAsB;QAC/C,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IACxC,CAAC;IAEQ,KAAK,CAAC,GAAQ;QACnB,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC3B,CAAC;IAEQ,aAAa,CAAC,GAAQ,EAAE,IAAqB,EAAE,QAA+B;QACnF,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAC;IACxE,CAAC;IAEQ,SAAS,CAAC,GAAQ;QACvB,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC;IACpD,CAAC;IAEQ,UAAU,CAAC,GAAQ;QACxB,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC;IACrD,CAAC;IAEQ,iBAAiB,CAAC,GAAQ;QAC/B,OAAO,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAAC,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC;IACnE,CAAC;IAEQ,YAAY,CAAC,GAAQ,EAAE,GAAQ;QACpC,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC;IACjF,CAAC;CACJ;AAhCD,8CAgCC"}
|
@@ -2,11 +2,11 @@ import type * as fs from 'fs';
|
|
2
2
|
import { FileSystem, MkDirOptions, Stats } from './common/fileSystem';
|
3
3
|
import { FileWatcher, FileWatcherEventHandler } from './common/fileWatcher';
|
4
4
|
import { Uri } from './common/uri/uri';
|
5
|
+
import { Disposable } from 'vscode-jsonrpc';
|
5
6
|
export declare class ReadOnlyAugmentedFileSystem implements FileSystem {
|
6
7
|
protected realFS: FileSystem;
|
7
8
|
private readonly _entryMap;
|
8
9
|
private readonly _reverseEntryMap;
|
9
|
-
private readonly _folderMap;
|
10
10
|
constructor(realFS: FileSystem);
|
11
11
|
existsSync(uri: Uri): boolean;
|
12
12
|
mkdirSync(uri: Uri, options?: MkDirOptions): void;
|
@@ -32,8 +32,11 @@ export declare class ReadOnlyAugmentedFileSystem implements FileSystem {
|
|
32
32
|
getOriginalUri(mappedFileUri: Uri): Uri;
|
33
33
|
getMappedUri(originalFileUri: Uri): Uri;
|
34
34
|
isInZip(uri: Uri): boolean;
|
35
|
-
|
36
|
-
protected getOriginalPath(mappedFileUri: Uri): Uri;
|
37
|
-
protected isMovedEntry(uri: Uri): boolean;
|
35
|
+
mapDirectory(mappedUri: Uri, originalUri: Uri, filter?: (originalUri: Uri, fs: FileSystem) => boolean): Disposable;
|
38
36
|
protected clear(): void;
|
37
|
+
private _findClosestMatch;
|
38
|
+
private _getOriginalEntry;
|
39
|
+
private _getInternalOriginalUri;
|
40
|
+
private _getMappedEntry;
|
41
|
+
private _isOriginalPath;
|
39
42
|
}
|