@zzzen/pyright-internal 1.2.0-dev.20220703 → 1.2.0-dev.20220724
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/README.md +82 -1
- package/dist/analyzer/analysis.js +1 -1
- package/dist/analyzer/analysis.js.map +1 -1
- package/dist/analyzer/analyzerFileInfo.d.ts +2 -1
- package/dist/analyzer/analyzerFileInfo.js.map +1 -1
- package/dist/analyzer/binder.js +15 -1
- package/dist/analyzer/binder.js.map +1 -1
- package/dist/analyzer/checker.d.ts +1 -0
- package/dist/analyzer/checker.js +100 -51
- package/dist/analyzer/checker.js.map +1 -1
- package/dist/analyzer/codeFlowEngine.d.ts +0 -1
- package/dist/analyzer/codeFlowEngine.js +196 -197
- package/dist/analyzer/codeFlowEngine.js.map +1 -1
- package/dist/analyzer/codeFlowTypes.d.ts +1 -1
- package/dist/analyzer/codeFlowTypes.js.map +1 -1
- package/dist/analyzer/constraintSolver.js +6 -7
- package/dist/analyzer/constraintSolver.js.map +1 -1
- package/dist/analyzer/dataClasses.js +13 -4
- package/dist/analyzer/dataClasses.js.map +1 -1
- package/dist/analyzer/functionTransform.js +2 -1
- package/dist/analyzer/functionTransform.js.map +1 -1
- package/dist/analyzer/importResolver.js +5 -4
- package/dist/analyzer/importResolver.js.map +1 -1
- package/dist/analyzer/importStatementUtils.d.ts +1 -1
- package/dist/analyzer/importStatementUtils.js +47 -18
- package/dist/analyzer/importStatementUtils.js.map +1 -1
- package/dist/analyzer/parseTreeUtils.d.ts +6 -1
- package/dist/analyzer/parseTreeUtils.js +118 -10
- package/dist/analyzer/parseTreeUtils.js.map +1 -1
- package/dist/analyzer/patternMatching.js +2 -2
- package/dist/analyzer/patternMatching.js.map +1 -1
- package/dist/analyzer/program.d.ts +2 -2
- package/dist/analyzer/program.js +1 -1
- package/dist/analyzer/program.js.map +1 -1
- package/dist/analyzer/service.d.ts +4 -3
- package/dist/analyzer/service.js +40 -39
- package/dist/analyzer/service.js.map +1 -1
- package/dist/analyzer/sourceFile.d.ts +6 -1
- package/dist/analyzer/sourceFile.js +57 -14
- package/dist/analyzer/sourceFile.js.map +1 -1
- package/dist/analyzer/typeEvaluator.d.ts +1 -1
- package/dist/analyzer/typeEvaluator.js +754 -618
- package/dist/analyzer/typeEvaluator.js.map +1 -1
- package/dist/analyzer/typeEvaluatorTypes.d.ts +15 -15
- package/dist/analyzer/typeEvaluatorWithTracker.js +8 -7
- package/dist/analyzer/typeEvaluatorWithTracker.js.map +1 -1
- package/dist/analyzer/typeGuards.d.ts +2 -0
- package/dist/analyzer/typeGuards.js +47 -14
- package/dist/analyzer/typeGuards.js.map +1 -1
- package/dist/analyzer/typeUtils.d.ts +5 -3
- package/dist/analyzer/typeUtils.js +103 -27
- package/dist/analyzer/typeUtils.js.map +1 -1
- package/dist/analyzer/typedDicts.d.ts +1 -0
- package/dist/analyzer/typedDicts.js +27 -4
- package/dist/analyzer/typedDicts.js.map +1 -1
- package/dist/analyzer/types.d.ts +15 -5
- package/dist/analyzer/types.js +107 -9
- package/dist/analyzer/types.js.map +1 -1
- package/dist/backgroundAnalysisBase.d.ts +2 -1
- package/dist/backgroundAnalysisBase.js +7 -0
- package/dist/backgroundAnalysisBase.js.map +1 -1
- package/dist/backgroundThreadBase.js +1 -0
- package/dist/backgroundThreadBase.js.map +1 -1
- package/dist/common/chokidarFileWatcherProvider.d.ts +1 -2
- package/dist/common/chokidarFileWatcherProvider.js +0 -3
- package/dist/common/chokidarFileWatcherProvider.js.map +1 -1
- package/dist/common/configOptions.d.ts +1 -0
- package/dist/common/configOptions.js +4 -0
- package/dist/common/configOptions.js.map +1 -1
- package/dist/common/diagnostic.d.ts +2 -1
- package/dist/common/diagnostic.js +2 -1
- package/dist/common/diagnostic.js.map +1 -1
- package/dist/common/diagnosticRules.d.ts +1 -0
- package/dist/common/diagnosticRules.js +1 -0
- package/dist/common/diagnosticRules.js.map +1 -1
- package/dist/common/diagnosticSink.d.ts +3 -0
- package/dist/common/diagnosticSink.js +15 -2
- package/dist/common/diagnosticSink.js.map +1 -1
- package/dist/common/editAction.d.ts +6 -0
- package/dist/common/editAction.js +15 -0
- package/dist/common/editAction.js.map +1 -1
- package/dist/common/fileSystem.d.ts +4 -1
- package/dist/common/fileSystem.js +6 -4
- package/dist/common/fileSystem.js.map +1 -1
- package/dist/common/realFileSystem.d.ts +2 -2
- package/dist/common/realFileSystem.js.map +1 -1
- package/dist/common/textEditUtils.d.ts +22 -2
- package/dist/common/textEditUtils.js +138 -1
- package/dist/common/textEditUtils.js.map +1 -1
- package/dist/common/uriParser.d.ts +2 -0
- package/dist/common/uriParser.js +11 -0
- package/dist/common/uriParser.js.map +1 -1
- package/dist/languageServerBase.d.ts +19 -18
- package/dist/languageServerBase.js +75 -61
- package/dist/languageServerBase.js.map +1 -1
- package/dist/languageService/codeActionProvider.d.ts +2 -2
- package/dist/languageService/codeActionProvider.js +1 -1
- package/dist/languageService/codeActionProvider.js.map +1 -1
- package/dist/languageService/completionProvider.d.ts +15 -11
- package/dist/languageService/completionProvider.js +76 -5
- package/dist/languageService/completionProvider.js.map +1 -1
- package/dist/languageService/indentationUtils.js +3 -2
- package/dist/languageService/indentationUtils.js.map +1 -1
- package/dist/languageService/insertionPointUtils.d.ts +9 -0
- package/dist/languageService/insertionPointUtils.js +110 -0
- package/dist/languageService/insertionPointUtils.js.map +1 -0
- package/dist/languageService/renameModuleProvider.d.ts +1 -4
- package/dist/languageService/renameModuleProvider.js +10 -46
- package/dist/languageService/renameModuleProvider.js.map +1 -1
- package/dist/languageService/signatureHelpProvider.js +4 -2
- package/dist/languageService/signatureHelpProvider.js.map +1 -1
- package/dist/languageService/tooltipUtils.js +1 -3
- package/dist/languageService/tooltipUtils.js.map +1 -1
- package/dist/localization/localize.d.ts +13 -0
- package/dist/localization/localize.js +4 -0
- package/dist/localization/localize.js.map +1 -1
- package/dist/localization/package.nls.en-us.json +4 -0
- package/dist/parser/parser.d.ts +2 -1
- package/dist/parser/parser.js +11 -2
- package/dist/parser/parser.js.map +1 -1
- package/dist/parser/tokenizer.d.ts +2 -1
- package/dist/parser/tokenizer.js +3 -2
- package/dist/parser/tokenizer.js.map +1 -1
- package/dist/pyright.js +3 -1
- package/dist/pyright.js.map +1 -1
- package/dist/pyrightFileSystem.d.ts +20 -2
- package/dist/pyrightFileSystem.js +29 -2
- package/dist/pyrightFileSystem.js.map +1 -1
- package/dist/server.js +4 -4
- package/dist/server.js.map +1 -1
- package/dist/tests/chainedSourceFiles.test.js +4 -1
- package/dist/tests/chainedSourceFiles.test.js.map +1 -1
- package/dist/tests/checker.test.js +9 -0
- package/dist/tests/checker.test.js.map +1 -1
- package/dist/tests/fourslash/completions.commitChars.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.commitChars.fourslash.js +47 -0
- package/dist/tests/fourslash/completions.commitChars.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.triggers.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.triggers.fourslash.js +29 -0
- package/dist/tests/fourslash/completions.triggers.fourslash.js.map +1 -0
- package/dist/tests/fourslash/fourslash.d.ts +1 -0
- package/dist/tests/fourslash/import.multipart.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/import.multipart.fourslash.js +18 -0
- package/dist/tests/fourslash/import.multipart.fourslash.js.map +1 -0
- package/dist/tests/fourslash/signature.simple.fourslash.js +16 -0
- package/dist/tests/fourslash/signature.simple.fourslash.js.map +1 -1
- package/dist/tests/harness/fourslash/testLanguageService.js +1 -1
- package/dist/tests/harness/fourslash/testLanguageService.js.map +1 -1
- package/dist/tests/harness/fourslash/testState.js +12 -3
- package/dist/tests/harness/fourslash/testState.js.map +1 -1
- package/dist/tests/insertionPointUtils.test.d.ts +1 -0
- package/dist/tests/insertionPointUtils.test.js +74 -0
- package/dist/tests/insertionPointUtils.test.js.map +1 -0
- package/dist/tests/pyrightFileSystem.test.js +28 -0
- package/dist/tests/pyrightFileSystem.test.js.map +1 -1
- package/dist/tests/renameModuleTestUtils.js +5 -87
- package/dist/tests/renameModuleTestUtils.js.map +1 -1
- package/dist/tests/testStateUtils.d.ts +8 -0
- package/dist/tests/testStateUtils.js +110 -0
- package/dist/tests/testStateUtils.js.map +1 -0
- package/dist/tests/testUtils.d.ts +2 -1
- package/dist/tests/testUtils.js +11 -7
- package/dist/tests/testUtils.js.map +1 -1
- package/dist/tests/typeEvaluator1.test.js +2 -6
- package/dist/tests/typeEvaluator1.test.js.map +1 -1
- package/dist/tests/typeEvaluator2.test.js +16 -4
- package/dist/tests/typeEvaluator2.test.js.map +1 -1
- package/dist/tests/typeEvaluator3.test.js +9 -1
- package/dist/tests/typeEvaluator3.test.js.map +1 -1
- package/dist/tests/typeEvaluator4.test.js +26 -0
- package/dist/tests/typeEvaluator4.test.js.map +1 -1
- package/dist/tests/typeEvaluator5.test.js +6 -0
- package/dist/tests/typeEvaluator5.test.js.map +1 -1
- package/dist/workspaceMap.d.ts +1 -0
- package/dist/workspaceMap.js +10 -0
- package/dist/workspaceMap.js.map +1 -1
- package/package.json +4 -3
@@ -1,5 +1,6 @@
|
|
1
1
|
import { Position } from 'vscode-languageserver';
|
2
2
|
import { TextDocumentIdentifier } from 'vscode-languageserver-protocol';
|
3
|
+
import { URI } from 'vscode-uri';
|
3
4
|
import { FileSystem } from './fileSystem';
|
4
5
|
export declare class UriParser {
|
5
6
|
protected readonly _fs: FileSystem;
|
@@ -9,4 +10,5 @@ export declare class UriParser {
|
|
9
10
|
position: Position;
|
10
11
|
};
|
11
12
|
decodeTextDocumentUri(uriString: string): string;
|
13
|
+
isLocal(uri: URI | string | undefined): boolean;
|
12
14
|
}
|
package/dist/common/uriParser.js
CHANGED
@@ -8,6 +8,8 @@
|
|
8
8
|
*/
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
10
10
|
exports.UriParser = void 0;
|
11
|
+
const vscode_uri_1 = require("vscode-uri");
|
12
|
+
const core_1 = require("./core");
|
11
13
|
const pathUtils_1 = require("./pathUtils");
|
12
14
|
class UriParser {
|
13
15
|
constructor(_fs) {
|
@@ -20,6 +22,15 @@ class UriParser {
|
|
20
22
|
decodeTextDocumentUri(uriString) {
|
21
23
|
return (0, pathUtils_1.convertUriToPath)(this._fs, uriString);
|
22
24
|
}
|
25
|
+
isLocal(uri) {
|
26
|
+
if (!uri) {
|
27
|
+
return false;
|
28
|
+
}
|
29
|
+
if ((0, core_1.isString)(uri)) {
|
30
|
+
uri = vscode_uri_1.URI.parse(uri);
|
31
|
+
}
|
32
|
+
return uri.scheme === 'file';
|
33
|
+
}
|
23
34
|
}
|
24
35
|
exports.UriParser = UriParser;
|
25
36
|
//# sourceMappingURL=uriParser.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"uriParser.js","sourceRoot":"","sources":["../../../src/common/uriParser.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;
|
1
|
+
{"version":3,"file":"uriParser.js","sourceRoot":"","sources":["../../../src/common/uriParser.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAIH,2CAAiC;AAEjC,iCAAkC;AAElC,2CAA+C;AAE/C,MAAa,SAAS;IAClB,YAA+B,GAAe;QAAf,QAAG,GAAH,GAAG,CAAY;IAAG,CAAC;IAE3C,0BAA0B,CAAC,YAAoC,EAAE,QAAkB;QACtF,MAAM,QAAQ,GAAG,IAAI,CAAC,qBAAqB,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC;QAC9D,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC;IAClC,CAAC;IAEM,qBAAqB,CAAC,SAAiB;QAC1C,OAAO,IAAA,4BAAgB,EAAC,IAAI,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;IACjD,CAAC;IAEM,OAAO,CAAC,GAA6B;QACxC,IAAI,CAAC,GAAG,EAAE;YACN,OAAO,KAAK,CAAC;SAChB;QAED,IAAI,IAAA,eAAQ,EAAC,GAAG,CAAC,EAAE;YACf,GAAG,GAAG,gBAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;SACxB;QAED,OAAO,GAAG,CAAC,MAAM,KAAK,MAAM,CAAC;IACjC,CAAC;CACJ;AAvBD,8BAuBC"}
|
@@ -6,6 +6,7 @@ import { BackgroundAnalysisProgram } from './analyzer/backgroundAnalysisProgram'
|
|
6
6
|
import { ImportResolver } from './analyzer/importResolver';
|
7
7
|
import { MaxAnalysisTime } from './analyzer/program';
|
8
8
|
import { AnalyzerService } from './analyzer/service';
|
9
|
+
import { IPythonMode } from './analyzer/sourceFile';
|
9
10
|
import type { BackgroundAnalysisBase } from './backgroundAnalysisBase';
|
10
11
|
import { CancellationProvider } from './common/cancellationUtils';
|
11
12
|
import { DiagnosticSeverityOverrides, DiagnosticSeverityOverridesMap } from './common/commandLineOptions';
|
@@ -15,13 +16,14 @@ import { Deferred } from './common/deferred';
|
|
15
16
|
import { DiagnosticRule } from './common/diagnosticRules';
|
16
17
|
import { FileDiagnostics } from './common/diagnosticSink';
|
17
18
|
import { LanguageServiceExtension } from './common/extensibility';
|
18
|
-
import { FileSystem,
|
19
|
+
import { FileSystem, FileWatcherHandler } from './common/fileSystem';
|
19
20
|
import { Host } from './common/host';
|
20
21
|
import { ProgressReporter } from './common/progressReporter';
|
21
22
|
import { DocumentRange, Position, Range } from './common/textRange';
|
22
23
|
import { UriParser } from './common/uriParser';
|
23
24
|
import { CompletionOptions, CompletionResultsList } from './languageService/completionProvider';
|
24
25
|
import { DefinitionFilter } from './languageService/definitionProvider';
|
26
|
+
import { PyrightFileSystem } from './pyrightFileSystem';
|
25
27
|
import { WorkspaceMap } from './workspaceMap';
|
26
28
|
export interface ServerSettings {
|
27
29
|
venvPath?: string | undefined;
|
@@ -48,6 +50,7 @@ export interface ServerSettings {
|
|
48
50
|
export declare enum WellKnownWorkspaceKinds {
|
49
51
|
Default = "default",
|
50
52
|
Regular = "regular",
|
53
|
+
Limited = "limited",
|
51
54
|
Cloned = "cloned",
|
52
55
|
Test = "test"
|
53
56
|
}
|
@@ -85,7 +88,6 @@ export interface LanguageServerInterface {
|
|
85
88
|
readonly rootPath: string;
|
86
89
|
readonly console: ConsoleInterface;
|
87
90
|
readonly window: WindowInterface;
|
88
|
-
readonly fs: FileSystem;
|
89
91
|
readonly supportAdvancedEdits: boolean;
|
90
92
|
}
|
91
93
|
export interface ServerOptions {
|
@@ -93,15 +95,19 @@ export interface ServerOptions {
|
|
93
95
|
rootDirectory: string;
|
94
96
|
version: string;
|
95
97
|
workspaceMap: WorkspaceMap;
|
96
|
-
fileSystem: FileSystem;
|
97
|
-
fileWatcherProvider: FileWatcherProvider;
|
98
98
|
cancellationProvider: CancellationProvider;
|
99
|
+
fileSystem: FileSystem;
|
100
|
+
fileWatcherHandler: FileWatcherHandler;
|
99
101
|
extension?: LanguageServiceExtension;
|
100
102
|
maxAnalysisTimeInForeground?: MaxAnalysisTime;
|
101
103
|
disableChecker?: boolean;
|
102
104
|
supportedCommands?: string[];
|
103
105
|
supportedCodeActions?: string[];
|
104
106
|
}
|
107
|
+
export interface WorkspaceServices {
|
108
|
+
fs: FileSystem;
|
109
|
+
backgroundAnalysis: BackgroundAnalysisBase | undefined;
|
110
|
+
}
|
105
111
|
interface ClientCapabilities {
|
106
112
|
hasConfigurationCapability: boolean;
|
107
113
|
hasVisualStudioExtensionsCapability: boolean;
|
@@ -115,6 +121,7 @@ interface ClientCapabilities {
|
|
115
121
|
hasGoToDeclarationCapability: boolean;
|
116
122
|
hasDocumentChangeCapability: boolean;
|
117
123
|
hasDocumentAnnotationCapability: boolean;
|
124
|
+
hasCompletionCommitCharCapability: boolean;
|
118
125
|
hoverContentFormat: MarkupKind;
|
119
126
|
completionDocFormat: MarkupKind;
|
120
127
|
completionSupportsSnippet: boolean;
|
@@ -129,7 +136,6 @@ export declare abstract class LanguageServerBase implements LanguageServerInterf
|
|
129
136
|
readonly console: ConsoleInterface;
|
130
137
|
protected _defaultClientConfig: any;
|
131
138
|
protected _workspaceMap: WorkspaceMap;
|
132
|
-
protected _fileWatcherProvider: FileWatcherProvider;
|
133
139
|
private _pendingFindAllRefsCancellationSource;
|
134
140
|
private _pendingCommandCancellationSource;
|
135
141
|
private _progressReporter;
|
@@ -137,7 +143,7 @@ export declare abstract class LanguageServerBase implements LanguageServerInterf
|
|
137
143
|
private _lastFileWatcherRegistration;
|
138
144
|
rootPath: string;
|
139
145
|
protected client: ClientCapabilities;
|
140
|
-
|
146
|
+
protected _serviceFS: PyrightFileSystem;
|
141
147
|
protected _uriParser: UriParser;
|
142
148
|
constructor(_serverOptions: ServerOptions, _connection: Connection, console: ConsoleInterface, uriParserFactory?: (fs: FileSystem) => UriParser);
|
143
149
|
decodeTextDocumentUri(uriString: string): string;
|
@@ -157,7 +163,7 @@ export declare abstract class LanguageServerBase implements LanguageServerInterf
|
|
157
163
|
protected setExtension(extension: any): void;
|
158
164
|
get window(): RemoteWindow;
|
159
165
|
get supportAdvancedEdits(): boolean;
|
160
|
-
createAnalyzerService(name: string, libraryReanalysisTimeProvider?: () => number): AnalyzerService;
|
166
|
+
createAnalyzerService(name: string, services?: WorkspaceServices, libraryReanalysisTimeProvider?: () => number): AnalyzerService;
|
161
167
|
getWorkspaceForFile(filePath: string): Promise<WorkspaceServiceInstance>;
|
162
168
|
reanalyze(): void;
|
163
169
|
restart(): void;
|
@@ -186,23 +192,18 @@ export declare abstract class LanguageServerBase implements LanguageServerInterf
|
|
186
192
|
protected onPrepare(params: CallHierarchyPrepareParams, token: CancellationToken): Promise<CallHierarchyItem[] | null>;
|
187
193
|
protected onIncomingCalls(params: CallHierarchyIncomingCallsParams, token: CancellationToken): Promise<import("vscode-languageserver-types").CallHierarchyIncomingCall[] | null>;
|
188
194
|
protected onOutgoingCalls(params: CallHierarchyOutgoingCallsParams, token: CancellationToken): Promise<CallHierarchyOutgoingCall[] | null>;
|
189
|
-
protected onDidOpenTextDocument(params: DidOpenTextDocumentParams, ipythonMode?:
|
190
|
-
protected onDidChangeTextDocument(params: DidChangeTextDocumentParams, ipythonMode?:
|
195
|
+
protected onDidOpenTextDocument(params: DidOpenTextDocumentParams, ipythonMode?: IPythonMode): Promise<void>;
|
196
|
+
protected onDidChangeTextDocument(params: DidChangeTextDocumentParams, ipythonMode?: IPythonMode): Promise<void>;
|
191
197
|
protected onDidCloseTextDocument(params: DidCloseTextDocumentParams): Promise<void>;
|
192
198
|
protected onDidChangeWatchedFiles(params: DidChangeWatchedFilesParams): void;
|
193
199
|
protected onExecuteCommand(params: ExecuteCommandParams, token: CancellationToken, reporter: WorkDoneProgressReporter): Promise<any>;
|
194
200
|
protected resolveWorkspaceCompletionItem(workspace: WorkspaceServiceInstance, filePath: string, item: CompletionItem, token: CancellationToken): void;
|
195
201
|
protected getWorkspaceCompletionsForPosition(workspace: WorkspaceServiceInstance, filePath: string, position: Position, workspacePath: string, options: CompletionOptions, token: CancellationToken): Promise<CompletionResultsList | undefined>;
|
196
202
|
updateSettingsForAllWorkspaces(): void;
|
197
|
-
protected getCompletionOptions(params?: CompletionParams):
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
autoImport: boolean;
|
202
|
-
};
|
203
|
-
protected createWorkspaceServiceInstance(workspace: WorkspaceFolder | undefined, rootPath: string, kind?: string): WorkspaceServiceInstance;
|
204
|
-
protected convertDiagnostics(fileDiagnostics: FileDiagnostics): PublishDiagnosticsParams[];
|
205
|
-
protected onAnalysisCompletedHandler(results: AnalysisResults): void;
|
203
|
+
protected getCompletionOptions(workspace: WorkspaceServiceInstance, params?: CompletionParams): CompletionOptions;
|
204
|
+
protected createWorkspaceServiceInstance(workspace: WorkspaceFolder | undefined, rootPath: string, kind?: string, services?: WorkspaceServices): WorkspaceServiceInstance;
|
205
|
+
protected convertDiagnostics(fs: FileSystem, fileDiagnostics: FileDiagnostics): PublishDiagnosticsParams[];
|
206
|
+
protected onAnalysisCompletedHandler(fs: FileSystem, results: AnalysisResults): void;
|
206
207
|
updateSettingsForWorkspace(workspace: WorkspaceServiceInstance, serverSettings?: ServerSettings): Promise<void>;
|
207
208
|
updateOptionsAndRestartService(workspace: WorkspaceServiceInstance, serverSettings: ServerSettings, typeStubTargetImportName?: string): void;
|
208
209
|
protected convertLogLevel(logLevelValue?: string): LogLevel;
|
@@ -16,6 +16,7 @@ const vscode_languageserver_1 = require("vscode-languageserver");
|
|
16
16
|
const progress_1 = require("vscode-languageserver/lib/common/progress");
|
17
17
|
const backgroundAnalysisProgram_1 = require("./analyzer/backgroundAnalysisProgram");
|
18
18
|
const service_1 = require("./analyzer/service");
|
19
|
+
const sourceFile_1 = require("./analyzer/sourceFile");
|
19
20
|
const commandResult_1 = require("./commands/commandResult");
|
20
21
|
const cancellationUtils_1 = require("./common/cancellationUtils");
|
21
22
|
const collectionUtils_1 = require("./common/collectionUtils");
|
@@ -38,6 +39,7 @@ var WellKnownWorkspaceKinds;
|
|
38
39
|
(function (WellKnownWorkspaceKinds) {
|
39
40
|
WellKnownWorkspaceKinds["Default"] = "default";
|
40
41
|
WellKnownWorkspaceKinds["Regular"] = "regular";
|
42
|
+
WellKnownWorkspaceKinds["Limited"] = "limited";
|
41
43
|
WellKnownWorkspaceKinds["Cloned"] = "cloned";
|
42
44
|
WellKnownWorkspaceKinds["Test"] = "test";
|
43
45
|
})(WellKnownWorkspaceKinds = exports.WellKnownWorkspaceKinds || (exports.WellKnownWorkspaceKinds = {}));
|
@@ -64,6 +66,7 @@ class LanguageServerBase {
|
|
64
66
|
hasGoToDeclarationCapability: false,
|
65
67
|
hasDocumentChangeCapability: false,
|
66
68
|
hasDocumentAnnotationCapability: false,
|
69
|
+
hasCompletionCommitCharCapability: false,
|
67
70
|
hoverContentFormat: vscode_languageserver_1.MarkupKind.PlainText,
|
68
71
|
completionDocFormat: vscode_languageserver_1.MarkupKind.PlainText,
|
69
72
|
completionSupportsSnippet: false,
|
@@ -78,15 +81,14 @@ class LanguageServerBase {
|
|
78
81
|
this.console.info(`${_serverOptions.productName} language server ${_serverOptions.version && _serverOptions.version + ' '}starting`);
|
79
82
|
this.console.info(`Server root directory: ${_serverOptions.rootDirectory}`);
|
80
83
|
this._workspaceMap = this._serverOptions.workspaceMap;
|
81
|
-
this.
|
82
|
-
this.
|
83
|
-
this._uriParser = uriParserFactory(this.fs);
|
84
|
+
this._serviceFS = new pyrightFileSystem_1.PyrightFileSystem(this._serverOptions.fileSystem);
|
85
|
+
this._uriParser = uriParserFactory(this._serviceFS);
|
84
86
|
// Set the working directory to a known location within
|
85
87
|
// the extension directory. Otherwise the execution of
|
86
88
|
// python can have unintended and surprising results.
|
87
|
-
const moduleDirectory = this.
|
89
|
+
const moduleDirectory = this._serviceFS.getModulePath();
|
88
90
|
if (moduleDirectory) {
|
89
|
-
this.
|
91
|
+
this._serviceFS.chdir(moduleDirectory);
|
90
92
|
}
|
91
93
|
// Set up callbacks.
|
92
94
|
this.setupConnection((_a = _serverOptions.supportedCommands) !== null && _a !== void 0 ? _a : [], (_b = _serverOptions.supportedCodeActions) !== null && _b !== void 0 ? _b : []);
|
@@ -149,20 +151,21 @@ class LanguageServerBase {
|
|
149
151
|
}
|
150
152
|
// Creates a service instance that's used for analyzing a
|
151
153
|
// program within a workspace.
|
152
|
-
createAnalyzerService(name, libraryReanalysisTimeProvider) {
|
153
|
-
|
154
|
-
|
154
|
+
createAnalyzerService(name, services, libraryReanalysisTimeProvider) {
|
155
|
+
var _a;
|
156
|
+
this.console.info(`Starting service instance "${name}"`);
|
157
|
+
const service = new service_1.AnalyzerService(name, (_a = services === null || services === void 0 ? void 0 : services.fs) !== null && _a !== void 0 ? _a : this._serviceFS, {
|
155
158
|
console: this.console,
|
156
159
|
hostFactory: this.createHost.bind(this),
|
157
160
|
importResolverFactory: this.createImportResolver.bind(this),
|
158
161
|
extension: this._serverOptions.extension,
|
159
|
-
backgroundAnalysis: this.createBackgroundAnalysis(),
|
162
|
+
backgroundAnalysis: services ? services.backgroundAnalysis : this.createBackgroundAnalysis(),
|
160
163
|
maxAnalysisTime: this._serverOptions.maxAnalysisTimeInForeground,
|
161
164
|
backgroundAnalysisProgramFactory: this.createBackgroundAnalysisProgram.bind(this),
|
162
165
|
cancellationProvider: this._serverOptions.cancellationProvider,
|
163
166
|
libraryReanalysisTimeProvider,
|
164
167
|
});
|
165
|
-
service.setCompletionCallback((results) => this.onAnalysisCompletedHandler(results));
|
168
|
+
service.setCompletionCallback((results) => this.onAnalysisCompletedHandler(service.fs, results));
|
166
169
|
return service;
|
167
170
|
}
|
168
171
|
async getWorkspaceForFile(filePath) {
|
@@ -211,7 +214,7 @@ class LanguageServerBase {
|
|
211
214
|
this._connection.onExecuteCommand(async (params, token, reporter) => this.onExecuteCommand(params, token, reporter));
|
212
215
|
}
|
213
216
|
initialize(params, supportedCommands, supportedCodeActions) {
|
214
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15;
|
217
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19;
|
215
218
|
if (params.locale) {
|
216
219
|
(0, localize_1.setLocaleOverride)(params.locale);
|
217
220
|
}
|
@@ -233,17 +236,20 @@ class LanguageServerBase {
|
|
233
236
|
!!((_s = (_r = capabilities.workspace) === null || _r === void 0 ? void 0 : _r.workspaceEdit) === null || _s === void 0 ? void 0 : _s.documentChanges) &&
|
234
237
|
!!((_t = capabilities.workspace.workspaceEdit) === null || _t === void 0 ? void 0 : _t.resourceOperations);
|
235
238
|
this.client.hasDocumentAnnotationCapability = !!((_v = (_u = capabilities.workspace) === null || _u === void 0 ? void 0 : _u.workspaceEdit) === null || _v === void 0 ? void 0 : _v.changeAnnotationSupport);
|
236
|
-
this.client.
|
237
|
-
|
238
|
-
|
239
|
-
this.client.
|
240
|
-
|
239
|
+
this.client.hasCompletionCommitCharCapability =
|
240
|
+
!!((_y = (_x = (_w = capabilities.textDocument) === null || _w === void 0 ? void 0 : _w.completion) === null || _x === void 0 ? void 0 : _x.completionList) === null || _y === void 0 ? void 0 : _y.itemDefaults) &&
|
241
|
+
!!((_z = capabilities.textDocument.completion.completionItem) === null || _z === void 0 ? void 0 : _z.commitCharactersSupport);
|
242
|
+
this.client.hoverContentFormat = this._getCompatibleMarkupKind((_1 = (_0 = capabilities.textDocument) === null || _0 === void 0 ? void 0 : _0.hover) === null || _1 === void 0 ? void 0 : _1.contentFormat);
|
243
|
+
this.client.completionDocFormat = this._getCompatibleMarkupKind((_4 = (_3 = (_2 = capabilities.textDocument) === null || _2 === void 0 ? void 0 : _2.completion) === null || _3 === void 0 ? void 0 : _3.completionItem) === null || _4 === void 0 ? void 0 : _4.documentationFormat);
|
244
|
+
this.client.completionSupportsSnippet = !!((_7 = (_6 = (_5 = capabilities.textDocument) === null || _5 === void 0 ? void 0 : _5.completion) === null || _6 === void 0 ? void 0 : _6.completionItem) === null || _7 === void 0 ? void 0 : _7.snippetSupport);
|
245
|
+
this.client.signatureDocFormat = this._getCompatibleMarkupKind((_10 = (_9 = (_8 = capabilities.textDocument) === null || _8 === void 0 ? void 0 : _8.signatureHelp) === null || _9 === void 0 ? void 0 : _9.signatureInformation) === null || _10 === void 0 ? void 0 : _10.documentationFormat);
|
246
|
+
const supportedDiagnosticTags = ((_13 = (_12 = (_11 = capabilities.textDocument) === null || _11 === void 0 ? void 0 : _11.publishDiagnostics) === null || _12 === void 0 ? void 0 : _12.tagSupport) === null || _13 === void 0 ? void 0 : _13.valueSet) || [];
|
241
247
|
this.client.supportsUnnecessaryDiagnosticTag = supportedDiagnosticTags.some((tag) => tag === vscode_languageserver_1.DiagnosticTag.Unnecessary);
|
242
248
|
this.client.supportsDeprecatedDiagnosticTag = supportedDiagnosticTags.some((tag) => tag === vscode_languageserver_1.DiagnosticTag.Deprecated);
|
243
|
-
this.client.hasWindowProgressCapability = !!((
|
244
|
-
this.client.hasGoToDeclarationCapability = !!((
|
249
|
+
this.client.hasWindowProgressCapability = !!((_14 = capabilities.window) === null || _14 === void 0 ? void 0 : _14.workDoneProgress);
|
250
|
+
this.client.hasGoToDeclarationCapability = !!((_15 = capabilities.textDocument) === null || _15 === void 0 ? void 0 : _15.declaration);
|
245
251
|
this.client.completionItemResolveSupportsAdditionalTextEdits =
|
246
|
-
!!((
|
252
|
+
!!((_19 = (_18 = (_17 = (_16 = capabilities.textDocument) === null || _16 === void 0 ? void 0 : _16.completion) === null || _17 === void 0 ? void 0 : _17.completionItem) === null || _18 === void 0 ? void 0 : _18.resolveSupport) === null || _19 === void 0 ? void 0 : _19.properties.some((p) => p === 'additionalTextEdits'));
|
247
253
|
// Create a service instance for each of the workspace folders.
|
248
254
|
if (params.workspaceFolders) {
|
249
255
|
params.workspaceFolders.forEach((folder) => {
|
@@ -322,11 +328,15 @@ class LanguageServerBase {
|
|
322
328
|
// Add all python search paths to watch list
|
323
329
|
if (this.client.hasWatchFileRelativePathCapability) {
|
324
330
|
// Dedup search paths from all workspaces.
|
325
|
-
|
331
|
+
// Get rid of any search path under workspace root since it is already watched by
|
332
|
+
// "**" above.
|
333
|
+
const foldersToWatch = (0, pathUtils_1.deduplicateFolders)(this._workspaceMap
|
334
|
+
.getNonDefaultWorkspaces()
|
335
|
+
.map((w) => w.searchPathsToWatch.filter((p) => !p.startsWith(w.rootPath))));
|
326
336
|
foldersToWatch.forEach((p) => {
|
327
|
-
const globPattern = (0, pathUtils_1.isFile)(this.
|
328
|
-
? { baseUri: (0, pathUtils_1.convertPathToUri)(this.
|
329
|
-
: { baseUri: (0, pathUtils_1.convertPathToUri)(this.
|
337
|
+
const globPattern = (0, pathUtils_1.isFile)(this._serviceFS, p, /* treatZipDirectoryAsFile */ true)
|
338
|
+
? { baseUri: (0, pathUtils_1.convertPathToUri)(this._serviceFS, (0, pathUtils_1.getDirectoryPath)(p)), pattern: (0, pathUtils_1.getFileName)(p) }
|
339
|
+
: { baseUri: (0, pathUtils_1.convertPathToUri)(this._serviceFS, p), pattern: '**' };
|
330
340
|
watchers.push({ globPattern, kind: watchKind });
|
331
341
|
});
|
332
342
|
}
|
@@ -366,8 +376,8 @@ class LanguageServerBase {
|
|
366
376
|
return undefined;
|
367
377
|
}
|
368
378
|
return locations
|
369
|
-
.filter((loc) => !
|
370
|
-
.map((loc) => vscode_languageserver_1.Location.create((0, pathUtils_1.convertPathToUri)(
|
379
|
+
.filter((loc) => !workspace.serviceInstance.fs.isInZipOrEgg(loc.path))
|
380
|
+
.map((loc) => vscode_languageserver_1.Location.create((0, pathUtils_1.convertPathToUri)(workspace.serviceInstance.fs, loc.path), loc.range));
|
371
381
|
}
|
372
382
|
async onReferences(params, token, workDoneReporter, resultReporter) {
|
373
383
|
if (this._pendingFindAllRefsCancellationSource) {
|
@@ -388,8 +398,8 @@ class LanguageServerBase {
|
|
388
398
|
}
|
389
399
|
const convert = (locs) => {
|
390
400
|
return locs
|
391
|
-
.filter((loc) => !
|
392
|
-
.map((loc) => vscode_languageserver_1.Location.create((0, pathUtils_1.convertPathToUri)(
|
401
|
+
.filter((loc) => !workspace.serviceInstance.fs.isInZipOrEgg(loc.path))
|
402
|
+
.map((loc) => vscode_languageserver_1.Location.create((0, pathUtils_1.convertPathToUri)(workspace.serviceInstance.fs, loc.path), loc.range));
|
393
403
|
};
|
394
404
|
const locations = [];
|
395
405
|
const reporter = resultReporter
|
@@ -539,7 +549,7 @@ class LanguageServerBase {
|
|
539
549
|
if (workspace.disableLanguageServices) {
|
540
550
|
return;
|
541
551
|
}
|
542
|
-
const completions = await this.getWorkspaceCompletionsForPosition(workspace, filePath, position, workspace.rootPath, this.getCompletionOptions(params), token);
|
552
|
+
const completions = await this.getWorkspaceCompletionsForPosition(workspace, filePath, position, workspace.rootPath, this.getCompletionOptions(workspace, params), token);
|
543
553
|
if (completions) {
|
544
554
|
completions.completionList.isIncomplete = completionIncomplete;
|
545
555
|
}
|
@@ -578,7 +588,7 @@ class LanguageServerBase {
|
|
578
588
|
if (!editActions) {
|
579
589
|
return undefined;
|
580
590
|
}
|
581
|
-
return (0, workspaceEditUtils_1.convertWorkspaceDocumentEdits)(
|
591
|
+
return (0, workspaceEditUtils_1.convertWorkspaceDocumentEdits)(workspace.serviceInstance.fs, editActions);
|
582
592
|
}
|
583
593
|
async onPrepare(params, token) {
|
584
594
|
const { filePath, position } = this._uriParser.decodeTextDocumentPosition(params.textDocument, params.position);
|
@@ -590,11 +600,11 @@ class LanguageServerBase {
|
|
590
600
|
if (!callItem) {
|
591
601
|
return null;
|
592
602
|
}
|
593
|
-
if (
|
603
|
+
if (workspace.serviceInstance.fs.isInZipOrEgg(callItem.uri)) {
|
594
604
|
return null;
|
595
605
|
}
|
596
606
|
// Convert the file path in the item to proper URI.
|
597
|
-
callItem.uri = (0, pathUtils_1.convertPathToUri)(
|
607
|
+
callItem.uri = (0, pathUtils_1.convertPathToUri)(workspace.serviceInstance.fs, callItem.uri);
|
598
608
|
return [callItem];
|
599
609
|
}
|
600
610
|
async onIncomingCalls(params, token) {
|
@@ -607,10 +617,10 @@ class LanguageServerBase {
|
|
607
617
|
if (!callItems || callItems.length === 0) {
|
608
618
|
return null;
|
609
619
|
}
|
610
|
-
callItems = callItems.filter((item) => !
|
620
|
+
callItems = callItems.filter((item) => !workspace.serviceInstance.fs.isInZipOrEgg(item.from.uri));
|
611
621
|
// Convert the file paths in the items to proper URIs.
|
612
622
|
callItems.forEach((item) => {
|
613
|
-
item.from.uri = (0, pathUtils_1.convertPathToUri)(
|
623
|
+
item.from.uri = (0, pathUtils_1.convertPathToUri)(workspace.serviceInstance.fs, item.from.uri);
|
614
624
|
});
|
615
625
|
return callItems;
|
616
626
|
}
|
@@ -624,26 +634,26 @@ class LanguageServerBase {
|
|
624
634
|
if (!callItems || callItems.length === 0) {
|
625
635
|
return null;
|
626
636
|
}
|
627
|
-
callItems = callItems.filter((item) => !
|
637
|
+
callItems = callItems.filter((item) => !workspace.serviceInstance.fs.isInZipOrEgg(item.to.uri));
|
628
638
|
// Convert the file paths in the items to proper URIs.
|
629
639
|
callItems.forEach((item) => {
|
630
|
-
item.to.uri = (0, pathUtils_1.convertPathToUri)(
|
640
|
+
item.to.uri = (0, pathUtils_1.convertPathToUri)(workspace.serviceInstance.fs, item.to.uri);
|
631
641
|
});
|
632
642
|
return callItems;
|
633
643
|
}
|
634
|
-
async onDidOpenTextDocument(params, ipythonMode =
|
644
|
+
async onDidOpenTextDocument(params, ipythonMode = sourceFile_1.IPythonMode.None) {
|
635
645
|
const filePath = this._uriParser.decodeTextDocumentUri(params.textDocument.uri);
|
636
|
-
if (!this.
|
646
|
+
if (!this._serviceFS.addUriMap(params.textDocument.uri, filePath)) {
|
637
647
|
// We do not support opening 1 file with 2 different uri.
|
638
648
|
return;
|
639
649
|
}
|
640
650
|
const workspace = await this.getWorkspaceForFile(filePath);
|
641
651
|
workspace.serviceInstance.setFileOpened(filePath, params.textDocument.version, params.textDocument.text, ipythonMode);
|
642
652
|
}
|
643
|
-
async onDidChangeTextDocument(params, ipythonMode =
|
653
|
+
async onDidChangeTextDocument(params, ipythonMode = sourceFile_1.IPythonMode.None) {
|
644
654
|
this.recordUserInteractionTime();
|
645
655
|
const filePath = this._uriParser.decodeTextDocumentUri(params.textDocument.uri);
|
646
|
-
if (!this.
|
656
|
+
if (!this._serviceFS.hasUriMapEntry(params.textDocument.uri, filePath)) {
|
647
657
|
// We do not support opening 1 file with 2 different uri.
|
648
658
|
return;
|
649
659
|
}
|
@@ -652,7 +662,7 @@ class LanguageServerBase {
|
|
652
662
|
}
|
653
663
|
async onDidCloseTextDocument(params) {
|
654
664
|
const filePath = this._uriParser.decodeTextDocumentUri(params.textDocument.uri);
|
655
|
-
if (!this.
|
665
|
+
if (!this._serviceFS.removeUriMap(params.textDocument.uri, filePath)) {
|
656
666
|
// We do not support opening 1 file with 2 different uri.
|
657
667
|
return;
|
658
668
|
}
|
@@ -661,9 +671,9 @@ class LanguageServerBase {
|
|
661
671
|
}
|
662
672
|
onDidChangeWatchedFiles(params) {
|
663
673
|
params.changes.forEach((change) => {
|
664
|
-
const filePath = this.
|
674
|
+
const filePath = this._serviceFS.realCasePath(this._uriParser.decodeTextDocumentUri(change.uri));
|
665
675
|
const eventType = change.type === 1 ? 'add' : 'change';
|
666
|
-
this.
|
676
|
+
this._serverOptions.fileWatcherHandler.onFileChange(eventType, filePath);
|
667
677
|
});
|
668
678
|
}
|
669
679
|
async onExecuteCommand(params, token, reporter) {
|
@@ -706,7 +716,7 @@ class LanguageServerBase {
|
|
706
716
|
}
|
707
717
|
}
|
708
718
|
resolveWorkspaceCompletionItem(workspace, filePath, item, token) {
|
709
|
-
workspace.serviceInstance.resolveCompletionItem(filePath, item, this.getCompletionOptions(),
|
719
|
+
workspace.serviceInstance.resolveCompletionItem(filePath, item, this.getCompletionOptions(workspace),
|
710
720
|
/* nameMap */ undefined, token);
|
711
721
|
}
|
712
722
|
getWorkspaceCompletionsForPosition(workspace, filePath, position, workspacePath, options, token) {
|
@@ -721,15 +731,16 @@ class LanguageServerBase {
|
|
721
731
|
this._setupFileWatcher();
|
722
732
|
});
|
723
733
|
}
|
724
|
-
getCompletionOptions(params) {
|
734
|
+
getCompletionOptions(workspace, params) {
|
725
735
|
return {
|
726
736
|
format: this.client.completionDocFormat,
|
727
737
|
snippet: this.client.completionSupportsSnippet,
|
728
738
|
lazyEdit: this.client.completionItemResolveSupportsAdditionalTextEdits,
|
729
739
|
autoImport: true,
|
740
|
+
extraCommitChars: false,
|
730
741
|
};
|
731
742
|
}
|
732
|
-
createWorkspaceServiceInstance(workspace, rootPath, kind = WellKnownWorkspaceKinds.Regular) {
|
743
|
+
createWorkspaceServiceInstance(workspace, rootPath, kind = WellKnownWorkspaceKinds.Regular, services) {
|
733
744
|
var _a, _b, _c;
|
734
745
|
// 5 seconds default
|
735
746
|
const defaultBackOffTime = 5 * 1000;
|
@@ -738,12 +749,13 @@ class LanguageServerBase {
|
|
738
749
|
const libraryReanalysisTimeProvider = kind === WellKnownWorkspaceKinds.Regular
|
739
750
|
? () => this._workspaceMap.hasMultipleWorkspaces(kind) ? multiWorkspaceBackOffTime : defaultBackOffTime
|
740
751
|
: () => defaultBackOffTime;
|
752
|
+
const rootUri = (_a = workspace === null || workspace === void 0 ? void 0 : workspace.uri) !== null && _a !== void 0 ? _a : '';
|
741
753
|
return {
|
742
|
-
workspaceName: (
|
754
|
+
workspaceName: (_b = workspace === null || workspace === void 0 ? void 0 : workspace.name) !== null && _b !== void 0 ? _b : '',
|
743
755
|
rootPath,
|
744
|
-
rootUri
|
756
|
+
rootUri,
|
745
757
|
kind,
|
746
|
-
serviceInstance: this.createAnalyzerService((_c = workspace === null || workspace === void 0 ? void 0 : workspace.name) !== null && _c !== void 0 ? _c : rootPath, libraryReanalysisTimeProvider),
|
758
|
+
serviceInstance: this.createAnalyzerService((_c = workspace === null || workspace === void 0 ? void 0 : workspace.name) !== null && _c !== void 0 ? _c : rootPath, services, libraryReanalysisTimeProvider),
|
747
759
|
disableLanguageServices: false,
|
748
760
|
disableOrganizeImports: false,
|
749
761
|
disableWorkspaceSymbol: false,
|
@@ -751,23 +763,23 @@ class LanguageServerBase {
|
|
751
763
|
searchPathsToWatch: [],
|
752
764
|
};
|
753
765
|
}
|
754
|
-
convertDiagnostics(fileDiagnostics) {
|
766
|
+
convertDiagnostics(fs, fileDiagnostics) {
|
755
767
|
return [
|
756
768
|
{
|
757
|
-
uri: (0, pathUtils_1.convertPathToUri)(
|
769
|
+
uri: (0, pathUtils_1.convertPathToUri)(fs, fileDiagnostics.filePath),
|
758
770
|
version: fileDiagnostics.version,
|
759
|
-
diagnostics: this._convertDiagnostics(fileDiagnostics.diagnostics),
|
771
|
+
diagnostics: this._convertDiagnostics(fs, fileDiagnostics.diagnostics),
|
760
772
|
},
|
761
773
|
];
|
762
774
|
}
|
763
|
-
onAnalysisCompletedHandler(results) {
|
775
|
+
onAnalysisCompletedHandler(fs, results) {
|
764
776
|
// Send the computed diagnostics to the client.
|
765
777
|
results.diagnostics.forEach((fileDiag) => {
|
766
|
-
if (
|
778
|
+
if (fs.isInZipOrEgg(fileDiag.filePath)) {
|
767
779
|
return;
|
768
780
|
}
|
769
|
-
this._sendDiagnostics(this.convertDiagnostics(fileDiag));
|
770
|
-
this.
|
781
|
+
this._sendDiagnostics(this.convertDiagnostics(fs, fileDiag));
|
782
|
+
this._serviceFS.pendingRequest(fileDiag.filePath, fileDiag.diagnostics.length > 0);
|
771
783
|
});
|
772
784
|
if (!this._progressReporter.isEnabled(results)) {
|
773
785
|
// Make sure to disable progress bar if it is currently active.
|
@@ -856,13 +868,14 @@ class LanguageServerBase {
|
|
856
868
|
source: (0, cancellationUtils_1.CancelAfter)(token, serverInitiatedReporter.token),
|
857
869
|
};
|
858
870
|
}
|
859
|
-
_convertDiagnostics(diags) {
|
871
|
+
_convertDiagnostics(fs, diags) {
|
860
872
|
const convertedDiags = [];
|
861
873
|
diags.forEach((diag) => {
|
862
874
|
const severity = convertCategoryToSeverity(diag.category);
|
863
875
|
const rule = diag.getRule();
|
864
876
|
const vsDiag = vscode_languageserver_1.Diagnostic.create(diag.range, diag.message, severity, rule, this._serverOptions.productName);
|
865
|
-
if (diag.category === 3 /* UnusedCode */
|
877
|
+
if (diag.category === 3 /* UnusedCode */ ||
|
878
|
+
diag.category === 4 /* UnreachableCode */) {
|
866
879
|
vsDiag.tags = [vscode_languageserver_1.DiagnosticTag.Unnecessary];
|
867
880
|
vsDiag.severity = vscode_languageserver_1.DiagnosticSeverity.Hint;
|
868
881
|
// If the client doesn't support "unnecessary" tags, don't report unused code.
|
@@ -870,7 +883,7 @@ class LanguageServerBase {
|
|
870
883
|
return;
|
871
884
|
}
|
872
885
|
}
|
873
|
-
else if (diag.category ===
|
886
|
+
else if (diag.category === 5 /* Deprecated */) {
|
874
887
|
vsDiag.tags = [vscode_languageserver_1.DiagnosticTag.Deprecated];
|
875
888
|
vsDiag.severity = vscode_languageserver_1.DiagnosticSeverity.Hint;
|
876
889
|
// If the client doesn't support "deprecated" tags, don't report.
|
@@ -889,8 +902,8 @@ class LanguageServerBase {
|
|
889
902
|
const relatedInfo = diag.getRelatedInfo();
|
890
903
|
if (relatedInfo.length > 0) {
|
891
904
|
vsDiag.relatedInformation = relatedInfo
|
892
|
-
.filter((info) => !
|
893
|
-
.map((info) => vscode_languageserver_1.DiagnosticRelatedInformation.create(vscode_languageserver_1.Location.create((0, pathUtils_1.convertPathToUri)(
|
905
|
+
.filter((info) => !fs.isInZipOrEgg(info.filePath))
|
906
|
+
.map((info) => vscode_languageserver_1.DiagnosticRelatedInformation.create(vscode_languageserver_1.Location.create((0, pathUtils_1.convertPathToUri)(fs, info.filePath), info.range), info.message));
|
894
907
|
}
|
895
908
|
convertedDiags.push(vsDiag);
|
896
909
|
});
|
@@ -903,7 +916,8 @@ class LanguageServerBase {
|
|
903
916
|
case 2 /* Information */:
|
904
917
|
return vscode_languageserver_1.DiagnosticSeverity.Information;
|
905
918
|
case 3 /* UnusedCode */:
|
906
|
-
case 4 /*
|
919
|
+
case 4 /* UnreachableCode */:
|
920
|
+
case 5 /* Deprecated */:
|
907
921
|
return vscode_languageserver_1.DiagnosticSeverity.Hint;
|
908
922
|
}
|
909
923
|
}
|