Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 0 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,6 @@ src/client/providers/docStringFoldingProvider.ts
src/client/providers/linterProvider.ts
src/client/providers/simpleRefactorProvider.ts
src/client/providers/completionProvider.ts
src/client/providers/jediProxy.ts
src/client/providers/definitionProvider.ts
src/client/providers/referenceProvider.ts
src/client/providers/terminalProvider.ts
Expand Down
2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1044,7 +1044,6 @@
"DeprecatePythonPath - experiment",
"RunByLine - experiment",
"tryPylance",
"jediLSP",
"debuggerDataViewer",
"pythonSendEntireLineToREPL",
"pythonTensorboardExperiment",
Expand Down Expand Up @@ -1074,7 +1073,6 @@
"DeprecatePythonPath - experiment",
"RunByLine - experiment",
"tryPylance",
"jediLSP",
"debuggerDataViewer",
"pythonSendEntireLineToREPL",
"pythonTensorboardExperiment",
Expand Down
42 changes: 41 additions & 1 deletion src/client/activation/jedi/analysisOptions.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,61 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
import { inject, injectable } from 'inversify';
import * as path from 'path';
import { WorkspaceFolder } from 'vscode';
import { IWorkspaceService } from '../../common/application/types';
import { IConfigurationService, Resource } from '../../common/types';

import { IEnvironmentVariablesProvider } from '../../common/variables/types';
import { PythonEnvironment } from '../../pythonEnvironments/info';
import { LanguageServerAnalysisOptionsWithEnv } from '../common/analysisOptions';
import { ILanguageServerOutputChannel } from '../types';

/* eslint-disable @typescript-eslint/explicit-module-boundary-types, class-methods-use-this */

@injectable()
export class JediLanguageServerAnalysisOptions extends LanguageServerAnalysisOptionsWithEnv {
// eslint-disable-next-line @typescript-eslint/no-useless-constructor
private resource: Resource | undefined;

constructor(
@inject(IEnvironmentVariablesProvider) envVarsProvider: IEnvironmentVariablesProvider,
@inject(ILanguageServerOutputChannel) lsOutputChannel: ILanguageServerOutputChannel,
@inject(IConfigurationService) private readonly configurationService: IConfigurationService,
@inject(IWorkspaceService) private readonly workspace: IWorkspaceService,
) {
super(envVarsProvider, lsOutputChannel);
this.resource = undefined;
}

public async initialize(resource: Resource, interpreter: PythonEnvironment | undefined) {
this.resource = resource;
return super.initialize(resource, interpreter);
}

protected getWorkspaceFolder(): WorkspaceFolder | undefined {
return this.workspace.getWorkspaceFolder(this.resource);
}

protected async getInitializationOptions() {
const pythonSettings = this.configurationService.getSettings(this.resource);
const workspacePath = this.getWorkspaceFolder()?.uri.fsPath;
const extraPaths = pythonSettings.autoComplete
? pythonSettings.autoComplete.extraPaths.map((extraPath) => {
if (path.isAbsolute(extraPath)) {
return extraPath;
}
return workspacePath ? path.join(workspacePath, extraPath) : '';
})
: [];

if (workspacePath) {
extraPaths.unshift(workspacePath);
}

const distinctExtraPaths = extraPaths
.filter((value) => value.length > 0)
.filter((value, index, self) => self.indexOf(value) === index);

return {
markupKindPreferred: 'markdown',
completion: {
Expand All @@ -31,6 +68,9 @@ export class JediLanguageServerAnalysisOptions extends LanguageServerAnalysisOpt
didSave: true,
didChange: true,
},
workspace: {
extraPaths: distinctExtraPaths,
},
};
}
}
Loading