Skip to content

Propagate files exclusion to the language server #1977

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Jun 18, 2018
Merged

Propagate files exclusion to the language server #1977

merged 12 commits into from
Jun 18, 2018

Conversation

MikhailArkhipov
Copy link

Fixes #1861

  • Always exclude '/Lib/', '/site-packages/'
  • Propagate files.exclude, files.watcherExclude, search.exclude, python.linting.ignorePatterns, python.workspaceSymbols.exclusionPatterns

This pull request:

  • Has a title summarizes what is changing
  • Has unit tests & code coverage is not adversely affected (within reason)
  • Works on all actively maintained versions of Python (e.g. Python 2.7 & the latest Python 3 release)
  • Works on Windows 10, macOS, and Linux (e.g. considered file system case-sensitivity)

Copy link

@DonJayamanne DonJayamanne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets discuss integration test. I'm reluctant to write any more, been burnt by VSC bugs causing our tests to fail, also they are slow.

@@ -3,15 +3,14 @@

import { inject, injectable } from 'inversify';
import * as path from 'path';
import { ExtensionContext, OutputChannel } from 'vscode';
import { ExtensionContext, OutputChannel, workspace } from 'vscode';

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use IWorkspaceService
You can remove ExtensionContext and use IExtensionContext (type is already imported).

@@ -46,6 +45,7 @@ export class AnalysisExtensionActivator implements IExtensionActivator {
private languageClient: LanguageClient | undefined;
private readonly context: ExtensionContext;
private interpreterHash: string = '';
private loadExtensionArgs;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

type definition for this property is missing.
This property needs to be marked as nullable (private loadExtensionArgs?)

}

private getPythonExcludeSection(setting: string, list: string[]): void {
const paths = workspace.getConfiguration('python', null).get<string[]>(setting);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please pass a resource identifier around instead of using null. This way, later all we need to do is provide the resource, or please add a TODO.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll need to figure out resource here for the multiroot case #1149. In the current incarnation LS only supports single root. I guess first workspaceFolder will do for now.

textDocument = await workspace.openTextDocument(file);
await activated;
await window.showTextDocument(textDocument);
await commands.executeCommand('vscode.executeCompletionItemProvider', textDocument.uri, new Position(0, 0));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whats the purpose of invoking this command in the openFile function?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Making sure LS completes loading files and analysis.


test('Default exclusions', async () => {
await openFile(fileOne);
const diag = languages.getDiagnostics();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't it better to write a unit test here to confirm file exclusions get passed to LSP.
And then have .NET tests to validate exclusions.
I.e. can avoid integration tests.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, this found pretty good bug in LS - race condition when diagnostic was published before initialization completed. So I'd rather have a real thing.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't have .NET unit tests and not planning to have them for some time. Besides, we wouldn't be able to detect the race condition in mocks and separate tests. From LS point of view everything is fine, it is free threaded. It is VSC that has problem accepting incoming notifications.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thats fine, please leave these tests.

}

async function setSetting(name: string, value: {} | undefined): Promise<void> {
await configService.updateSettingAsync(name, value, undefined, ConfigurationTarget.Global);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be great if we could avoid integration tests where we update VSC settings. VSC have had a few bugs are updating of settings. I've noticed that some of our tests still fail (flaky) due to VSC bugs.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Setting test (custom folder) is not strictly needed, I can nix it

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need.

@codecov
Copy link

codecov bot commented Jun 15, 2018

Codecov Report

Merging #1977 into master will decrease coverage by 0.15%.
The diff coverage is 6.55%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1977      +/-   ##
==========================================
- Coverage   74.51%   74.35%   -0.16%     
==========================================
  Files         285      287       +2     
  Lines       13364    13511     +147     
  Branches     2390     2408      +18     
==========================================
+ Hits         9958    10046      +88     
- Misses       3268     3332      +64     
+ Partials      138      133       -5
Impacted Files Coverage Δ
src/client/activation/analysis.ts 14.47% <3.44%> (-3.93%) ⬇️
src/client/activation/downloader.ts 19.31% <66.66%> (ø) ⬆️
src/client/debugger/mainV2.ts 77.1% <0%> (-2.82%) ⬇️
src/client/common/types.ts 100% <0%> (ø) ⬆️
src/client/common/serviceRegistry.ts 100% <0%> (ø) ⬆️
src/client/common/application/types.ts 100% <0%> (ø) ⬆️
src/client/debugger/Common/constants.ts 100% <0%> (ø) ⬆️
src/client/debugger/types.ts 100% <0%> (ø) ⬆️
...rc/client/debugger/PythonProcessCallbackHandler.ts 53.61% <0%> (ø) ⬆️
src/client/debugger/serviceRegistry.ts 100% <0%> (ø) ⬆️
... and 9 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5356b12...184d977. Read the comment docs.

@MikhailArkhipov MikhailArkhipov merged commit bd1b746 into microsoft:master Jun 18, 2018
@MikhailArkhipov MikhailArkhipov deleted the exclude branch June 18, 2018 21:54
@lock lock bot locked as resolved and limited conversation to collaborators Jul 31, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Analysis engine should not analyze entire project
2 participants