Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
482d4be
fixes to unit tests and forgotten multiroot
DonJayamanne Oct 26, 2017
62683ff
globally retry all tests 3 times
DonJayamanne Oct 27, 2017
75570ee
refactor changing interpreters
DonJayamanne Oct 27, 2017
e3374fe
added tests
DonJayamanne Oct 27, 2017
7498536
fixed linter
DonJayamanne Oct 27, 2017
7debbcf
removed redundant files
DonJayamanne Oct 27, 2017
0c23972
temp changes
DonJayamanne Oct 27, 2017
a6d89f7
more changes
DonJayamanne Oct 27, 2017
7ddbb18
lots of refactoring
DonJayamanne Oct 27, 2017
dfb86e6
adding support for multiroot workspaces
DonJayamanne Oct 27, 2017
694c65f
merged
DonJayamanne Oct 27, 2017
6c1e207
removed grep
DonJayamanne Oct 27, 2017
c753dbe
copy changes for #948 and #1353 into multroot
DonJayamanne Oct 29, 2017
57821f9
replicate solution for #1041 and #1354
DonJayamanne Oct 29, 2017
042dce1
#1041 create enum for creation of cancellation token
DonJayamanne Oct 30, 2017
3cf8a9c
multiroot support for unit tests
DonJayamanne Oct 30, 2017
dff9f20
remove empty line (linter warning)
DonJayamanne Oct 30, 2017
e53fa97
delete pyc before making changes to py file
DonJayamanne Oct 30, 2017
59f1d3f
delete pyc file in teardown
DonJayamanne Oct 30, 2017
277c535
merged multiroot master
DonJayamanne Oct 30, 2017
25cb458
merged multiroot master
DonJayamanne Oct 30, 2017
f102cfb
pass uri of workspace when displaing prompt for configuration
DonJayamanne Oct 31, 2017
d8dfd0a
pass uri to commands
DonJayamanne Oct 31, 2017
cd17714
merged
DonJayamanne Oct 31, 2017
118e899
fixed typos based on code review
DonJayamanne Oct 31, 2017
456ce92
prefix path with forward slash, as is done in the extension unit tests
DonJayamanne Oct 31, 2017
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
12 changes: 9 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
"jupyter",
"django",
"debugger",
"unittest"
"unittest",
"multi-root ready"
],
"categories": [
"Languages",
Expand Down Expand Up @@ -1629,6 +1630,8 @@
"vscode": "^1.1.5"
},
"devDependencies": {
"@types/chai": "^4.0.4",
"@types/chai-as-promised": "^7.1.0",
"@types/fs-extra": "^4.0.2",
"@types/jquery": "^1.10.31",
"@types/lodash": "^4.14.74",
Expand All @@ -1641,19 +1644,22 @@
"@types/socket.io-client": "^1.4.27",
"@types/uuid": "^3.3.27",
"@types/winreg": "^1.2.30",
"@types/xml2js": "^0.4.0",
"babel-core": "^6.14.0",
"babel-loader": "^6.2.5",
"babel-preset-es2015": "^6.14.0",
"chai": "^4.1.2",
"chai-as-promised": "^7.1.1",
"event-stream": "^3.3.4",
"gulp": "^3.9.1",
"gulp-filter": "^5.0.1",
"gulp-typescript": "^3.2.2",
"husky": "^0.14.3",
"ignore-loader": "^0.1.1",
"retyped-diff-match-patch-tsd-ambient": "^1.0.0-0",
"sinon": "^2.3.6",
"mocha": "^2.3.3",
"relative": "^3.0.2",
"retyped-diff-match-patch-tsd-ambient": "^1.0.0-0",
"sinon": "^2.3.6",
"ts-loader": "^2.3.4",
"tslint": "^5.7.0",
"tslint-eslint-rules": "^4.1.1",
Expand Down
2 changes: 1 addition & 1 deletion src/client/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,4 @@ export namespace Documentation {
export const Home = '/docs/workspaceSymbols/';
export const InstallOnWindows = '/docs/workspaceSymbols/#Install-Windows';
}
}
}
47 changes: 29 additions & 18 deletions src/client/common/installer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ export class Installer implements vscode.Disposable {
// tslint:disable-next-line:no-non-null-assertion
const productName = ProductNames.get(product)!;
const pythonConfig = workspace.getConfiguration('python');
// tslint:disable-next-line:prefer-type-cast
const disablePromptForFeatures = pythonConfig.get('disablePromptForFeatures', [] as string[]);
return disablePromptForFeatures.indexOf(productName) === -1;
}
Expand All @@ -185,7 +186,8 @@ export class Installer implements vscode.Disposable {
public async promptToInstall(product: Product, resource?: Uri): Promise<InstallerResponse> {
// tslint:disable-next-line:no-non-null-assertion
const productType = ProductTypes.get(product)!;
const productTypeName = ProductTypeNames.get(productType);
// tslint:disable-next-line:no-non-null-assertion
const productTypeName = ProductTypeNames.get(productType)!;
// tslint:disable-next-line:no-non-null-assertion
const productName = ProductNames.get(product)!;

Expand All @@ -199,9 +201,9 @@ export class Installer implements vscode.Disposable {
return InstallerResponse.Ignore;
}

const installOption = ProductInstallationPrompt.has(product) ? ProductInstallationPrompt.get(product) : 'Install ' + productName;
const disableOption = 'Disable ' + productTypeName;
const dontShowAgain = `Don't show this prompt again`;
const installOption = ProductInstallationPrompt.has(product) ? ProductInstallationPrompt.get(product) : `Install ${productName}`;
const disableOption = `Disable ${productTypeName}`;
const dontShowAgain = 'Don\'t show this prompt again';
const alternateFormatter = product === Product.autopep8 ? 'yapf' : 'autopep8';
const useOtherFormatter = `Use '${alternateFormatter}' formatter`;
const options = [];
Expand All @@ -220,8 +222,8 @@ export class Installer implements vscode.Disposable {
case disableOption: {
if (Linters.indexOf(product) >= 0) {
return this.disableLinter(product, resource).then(() => InstallerResponse.Disabled);
}
else {
} else {
// tslint:disable-next-line:no-non-null-assertion
const settingToDisable = SettingToDisableProduct.get(product)!;
return this.updateSetting(settingToDisable, false, resource).then(() => InstallerResponse.Disabled);
}
Expand All @@ -232,6 +234,7 @@ export class Installer implements vscode.Disposable {
}
case dontShowAgain: {
const pythonConfig = workspace.getConfiguration('python');
// tslint:disable-next-line:prefer-type-cast
const features = pythonConfig.get('disablePromptForFeatures', [] as string[]);
features.push(productName);
return pythonConfig.update('disablePromptForFeatures', features, true).then(() => InstallerResponse.Ignore);
Expand All @@ -255,31 +258,32 @@ export class Installer implements vscode.Disposable {
this.outputChannel.appendLine('Option 2: Extract to any folder and add the path to this folder to the command setting.');
this.outputChannel.appendLine('Option 3: Extract to any folder and define that path in the python.workspaceSymbols.ctagsPath setting of your user settings file (settings.json).');
this.outputChannel.show();
}
else {
} else {
window.showInformationMessage('Install Universal Ctags and set it in your path or define the path in your python.workspaceSymbols.ctagsPath settings');
}
return InstallerResponse.Ignore;
}

// tslint:disable-next-line:no-non-null-assertion
let installArgs = ProductInstallScripts.get(product)!;
let pipIndex = installArgs.indexOf('pip');
const pipIndex = installArgs.indexOf('pip');
if (pipIndex > 0) {
installArgs = installArgs.slice();
let proxy = vscode.workspace.getConfiguration('http').get('proxy', '');
const proxy = vscode.workspace.getConfiguration('http').get('proxy', '');
if (proxy.length > 0) {
installArgs.splice(2, 0, proxy);
installArgs.splice(2, 0, '--proxy');
}
}
// tslint:disable-next-line:no-any
let installationPromise: Promise<any>;
if (this.outputChannel && installArgs[0] === '-m') {
// Errors are just displayed to the user
this.outputChannel.show();
installationPromise = execPythonFile(resource, settings.PythonSettings.getInstance(resource).pythonPath,
// tslint:disable-next-line:no-non-null-assertion
installArgs, getCwdForInstallScript(resource), true, (data) => { this.outputChannel!.append(data); });
}
else {
} else {
// When using terminal get the fully qualitified path
// Cuz people may launch vs code from terminal when they have activated the appropriate virtual env
// Problem is terminal doesn't use the currently activated virtual env
Expand All @@ -291,12 +295,13 @@ export class Installer implements vscode.Disposable {
if (installArgs[0] === '-m') {
if (pythonPath.indexOf(' ') >= 0) {
installScript = `"${pythonPath}" ${installScript}`;
}
else {
} else {
installScript = `${pythonPath} ${installScript}`;
}
}
// tslint:disable-next-line:no-non-null-assertion
Installer.terminal!.sendText(installScript);
// tslint:disable-next-line:no-non-null-assertion
Installer.terminal!.show(false);
});
}
Expand All @@ -306,30 +311,33 @@ export class Installer implements vscode.Disposable {
.then(isInstalled => isInstalled ? InstallerResponse.Installed : InstallerResponse.Ignore);
}

// tslint:disable-next-line:member-ordering
public isInstalled(product: Product, resource?: Uri): Promise<boolean | undefined> {
return isProductInstalled(product, resource);
}

// tslint:disable-next-line:member-ordering no-any
public uninstall(product: Product, resource?: Uri): Promise<any> {
return uninstallproduct(product, resource);
}
// tslint:disable-next-line:member-ordering
public disableLinter(product: Product, resource: Uri) {
if (resource && !workspace.getWorkspaceFolder(resource)) {
// tslint:disable-next-line:no-non-null-assertion
const settingToDisable = SettingToDisableProduct.get(product)!;
const pythonConfig = workspace.getConfiguration('python', resource);
return pythonConfig.update(settingToDisable, false, ConfigurationTarget.Workspace);
}
else {
} else {
const pythonConfig = workspace.getConfiguration('python');
return pythonConfig.update('linting.enabledWithoutWorkspace', false, true);
}
}
// tslint:disable-next-line:no-any
private updateSetting(setting: string, value: any, resource?: Uri) {
if (resource && !workspace.getWorkspaceFolder(resource)) {
const pythonConfig = workspace.getConfiguration('python', resource);
return pythonConfig.update(setting, value, ConfigurationTarget.Workspace);
}
else {
} else {
const pythonConfig = workspace.getConfiguration('python');
return pythonConfig.update(setting, value, true);
}
Expand All @@ -351,17 +359,20 @@ async function isProductInstalled(product: Product, resource?: Uri): Promise<boo
if (!ProductExecutableAndArgs.has(product)) {
return;
}
// tslint:disable-next-line:no-non-null-assertion
const prodExec = ProductExecutableAndArgs.get(product)!;
const cwd = getCwdForInstallScript(resource);
return execPythonFile(resource, prodExec.executable, prodExec.args.concat(['--version']), cwd, false)
.then(() => true)
.catch(reason => !isNotInstalledError(reason));
}

// tslint:disable-next-line:no-any
function uninstallproduct(product: Product, resource?: Uri): Promise<any> {
if (!ProductUninstallScripts.has(product)) {
return Promise.resolve();
}
// tslint:disable-next-line:no-non-null-assertion
const uninstallArgs = ProductUninstallScripts.get(product)!;
return execPythonFile(resource, 'python', uninstallArgs, getCwdForInstallScript(resource), false);
}
4 changes: 2 additions & 2 deletions src/client/common/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ function handleResponse(file: string, includeErrorAsResponse: boolean, error: Er

// pylint:
// In the case of pylint we have some messages (such as config file not found and using default etc...) being returned in stderr
// These error messages are useless when using pylint
// These error messages are useless when using pylint
if (includeErrorAsResponse && (stdout.length > 0 || stderr.length > 0)) {
return Promise.resolve(stdout + '\n' + stderr);
}
Expand All @@ -189,7 +189,7 @@ function handlePythonModuleResponse(includeErrorAsResponse: boolean, error: Erro

// pylint:
// In the case of pylint we have some messages (such as config file not found and using default etc...) being returned in stderr
// These error messages are useless when using pylint
// These error messages are useless when using pylint
if (includeErrorAsResponse && (stdout.length > 0 || stderr.length > 0)) {
return Promise.resolve(stdout + '\n' + stderr);
}
Expand Down
2 changes: 1 addition & 1 deletion src/client/linters/baseLinter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ export abstract class BaseLinter {
});
}

protected handleError(expectedFileName: string, fileName: string, error: Error, resource?: Uri) {
protected handleError(expectedFileName: string, fileName: string, error: Error, resource: Uri) {
this._errorHandler.handleError(expectedFileName, fileName, error, resource);
}
}
9 changes: 5 additions & 4 deletions src/client/linters/errorHandlers/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
import { OutputChannel, Uri } from 'vscode';
import { Installer, Product } from '../../common/installer';
import { InvalidArgumentsErrorHandler } from './invalidArgs';
import { StandardErrorHandler } from './standard';
import { NotInstalledErrorHandler } from './notInstalled';
import { StandardErrorHandler } from './standard';

export class ErrorHandler {
// tslint:disable-next-line:variable-name
private _errorHandlers: StandardErrorHandler[] = [];
constructor(protected id: string, protected product: Product, protected installer: Installer, protected outputChannel: OutputChannel) {
this._errorHandlers = [
Expand All @@ -15,7 +16,7 @@ export class ErrorHandler {
];
}

public handleError(expectedFileName: string, fileName: string, error: Error, resource?: Uri) {
this._errorHandlers.some(handler => handler.handleError(expectedFileName, fileName, error));
public handleError(expectedFileName: string, fileName: string, error: Error, resource: Uri) {
this._errorHandlers.some(handler => handler.handleError(expectedFileName, fileName, error, resource));
}
}
}
4 changes: 2 additions & 2 deletions src/client/linters/errorHandlers/standard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export class StandardErrorHandler {
constructor(protected id: string, protected product: Product, protected installer: Installer, protected outputChannel: OutputChannel) {

}
private displayLinterError(resource?: Uri) {
private displayLinterError(resource: Uri) {
const message = `There was an error in running the linter '${this.id}'`;
window.showErrorMessage(message, 'Disable linter', 'View Errors').then(item => {
switch (item) {
Expand All @@ -22,7 +22,7 @@ export class StandardErrorHandler {
});
}

public handleError(expectedFileName: string, fileName: string, error: Error, resource?: Uri): boolean {
public handleError(expectedFileName: string, fileName: string, error: Error, resource: Uri): boolean {
if (typeof error === 'string' && (error as string).indexOf("OSError: [Errno 2] No such file or directory: '/") > 0) {
return false;
}
Expand Down
17 changes: 9 additions & 8 deletions src/client/unittests/codeLenses/main.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
import * as vscode from 'vscode';
import * as constants from '../../common/constants';

import { TestFileCodeLensProvider } from './testFiles';
import { PythonSymbolProvider } from '../../providers/symbolProvider';
import { ITestCollectionStorageService } from '../common/types';
import { TestFileCodeLensProvider } from './testFiles';

export function activateCodeLenses(onDidChange: vscode.EventEmitter<void>,
symboldProvider: PythonSymbolProvider, testCollectionStorage: ITestCollectionStorageService): vscode.Disposable {

export function activateCodeLenses(onDidChange: vscode.EventEmitter<void>, symboldProvider: PythonSymbolProvider): vscode.Disposable {
const disposables: vscode.Disposable[] = [];
disposables.push(vscode.languages.registerCodeLensProvider(constants.PythonLanguage, new TestFileCodeLensProvider(onDidChange, symboldProvider)));
const codeLensProvider = new TestFileCodeLensProvider(onDidChange, symboldProvider, testCollectionStorage);
disposables.push(vscode.languages.registerCodeLensProvider(constants.PythonLanguage, codeLensProvider));

return {
dispose: function () {
disposables.forEach(d => d.dispose());
}
dispose: () => { disposables.forEach(d => d.dispose()); }
};
}
}
Loading